GtkDialog - tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

#1021 Post by recobayu »

With <button relief="2">, the startmenu is like cinnamon's start menu.
This is the screenshoot:
Image

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1022 Post by MochiMoppel »

Tree items are "unreliefed" by design and with <tree hover-selection="true"> you get a button-like hover effect.

User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

#1023 Post by recobayu »

Yap. It's very great :D
39 mochi.

User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

#1024 Post by recobayu »

Alhamdulillah.. Finally, I did it. :D
Here is my code:

Code: Select all

#!/bin/sh
#rm nbMain

cek(){
	if [[ $E == "" ]];then
		echo 0 > nbsubMain
	else
		echo 1 > nbsubMain
	fi
}
export -f cek



export main='
<window>
  <vbox>
	<entry>
		<action>cek</action>
		<action>refresh:nbCari</action>
		<variable>E</variable>
	</entry>
	<notebook show-tabs="false" show-border="false" tab-pos="1">
	<hbox>
	  <vbox>
		<button relief="2">
			<label>All</label>
			<action signal="enter-notify-event">echo "0" >nbMain</action>
			<action signal="focus-in-event">echo "0" >nbMain</action>
			<action signal="focus-in-event">refresh:nbGanti</action>
			<action signal="enter-notify-event">refresh:nbGanti</action>
		</button>
		<button relief="2">
			<label>Destop</label>
			<action signal="enter-notify-event">echo "1" >nbMain</action>
			<action signal="focus-in-event">echo "1" >nbMain</action>
			<action signal="focus-in-event">refresh:nbGanti</action>
			<action signal="enter-notify-event">refresh:nbGanti</action>
		</button>
		<button relief="2">
			<label>System</label>
			<action signal="enter-notify-event">echo "2" >nbMain</action>
			<action signal="focus-in-event">echo "2" >nbMain</action>
			<action signal="focus-in-event">refresh:nbGanti</action>
			<action signal="enter-notify-event">refresh:nbGanti</action>
		</button>
		<button relief="2">
			<label>Setup</label>
			<action signal="enter-notify-event">echo "3" >nbMain</action>
			<action signal="focus-in-event">echo "3" >nbMain</action>
			<action signal="focus-in-event">refresh:nbGanti</action>
			<action signal="enter-notify-event">refresh:nbGanti</action>
		</button>
	  </vbox>
	<notebook show-tabs="false" show-border="false">
		<vbox>
			<button relief="2">
				<label>bersama</label>
			</button>
			<button relief="2">
				<label>ke sini</label>
			</button>
			<button relief="2">
				<label>dan juga</label>
			</button>
			<button relief="2">
				<label>sekarang</label>
			</button>
			<button relief="2">
				<label>lanjut</label>
			</button>
		</vbox>
		<vbox>
			<button relief="2">
				<label>next</label>
			</button>
			<button relief="2">
				<label>okay</label>
			</button>
			<button relief="2">
				<label>ini</label>
			</button>
			<button relief="2">
				<label>juga</label>
			</button>
			<button relief="2">
				<label>next</label>
			</button>
		</vbox>
		<vbox>
			<button relief="2">
				<label>ini</label>
			</button>
			<button relief="2">
				<label>ada satu</label>
			</button>
			<button relief="2">
				<label>lagi</label>
			</button>
			<button relief="2">
				<label>yang nambah</label>
			</button>
			<button relief="2">
				<label>di framenya</label>
			</button>
		</vbox>
		<vbox>
			<button relief="2">
				<label>dan</label>
			</button>
			<button relief="2">
				<label>lagi</label>
			</button>
			<button relief="2">
				<label>orang</label>
			</button>
			<button relief="2">
				<label>beriman</label>
			</button>
			<button relief="2">
				<label>amal salih</label>
			</button>
		</vbox>
		<variable>nbGanti</variable> 
        <input file>nbMain</input> 
	</notebook>
	</hbox>
	<hbox>
		<tree rules-hint="true" headers-visible="false">
			<item>first</item>
			<item>second</item>
			<item>third</item>
			<item>fourth</item>
		</tree>
	</hbox>
	<variable>nbCari</variable> 
	<input file>nbsubMain</input> 
	</notebook>
  </vbox>
</window>'
gtkdialog -p main
We can change on right side by hover button or by keyboard arrow, also we can find something by search on entry. All of that done by "notebook"

Now, how to write a function that can automatically write code <vbox> or <Button> so we are not write every button. But we just call that function. I still learn that. 8)

User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

#1025 Post by recobayu »

Hi guys,
I want to ask a question.
If I have a file text.txt that contain a text,
and I have a file icon.txt that contain a path/to/icon.

How to make a tree that column one based on icon.txt and column two based on text.txt?

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1026 Post by MochiMoppel »

Code: Select all

#!/bin/sh
echo "/path/to/icon1"   >  /tmp/icon.txt
echo "/path/to/icon2"   >> /tmp/icon.txt

echo "text more text 1" >  /tmp/text.txt
echo "text more text 2" >> /tmp/text.txt

export MERGED=$(paste -d"|" /tmp/icon.txt /tmp/text.txt)

echo -n '<tree>
<input>echo -n "$MERGED"</input>
<label>"iconpaths|text"</label>
</tree>' |gtkdialog -s

User avatar
Moose On The Loose
Posts: 965
Joined: Thu 24 Feb 2011, 14:54

#1027 Post by Moose On The Loose »

recobayu wrote:Alhamdulillah.. Finally, I did it. :D

....
Now, how to write a function that can automatically write code <vbox> or <Button> so we are not write every button. But we just call that function. I still learn that. 8)
The basic method is like this:

Code: Select all

#!/bin/bash

function Thing() {
  echo "bla bla bla $1 bla ba bla"
  }
  
Main=" stuff here $(Thing word1) stuff there"
echo "$Main"

Whatever the function "Thing()" sends out stdout, ends up in $Main

The function Thing() can loop through a list and make many buttons if you want.

Code: Select all

for WORD in this that other ; do
  echo "stuff before ${WORD} stuff after"
  done
makes

Code: Select all

stuff before this stuff after
stuff before that stuff after
stuff before other stuff after
This means you can construct the list of buttons in a variable and then loop to implement them.

User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

Still, mukstart

#1028 Post by recobayu »

Thank you mochi and moose for your very nice help.
This is what I got so far.

Code: Select all

#!/bin/sh
#rm nbMain

echo 'asunder|first
gtkam|second
python2.7|third
mtpaint|fourth'>gabung.txt

cek(){
	if [[ $E == "" ]];then
		echo 0 > nbsubMain
	else
		echo 1 > nbsubMain
	fi
}
export -f cek

buatButtonMain(){
	echo '
	<button relief="2" homogeneous="true">
		<label>'$1'</label>
		<input file>/root/puppy-reference/midi-icons/'$3'</input>
		<action signal="enter-notify-event">echo "'$2'" >nbMain</action>
		<action signal="focus-in-event">echo "'$2'" >nbMain</action>
		<action signal="focus-in-event">refresh:nbGanti</action>
		<action signal="enter-notify-event">refresh:nbGanti</action>
	</button>'
}

buatButtonSub(){
	echo '
	<button relief="2" homogeneous="true">
		<label>'$1'</label>
		<input file>/root/puppy-reference/midi-icons/'$2'</input>
	</button>'
}

export main='
<window title="Mukstart">
  <vbox>
	<entry>
		<action>cek</action>
		<action>refresh:nbCari</action>
		<variable>E</variable>
	</entry>
	<notebook show-tabs="false" show-border="false" tab-pos="1">
	<hbox>
	  <vbox>
		'"`buatButtonMain All 0 console48.png`"'
		'"`buatButtonMain Destop 1 folder48.png`"'
		'"`buatButtonMain System 2 draw48.png`"'
		'"`buatButtonMain Setup 3 archive48.png`"'				
	  </vbox>
	  
	<notebook show-tabs="false" show-border="false">
		<vbox>
		'"`buatButtonSub "some text" info.xpm`"'
		'"`buatButtonSub "other text" ok.xpm`"'
		'"`buatButtonSub "side text" help48.png`"'
		'"`buatButtonSub "last text" module24.xpm`"'
		</vbox>
		<vbox>
		'"`buatButtonSub "text1" inkscape48.png`"'
		'"`buatButtonSub "text2" games48.png`"'
		'"`buatButtonSub "text3" multimedia48.png`"'
		'"`buatButtonSub "text4" floppy48.png`"'
		</vbox>
		<vbox>
		'"`buatButtonSub "first text" ok.xpm`"'
		'"`buatButtonSub "second text" ok.xpm`"'
		'"`buatButtonSub "third text" games24.png`"'
		'"`buatButtonSub "fourth text" camera48.png`"'
		</vbox>
		<vbox>
		'"`buatButtonSub "this" email48.png`"'
		'"`buatButtonSub "is" go48.png`"'
		'"`buatButtonSub "the other" edit48.png`"'
		'"`buatButtonSub "vbox" chat48.png`"'
		</vbox>
		<variable>nbGanti</variable> 
        <input file>nbMain</input> 
	</notebook>
	</hbox>
	<hbox>
		<tree rules-hint="true" headers-visible="false">
			<input file icon-column="0">gabung.txt</input>
		</tree>
	</hbox>
	<variable>nbCari</variable> 
	<input file>nbsubMain</input> 
	</notebook>
  </vbox>
</window>'
gtkdialog -p main
I can use paste methode like mochi's suggest in <tree>, but the allowed icons only on /usr/share/pixmaps. How to insert arbitary location of icons on tree? Thanks.

Edit:
I look at findnrun's script. And I see a link symbolic icon to /usr/share/pixmaps/. But i don't see any added sym link icon on /usr/share/pixmaps. Amazing. How step do that? Thanks.

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#1029 Post by smokey01 »

Is it possible to have hyperlinks in Gtkdialog, something like:
<url>file:///$filepath</url>

Thanks

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#1030 Post by MochiMoppel »

Code: Select all

#!/bin/sh
export filepath="localhost/usr/share/doc/index.html"
echo '<button>
<action>defaultbrowser file://$filepath</action>
</button>'|gtkdialog -s

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#1031 Post by smokey01 »

MochiMoppel wrote:

Code: Select all

#!/bin/sh
export filepath="localhost/usr/share/doc/index.html"
echo '<button>
<action>defaultbrowser file://$filepath</action>
</button>'|gtkdialog -s
Thanks MochiMoppel but it's a bit more complicated than that.

I have a little app that creates a long list of /path/filenames. What I want is to be able to turn each /path/filename into a link.

It would be really nice if the link would be Rox right click smart.

The app I'm trying to modify is my locator-1.1.
http://smokey01.com/fd700/packages/loca ... 6_64-1.txz

Thanks

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#1032 Post by Geoffrey »

Using eventbox

Code: Select all

#!/bin/sh
export filepath="localhost/usr/share/doc/index.html"
TEXT="<b><u><span color='"'blue'"'>Puppy Help</span></u></b>"
echo '<eventbox hover-selection="true" homogeneous="true">
      <text justify="2" use-markup="true"><label>"'$TEXT'"</label></text>
<action signal="button-press-event">defaultbrowser file://$filepath</action>
</eventbox>'|gtkdialog -s
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#1033 Post by smokey01 »

Thanks.

Locate-GUI is much better now.

PastorEdBTwo
Posts: 3
Joined: Thu 01 Oct 2015, 18:50

Can't get my gtkdialog to go away

#1034 Post by PastorEdBTwo »

Hello, everyone.

You guys seem to be the experts on gtkdialog these days, so here's my question (which after much search, I still have not found an answer):

I have created a launcher for programs on my computer, much like Whisker Menu for XFCE, or MintMenu for Mint Linux.

I'm using JWM as my window manager, and I wanted something a little snazzier than the plain root menu.

My PROBLEM is that while the launcher menu works, and looks okay, it does NOT go away once I've clicked on a program... so if, for example, I use it to launch a terminal, the launch menu still stays on the screen UNTIL I close the terminal program. ONLY THEN does it close itself.

How do I get my gtkdialog window to close immediately upon the *selection* of a program, instead of upon the *termination* of that program?

Thanks for any help you can provide.

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

Re: Can't get my gtkdialog to go away

#1035 Post by Geoffrey »

PastorEdBTwo wrote: How do I get my gtkdialog window to close immediately upon the *selection* of a program, instead of upon the *termination* of that program?
Hi and welcome to the forum, I think by the sounds of it you need to add a ampersand after the command in your script.

Code: Select all

<action>command &</action>
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

PastorEdBTwo
Posts: 3
Joined: Thu 01 Oct 2015, 18:50

#1036 Post by PastorEdBTwo »

Geoffrey -

Thank you for responding. However adding the ampersand (&) after the program name in the action does NOT make the original gtkdialog menu go away.

It just lets me run the command, with the menu still active in the background.

For example:

Code: Select all

<menuitem icon="accessories-calculator"><label>Calculator</label><action>galculator &</action></menuitem>
DOES run the program "galculator" - but right over the top of the still-in-existence-not-dismissed menu.

What I'm wanting to happen is whenever I select a program, the menu is dismissed right after I've clicked it AS the program is launching.[/code]

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#1037 Post by Geoffrey »

PastorEdBTwo wrote:It just lets me run the command, with the menu still active in the background.

For example:

Code: Select all

<menuitem icon="accessories-calculator"><label>Calculator</label><action>galculator &</action></menuitem>
DOES run the program "galculator" - but right over the top of the still-in-existence-not-dismissed menu.

What I'm wanting to happen is whenever I select a program, the menu is dismissed right after I've clicked it AS the program is launching.[/code]
This will fix it, you need to run exit also. :)

Code: Select all

<menuitem icon="accessories-calculator"><label>Calculator</label><action>galculator &</action><action>exit:Quit</action></menuitem>
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

PastorEdBTwo
Posts: 3
Joined: Thu 01 Oct 2015, 18:50

#1038 Post by PastorEdBTwo »

WHOO HOO!

The combination of the last two hints makes it work:

Both the ampersand (&) AND the <action>exit:Quit</action> command make it work the way I want.

Thanks, everyone! It works a treat. Here's the final result:

Image

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

comboboxentry widget

#1039 Post by Argolance »


User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#1040 Post by don570 »

to PastorEdBTwo...


You could make the cancel button small (homogeneous) and place it in the middle or to
to extreme side of a column ---> Thunor's tip

I show how in gtkdialog manual

http://murga-linux.com/puppy/viewtopic.php?t=89045

___________________________________________

Another tip - I found that <window> widget is needed when
using gtkdialog in Ubuntu

Scripts just wouldn't work without it.

_____________________________________

Post Reply