Dirty rdesktop.lua 'choose resolution' code


Forum: DSL Ideas and Suggestions
Topic: Dirty rdesktop.lua 'choose resolution' code
started by: MakodFilu

Posted by MakodFilu on Jan. 13 2007,21:14
I made this modifications to my own /usr/local/bin/rdesktop.lua (DSL 3.1) for personal use.

I concede I mostly borrowed code from fdtools.lua to make the quick and dirty hack, but it works.

This is the diff
Code Sample

5c5
< w = fltk:Fl_Window(320,75, "Rdesktop")
---
> w = fltk:Fl_Window(320,120, "Rdesktop")
8c8,25
< cancel = fltk:Fl_Button(90,40,70,25,"C&ancel")
---
> sel640x480 = fltk:Fl_Round_Button(2,40,75,25,"640x480")
> sel640x480:type(fltk.FL_RADIO_BUTTON)
> sel640x480:selection_color(fltk.FL_RED)
>
> sel800x600 = fltk:Fl_Round_Button(76,40,75,25,"800x600")
> sel800x600:value(1)
> sel800x600:type(fltk.FL_RADIO_BUTTON)
> sel800x600:selection_color(fltk.FL_RED)
>
> sel1024x768 = fltk:Fl_Round_Button(150,40,83,25,"1024x768")
> sel1024x768:type(fltk.FL_RADIO_BUTTON)
> sel1024x768:selection_color(fltk.FL_RED)
>
> selfull = fltk:Fl_Round_Button(232,40,88,25,"Fullscreen")
> selfull:type(fltk.FL_RADIO_BUTTON)
> selfull:selection_color(fltk.FL_RED)
>
> cancel = fltk:Fl_Button(90,80,70,25,"C&ancel")
14c31
< connect = fltk:Fl_Button(160,40,70,25,"&Connect")
---
> connect = fltk:Fl_Button(160,80,70,25,"&Connect")
20c37,48
<      os.execute('/usr/bin/rdesktop ' .. input:value())
---
>      if sel800x600:value() == 1 then
>         os.execute('/usr/bin/rdesktop -g 800x600 ' .. input:value())
>      end
>      if sel640x480:value() == 1 then
>         os.execute('/usr/bin/rdesktop -g 640x480 ' .. input:value())
>      end
>      if sel1024x768:value() == 1 then
>         os.execute('/usr/bin/rdesktop -g 1024x768 ' .. input:value())
>      end
>      if selfull:value() == 1 then
>         os.execute('/usr/bin/rdesktop -f ' .. input:value())
>      end

Posted by ^thehatsrule^ on Jan. 13 2007,22:06
If you want to, why don't you add the bit depth as well while you're at it?

But this should be quite handy for those not using the cmdline...

Posted by roberts on Jan. 13 2007,23:10
Submit it when you are done. It wil make a nice ehancement for those who regularly use rdesktop. Send to me at extensions@damnsmalllinux.org
Posted by MakodFilu on Jan. 14 2007,04:34
Quote (^thehatsrule^ @ Jan. 13 2007,22:06)
If you want to, why don't you add the bit depth as well while you're at it?

I set the default resolution to 800x600 because that is what the DSL rdesktop defaults to if not specified otherwise in the input box, or (for what is worth) if you only specify an IP there.

I think the GUI should provide the least astonishing results, and I think a GUI user with no knowledge of bandwith constraints, cmd and the like, would expect the maximum of his/ her hardware (if not even more).

That presents a dilemma for me, because rdesktop defaults to 8 bit depth, when an average user would expect to see all the fancy colors he/ she is accustomed to. I'll set the default to 16 bit depth, that as I've read in rdesktop man is the maximum supported by xp and the like and let rdesktop fallback to 8 bit depth if the server don't support more.

Whatever the content of the checkboxes, the input box content takes prevalence (and it should behave that way), so -f -a 8 -u Sales 192.168.1.100 would override the 800x600 checkbox, or for what matters, a 'upgrade' to 16 bit depth as DSL default from to date default of 8 bit.

Comments?

Posted by MakodFilu on Feb. 03 2007,01:10
Quote (^thehatsrule^ @ Jan. 13 2007,17:06)
If you want to, why don't you add the bit depth as well while you're at it?

Finally done :)
Code Sample

4c4
< -- resolution selection by MakoFilu from the DSL forums Jan 14, 2007
---
> -- resolution, bit depth selection by Daniel Plata Lorenzo "MakodFilu"
6c6,9
< w = fltk:Fl_Window(320,120, "Rdesktop")
---
> width=400
> height=150
>
> w = fltk:Fl_Window(width,height, "Rdesktop")
9c12,13
< sel640x480 = fltk:Fl_Round_Button(2,40,75,25,"640x480")
---
> frame1=fltk:Fl_Group(1,69,320,27,"Resolution")
> sel640x480 = fltk:Fl_Round_Button(2,70,75,25,"640x480")
13c17
< sel800x600 = fltk:Fl_Round_Button(76,40,75,25,"800x600")
---
> sel800x600 = fltk:Fl_Round_Button(76,70,75,25,"800x600")
18c22
< sel1024x768 = fltk:Fl_Round_Button(150,40,83,25,"1024x768")
---
> sel1024x768 = fltk:Fl_Round_Button(150,70,83,25,"1024x768")
22c26
< selfull = fltk:Fl_Round_Button(232,40,88,25,"Fullscreen")
---
> selfull = fltk:Fl_Round_Button(232,70,88,25,"Fullscreen")
24a29,40
> fltk:Fl_End()
>
> frame2=fltk:Fl_Group(width-70,30,60,100,"Color Depth")
> sel8bit = fltk:Fl_Round_Button(width-65,31,45,25,"8bit")
> sel8bit:value(1)
> sel8bit:type(fltk.FL_RADIO_BUTTON)
> sel8bit:selection_color(fltk.FL_RED)
>
> sel16bit = fltk:Fl_Round_Button(width-65,60,50,25,"16bit")
> sel16bit:type(fltk.FL_RADIO_BUTTON)
> sel16bit:selection_color(fltk.FL_RED)
> fltk:Fl_End()
26c42
< cancel = fltk:Fl_Button(90,80,70,25,"C&ancel")
---
> cancel = fltk:Fl_Button(90,height-40,70,25,"C&ancel")
32c48
< connect = fltk:Fl_Button(160,80,70,25,"&Connect")
---
> connect = fltk:Fl_Button(160,height-40,70,25,"&Connect")
38,49c54,60
<      if sel800x600:value() == 1 then
<         os.execute('/usr/bin/rdesktop -g 800x600 ' .. input:value())
<      end
<      if sel640x480:value() == 1 then
<         os.execute('/usr/bin/rdesktop -g 640x480 ' .. input:value())
<      end
<      if sel1024x768:value() == 1 then
<         os.execute('/usr/bin/rdesktop -g 1024x768 ' .. input:value())
<      end
<      if selfull:value() == 1 then
<         os.execute('/usr/bin/rdesktop -f ' .. input:value())
<      end
---
>      if sel800x600:value() == 1 then resolution="-g 800x600 " end
>      if sel640x480:value() == 1 then resolution="-g 640x480 " end
>      if sel1024x768:value() == 1 then resolution="-g 1024x768 " end
>      if selfull:value() == 1 then resolution="-f " end
>      if sel8bit:value() == 1 then depth="-a 8 " end
>      if sel16bit:value() == 1 then depth="-a 16 " end
>      os.execute('/usr/bin/rdesktop '..resolution..depth..input:value())

Posted by roberts on Feb. 04 2007,00:49
Thanks MakodFilu,

I got it and it will be v3.3RC1.

Posted by MakodFilu on Feb. 04 2007,01:48
I have already found a bug in the rightmost frame. Not counting the interface is a downright ugly mess. Eventually I'll dig how to draw nice frames, clean up the magic numbers in the code to draw properly and so on, but I am more on the pragmatic side rather than the fancy graphics one, so if someone wants to reorganize the widgets I'll don't byte either.
Posted by MakodFilu on Feb. 04 2007,16:35
I have cleaned, beautified, updated and greatly improved the code and widgets look and feel. Too many differences to post.

Lessons learnt:

1) I should not ashame myself with silly posts.
2) I should not ashame myself posting bad code.
3) Excuses for not doing something are no good for anyone: see point 1.
4) There is no 3rd point without a 4th.
5) Round buttons shall not be used for what a slider is worth.
6) Me think why am I talking like a caveman.

Posted by roberts on Feb. 04 2007,17:16
Hey, we all have to start from somewhere.

The fact that you have taken the time to learn Lua and FLtk and contribute is great. Many times, I too, want to rewrite my code and make it better. Some of my first attempts were/are still pretty crude.
But that is called learning and that is both fun and challenging. Keep up the good work.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.