Author |
Message |
koulaxizis

Joined: 17 Jul 2011 Posts: 437 Location: Greece
|
Posted: Fri 16 Aug 2013, 13:07 Post subject:
|
|
Nathan F wrote: | @koulaxizis - check out the comboboxtext and comboboxentry widgets, which are more powerful than the stock combobox.
For comboboxtext, the default signal is "changed", which is emitted when you choose another selection in the combobox. So you can easily do some useful things with it. The following example lists the contents of all the hidden directories in your home folder in the tree widget.
Code: | <vbox>
<comboboxtext tooltip-text="List contents of your dotdirs">
<variable>COMB1</variable>
<input>find $HOME -maxdepth 1 -mindepth 1 -type d -name '.*'</input>
<default>$HOME/.config</default>
<action>refresh:TREE1</action>
</comboboxtext>
<tree>
<label>Contents</label>
<variable>TREE1</variable>
<input>ls \$COMB1</input>
</tree>
<button ok></button>
</vbox> |
Hope that's helpful in the future even though you settled on a different approach. |
Thank you very much! I'll try this too to see how it goes!
_________________ Christos Koulaxizis
Woof woof from Greece...
|
Back to top
|
|
 |
Nathan F

Joined: 08 Jun 2005 Posts: 1760 Location: Wadsworth, OH (occasionally home)
|
Posted: Sun 18 Aug 2013, 01:54 Post subject:
|
|
Quick question. Is it still possible to do right click actions on the tree widget? Adding 'signal="button-press-event"' seems to execute the actions on both right and left click, which is not what I remember the case being before.
_________________ Bring on the locusts ...
|
Back to top
|
|
 |
Nathan F

Joined: 08 Jun 2005 Posts: 1760 Location: Wadsworth, OH (occasionally home)
|
Posted: Sun 18 Aug 2013, 02:55 Post subject:
|
|
And another one. Trying to set accel-keys for an app. So far as I can tell, the menu and menuitem widgets are the only ones that accept accel keys.
What I would like to do is set an accel key for an action without actually showing the menuitem. However, so far my experimentation has not worked. It seems if the widget set 'visible="false"' then the accel-key no longer works. I also tried putting a menubar inside a notebook tab with the 'show-tabs="false"' setting, and once again no luck.
At the moment what does work is a menu with a blank label. It doesn't show on the menubar, but it can still be opened by clicking it's location, and the accel-key works. But this is not exactly what I want.
_________________ Bring on the locusts ...
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6541 Location: Valåmoen, Norway
|
Posted: Sun 18 Aug 2013, 02:57 Post subject:
|
|
Nathan
gtkdialog sends the status of $PTR_BTN. - 1=left, 2=middle, 3=right
Code: | [ $PTR_BTN != 3 ] && exit |
_________________ Stardust resources
|
Back to top
|
|
 |
Nathan F

Joined: 08 Jun 2005 Posts: 1760 Location: Wadsworth, OH (occasionally home)
|
Posted: Sun 18 Aug 2013, 03:15 Post subject:
|
|
Thanks. Works like a champ.
_________________ Bring on the locusts ...
|
Back to top
|
|
 |
smokey01

Joined: 30 Dec 2006 Posts: 2681 Location: South Australia
|
Posted: Mon 19 Aug 2013, 10:21 Post subject:
|
|
Does anyone know how to automatically shrink a gtkdialog window?
By unhiding frames the window will automatically expand to show the new frames but unfortunately it won't shrink back when the frames are hidden again.
_________________ Software <-> Distros <-> Tips <-> Newsletters
|
Back to top
|
|
 |
Nathan F

Joined: 08 Jun 2005 Posts: 1760 Location: Wadsworth, OH (occasionally home)
|
Posted: Mon 19 Aug 2013, 11:01 Post subject:
|
|
From my experiments if you set 'resizable="false"' then it will resize back.
_________________ Bring on the locusts ...
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 4985 Location: Ontario
|
Posted: Mon 19 Aug 2013, 16:07 Post subject:
|
|
Here's a tip for the entry widget...
To make a button so that it will execute when the <ENTER>
key is pressed...
To get the default button to work properly with an
entry widget I found that I needed to put
activates_default="true" with the entry tag
Code: | <entry max_length="2" activates_default="true"> |
and then make the button the default
Code: | <button can-default="true" has-default="true"> |
Taken from Bulldog Finder application
_______________________________________
Last edited by don570 on Sat 24 Aug 2013, 14:23; edited 1 time in total
|
Back to top
|
|
 |
smokey01

Joined: 30 Dec 2006 Posts: 2681 Location: South Australia
|
Posted: Mon 19 Aug 2013, 22:52 Post subject:
|
|
Nathan F wrote: | From my experiments if you set 'resizable="false"' then it will resize back. |
Thanks Nathan, works great.
_________________ Software <-> Distros <-> Tips <-> Newsletters
|
Back to top
|
|
 |
disciple
Joined: 20 May 2006 Posts: 6781 Location: Auckland, New Zealand
|
Posted: Tue 20 Aug 2013, 07:30 Post subject:
|
|
thunor wrote: | Here's another top tip:
A text widget that has space-expand and space-fill set to true can be used as a spacer to push neighbouring widgets in certain directions.
Here the spacer text is "[]" so you can see it -- drag the window out and watch the button.
Code: | #!/bin/sh
GTKDIALOG=gtkdialog
Spacer="[]"
MAIN_DIALOG='
<window title="Spacer Test" window-position="1">
<vbox>
<hbox>
<button space-expand="false" space-fill="false">
<label>This button will stay put</label>
<input file stock="gtk-about"></input>
</button>
<text space-expand="true" space-fill="true">
<label>"'$Spacer'"</label>
</text>
</hbox>
</vbox>
</window>
'
export MAIN_DIALOG
case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac |
Regards,
Thunor |
Question: is the space-fill tag actually supposed to do anything? Changing it doesn't seem to have any effect here (0.8.3)...
_________________ If you have or know of a good gtkdialog application, please post a link here
Classic Puppy quotes
ROOT FOREVER
|
Back to top
|
|
 |
don570

Joined: 10 Mar 2010 Posts: 4985 Location: Ontario
|
Posted: Wed 21 Aug 2013, 16:22 Post subject:
|
|
to Disciple:
Just guessing... but maybe it's related to 'resizable="false/true"' option
in the window tag
____________________________
|
Back to top
|
|
 |
koulaxizis

Joined: 17 Jul 2011 Posts: 437 Location: Greece
|
Posted: Thu 22 Aug 2013, 10:56 Post subject:
|
|
Still playing with gtkdialog!
If you have some spare time, try this one and suggest me ways to improve it, so i can further understand the possibilities of gtkdialog.
Thank you friends!!
Code: | #!/bin/sh
GTKDIALOG=gtkdialog
export MAIN_DIALOG='
<window title="Find Subtitles" window_position="1">
<vbox>
<frame Choose preferred interface>
<hbox>
<combobox>
<variable>COMBOBOX1</variable>
<item>el</item>
<item>en</item>
<item>es/sp</item>
</combobox>
</hbox>
</frame>
<frame Choose preferred language>
<hbox>
<combobox>
<variable>COMBOBOX2</variable>
<item>ell</item>
<item>eng</item>
<item>spa</item>
</combobox>
</hbox>
</frame>
<frame Paste the exact movie name>
<hbox>
<entry>
<variable>ent2</variable>
</entry>
</hbox>
</frame>
<hbox>
<button>
<label>Find subs!</label>
<action>defaultbrowser http://www.opensubtitles.org/"$COMBOBOX1"/search/sublanguageid-"$COMBOBOX2"/moviename-"$ent2" &</action>
<action>exit:EXIT</action>
</button>
<button cancel></button>
</hbox>
</vbox>
</window>
'
$GTKDIALOG --program=MAIN_DIALOG |
Question: Is there a way to automatically read the movie's name with "right-click" on the movie file and clicking the script instead of copy-paste it in the entry?
_________________ Christos Koulaxizis
Woof woof from Greece...
|
Back to top
|
|
 |
Karl Godt

Joined: 20 Jun 2010 Posts: 4208 Location: Kiel,Germany
|
Posted: Thu 22 Aug 2013, 12:26 Post subject:
|
|
There are two options for a wrapper :
MOVIENAME="$MOVIENAME" /root/my-applications/bin/myz-gui
or
/root/my-applications/bin/myz-gui "$@"
.
The second is the common one .
Then myz-gui would look like
ent2="$MOVIENAME" for the first case
or
ent2="$@" for the second case
and
export ent2
ORIGINAL_CODE
here ..
IfIUnderstoodCorrectly
|
Back to top
|
|
 |
koulaxizis

Joined: 17 Jul 2011 Posts: 437 Location: Greece
|
Posted: Thu 22 Aug 2013, 12:33 Post subject:
|
|
Karl Godt wrote: | There are two options for a wrapper :
MOVIENAME="$MOVIENAME" /root/my-applications/bin/myz-gui
or
/root/my-applications/bin/myz-gui "$@"
.
The second is the common one .
Then myz-gui would look like
ent2="$MOVIENAME" for the first case
or
ent2="$@" for the second case
and
export ent2
ORIGINAL_CODE
here ..
IfIUnderstoodCorrectly |
I'm not sure if i understood...
Can you please place it in the code to figure out how it works?
_________________ Christos Koulaxizis
Woof woof from Greece...
|
Back to top
|
|
 |
Nathan F

Joined: 08 Jun 2005 Posts: 1760 Location: Wadsworth, OH (occasionally home)
|
Posted: Thu 22 Aug 2013, 13:31 Post subject:
|
|
Mainly stylistic changes, use what you like and discard the rest.
Code: | #!/bin/sh
: ${GTKDIALOG:=gtkdialog}
export MAIN_DIALOG="
<window title=\"Find Subtitles\" window_position=\"2\">
<vbox>
<hbox>
<text space-expand=\"false\" space-fill=\"false\">
<label>$(gettext 'Preferred interface')</label>
</text>
<hbox space-expand=\"true\" space-fill=\"true\"><text><label>\"\"</label></text></hbox>
<comboboxtext space-expand=\"false\" space-fill=\"false\" tooltip-text=\"$(gettext 'The language used to display search results and information')\">
<variable>COMBOBOX1</variable>
<item>el</item>
<item>en</item>
<item>es/sp</item>
</comboboxtext>
</hbox>
<hbox>
<text space-expand=\"false\" space-fill=\"false\">
<label>$(gettext 'Preferred language')</label>
</text>
<hbox space-expand=\"true\" space-fill=\"true\"><text><label>\"\"</label></text></hbox>
<comboboxtext space-expand=\"false\" space-fill=\"false\" tooltip-text=\"$(gettext 'The language the subtitles should be in')\">
<variable>COMBOBOX2</variable>
<item>ell</item>
<item>eng</item>
<item>spa</item>
</comboboxtext>
</hbox>
<hbox>
<entry tooltip-text=\"$(gettext 'Paste the exact movie title in this box')\" activates-default=\"true\">
<variable>ent2</variable>
</entry>
</hbox>
<hbox>
<button tooltip-text=\"$(gettext 'Get subtitles with an internet browser')\" can-default=\"true\" has-default=\"true\">
<input file icon=\"gtk-ok\"></input>
<label>$(gettext 'Go')</label>
<action>defaultbrowser \"http://www.opensubtitles.org/\$COMBOBOX1/search/sublanguageid-\$COMBOBOX2/moviename-\$ent2\" &</action>
<action>exit:EXIT</action>
</button>
<button tooltip-text=\"$(gettext 'Exit program')\">
<label>$(gettext 'Cancel')</label>
<input file stock=\"gtk-cancel\"></input>
<action>exit:ABORT</action>
</button>
</hbox>
</vbox>
</window>
"
$GTKDIALOG -p MAIN_DIALOG
|
The construct at the top only assigns the variable GTKDIALOG if it isn't already set. Useful for portability.
My feelings are that sometimes a more concise gui is desirable. I don't really care for the use of frames to display information or to label content, although I've done it before to mock something up quick. Here there is a concise label and a more meaningful tooltip. The entry should be obvious so it's unlabeled, but if unsure the tooltip should clue the user in.
The code to activate the "Go" button is very useful in a case like this and makes it quicker since the user can just press Enter and be taken to the site. Less mouse interaction is desired by a lot of users, especially power users.
I thought it appropriate that an app designed to get subtitles should be localized, so all text strings are displayed via gettext. You would need a line saying 'export TEXTDOMAIN=" near the top, and then it would be localization ready.
It seems more concise to me to quote the entire url.
I wrapped the entire dialog description in double quotes rather than single. This means all double quotes have to be ascaped, but it allows command substitution within the dialog description. Also escaped are the variables set by the comboboxes, so that if you follow my advice below about a state file they will use the current value rather than the saved one.
I also switched it from centered display to display near mouse. Centered display is somehow arrogant to me (look at my app now user!) and not as useful anyway. Place it near the pointer and it's quicker for the user to access. IMO dialogs should only be centered if they are displaying important system information and need to grab the user's attention.
One further suggestion would be to save the output to a state file inside ~/.config, which can then be sourced to set defaults for the two comboboxes on future runs of the program. Users appreciate little touches like that.
Cheers!
_________________ Bring on the locusts ...
|
Back to top
|
|
 |
|