Page 1 of 2

gtkdialog getting started

Posted: 20 Mar 2012, 03:59
by bigbass
This is a place holder for more stuff we will post here about gtkdialog
the new topic Programming !

thanks to the fast action taken by fanthom he set it up for us :Yahoo!:

*this Programming topic could be used for any programming language
that we could use on Porteus *


brokenman will be writing many more gtkdialog scripts for Porteus so
the sooner we all start adjusting the better

http://code.google.com/p/gtkdialog/

official
http://xpt.sourceforge.net/techdocs/lan ... es/single/

here are "officialy tested on Porteus examples" with color highlighting and new images
http://puppy2.org/slaxer/Porteus/Gtkdia ... color.html

The best tips and getting started by zigbert
http://www.murga-linux.com/puppy/viewtopic.php?t=38608

excellent tech side of gtkdialog by thunor
http://www.murga-linux.com/puppy/viewto ... 88&start=2

Here are tested on Porteus simplified examples
there's no way I can do better than the official site's info
so my plan is to take stuff and write stuff tested to be working on Porteus and make easier examples
this way getting started with working examples and a good way to put all the code in one place
to share

and we need our own gtkdialog place !!!

Image

Code: Select all

#!/bin/sh

# 2button_icon_actiones
# simple example for Porteus

export MAIN_DIALOG='
<vbox>
  <hbox>    
    
    <button>
      <input file icon="gnome-mplayer"></input>
      <label>media player</label>
      <action>gnome-mplayer</action>
    </button>         
    
    <button>
     <input file icon="xarchiver"></input>
     <label>compression tool</label>
     <action>xarchiver</action>
   </button>   
   
  </hbox>
</vbox>
'

gtkdialog --program=MAIN_DIALOG

Re: gtkdialog getting started

Posted: 20 Mar 2012, 13:00
by brokenman
Thanks BigBass.

It would be great if people started to learn gtkdialog and writing apps for porteus. If you need any help feel free to ping me. I am no guru, but i am getting more and more acquainted with gtkdialog as time passes.

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

This leaves other gtk wrappers such as zenity, xdialog & kdialog dead in the water!

Re: gtkdialog getting started

Posted: 20 Mar 2012, 15:26
by bigbass
brokenman
It would be great if people started to learn gtkdialog and writing apps for porteus. If you need any help feel free to ping me. I am no guru, but i am getting more and more acquainted with gtkdialog as time passes.
ping, ping testing the ping button since I know in advance I will be asking for your help :)
thanks !
Joe
--------------------------------------------------------------------------------------------



getting started 2
the button widget shows what other options could be used as a reference only dont get bothered with too much info I have an easy example below (you can skip this and test the code example first )
http://code.google.com/p/gtkdialog/wiki/button

in this example we will change only the icon to use the built in icons that belong to gtk

<input file stock="gtk-image"></input>


list of gtk stock icons as a reference only for more options (you can skip this and test the code example first )
http://developer.gnome.org/gtk/2.24/gtk ... ABOUT:CAPS
here we only care about the icon names between the quotes "gtk-about" or "gtk-edit" used below
dont let that confuse you with too much info

Image
*brokenman provides a code example next post to generate this image with mouse over to see the names*


*I added a new thing here that will make different default apps open
its better than hard coding only one app it uses xdg-open
what that does is find the default app that would normally open this filetype
in the example below the default text editor will be used

P.S normally you don't have extra spaces in the code
I did this so its easy to read and you can cut and paste code better this way
to add more stuff later

Image

Code: Select all

#!/bin/sh

# 1button_icon_gtk_stock
# now using stock gtk icon instead 
# simple example for Porteus

export MAIN_DIALOG='
<vbox>
  <hbox>   
   
   <button>
     <input file stock="gtk-edit"></input>     
     <label>default editor</label>
     <action>xdg-open /etc/porteus-version</action>
   </button>   
   
  </hbox>
</vbox>
'

gtkdialog --program=MAIN_DIALOG

Re: gtkdialog getting started

Posted: 20 Mar 2012, 17:45
by brokenman
Here is a script that displays the stock gtk-icons (the ones i could find) that you can use in the example above. Hover over the icon to see the name.

Example:
<input file stock="gtk-about"></input>

Code: Select all

#! /bin/sh

pmap(){
echo '<pixmap icon_size="6" tooltip-text="'$1'"><input file stock="'$1'"></input></pixmap>'
}
export MAIN_DIALOG='
<vbox><hbox>
'"$(pmap gtk-about)"'
'"$(pmap gtk-add)"'
'"$(pmap gtk-apply)"'
'"$(pmap gtk-bold)"'
'"$(pmap gtk-cancel)"'
'"$(pmap gtk-cdrom)"'
'"$(pmap gtk-clear)"'
'"$(pmap gtk-close)"'
'"$(pmap gtk-color-picker)"'
'"$(pmap gtk-connect)"'
'"$(pmap gtk-convert)"'
'"$(pmap gtk-copy)"'
'"$(pmap gtk-cut)"'
'"$(pmap gtk-delete)"'
'"$(pmap gtk-dialog-authentication)"'
'"$(pmap gtk-dialog-error)"'
'"$(pmap gtk-dialog-info)"'
'"$(pmap gtk-dialog-question)"'
'"$(pmap gtk-dialog-warning)"'
'"$(pmap gtk-directory)"'
'"$(pmap gtk-disconnect)"'
</hbox><hbox>
'"$(pmap gtk-dnd)"'
'"$(pmap gtk-dnd-multiple)"'
'"$(pmap gtk-edit)"'
'"$(pmap gtk-execute)"'
'"$(pmap gtk-file)"'
'"$(pmap gtk-find)"'
'"$(pmap gtk-find-and-replace)"'
'"$(pmap gtk-floppy)"'
'"$(pmap gtk-fullscreen)"'
'"$(pmap gtk-go-back)"'
'"$(pmap gtk-go-down)"'
'"$(pmap gtk-go-forward)"'
'"$(pmap gtk-go-up)"'
'"$(pmap gtk-goto-bottom)"'
'"$(pmap gtk-goto-first)"'
'"$(pmap gtk-goto-last)"'
'"$(pmap gtk-goto-top)"'
'"$(pmap gtk-harddisk)"'
'"$(pmap gtk-help)"'
'"$(pmap gtk-home)"'
'"$(pmap gtk-indent)"'
</hbox><hbox>
'"$(pmap gtk-index)"'
'"$(pmap gtk-info)"'
'"$(pmap gtk-italic)"'
'"$(pmap gtk-jump-to)"'
'"$(pmap gtk-justify-center)"'
'"$(pmap gtk-justify-fill)"'
'"$(pmap gtk-justify-left)"'
'"$(pmap gtk-justify-right)"'
'"$(pmap gtk-leave-fullscreen)"'
'"$(pmap gtk-media-forward)"'
'"$(pmap gtk-media-next)"'
'"$(pmap gtk-media-pause)"'
'"$(pmap gtk-media-play)"'
'"$(pmap gtk-media-previous)"'
'"$(pmap gtk-media-record)"'
'"$(pmap gtk-media-rewind)"'
'"$(pmap gtk-media-stop)"'
'"$(pmap gtk-missing-image)"'
'"$(pmap gtk-network)"'
'"$(pmap gtk-new)"'
'"$(pmap gtk-no)"'
</hbox><hbox>
'"$(pmap gtk-ok)"'
'"$(pmap gtk-open)"'
'"$(pmap gtk-orientation-landscape)"'
'"$(pmap gtk-orientation-portrait)"'
'"$(pmap gtk-orientation-reverse-landscape)"'
'"$(pmap gtk-orientation-reverse-portrait)"'
'"$(pmap gtk-page-setup)"'
'"$(pmap gtk-paste)"'
'"$(pmap gtk-preferences)"'
'"$(pmap gtk-print)"'
'"$(pmap gtk-print-error)"'
'"$(pmap gtk-print-paused)"'
'"$(pmap gtk-print-preview)"'
'"$(pmap gtk-print-report)"'
'"$(pmap gtk-print-warning)"'
'"$(pmap gtk-properties)"'
'"$(pmap gtk-quit)"'
'"$(pmap gtk-redo)"'
'"$(pmap gtk-refresh)"'
'"$(pmap gtk-remove)"'
'"$(pmap gtk-revert-to-saved)"'
</hbox><hbox>
'"$(pmap gtk-save)"'
'"$(pmap gtk-save-as)"'
'"$(pmap gtk-select-all)"'
'"$(pmap gtk-select-color)"'
'"$(pmap gtk-select-font)"'
'"$(pmap gtk-sort-ascending)"'
'"$(pmap gtk-sort-descending)"'
'"$(pmap gtk-spell-check)"'
'"$(pmap gtk-stop)"'
'"$(pmap gtk-strikethrough)"'
'"$(pmap gtk-undelete)"'
'"$(pmap gtk-underline)"'
'"$(pmap gtk-undo)"'
'"$(pmap gtk-yes)"'
'"$(pmap gtk-unindent)"'
'"$(pmap gtk-zoom-100)"'
'"$(pmap gtk-zoom-fit)"'
'"$(pmap gtk-zoom-in)"'
'"$(pmap gtk-zoom-out)"'
</hbox>
<button cancel></button>
</vbox>
'

gtkdialog --program=MAIN_DIALOG

Re: gtkdialog getting started

Posted: 20 Mar 2012, 19:32
by bigbass
Hey brokenman great stuff
this is what brokenman's example looks like above
Image



Joe


------------------------------------------------------------------------------------------------
*this post is only going to explain brokenman's code above *
it is an advanced example

------------------------------------------------------------------------------------------------
brokenman gave me an opportunity to explain what he did above using the gtk-icons and tool-tips

this will show you another great advanced feature using functions to replace
code so that it is easier to edit once you understand what is happening

1.) notice that there is one long line starting with <pixmap icon_size="6"
then a space and another command tool-tip it is closed with a >
then another space and the input command then everything is closed in </pixmap>

now I will rewrite it in two lines so its easier to read below in the second code example

Image

Code: Select all

#! /bin/sh

# shortened the example from brokenman

export MAIN_DIALOG='
<vbox>
 <hbox>
       <pixmap icon_size="6" tooltip-text="gtk-about">
       <input file stock="gtk-about"></input>     
       </pixmap>
      
 </hbox>
 <hbox>
       <pixmap icon_size="6" tooltip-text="gtk-ok">
       <input file stock="gtk-ok"></input>
       </pixmap>
 
 </hbox>
 <button cancel></button>
</vbox>
'

gtkdialog --program=MAIN_DIALOG

brokenman used this code (function) so that he would not have to manually edit a lot of code
if he wanted to make some changes in his code later so its a good idea to use functions its just a bit
of a steep learning curve
but it is a great way to see how functions can be used to remove code that is repeated
notice that the string "gtk-about" would be use two times and also
<pixmap icon_size="6" tooltip-text=
<input file stock=

writing a function simplifies code once tested to be working correctly
so it is a second step to clean up the code ( and functions are used often in code to process info and feed it back into the app )


pmap(){
echo '<pixmap icon_size="6" tooltip-text="'$1'"><input file stock="'$1'"></input></pixmap>'
}
Image

Code: Select all

#! /bin/sh
#brokenman's shortened code 
# even though its shortened now its still complex for people getting started
# but a great example how to use functions !

    pmap(){
    echo '<pixmap icon_size="6" tooltip-text="'$1'"><input file stock="'$1'"></input></pixmap>'
    }
    export MAIN_DIALOG='
    <vbox><hbox>
    '"$(pmap gtk-about)"'
    </hbox><hbox>
    '"$(pmap gtk-dnd)"'
    </hbox><hbox>
    '"$(pmap gtk-index)"'
    </hbox>
    <button cancel></button>
    </vbox>
    '

    gtkdialog --program=MAIN_DIALOG

Re: gtkdialog getting started

Posted: 21 Mar 2012, 11:26
by wread
@bigbass
Hello, bigbass, I have some old fortran programs already written and running in porteus (engineering programs).
Is it possible to write an input gui using gtkdialog? If so I will dig deeper into this and become addict to this forum topic!

Thanks for your info :Yahoo!:

Re: gtkdialog getting started

Posted: 27 Mar 2012, 18:13
by bigbass
Hey wread thanks for posting
wread wrote:@bigbass
Hello, bigbass, I have some old fortran programs already written and running in porteus (engineering programs).
Is it possible to write an input gui using gtkdialog?
any GUI could call the executable file(s) as backend tools if they run from the command line
so yes this would work for you


Posted after 1 day 3 hours 10 minutes 10 seconds:
A big thanks to brokenman for posting and offering the function code :Yahoo!:
I modified it for buttons this is an easy way to code once you get an idea what's happening :D
added undocumented tool-tips
Joe

Image

Code: Select all

#! /bin/sh
    # bigbass modified brokenman's function for buttons and apps to be
    # launched instead  and added a label
    # -->this is just too cool for getting started with gtkdialog
    #  a great example how to use functions !
    # added tool-tips

            pmap(){
                    echo '<button tooltip-text="'$1'">'   '<input file icon="'$1'"></input>' '<label>"'$1'"</label> ' '<action>'"$1"'</action>''</button>'
                   
                 }       
           
           
            export MAIN_DIALOG='
            <vbox>
            '"$(pmap lxterminal)"'       
            '"$(pmap leafpad)"'       
            '"$(pmap gpicview)"'       
            <button cancel></button>
            </vbox>
            '

            gtkdialog --program=MAIN_DIALOG




Posted after 22 hours 25 minutes 46 seconds:
maybe you want to launch some kde apps or commands that are more than one word
added undocumented tool-tips


Image

Code: Select all

#!/bin/sh       
    # maybe you want to launch some kde apps or commands that are more than one word           
    # added undocumented tool-tips
               
    export MAIN_DIALOG='
    <vbox>
    <button tooltip-text="kde memory info">
            <input file stock="gtk-preferences"></input>
            <label>Memory information</label>
            <action>kcmshell memory</action>
    </button>     
   
    <button tooltip-text="kde privacy clean up">
           <input file stock="gtk-preferences"></input>
           <label>privacy clean up</label>
           <action>kcmshell privacy</action>
    </button>       
    <button cancel></button>   
           </vbox>

           '
            gtkdialog --program=MAIN_DIALOG
Image
lets have some fun :)

Code: Select all

#!/bin/sh       
# maybe you want to launch some apps or commands that are more than one word           
# added undocumented tool-tips
# bigbass
                       
export MAIN_DIALOG='
<vbox>       

    <button tooltip-text="Listen to music">
    <input file icon="audacious"></input>
    <label>Audacious</label>
    <action>audacious2 %U</action></button>
    
    <button tooltip-text="Play your media">
    <input file icon="gnome-mplayer"></input>
    <label>GNOME MPlayer</label>
    <action>gnome-mplayer %U</action></button>
    
    <button tooltip-text="View your images easily">
    <input file icon="gpicview"></input>
    <label>Image Viewer</label> <action>gpicview %f</action></button>
    
    <button tooltip-text="Use Porteus Module">
    <input file icon="cdr"></input>
    <label>Use Porteus Module</label>
    <action>kactivate</action></button>
    
    <button tooltip-text="Simple text editor">
    <input file icon="leafpad"></input>
    <label>Leafpad</label> <action>leafpad %f</action></button>
    
    <button tooltip-text="Use the command line"> 
    <input file icon="lxterminal"></input> 
    <label>LXTerminal</label> <action>lxterminal</action></button>
    
    <button tooltip-text="Porteus Installer"> 
    <input file icon="drive-external-usb"></input> 
    <label>Porteus Installer</label>
    <action>/tmp/.terminal -e "ktsuss /opt/porteus-scripts/pinstaller"</action></button>
    
    <button tooltip-text="Start the Wicd client without system tray icon"> 
    <input file icon="wicd-gtk"></input> 
    <label>Wicd Network Manager</label>
    <action>wicd-gtk --no-tray</action></button>
    
    <button tooltip-text="A GTK+2 only archive manager"> 
    <input file icon="xarchiver"></input> 
    <label>Xarchiver</label> <action>xarchiver</action></button>

           
    <button cancel></button>   
</vbox>

'
gtkdialog --program=MAIN_DIALOG
                   
                   
          
Posted after 4 days 1 hour 26 minutes 56 seconds:
this is more advanced but it was fun to play with how to add lables that update!
(it is a cheat using the entry ) but don't tell anyone because it gets around a static problem in gtkdialog
I used the toggle code from thunnor

you need these two images in the same directory as the app
Image
http://bigbass-porteus.googlecode.com/files/no.png
Image
http://bigbass-porteus.googlecode.com/files/yes.png

this is the same box not two boxes it auto changes when you click the button !
Image
Image

Code: Select all

#!/bin/sh

# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). 
# March 27 2012 btnImage and lable Toggle bigbass modified example added 
# entry label and default start  



GTKDIALOG=gtkdialog

# set up default start or stop here 
echo "click button to stop first run" >$PWD/LABLE.txt
echo 0 > TOGGLE
ln -sf no.png toggle.png

function funcImageToggle() {
   if [ $(< TOGGLE) = 1 ]; then
      ln -sf no.png toggle.png
      echo "click button to stop function" >$PWD/LABLE.txt
      echo 0 > TOGGLE
   else
      ln -sf yes.png toggle.png
      echo 1 > TOGGLE
     
     echo "click button to start function" >$PWD/LABLE.txt
   fi
}
export -f funcImageToggle

if [ ! -f TOGGLE ]; then echo 0 > TOGGLE; funcImageToggle; fi

export MAIN_DIALOG='
<window title="btnImage and lable Toggle" resizable="false" width-request="400" height-request="100">
   <vbox homogeneous="true">
      <hbox homogeneous="true">
        <entry>
            <variable>ENTRY</variable>
            <input>cat $PWD/LABLE.txt</input>
            <variable>ENTRY</variable>           
        </entry>
        
         <button tooltip-text="click button for on or off !">           
            <action>cat $PWD/LABLE.txt</action>            
            <variable>TOGGLEMETOO</variable>
            <input file>toggle.png</input>
            <action>funcImageToggle</action>
            <action type="refresh">TOGGLEMETOO</action>
           <action type="refresh">ENTRY</action>
         </button>
                  
      </hbox>
   </vbox>
   <action signal="hide">exit:Exit</action>
</window>
'

$GTKDIALOG --center --program=MAIN_DIALOG



Re: gtkdialog getting started

Posted: 29 Mar 2012, 15:45
by Ahau
Thanks for starting this thread, bigbass! I'm interested in gtkdialog as well, but still getting my feet wet with it.

Here's my first script that uses it, pxf-sound:

Code: Select all

#!/bin/bash

# script by Ahau <ahau@porteus.org>
# script to change the volume in Porteus-XFCE
# channel is tied to the selected channel in the retrovol tray, so this requires retrovol (unless you only want to change Master Volume)

#some user editable variables:

#change to 0 if you don't want gtkdialog gui box
show_gui=1
#alter this to change how much the volume changes for each button press
step=4
#change icons...
activeicon=/usr/share/retrovol/images/audio-volume-high.png
muteicon=/usr/share/retrovol/images/audio-volume-muted.png

# This will search the retrovol configs for the specified volume channel
# this file will not exist unless the user reconfigures retrovol, so it defaults to Master Playback Volume
# if ~/retrovolrc is not found.

if [ ! -e ~/.retrovolrc ]; then
  retrovol
  kill `ps aux |grep retrovol |grep -v grep |grep -v hide|cut -d ' ' -f6,7|sed 's/ //g'`
fi


if [ -e ~/.retrovolrc ]; then
  tray_numid=`grep tray_control ~/.retrovolrc | grep -v \# | cut -d '=' -f2`
  vol_channel=`amixer controls | grep 'numid='$tray_numid`
  vol_channel=${vol_channel##*name=\'}
  vol_channel=${vol_channel%%\'}
else
  vol_channel='Master Playback Volume'
fi
export vol_channel

if [ "$1" = "up" ]; then
  amixer set $vol_channel $step%+
fi

if [ "$1" = "down" ]; then
  amixer set $vol_channel $step%-
fi

if [ "$1" = "toggle" ]; then  
  amixer set $vol_channel toggle
fi

# the rest will only be executed if the user wants to show the gtkdialog volume box
if [ "$show_gui" = "1" ]; then

  vol_level=`amixer get $vol_channel|tail -n1| sed -r 's/.*\[(.*)%\].*/\1/'`
  echo $vol_level > /tmp/.pxf-volume

  unset sound_off
  sound_off=`amixer get $vol_channel|tail -n1| grep '\[off\]'`
  if [ "$sound_off" ]; then
    mute=\(muted\)
    vicon=$muteicon
    export mute
  else
    vicon=$activeicon
  fi
  export vicon

  find_level (){
    vol_level=`amixer get $vol_channel|tail -n1| sed -r 's/.*\[(.*)%\].*/\1/'`
    export vol_level
  }

  export PXF_DIALOG='
  <window decorated="false" skip_taskbar_hint="true">
  <hbox>
        <pixmap>
            <input file>'$vicon'</input>
        </pixmap>
        <progressbar>
            <label>Volume '`echo $mute`'</label>
            <input>while [ "$M" != "100" ]; do M=`cat /tmp/.pxf-volume`; echo $M; sleep .125; done;</input>
	    <action type="exit">Ready</action>
        </progressbar>

    </hbox>
   </window>
  '

  show_volume (){
  p=0

  gtkdialog --program=PXF_DIALOG &

  while [ "$p" -lt "12" ]; do
    vol_status=`amixer get $vol_channel|tail -n1` 
    find_level
    if [ "$vol_level" = 100 ]; then
      vol_level=99.5
    fi
    if [ "$vol_status" != "$vol_check" ]; then
      p=0
    fi
    echo $vol_level > /tmp/.pxf-volume
    vol_check=$vol_status
    sleep .125
    p=$(( p + 1 ));
    done
  echo 100 > /tmp/.pxf-volume
  }


  if [ "$1" = "toggle" ]; then  
    old_pid=`ps aux |grep PXF_DIALOG |grep -v grep|cut -d ' ' -f6,7|sed 's/ //g'`
    [ "$old_pid" ] && kill $old_pid
    show_volume
  fi

  if [ "$1" = "up" ]; then 
    if [ ! `ps aux | grep -v grep |grep PXF_DIALOG` ]; then
      show_volume
    fi
  fi

  if [ "$1" = "down" ]; then 
    if [ ! `ps aux | grep -v grep |grep PXF_DIALOG` ]; then
      show_volume
    fi
  fi

fi
I wrote it for use in xfce, because when I dropped all things gstreamer from xfce, I lost the xfce volume daemon, which displayed the volume level on the screen, and I like to have that visual indicator when I'm pushing the volume buttons on my laptop.

The actual gtkdialog bit is quite short, because this is just a single progress bar (less is more in this instance). This script gets bound to the laptop volume keys via a keybinding in xfce, and it interfaces with the amixer command line utility and pulls configuration information from the retrovol config file (retrovol is the sound mixer that comes with porteus-xfce, another app borrowed from puppy :) ). The progress bar gets updated ever eigth of a second and stays up for a second and a half after the last volume change, so if the user keeps pressing the volume up/down buttons, the progress bar will move up and down to show the change. If the user presses the mute button, it will kill the dialog, change the icon and the text inside the progress bar to reflect that the sound is muted, then display it again (this is less than graceful, and I fought it for a long time -- suggestions for improvement are welcome).

Re: gtkdialog getting started

Posted: 11 Apr 2012, 04:53
by bigbass
Ahau Thanks for posting code to share !


here's an update on toggling a pixmap image ,button and entry
gtkdialog is a static GUI so much trickery involved to get it to look like a dynamic GUI
meaning updating the GUI when its running

the pixmap took me awhile to figure out so don't feel bad if
it takes you some time to get a working example going
it starts to make sense after the dizzy feeling goes away from following all the zig-zags :)

*required images * place in the same directory as the script
http://bigbass-porteus.googlecode.com/files/ok-orig.png
http://bigbass-porteus.googlecode.com/files/ok.png
http://bigbass-porteus.googlecode.com/files/cancel.png
http://bigbass-porteus.googlecode.com/files/no.png
http://bigbass-porteus.googlecode.com/files/yes.png

Image

Code: Select all

#!/bin/sh

# NOTE: This example requires at least gtkdialog-0.7.21 (please visit
# http://code.google.com/p/gtkdialog/). 
# March 27 2012 btnImage and lable Toggle bigbass modified example added 
# entry label and default start  
# March 29 -2012 added pixmap function 
# /tmp/ replaced with /dev/shm/ for guest account permissions problems

# required images in the same directory as the script
# ok-orig.png ,cancel.png ,ok.png,yes.png,no.png

#http://bigbass-porteus.googlecode.com/files/ok-orig.png
#http://bigbass-porteus.googlecode.com/files/ok.png
#http://bigbass-porteus.googlecode.com/files/cancel.png
#http://bigbass-porteus.googlecode.com/files/no.png
#http://bigbass-porteus.googlecode.com/files/yes.png

# set up default start or stop here 
# what GAMES TO PLAY to make static gtkdialog 'pretend to be dynamic' 
echo "click button to stop first run" >$PWD/LABLE.txt
echo 0 > TOGGLE
ln -sf no.png toggle.png
cp -f $PWD/ok-orig.png /dev/shm/ok.png

# we have to always start with the cancel image
# or you would have to click once with no changes 
# because you would have two ok's in a row 
cp -f $PWD/cancel.png $PWD/ok.png      



#--------------------------------------------------
# small button image next to entry yes and no .png
#--------------------------------------------------

function funcImageToggle() {
   if [ $(< TOGGLE) = 1 ]; then
      ln -sf no.png toggle.png        
      echo 0 > TOGGLE
      echo "click button to stop function" >$PWD/LABLE.txt
   else
      ln -sf yes.png toggle.png         
      echo 1 > TOGGLE     
     echo "click button to start function" >$PWD/LABLE.txt
   fi
}
export -f funcImageToggle

if [ ! -f TOGGLE ]; then echo 0 > TOGGLE; funcImageToggle; fi


#--------------------------------------------------
# PIXMAP image cancel and ok .png
#--------------------------------------------------

function funcPixmapToggle() {
   if [ $(< TOGGLE2) = 1 ]; then
            
      # copy file to tmp so we dont over write the original 
      cp -f $PWD/ok.png /dev/shm/ok.png
      # overwrite file now cancel=ok 
      cp -f $PWD/cancel.png $PWD/ok.png      
      echo 0 > TOGGLE2
     
   else
      
      # return the original ok   ok=ok
      cp -f $PWD/ok-orig.png $PWD/ok.png      
      echo 1 > TOGGLE2     
    
   fi
}
export -f funcPixmapToggle

if [ ! -f TOGGLE2 ]; then echo 0 > TOGGLE2; funcPixmapToggle; fi






export MAIN_DIALOG='
<window title="btnImage and lable Toggle + pixmap toggle" resizable="false" width-request="390" height-request="100">
  <vbox homogeneous="true">

  <pixmap> 
  <variable>IMAGE</variable>
  <input file>'"$PWD"'/ok.png</input>  
  </pixmap>
 
  <button tooltip-text="change pixmap image " resizable="false"  height-request="40">  
  <label>Change image</label>
  <action>funcPixmapToggle</action>
  <action type="refresh">IMAGE</action>     
  </button>
    
  
      <hbox homogeneous="true">
        <entry>
            <variable>ENTRY</variable>
            <input>cat $PWD/LABLE.txt</input>
            <variable>ENTRY</variable>           
        </entry>
        
         <button tooltip-text="click button for on or off !">           
            <action>cat $PWD/LABLE.txt</action>            
            <variable>TOGGLEMETOO</variable>
            <input file>toggle.png</input>
            <action>funcImageToggle</action>
            <action type="refresh">TOGGLEMETOO</action>
           <action type="refresh">ENTRY</action>
         </button>
                  
      </hbox>
   </vbox>
   <action signal="hide">exit:Exit</action>
</window>
'

gtkdialog --center --program=MAIN_DIALOG





Image
Posted after 2 days 19 hours 52 minutes 34 seconds:
txt2image in gtkdialog
http://porteus.org/forum/viewtopic.php? ... 8802#p8802








Posted after 5 days 8 hours 43 minutes 21 second:
Image

menu item example
Remember I am looking for code tested to be working on Porteus
if you have some snippets
place this logo in /usr/share/icons
http://bigbass-porteus.googlecode.com/f ... k-logo.png

Code: Select all

#!/bin/bash
# SIMPLE_MENU
# Example code using menuitem
# For Porteus 1.2 by bigbass

export SIMPLE_MENU='
<window title="Simple Menu" window-position="1">
<vbox>
<menubar>
   <menu>
	<menuitem icon="gpicview"> <label>Image Viewer</label> <action>gpicview &</action> <action>exit</action>  </menuitem>
	<menuitem icon="noatun"> <label>Noatun</label> <action>noatun %i %m -caption "%c" %U &</action><action>exit</action>  </menuitem>
	<menuitem icon="gnome-mplayer"> <label>GNOME MPlayer</label> <action>gnome-mplayer &</action><action>exit</action>  </menuitem>
	<menuitem icon="leafpad"> <label>Leafpad</label> <action>leafpad &</action><action>exit</action></menuitem>                   
	<menuitem icon="firefox"> <label>Firefox</label> <action>firefox &</action><action>exit</action>  </menuitem>
	<menuitem icon="lxterminal"> <label>Super User Mode - Terminal</label> <action>/tmp/.terminal -e su - &</action><action>exit</action>  </menuitem>
	<menuitem icon="xarchiver"> <label>Xarchiver</label> <action>xarchiver &</action><action>exit</action>  </menuitem>
	<menuitem icon="lxtask"> <label>Task Manager</label> <action>lxtask &</action><action>exit</action>  </menuitem>
	<menuitem icon="gparted"> <label>GParted</label> <action>gparted &</action><action>exit</action>  </menuitem>
   <label>Programs</label>   
   </menu>
   
   <menu>
	<menuitem icon="status_unknown"> <label>Porteus System Info</label> <action>/tmp/.terminal -e /opt/porteus-scripts/psinfo &</action><action>exit</action>  </menuitem>
	<menuitem icon="pmodule"> <label>Porteus Package Manager</label> <action>/tmp/.terminal -e "ktsuss /opt/porteus-scripts/porteus-package-manager" &</action><action>exit</action>  </menuitem>
	<menuitem icon="drive-external-usb"> <label>Porteus Installer</label> <action>/tmp/.terminal -e "ktsuss /opt/porteus-scripts/pinstaller" &</action><action>exit</action>  </menuitem>
	<label>Special</label>   
   </menu>   
   
   
	<menu>         
	 <menuitem icon="firefox">  <label>Porteus.org</label> <action>firefox http://porteus.org/ &</action><action>exit</action>  </menuitem>
	 <menuitem icon="firefox">  <label>Porteus download stuff</label> <action>firefox  http://ponce.cc/porteus/ &</action><action>exit</action>  </menuitem>
	 <menuitem icon="kfind"> <label>Porteus FAQ</label> <action>/tmp/.browser /usr/doc/Porteus-FAQ/index.html &</action><action>exit</action>  </menuitem>
	<label>Help</label>
	</menu>   
   
</menubar>

  <frame>
	<pixmap>
		   <input file>/usr/share/icons/black-logo.png</input>
	</pixmap>
		   <text><label>Simple menu for Porteus</label></text>
  </frame>
   <hbox>
		<button cancel></button>
  </hbox>
</vbox>
</window>'

gtkdialog --program SIMPLE_MENU
unset SIMPLE_MENU 



Posted after 4 days 5 hours 23 minutes 37 seconds:

this is how to think when using gtkdialog
I hated gtkdialog before for the reason it looks odd to read
and stayed away from it after a little practice it becomes easy to read :)

Image

The first thing you need to see is how the code is grouped in blocks like legos

1.) The light blue is the head and foot
2.) The yellow is in this example the start and end of the body everything else is between this
3.) The grey in this example the text starts and ends and the lable is what shows in the GUI
4.)The orange is a simple double button one is ok the other is cancel it starts with a hbox in this example
Image
sometimes you want things horizonal that's hbox
sometimes you want things vertical that's vbox

the faster you see how the code is grouped the faster you can add and remove code
in blocks this is the first hurdle when reading gtkdialog

that thought led me to start developing a syntax high lighting tool for gtkdialog more to come !
http://porteus.org/forum/viewtopic.php?f=94&t=1177

Re: gtkdialog getting started

Posted: 18 Jul 2012, 09:51
by XmnemoniC
@bigbass

Hi bigbass
I'm completly newbie in threat gtkdialog. So, my questions are very simple.
1. How can I write my scripts?
2. How to run?
3. Can I make them with python's scripts?

XmnemoniC

Re: gtkdialog getting started

Posted: 19 Jul 2012, 15:05
by bigbass
1. How can I write my scripts?
2. How to run?
3. Can I make them with python's scripts?

ok this is a getting started page so go to the first example

Code: Select all

#!/bin/sh

# 2button_icon_actiones
# simple example for Porteus

export MAIN_DIALOG='
<vbox>
  <hbox>   
   
    <button>
      <input file icon="gnome-mplayer"></input>
      <label>media player</label>
      <action>gnome-mplayer</action>
    </button>         
   
    <button>
     <input file icon="xarchiver"></input>
     <label>compression tool</label>
     <action>xarchiver</action>
   </button>   
   
  </hbox>
</vbox>
'

gtkdialog --program=MAIN_DIALOG
manually select all the text from the code box (dont use the link that say select all it doesnt work)
open a terminal and paste it then press enter

you could call any program or binary or script the same way you would using bash commands

most importantly have fun :)
Joe

Re: gtkdialog getting started

Posted: 23 Jul 2012, 15:21
by XmnemoniC
Thx bigbass for reply :)
I'll start learn gtkdialog at evening.

Hi bigbass, again :)
I play with your scripts. Why does a dialog box with a third script, I can not move?
Others can. Sources of scripts are similar.

Napisane after 3 days 8 hours 37 minutes 32 seconds:
XmnemoniC wrote: I play with your scripts. Why does a dialog box with a third script, I can not move?
Others can. Sources of scripts are similar.
All good. It's my mistake.

Re: gtkdialog getting started

Posted: 02 Oct 2012, 02:48
by brokenman
New gtkdialog was released in Sept 2012 v0.8.2 which has some nice additions. Please check the googlecode page for source code and changelog.

http://code.google.com/p/gtkdialog/downloads/list

Re: gtkdialog getting started

Posted: 02 Oct 2012, 13:25
by bigbass
Thanks Jay

gtkdialog-8.2 compiled and packaged on porteus-1.2
http://bigbass-porteus.googlecode.com/f ... 1_PORT.tgz

will do one for slackware 14 too

test with

Code: Select all

gtkdialog --version

Joe
Gtkdialog 0.8.2 Released

Gtkdialog is a small utility for fast and easy GUI building.

Changes:
* Added eventbox, expander and fontbutton widgets.
* Added a terminal widget -- requires libvte but is not mandatory.
* Added activate, grabfocus, hide, show, and presentwindow functions.
* Added widget signal emission on input file change (file-monitor).
* Added widget auto-refreshing on input file change (auto-refresh).
* Greatly improved the table and tree widgets including natural sorting.
* Greatly enhanced the performance of the table, tree and comboboxes.
* Greatly expanded the feature set of several incomplete widgets.
* Added many useful exported variables on button and key press events.
* Added the envvar GTKDIALOG_PIXMAP_PATH to help locate pixmaps.
* Re-engineered the launch and closewindow system to be more robust.
* Fixed the longstanding not exiting via the window manager bug.
* Fixed and improved the button horizontal image with label alignment.
* Fixed the Raspberry Pi's (ARM) incorrectly ordered widgets problem.
* Added build and extra library details to the --version argument.
* Added more than a dozen new examples.
* Added a default application icon.
* Fixed several bugs.

http://code.google.com/p/gtkdialog/

Re: gtkdialog getting started

Posted: 02 Oct 2012, 15:40
by Ahau
Whoa, that looks like a NICE upgrade!
* Fixed the Raspberry Pi's (ARM) incorrectly ordered widgets problem.
So, I guess I wasn't the only one who had upside-down gtkdialogs on ARM architecture! I had no idea how to fix this, so I'm glad someone else did!
Greatly enhanced the performance of the table, tree and comboboxes
I hope this means long comboboxes won't open up with a ton of blank space at the top ;)
Added widget signal emission on input file change (file-monitor).
* Added widget auto-refreshing on input file change (auto-refresh).
I'm excited to see how these work!