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
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#1201 Post by zigbert »

:lol: :lol: :lol:

That means the solution is to combine a <chooser> in mode 0 (select file) with an <entry> holding the filename. Thank you.

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

#1202 Post by MochiMoppel »

No, that's not what it meant. But if you somehow are able to achieve this with a separate <entry> widget I would be keen to see your solution :wink:

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#1203 Post by zigbert »

I am onto it :wink:

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#1204 Post by zigbert »

First draft:

Code: Select all

echo /usr/share/backgrounds > /tmp/savepath
echo "default.svg" > /tmp/savefile

echo ' 
<vbox> 
 <entry visible="false">
  <variable>SAVEPATH</variable>
  <input file>/tmp/savepath</input>
 </entry>
 <entry>
  <variable>SAVEFILE</variable>
  <input file>/tmp/savefile</input>
 </entry>
 <chooser action="0" create-folders="true" >
  <width>600</width> 
  <height>400</height> 
  <variable>SAVE_CHOOSER</variable>
  <default>'$(cat /tmp/savepath)'</default>
  <action signal="button-release-event" condition="command_is_true([[ -f \"$SAVE_CHOOSER\" ]] && echo true)">basename "$SAVE_CHOOSER" > /tmp/savefile</action> 
  <action signal="button-release-event" condition="command_is_true([[ -d \"$SAVE_CHOOSER\" ]] && echo true)">dirname "$SAVE_CHOOSER" > /tmp/savepath</action> 
  <action signal="button-release-event">refresh:SAVEFILE</action>
  <action signal="button-release-event">refresh:SAVEPATH</action> 
 </chooser>
 <hbox> 
  <button cancel></button> 
  <button>
   <label>Save</label>
   <input file stock="gtk-save"></input>
   <action>gxmessage "savefile: $SAVEPATH"/"$SAVEFILE"</action>
  </button> 
 </hbox> 
</vbox> 
' |  gtkdialog -s
Seems to work ok, but it doesn't update $SAVEPATH when pressing one of the path-buttons (second row in the gui). I got problems to control that...

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

#1205 Post by don570 »

Simple example to show left side buttons...

Code: Select all

echo '
<vbox width-request="300">
 <hbox>
                   
              <button  space-expand="false" space-fill="false"> 
            <label>"Action"</label> 
                      <input file stock="gtk-help"></input>
            <action>xmessage here</action>
      </button> 
       <button  space-expand="false" space-fill="false"> 
                      <input file stock="gtk-preferences"></input>

            <action>xmessage here</action>
      </button> 

       <text space-expand="true" space-fill="true">
            <label>""</label> 
       </text>  
       <button cancel></button>  
 </hbox>  
 

</vbox>' | gtkdialog -s 
Attachments
screenshot-button.png
left side buttons
(6.53 KiB) Downloaded 467 times

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

#1206 Post by smokey01 »

Is it possible to change the background colour of the <edit> widget?

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

#1207 Post by MochiMoppel »

smokey01 wrote:Is it possible to change the background colour of the <edit> widget?
Yes.

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

#1208 Post by smokey01 »

MochiMoppel wrote:
smokey01 wrote:Is it possible to change the background colour of the <edit> widget?
Yes.
Thanks.

some1
Posts: 117
Joined: Thu 17 Jan 2013, 11:07

#1209 Post by some1 »

Yes!

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

#1210 Post by don570 »

Here's another example of a colored background..
http://45.33.15.200/puppy/viewtopic.php ... dea#881811

___________________________________________________

livernote1
Posts: 3
Joined: Sat 09 Sep 2017, 03:36

#1211 Post by livernote1 »

Hello guys newbie here, help needed...

below i have provide two code from two different program but the problem here is how can i merge this two program. if u guys can see there is button continue below the date button,so i want to make the continue button will open the second program code that i have provide below. The second problem is the picture that i used on pixmap fuction is not showing the picture but show sign like it cant read the picture.. so thanks in advance.

Code: Select all


#!/bin/bash 
GTKDIALOG=gtkdialog 
export MAIN_DIALOG=' 
<window title="welcome" width-request="480" height-request="320"> 
<vbox>

	<frame>
		<text>
			<label> Welcome </label>
		</text>	
		<pixmap>
		<input file> /home/livernote/Desktop/L.jpg </input> 
		</pixmap>	
	</frame>
	
	<frame Label from command>
     <text>
       <label>This is a static text.</label>
       <input>date</input>
       <variable>DATE</variable>
     </text>
     <hbox>
       <button>
         <label>refresh</label>
         <action type="refresh">DATE</action>
       </button>
       <button> 
		 <label>Continue</label>
		 <action>
			<input file> /home/livernote/Desktop/my </input>
	     </action>
       </button>
 	</hbox>
   </frame>	

</vbox>
</window> 
' 
case $1 in 
-d | --dump) echo "$MAIN_DIALOG" ;; 
*) $GTKDIALOG --program=MAIN_DIALOG --center ;; 
esac 
------------

Code: Select all


#!/bin/bash 
GTKDIALOG=gtkdialog 
export MAIN_DIALOG=' 
<window title="welcome" width-request="480" height-request="320"> 
<hbox>

		<vbox space-expand="true" space-fill="true">
			
			<button>	 
			<label>1</label>  
			<action>echo "Button 1"</action> 
			</button>

			<button>	 
			<label>2</label>  
			<action>echo "Button 2"</action> 
			</button>
					
		</vbox>
</hbox>

</window> 
' 
case $1 in 
-d | --dump) echo "$MAIN_DIALOG" ;; 
*) $GTKDIALOG --program=MAIN_DIALOG --center ;; 
esac 
------------ 

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

#1212 Post by MochiMoppel »

"Merge" two programs? It appears that you have 2 different scripts, each containing a MAIN_DIALOG, and that you are trying to call the second script from the first. Could be done with a simple button action <action>/path/to/my/secondscript.sh &</action>

You could also put both dialogs into 1 script and launch the second dialog from your first. Something like this:

Code: Select all

#!/bin/bash
export SUB_DIALOG=' 
<window> 
<vbox> 
 <text><label>SUB_DIALOG</label></text> 
 <button>
   <label>Close</label>
   <action>closewindow:SUB_DIALOG</action> 
 </button> 
</vbox> 
<variable>SUB_DIALOG</variable> 
</window>' 

export MAIN_DIALOG=' 
<window> 
<vbox> 
 <text><label>MAIN_DIALOG</label></text> 
 <button> 
   <label>Continue</label> 
   <action>launch:SUB_DIALOG</action> 
 </button> 
</vbox> 
</window>' 
gtkdialog -cp MAIN_DIALOG
More examples for launching child windows:
http://www.murga-linux.com/puppy/viewto ... 875#353875
http://www.murga-linux.com/puppy/viewto ... 300#758300

Your second question: Remove the surrounding whitespace or put the file path in quotes.

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

#1213 Post by recobayu »

Hi All,
Can we make bigger icon on tree? How?
Thank You.

User avatar
torm
Posts: 186
Joined: Sat 07 Mar 2015, 19:56

#1214 Post by torm »

Hello ..again :)

To ansver my own strange question about how to move
an undecorated window with mouse only..

Turns out to be pretty simple.. GTK2, no external dependencies.
Just add gtkrc for named widgets.

Allows to move and close the window as usual, for fixed size window.
Added a resizable window with stock icon.
btw, window can also be moved with resize grip using middle mousebutton.

I hope it's any use, for skinned custom widgets or something like that..

JWM is known to "shape" even undecorated windows,
while it should look as on screenshot with most other WM-s.

edit: re-uploaded

added some extra cosmetics.
Attachments
undecorated_examples_v2.tar.gz
(5.82 KiB) Downloaded 134 times
undecorated-simple.png
screenshot
(6.88 KiB) Downloaded 217 times
Last edited by torm on Fri 20 Oct 2017, 20:39, edited 1 time in total.

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

#1215 Post by MochiMoppel »

export GTK2_RC_FILES
Without this fix your examples don't work.


Nice move functionality of the statusbar grip. But why would gtkrc theming provide a solution to your "strange question about how to move an undecorated window with mouse only"?

And how can I move the "fixed size" window with mouse only? OK, I can always use the JWM TaskList menu, but I assume that you were looking for a different way.

BTW: Resizing the "fixed size" window results in strange artifacts :cry:
Attachments
dialog-fixed_resized.png
(5.39 KiB) Downloaded 188 times

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

#1216 Post by MochiMoppel »

Today I wondered why one of my <pixmap> widgets recognizes key-press-event signals while another - seemingly identical - widget doesn't.

Turns out that it makes a difference if the pixmap is packed into a scrollable or (default) not scrollable box container.
I updated my collection of <eventbox> mysteries.

User avatar
torm
Posts: 186
Joined: Sat 07 Mar 2015, 19:56

#1217 Post by torm »

export GTK2_RC_FILES
..interesting, works as is on this system.. no need to export.


OK, I can always use the JWM TaskList menu,

..not using JWM if possible, while double checked with JWM, looks working.
Maybe should have made better mimic of window border.. ? Top gray area?

BTW: Resizing the "fixed size" window results in strange artifacts
.. will add resizable="false" when update.
Also some more detailed rc file to support dark themes ( for resizable window ) .

livernote1
Posts: 3
Joined: Sat 09 Sep 2017, 03:36

#1218 Post by livernote1 »

Guys help needed, been working with this progress bar if using the example like give in page page 1 it is working fine but after i change the action it seem the program is running on the background only the progress bar is just silence

Code: Select all

<frame Progress>
    <text>
      <label>Duplication process is happening.</label>
    </text>
    <progressbar>
      <input>dd if=/dev/sda of=/dev/sdb</input>
	  <action>launch:END_DIALOG</action>
    </progressbar>
  </frame>

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#1219 Post by misko_2083 »

livernote1 wrote:Guys help needed, been working with this progress bar if using the example like give in page page 1 it is working fine but after i change the action it seem the program is running on the background only the progress bar is just silence

Code: Select all

<frame Progress>
    <text>
      <label>Duplication process is happening.</label>
    </text>
    <progressbar>
      <input>dd if=/dev/sda of=/dev/sdb</input>
	  <action>launch:END_DIALOG</action>
    </progressbar>
  </frame>
This is a way to show the progress bar with dd and pv in terminal.

Code: Select all

USB="/dev/sdb"
ISO_IMAGE="/path/to/ubuntu-15.04-desktop-amd64.iso"
SIZE=$(du -h -B1 "$ISO_IMAGE" | awk '{print $1}')

dd if="$ISO_IMAGE" | pv -s "$SIZE" | dd of="$USB" bs=4M oflag=dsync
With oflag=dsync dd will ask for completely synchronous output to disk. Slower but you'll have a progress bar.

Someone asked how to do this with yad.
To show this in a UI you need line by line output. For that add -n to pv.

Code: Select all

USB="/dev/sdb"
 ISO_IMAGE="/path/to/ubuntu-15.04-desktop-amd64.iso"
 SIZE=$(du -h -B1 "$ISO_IMAGE" | awk '{print $1}')

(dd if="$ISO_IMAGE" | pv -n -s "$SIZE" | dd of="$USB" bs=4M oflag=dsync) 2>&1 | \
  yad --center --borders=6 --title="Image writer" --text="$(echo -e "Writing $(basename "$ISO_IMAGE"):")"\
        --width=300 --progress --no-buttons --auto-close --image=system-run --window-icon=drive-removable-media-usb
You can apply something similar with gtkdialog.

User avatar
torm
Posts: 186
Joined: Sat 07 Mar 2015, 19:56

#1220 Post by torm »

Different versions of GTK2 and BASH..

fixed some,I hope ..

Post Reply