Page 41 of 76

Posted: Mon 19 Aug 2013, 14:21
by smokey01
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.

Posted: Mon 19 Aug 2013, 15:01
by Nathan F
From my experiments if you set 'resizable="false"' then it will resize back.

Posted: Mon 19 Aug 2013, 20:07
by don570
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: Select all

<entry max_length="2"  activates_default="true">
and then make the button the default

Code: Select all

<button can-default="true" has-default="true">
Taken from Bulldog Finder application
Image
_______________________________________

Posted: Tue 20 Aug 2013, 02:52
by smokey01
Nathan F wrote:From my experiments if you set 'resizable="false"' then it will resize back.
Thanks Nathan, works great.

Posted: Tue 20 Aug 2013, 11:30
by disciple
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: Select all

#!/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)...

Posted: Wed 21 Aug 2013, 20:22
by don570
to Disciple:

Just guessing... but maybe it's related to 'resizable="false/true"' option
in the window tag

____________________________

Posted: Thu 22 Aug 2013, 14:56
by koulaxizis
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: Select all

#!/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?

Posted: Thu 22 Aug 2013, 16:26
by Karl Godt
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

Posted: Thu 22 Aug 2013, 16:33
by koulaxizis
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?

Posted: Thu 22 Aug 2013, 17:31
by Nathan F
Mainly stylistic changes, use what you like and discard the rest.

Code: Select all

#!/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!

Posted: Thu 22 Aug 2013, 17:40
by Karl Godt
First you would need a wrapper script that calls the main script.
This wrapper script needs to be linked into the rox open with directory to be able to right-click it.
( /root/.config/rox.sourceforge.net/OpenWith/ )

Wrapper :

Code: Select all

#!/bin/sh

exec myz-gui "$@"

Code: Select all

#!/bin/sh
GTKDIALOG=gtkdialog

ent2=`basename "$@"`
[ "$ent2" ] && export ent2

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>
<default>\"$ent2\"</default>
<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

Posted: Thu 22 Aug 2013, 18:04
by Nathan F
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?
Assuming the title of the movie file is the exact title of the movie plus some extension then yes. Say for an avi:

Code: Select all

TITLE="$(basename "$@" .avi)"
To handle multiple extensions it gets a little more involved.

Code: Select all

TITLE="$(basename "$@" | \
sed -e 's/.avi//' | \
-e 's/.mpeg//' | \
-e 's/.wmv//' | \
-e 's/.m4v//')"

mukstart

Posted: Thu 22 Aug 2013, 18:41
by recobayu
Hi All,
I just make a simple menu like start metro wdz8. I learn by looking another script, especially in programming thread and akita. But it just simple and so far to good. I have a problem in search and press enter. The screenshot is here:
http://dl.dropboxusercontent.com/s/g38l ... kstart.png
I originally wanted if search button pressed, the button (not tree) show. Another things are can gtkdesklet show blur transparent? So it will like unity effect. But it seems, that are not easy for me. Can anyone help me? Or developing this script? I really happy.
Thank you.
:D

Posted: Thu 22 Aug 2013, 23:38
by don570
To recobayu:


If your problem is how to transfer data using the clipboard I suggest that you
read this script by forum member Seaside.

He uses an utility app (xclip) that is built into every puppy.

The app was written to compare md5sums to make sure that the
download was correct.

Posted: Sat 24 Aug 2013, 13:44
by recobayu
thanks don570, but I still don't understand with that. I had extract that pet and find any script I can study, but still not too much understand that. Ok, I make the simple problem. Now I have this script, there are an entrybox and a tree. When I change the entrybox, I want the tree selected on the top of tree, and when I press enter, it can execute the selection (top of tree). How to do that? Can anyone help me? Thank You.

Code: Select all

#!/bin/sh
ls /usr/share/applications > aplikasiku
luru(){
	cat aplikasiku | grep $Entriku > ketemu
}
export -f luru
export auto='
<window height-request="400" width-request="200">
	<vbox>
		<entry>
			<variable>Entriku</variable>
			<label>search application here</label>
			<action>luru</action>
			<action>refresh:Wit</action>
		</entry>
		<tree rules-hint="true" headers-visible="false">
			<variable>Wit</variable>
			<input file>ketemu</input>
		</tree>
	</vbox>
</window>'
gtkdialog --program=auto --center

Posted: Sat 24 Aug 2013, 14:21
by Nathan F
If I'm understanding what you want to do correctly, you need to change the signal for the entrybox so that it performs the action you want when you press Enter.

Code: Select all

<action signal="activate">actions...</action>
I'm having a hard time following exactly what you want to do. It seems to be a language barrier problem. Sorry if that's not helpful.

Posted: Sat 24 Aug 2013, 17:55
by don570
The old fashioned way of getting something to the top of a list
was to have a default tag <default>....</default> then relaunch.

...But that wasn't very slick so there are better ways of doing it
as Nathan F points out.


If you install the gtkdialog examples by Thunor
http://murga-linux.com/puppy/viewtopic.php?t=82059
Look at comboboxtext and comboboxentry examples. They are difficult to
understand but maybe they will explain how signal activation works.
__________________________________________________

Posted: Sat 24 Aug 2013, 18:06
by Nathan F
+1 but to make them easier to follow run them with the --dump option, which will spit out the actual dialog passed to gtkdialog instead of all the functions he used to build the dialog. Even better save the dump to a file so you can look it over while you actually run the example.

Posted: Sat 24 Aug 2013, 18:17
by Nathan F
The key here if I understand correctly what is wanted, is that the default signal passed by the entry widget is "changed", and it's emitted every time you type any character into the box. What is needed is to perform the action on the press of the "Enter" key, which is why you have to change the signal to "activate".

Posted: Sat 24 Aug 2013, 18:25
by don570
To NathanF

Thanks for tip. The only way I could make any sense of
the combobox entry examples was to cut out as many buttons and
tags as possible to simplify the examples.

_________________________________________

The options in the entry tag are important to set
See my example
http://murga-linux.com/puppy/viewtopic. ... 397#720397


Here is the official list of options available
https://code.google.com/p/gtkdialog/wiki/entry

_________________________