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
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 ..

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

#1221 Post by livernote1 »

misko_2083 wrote:
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.
i have try me best to understand but apparently still cant make the progress bar in the gtkdialog moving...its work smoothly if i just want to use the pv at terminal but on the gtkdialog interface the progress bar is no moving :(

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

#1222 Post by don570 »

Tip for a horizontal line of buttons at the bottom of a window (see image)

Instead of all the icons sharing the window equally
or force them all to the right side , I found a way to
give a button less space. In the example the help button
is small and on the left side. The other two buttons share the remaining space equally.

Code: Select all

#!/bin/sh


export TEXTSTRING="$(gettext 'How to use pho
Usage: : pho *.jpg (or whatever format). ')"

export VIEWER='
<window title="Experiment">
     <vbox   width-request="740">
             <text><label>Experiment</label></text>


             <hseparator></hseparator>
  
            <hbox>    
                       <button   space-expand="false" space-fill="false"> 
                      <input file stock="gtk-help"></input>
                       <action>Xdialog --title "'$(gettext 'Help')'"  --ok-label "'$(gettext 'OK')'" --backtitle "\n$TEXTSTRING \n "  --msgbox  "" 0 0 &</action>
                       </button> 


            <hbox   space-expand="true" space-fill="true">
                       <button>
                      <input file stock="gtk-cancel"></input>
                      <label>Cancel</label>
                     </button>

                      <button>
                       <input file stock="gtk-apply"></input>
                       <label>Proceed</label>        
                      <action>xmessage clicked</action>  
                      <action type="exit">CLOSE</action>           
                      </button> 
    
            </hbox></hbox>

      </vbox>
</window>'

gtkdialog -p VIEWER --center



Attachments
screenshot-script.png
(8.65 KiB) Downloaded 480 times

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

#1223 Post by don570 »

Here is final app --> pho viewer

http://murga-linux.com/puppy/viewtopic. ... 027#974027
____________________________________________________
Attachments
screenshot-pho.png
(31.41 KiB) Downloaded 430 times

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#1224 Post by mavrothal »

I was wondering if anyone has any idea under what conditions the gtkdialog elements of an app/script may be shown in reverse order
i.e. from bottom to top and from right to left (see pick below)

Should point out that this is with the mac version of gtkdialog :oops: , but still...
The gtkdialog dependencies appear to be ok, btw

Code: Select all

gm$ otool -L /usr/local/bin/gtkdialog # otool is the dll equivalent for ox x
/usr/local/bin/gtkdialog:
/usr/local/opt/gtk+/lib/libgtk-quartz-2.0.0.dylib (compatibility version 2401.0.0, current version 2401.31.0)
/usr/local/opt/gtk+/lib/libgdk-quartz-2.0.0.dylib (compatibility version 2401.0.0, current version 2401.31.0)
/usr/local/opt/pango/lib/libpangocairo-1.0.0.dylib (compatibility version 4001.0.0, current version 4001.3.0)
/usr/local/opt/pango/lib/libpango-1.0.0.dylib (compatibility version 4001.0.0, current version 4001.3.0)
/usr/local/opt/atk/lib/libatk-1.0.0.dylib (compatibility version 22210.0.0, current version 22210.1.0)
/usr/local/opt/cairo/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.6.0)
/usr/local/opt/gdk-pixbuf/lib/libgdk_pixbuf-2.0.0.dylib (compatibility version 3601.0.0, current version 3601.0.0)
/usr/local/opt/glib/lib/libgio-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/glib/lib/libgobject-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/glib/lib/libglib-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.5.0)
/usr/local/opt/glib/lib/libgthread-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
Attachments
gtkdialog_mac.png
(171.68 KiB) Downloaded 410 times
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#1225 Post by 01micko »

mavrothal wrote:I was wondering if anyone has any idea under what conditions the gtkdialog elements of an app/script may be shown in reverse order
i.e. from bottom to top and from right to left (see pick below)

Should point out that this is with the mac version of gtkdialog :oops: , but still...
The gtkdialog dependencies appear to be ok, btw

Code: Select all

gm$ otool -L /usr/local/bin/gtkdialog # otool is the dll equivalent for ox x
/usr/local/bin/gtkdialog:
/usr/local/opt/gtk+/lib/libgtk-quartz-2.0.0.dylib (compatibility version 2401.0.0, current version 2401.31.0)
/usr/local/opt/gtk+/lib/libgdk-quartz-2.0.0.dylib (compatibility version 2401.0.0, current version 2401.31.0)
/usr/local/opt/pango/lib/libpangocairo-1.0.0.dylib (compatibility version 4001.0.0, current version 4001.3.0)
/usr/local/opt/pango/lib/libpango-1.0.0.dylib (compatibility version 4001.0.0, current version 4001.3.0)
/usr/local/opt/atk/lib/libatk-1.0.0.dylib (compatibility version 22210.0.0, current version 22210.1.0)
/usr/local/opt/cairo/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.6.0)
/usr/local/opt/gdk-pixbuf/lib/libgdk_pixbuf-2.0.0.dylib (compatibility version 3601.0.0, current version 3601.0.0)
/usr/local/opt/glib/lib/libgio-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/glib/lib/libgobject-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/glib/lib/libglib-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.5.0)
/usr/local/opt/glib/lib/libgthread-2.0.0.dylib (compatibility version 5001.0.0, current version 5001.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
Said 'mac version' seems to exhibit the exact same problem of arm versions before jamesbond patched it... (take a close look at the screeny from your linked thread :wink: ).

You can try applying the untested patch attached.

NB: possibly in automaton.c (refer to patch) there are other possibilities. '__APPLE__' may work. If not replace it with '__MACH__'.
Attachments
apple_gtkdialog.patch.gz
real gzip (lol)
(343 Bytes) Downloaded 159 times
Puppy Linux Blog - contact me for access

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#1226 Post by mavrothal »

01micko wrote: Said 'mac version' seems to exhibit the exact same problem of arm versions before jamesbond patched it... (take a close look at the screeny from your linked thread :wink: ).

You can try applying the untested patch attached.

NB: possibly in automaton.c (refer to patch) there are other possibilities. '__APPLE__' may work. If not replace it with '__MACH__'.
This was it!
Needed some more changes to build but it worked.
Find the final gtkdialog mac binary and patch in the original post
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

slippery60
Posts: 5
Joined: Mon 18 Dec 2017, 20:31
Location: Fairmont, WV

How to calculate an suggested value for an entry widget

#1227 Post by slippery60 »

I am trying to calculate a suggested value for an entry field. The specific value I am looking for is the total number of bytes a storage device can hold.

A program "blockdev --getsize64 /dev/XXXX" will get the value for me. The sticky part is that I will not know the "/dev/xxxx" value until the user selects it.

The snippet below produces a list that the user selects from. The selection identifies the drive I want to determine the size of, in bytes.

Code: Select all

<list>
       <width>150</width>
       <height>80</height>
       <variable>EWF_SusPDrv</variable>
       <input>find /dev -type b -exec echo '{}' \; | sort </input></list>
</list>
I want to use the output from blockdev --getsize64 $EWF_SusPDrv to get that number.

Code: Select all

<text xalign="0" width-request="200"><label>"Number of Bytes to acquire"</label></text>
<entry width-request="100">
       <default>0</default>
       <variable>EWF_B</variable>
       <input>0</input>
</entry>
I could really use suggestions, thoughts, hints.

Thanks in advance guys

User avatar
SFR
Posts: 1800
Joined: Wed 26 Oct 2011, 21:52

#1228 Post by SFR »

Hey Slippery60, try this:

Code: Select all

#!/bin/sh

export MAIN='
<window>
  <vbox>
    <list> 
       <width>150</width> 
       <height>80</height> 
       <variable>EWF_SusPDrv</variable> 
       <input>find /dev -type b | sort </input>
       <action>refresh:EWF_B</action>
	</list>
    
    <text xalign="0" width-request="200"><label>"Number of Bytes to acquire"</label></text> 
	<entry width-request="100"> 
       <variable>EWF_B</variable> 
       <input>[ $EWF_SusPDrv ] && blockdev --getsize64 $EWF_SusPDrv || echo "N/A"</input> 
	</entry>
  </vbox>
</window>'

gtkdialog -p MAIN
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]

User avatar
spiritwild
Posts: 181
Joined: Mon 03 Oct 2016, 10:06

#1229 Post by spiritwild »

question...

I'm not someone who can put all the gtk code together to make what I want. I could take a simple app like what I need and possibly edit it to my likes. Is there a simple "menu" app / code that I could mess with?

It basically just needs to be a small window with buttons that I can run programs from. Combine a few apps to one menu, so to speak.
I'm just not familiar so if theres a simple code or app I could mess around with, that would be helpful. Thanks

slippery60
Posts: 5
Joined: Mon 18 Dec 2017, 20:31
Location: Fairmont, WV

How to calculate an suggested value for an entry widget

#1230 Post by slippery60 »

SFR;

Thanks Dude, exactly what I needed.

Fantastic.

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

#1231 Post by don570 »

It basically just needs to be a small window with buttons that I can run programs from.
People on the forum have already written this...

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

____________________________________________

To make a quick launcher yourself...

Put links to the desktop files in one folder,
then you can open this folder with the command

Code: Select all

rox -d /path/to/folder
__________________________________________

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

Launch pmusic in a script

#1232 Post by don570 »

Launch pmusic in a script
I have found that it is difficult to launch pmusic inside a script.

Here is method that works reliably even when pmusic has an option.
First of all , choose pmusic from other apps

Code: Select all

for P in mpg123 mpg321  pmusic parole vlc  xine defaultaudioplayer ; do
  MUSIC_APP=$(which $P) && break
done
Now replace pmusic with 'pmusic -B' if you want background music.
Put the command in a file and make executable.

Code: Select all

[ $MUSIC_APP = /usr/local/bin/pmusic ] && MUSIC_APP="pmusic -B"
echo "$MUSIC_APP" \""${snd}"\" > /tmp/pmusic_launch
chmod +x /tmp/pmusic_launch
/tmp/pmusic_launch 2>/dev/null &
_________________________________________________________

I used this method in PTM timer
http://murga-linux.com/puppy/viewtopic.php?t=112410
_________________________

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

Re: Launch pmusic in a script

#1233 Post by MochiMoppel »

don570 wrote:Here is method that works reliably even when pmusic has an option.
First of all , choose pmusic from other apps

Code: Select all

for P in mpg123 mpg321  pmusic parole vlc  xine defaultaudioplayer ; do
  MUSIC_APP=$(which $P) && break
done
Now replace pmusic with 'pmusic -B' if you want background music.
Put the command in a file and make executable.

Code: Select all

[ $MUSIC_APP = /usr/local/bin/pmusic ] && MUSIC_APP="pmusic -B"
echo "$MUSIC_APP" ""${snd}"" > /tmp/pmusic_launch
chmod +x /tmp/pmusic_launch
/tmp/pmusic_launch 2>/dev/null &
Try

Code: Select all

for MUSIC_APP in mpg123 mpg321  pmusic parole vlc  xine defaultaudioplayer ; do 
   which $MUSIC_APP && break 
done 
[ $MUSIC_APP = pmusic ] && OPTION="-B" 
exec $MUSIC_APP $OPTION "$snd"

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

#1234 Post by don570 »

[ $MUSIC_APP = pmusic ] && OPTION="-B"
exec $MUSIC_APP $OPTION "$snd"
I hadn't thought of that. I was trying to do it all as one variable
MUSIC_APP="pmusic -B"
________________________________

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

#1235 Post by MochiMoppel »

don570 wrote:I hadn't thought of that. I was trying to do it all as one variable
MUSIC_APP="pmusic -B"
...which would work perfectly - unless you have unintentionally changed your IFS assignment :wink:

Post Reply