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:

#921 Post by zigbert »

Try a slash in front of $

Code: Select all

<action signal=\"button-release-event\">[ \$nTabPage -eq 0 ] && xmessage \"first tab\"</action> 

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

#922 Post by don570 »

I found that it is possible to force a button to bottom of list by a simple
trick. ---> text widget gets space-expand="true"

Code: Select all

<vbox>
<button>....</button>
...
...
<text space-expand="true"><label>""</label></text>

<button>...</button>
</vbox>
Note the button in right bottom corner. The button doesn't go
all the way to bottom, but close enough.
Image

Puma
Posts: 7
Joined: Tue 09 Oct 2012, 15:59

notebook tab refresh

#923 Post by Puma »

Thanks all for the quick reply. Code example of SFR works perfect but a new
problem arised. First some explanation.

At the moment i developed a Wary Distribution with special attention to server administration of VNC, PureFtp, Hiawatha (WebServer), PHP, and MySql.

Name of the distribution is Pumalix (Pu for Puppy, Ma for Part of my Name and Lix for Linux). Distribution is based on Wary becauce of old Bios support.

Included are Firefox (latest Version), PlayOnLinux, Gimp, Virtual Box and many more. Also i adapted all GtkDialog code to support multilingual appearance.

All is controlled by a GUI shown in attachement. Each Tab of the GUI is represented by a string variable which is allocated by a Function.

Because there is some code behind each Tab (especially ther Server Tab)
i would like to avoid running this code if only Tab one is shown. In this
case only code for Tab one should run and for the other tabs there is a simple dummy function running.

But if you click Tab two then the content of the represented string should change by calling the appropriate function.

Do do this i miss a event or something i can refresh after click.

below a simple code example.

Code: Select all

#! /bin/bash


########################  EXPORT Variablen  ##############################

export cTabBlank
export cTabPage1
export cTabPage2
export cTabPage3

#typeset -i nTabPage=0
#declare -i nTabPage=1

########################  EXPORT Functions  ##############################

function GetTabPage1()
{
  cTabPage1="<frame>
    <text>
      <label>\"first tab\"</label>
    </text>
  </frame>"
  
  echo $cTabPage1 
}
export -f GetTabPage1


#########################################################################

function GetTabPage2()
{
  cTabPage2="<frame>
    <text>
      <label>\"second tab\"</label>
    </text>
  </frame>"
  
  echo $cTabPage2 
}
export -f GetTabPage2


#########################################################################

function GetTabPage3()
{
  cTabPage3="<frame>
    <text>
      <label>\"third tab\"</label>
    </text>
  </frame>"
  
  echo $cTabPage3 
}
export -f GetTabPage3

#########################################################################

function GetTabBlank()
{
  cTabBlank="<frame>
    <text>
      <label>\"blank tab\"</label>
    </text>
  </frame>"
  
  echo $cTabBlank 
}
export -f GetTabBlank

#########################################################################

function OnTabPageChanged()
{
  declare -i local nActPage

  nActPage=$1

  if [ $nActPage -eq 0 ]; then
    xmessage "content of tab one is allways the same, no changes needed"
    #cTabPage1=$(GetTabPage1) 
  elif [ $nActPage -eq 1 ]; then
    xmessage "content of tab two should change by changing variable cTabPage2"
    cTabPage2=$(GetTabPage2)   
  elif [ $nActPage -eq 2 ]; then
	xmessage "content of tab three should change by changing variable cTabPage3"
	cTabPage3=$(GetTabPage3)
  fi  
  
}
export -f OnTabPageChanged


####################  INIT Notebook Tabs ################################

cTabPage1=$(GetTabPage1)
cTabPage2=$(GetTabBlank)
cTabPage3=$(GetTabBlank)

#############################  M A I N ##################################

export MAIN="
<notebook>

  $cTabPage1
  $cTabPage2
  $cTabPage3
  
  <variable>nTabPage</variable> 
  <action signal=\"button-release-event\">[ "'$nTabPage'" -eq 0 ] && OnTabPageChanged "'$nTabPage'" && refresh:nTabPage</action>
  <action signal=\"button-release-event\">[ "'$nTabPage'" -eq 1 ] && OnTabPageChanged "'$nTabPage'" && refresh:nTabPage</action>
  <action signal=\"button-release-event\">[ "'$nTabPage'" -eq 2 ] && OnTabPageChanged "'$nTabPage'" && refresh:nTabPage</action>      

</notebook>"

#############################  T E S T ##################################

#I=$IFS; IFS=""
#for STATEMENTS in  $(gtkdialog -cp MAIN	); do
#  eval $STATEMENTS
#done
#IFS=$I 

gtkdialog -cp MAIN	

##################### UNSET Functions ################################

unset GetTabBlank
unset GetTabPage1
unset GetTabPage2
unset GetTabPage3
unset OnTabPageChanged

##################### UNSET Variablen ################################

unset cTabBlank
unset cTabPage1
unset cTabPage2
unset cTabPage3

Puma
Posts: 7
Joined: Tue 09 Oct 2012, 15:59

screenshoot of control gui

#924 Post by Puma »

see attachment
Last edited by Puma on Tue 25 Feb 2014, 19:26, edited 7 times in total.

Puma
Posts: 7
Joined: Tue 09 Oct 2012, 15:59

next try image upload

#925 Post by Puma »

as embedded image

[img]/home/puma/Desktop/ServerControl.png[/img]
Last edited by Puma on Sun 23 Feb 2014, 18:56, edited 1 time in total.

Puma
Posts: 7
Joined: Tue 09 Oct 2012, 15:59

s o r r y

#926 Post by Puma »

cant upload any image neither as embedded image nor attachment

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

#927 Post by don570 »

When I post an image I use photobucket.com as a server,
then I can use <IMG>.....</IMG> tags
_________________________________________________

thanius
Posts: 10
Joined: Tue 04 Feb 2014, 17:19

Regarding updating pixmaps

#928 Post by thanius »

I just wrote an ad cycler and thought I'd share some on the pixmap updater. I saw the example here but I found it more clean to make symbolic links instead of copying the files. Here's my ad cycler:

Code: Select all

#!/bin/bash 

ln -fs ad1.png ad.png
echo 2 > /tmp/count

function cycle_ad {

# Because gtkdialog won't handle global vars for some retarded reason!
i=`cat /tmp/count`

if [ -e "ad$i.png" ]; then
  ln -fs ad$i.png ad.png
  echo $i+1|bc > /tmp/count
else
  ln -fs ad1.png ad.png
  echo 2 > /tmp/count
fi

}

export MAIN=' 
<window width-request="600" height-request="400"> 

<vbox homogeneous="true">
 <pixmap> 
  <variable>IMAGE</variable>
  <input file>ad.png</input> 
 </pixmap>
 
 <timer milliseconds="false" interval="13" visible="false"> 
   <action>exec $SHELL -c cycle_ad</action> 
   <action>sleep 2</action>
   <action type="refresh">IMAGE</action> 
 </timer>

</vbox> 
</window>' 

export -f cycle_ad

gtkdialog --center --program=MAIN

brokenman
Posts: 25
Joined: Thu 20 Oct 2011, 23:00

Always on top

#929 Post by brokenman »

Keeping a gtkdialog app 'always on top'

I've just read that this is possible in jwm using the .jwmrc file and launching the gtkdialog as a --class=APPLET. Is there an inbuilt way to do the same in openbox?

This could probably be achieved with other methods inside the openbox rc.xml file but I am wondering if something similar to the JWM solution si viable.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#930 Post by disciple »

"other methods inside the openbox rc.xml file" sounds similar to "using the .jwmrc file" to me...
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#931 Post by seaside »

JWM can be set by placing this in /root/.jwm/jwmrc-personal-

Code: Select all

<Group>
<Name>on-top</Name>
<Class>on-top</Class>
<Option>layer:12</Option>
</Group>
Openbox set by openbox rc.xml "layer" property.
http://openbox.org/wiki/Help:Applicatio ... n_settings

Cheers,
s

User avatar
neerajkolte
Posts: 516
Joined: Mon 10 Feb 2014, 07:05
Location: Pune, India.

#932 Post by neerajkolte »

Nice thread. Just bookmarking for reference.
"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson

“We tend to overestimate the effect of a technology in the short run and underestimate the effect in the long run.â€￾
- Amara’s Law.

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

#933 Post by Argolance »

Bonjour,
JWM Configuration web page wrote:layer
The layer of the tray. The default is above. Valid values are below, normal, and above.
So, depending on the JWM version you are running:

Code: Select all

<Group>
<Name>on-top</Name>
<Class>on-top</Class>
<Option>layer:12</Option>
</Group>
... is now deprecated and doesn't work properly.
It should be:

Code: Select all

<Group>
<Name>on-top</Name>
<Class>on-top</Class>
<Option>layer:above</Option>
</Group>
Cordialement.

User avatar
puppy_apprentice
Posts: 299
Joined: Tue 07 Feb 2012, 20:32

#934 Post by puppy_apprentice »

I want to make buttons UP and DOWN to move item on the list/tree gadget one place up or down. Is there built-in function for this task or i will have make own bash function for this? Maybe someone has code snippet for this?

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

#935 Post by MochiMoppel »

puppy_apprentice wrote:I want to make buttons UP and DOWN to move item on the list/tree gadget one place up or down. Is there built-in function for this task or i will have make own bash function for this? Maybe someone has code snippet for this?
Zigbert provides a code snippet on the first page of this thread ("The next script shows how to move items in list by drag'n drop"). Not really buttons and I haven't tested, but maybe a start.

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

#936 Post by zigbert »

pBurn use buttons to move items up/down in a <tree>.
/usr/local/pburn/func_gui - line 351

Code: Select all

     <button tooltip-text=\" $(gettext 'Move item UP') \">
      <variable>MOVE_UP</variable>
      <input file stock=\"gtk-go-up\"></input>
      <visible>$VISIBLE_MOVE_UPDOWN</visible>
      <action>DIRECTION=up; . $APPDIR/func -move_up_down; . $APPDIR/func -info_burn</action>
      <action>refresh:BURNLIST</action>
     </button>
function -move_up_down is found in /usr/local/pburn/func - line 424

In the pMusic playqueue, you can move items by drag'n'drop.
/usr/local/pmusic/gui_playlist - line 27-29

Code: Select all

 <action signal="button-press-event">grep -F "$PLAYLIST" '$WORKDIR'/playlist > '$WORKDIR'/PLAYLIST_PRESS_EVENT; [ "$PLAYLIST" ] && . '$APPDIR'/menu_playqueue</action>
 <action signal="button-release-event">. '$APPDIR'/func -playlist_move</action> ##this will play the track as well
 <action signal="button-release-event">refresh:PLAYLIST</action>
The -playlist_move function is found in /usr/local/pmusic/func - line 479

User avatar
puppy_apprentice
Posts: 299
Joined: Tue 07 Feb 2012, 20:32

#937 Post by puppy_apprentice »

thx for both of you i will check this

titi89
Posts: 17
Joined: Fri 02 Apr 2010, 07:57

color cell tree

#938 Post by titi89 »

Hello, saddened for my English it is possible to color a cell(unit) in a tree?
And if yes how?
Thank you

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

#939 Post by zigbert »

I don't think that is possible inside the <tree> widget.


Sigmund

titi89
Posts: 17
Joined: Fri 02 Apr 2010, 07:57

#940 Post by titi89 »

ok thank you

Post Reply