Gtkdialog Development
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
This is the eventbox inside another eventbox border trick using some of the code from Sigmund's menu prototype just to illustrate what you can do (it might be of interest to somebody, it might not):
Code: Select all
#!/bin/sh
[ -z $GTKDIALOG ] && GTKDIALOG=gtkdialog
## ---------------------------------------------------------------------
## Local Functions
## ---------------------------------------------------------------------
## Create a custom GTK+ 2 style for specific widgets.
funcgtkrcCreate() {
echo '
style "styleExterior" {
bg[NORMAL] = "#000000"
}
widget "*Exterior" style "styleExterior"
' > "$TMPDIR"/.gtkrc-2.0
GTK2_RC_FILES="$TMPDIR"/.gtkrc-2.0:~/.gtkrc-2.0
export GTK2_RC_FILES
}
## Create a custom GTK+ 3 style for specific widgets.
funcgtkcssCreate() {
echo '
#Exterior {
background-color: #000000
}
#Interior {
background-color: #ffffff
}
' > "$TMPDIR"/gtk.css
EXTRA_ARGS="$EXTRA_ARGS --styles $TMPDIR/gtk.css"
}
## ---------------------------------------------------------------------
## Main
## ---------------------------------------------------------------------
TMPDIR=/tmp/gtkdialog/examples/"`basename $0`"
mkdir -p "$TMPDIR"
EXTRA_ARGS=
case `$GTKDIALOG -v` in
*"GTK+ 3"*) funcgtkcssCreate ;;
*) funcgtkrcCreate ;;
esac
MAIN_DIALOG='
<window decorated="false" window-position="1">
<eventbox name="Exterior">
<eventbox name="Interior" border-width="5">
<vbox spacing="2">
<hbox spacing="0">
<pixmap height-request="20" icon-size="1"
space-expand="false" space-fill="false">
<input file stock="gtk-add"></input>
</pixmap>
<button height-request="20" xalign="0" can-focus="no" relief="2">
<label>" This could have been a nice ADD menuitem, but menu is too narrow"</label>
</button>
</hbox>
<hbox spacing="0">
<pixmap height-request="20" icon-size="1"
space-expand="false" space-fill="false">
<input file stock="gtk-add"></input>
</pixmap>
<button height-request="20" xalign="0" can-focus="no" relief="2">
<label>" Another nice ADD menuitem"</label>
</button>
</hbox>
</vbox>
</eventbox>
</eventbox>
</window>
'
export MAIN_DIALOG
case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --space-expand=true --space-fill=true --program=MAIN_DIALOG $EXTRA_ARGS ;;
esac
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Instead of painting the background to a specific colour, you could tile it with a black square 50% opaque so for the most part this would give the impression of a border regardless of theme.zigbert wrote:Nifty
The gtkrc and gtk.css code for bitmaps is:
Code: Select all
GTK+ 2:
pixmap_path "/image/folder"
style "styleBgPixmap" {
bg_pixmap[NORMAL] = "myblacksquare.png"
}
widget "*BgPixmap" style "styleBgPixmap"
GTK+ 3:
#BgPixmap {
background-image: url("/image/folder/myblacksquare.png")
}
I'm just throwing stuff in.
-
- Posts: 1
- Joined: Sun 19 May 2013, 10:08
Using variables in dialogue
I am not sure if this is the right place to ask this, but I didn't find anywhere else to go…
Let's say that I create a window with a few items on it. One of them is a text field (I think it's called
Let's say that I create a window with a few items on it. One of them is a text field (I think it's called
- DocSalvage
- Posts: 11
- Joined: Sat 30 Jun 2012, 18:59
- Location: Tallahassee, FL, USA
- Contact:
Line continuation within tags
I've discovered some unexpected behavior. (at least under bash 4.1.0(1) as of gtkdialog 0.8.4 r503M) and am posting for feedback...
PROBLEM
• The well-known bash backslash (\) works as expected as long as it is preceded by a space to separate the attributes, as in...
• But experiments reveal that 3-dot-ellipsis (...), comas (,), and probably other characters also work and may be less distracting. It's possible that some extraneous characters are being tolerated and ignored, thus leading to this behavior.
• The most portable solution is probably to just turn off the stripping of trailing spaces in the editor and insuring each line ends with at least one space ("_" below indicates the invisible trailing space)...
RESOURCES
PROBLEM
- In coding GtkDialog, attributes often extend far more than a comfortable screen width.
Having many attributes off-screen, accessible only by scrolling, is error-prone and the editor's word-wrapping may not improve readability.
Using the bash backslash (\) for line-continuation introduces perceptional "noise" that some find distracting.
Using an editor, such as Geany, set to strip trailing spaces leaves no spaces between attributes and thus generates an error. (Indentation tabs and spaces apparently are ignored.)
- However, experimentation has revealed that there are actually several options for achieving line-continuation in tags.
As is documented and used in several standard examples, no line-continuation characters are needed for the common case of assigning the string of code to an environment variable as in...
Code: Select all
export MAIN_DIALOG='
<entry
file-monitor="true"
fs-action="file"
fs-folder=""
fs-filters-mime="text/plain|text/html"
fs-title="File Select"
space-expand="true"
space-fill="true">'
- However, if the editor is set to strip trailing spaces, echoing the code fails...
Code: Select all
echo '
<entry
file-monitor="true"
fs-action="file"
fs-folder=""
fs-filters-mime="text/plain|text/html"
fs-title="File Select"
space-expand="true"
space-fill="true">' >>gtk_code_file
- ERROR : gtkdialog: Error in line ___, near token 'string': syntax error
• The well-known bash backslash (\) works as expected as long as it is preceded by a space to separate the attributes, as in...
Code: Select all
echo ' \
<entry \
file-monitor="true" \
fs-action="file" \
fs-folder="" \
fs-filters-mime="text/plain|text/html" \
fs-title="File Select" \
space-expand="true" \
space-fill="true">' >>gtk_code_file
Code: Select all
echo '<entry ...
file-monitor="true" ,
fs-action="file" ,
fs-folder="" .
fs-filters-mime="text/plain|text/html" ,
fs-title="File Select" ,
space-expand="true" ,
space-fill="true">' >>gtk_code_file
Code: Select all
echo '<entry _
file-monitor="true"_
fs-action="file"_
fs-folder=""_
fs-filters-mime="text/plain|text/html"_
fs-title="File Select"_
space-expand="true"_
space-fill="true">' >>gtk_code_file
- This file may be the "motherload" of info for those struggling with the GTK+ signal and event system... https://git.gnome.org/browse/gtk+/plain ... system.txt
[i][color=blue]DocSalvager (a.k.a. DocSalvage)[/color][/i]
[url]http://www.docsalvage.info[/url], [url]http://www.softwarerevisions.net[/url]
[url]http://www.docsalvage.info[/url], [url]http://www.softwarerevisions.net[/url]
I have built an app that does a simple right click copy of a
file or folder, but I found a strange bug.
Reference:
copy-fast-1.4.pet
I believe that there is
an incompatibility with pwidgets and 'visible' tag
I use an invisible entry box to form the 'Add' button.
Here is the code. See 'visible="false"'
When I tested on Precise NOP note that the invisible entry box
is visible . The app can still be used.
__________________________________________________
file or folder, but I found a strange bug.
Reference:
copy-fast-1.4.pet
I believe that there is
an incompatibility with pwidgets and 'visible' tag
I use an invisible entry box to form the 'Add' button.
Here is the code. See 'visible="false"'
When I tested on Precise NOP note that the invisible entry box
is visible . The app can still be used.
__________________________________________________
Dear Don,
Just so you know. Your v. 1.4 works fine with Lucid and Thunor's latest gtkdialog. No invisible window showing for me, but then my gtk theme fills the background with a stippled pixbuf, so my observation regarding visibility/invisibility may not be too universal.
With thanks and kind regards,
vovchik
Just so you know. Your v. 1.4 works fine with Lucid and Thunor's latest gtkdialog. No invisible window showing for me, but then my gtk theme fills the background with a stippled pixbuf, so my observation regarding visibility/invisibility may not be too universal.
With thanks and kind regards,
vovchik
ahah! and 1.6 is found where please? I was using 1.4, what I thought was the latest in a message just 6 above.don570 wrote:I tested on wary 5.4.9 and it's fine.
(see image)
That's why I think pwidgets is involved.
__________________________________________
EDIT: just found it, it's in the same topic. I shall download and test.
No, still there. Moving the problem to copyfast thread.
- DocSalvage
- Posts: 11
- Joined: Sat 30 Jun 2012, 18:59
- Location: Tallahassee, FL, USA
- Contact:
GtkDialog Variables
Thunor,
I love GtkDialog 0.8.3 and am working on a fairly large conversion application using it.
In the process, I'm putting together documentation regarding variable passing and was hoping you could confirm if the following statement is correct and straighten me me out if not?
"On startup, GtkDialog processes all <input> and <output> directives for all widgets before processing any <action> directives for any widgets."
If this is all covered somewhere, I haven't been a able to find it. It has taken several days of trial and error to reach this point.
Happy Coding!
I love GtkDialog 0.8.3 and am working on a fairly large conversion application using it.
In the process, I'm putting together documentation regarding variable passing and was hoping you could confirm if the following statement is correct and straighten me me out if not?
"On startup, GtkDialog processes all <input> and <output> directives for all widgets before processing any <action> directives for any widgets."
If this is all covered somewhere, I haven't been a able to find it. It has taken several days of trial and error to reach this point.
Happy Coding!
[i][color=blue]DocSalvager (a.k.a. DocSalvage)[/color][/i]
[url]http://www.docsalvage.info[/url], [url]http://www.softwarerevisions.net[/url]
[url]http://www.docsalvage.info[/url], [url]http://www.softwarerevisions.net[/url]
When you create a button to do an action you can also
set how the exit variable is set. For instance
<action>exit:EXIT</action> sets the exit variable to "EXIT"
When you run your script in the terminal the variable is printed.
(a nice feature of terminal )
Then after gtkdialog has run you can put a line that can
decide what is done next . Here's an example in my bulldog-finder
program.
In my example I do a deletion , in your case you would want to launch
gtkdialog again
set how the exit variable is set. For instance
<action>exit:EXIT</action> sets the exit variable to "EXIT"
When you run your script in the terminal the variable is printed.
(a nice feature of terminal )
Code: Select all
funcbtnType0Create3() {
echo '<button image-position="'$1'" use-stock="true" tooltip-text="'$(gettext 'Relaunch Bulldog Finder')'">
<input file stock="gtk-ok"></input>
<label>"'$(gettext 'Relaunch')'"</label>
<action>bulldog-finder "$FPATH" &</action>
<action>exit:EXIT</action>
</button>'
decide what is done next . Here's an example in my bulldog-finder
program.
Code: Select all
for STATEMENTS in $($GTKDIALOG -c -p SETTINGS); do
eval $STATEMENTS
done
IFS=$I
if [ "$EXIT" = "EXIT" ] || [ "$EXIT" = "abort" ];then # delete temp
rm -rf $TEMPDIR
exit 0
fi
gtkdialog again
memory leak?
Am I doing this wrong or is there a memory leak in gtkdialog?
I ran a gtkdialog script that I'm working on for a day. After about 8 hours it ran out of RAM (there wasn't very much available to start with). The script was sitting idle all day only updating clock display twice a second so I tried removing the clock. Gtkdialog process stopped growing.
Then I narrowed it down to this script that just updates date and time:
and watched it grow:
I tried this under Ubuntu 10.04 Lucid Lynx (x86_64 desktop) and an A13-OLinuXino-WIFI board running Debian Wheezy (armhf). Bash versions are 4.1.5 for the desktop and 4.2.20 for the arm board.
I tried gtkdialog 0.8.3 tarball on both platforms and on desktop I also tried svn rev 514. All kept growing.
P.S. Those "clear" actions were added for testing, it leaks without them as well. The timer was originally 500 ms, I sped it up to maybe get it to leak more.
I ran a gtkdialog script that I'm working on for a day. After about 8 hours it ran out of RAM (there wasn't very much available to start with). The script was sitting idle all day only updating clock display twice a second so I tried removing the clock. Gtkdialog process stopped growing.
Then I narrowed it down to this script that just updates date and time:
Code: Select all
#!/bin/bash
GTKDIALOG=gtkdialog
MAIN_DIALOG='
<window title="memory leak test">
<vbox>
<text use-markup="true">
<variable>TIMEDISPLAY</variable>
<input>date +%H:%M:%S</input>
</text>
<text>
<variable>DATEDISPLAY</variable>
<input>date +%A\ %-d.%m.%Y</input>
</text>
<timer milliseconds="true" interval="50" visible="false">
<action>clear:TIMEDISPLAY</action>
<action>refresh:TIMEDISPLAY</action>
<action>clear:DATEDISPLAY</action>
<action>refresh:DATEDISPLAY</action>
</timer>
</vbox>
</window>
'
export MAIN_DIALOG
$GTKDIALOG --program=MAIN_DIALOG
Code: Select all
chmod u+x leaktest
./leaktest&
while [ 1 ]; do date; ps -C "gtkdialog" u; sleep 10; done
I tried this under Ubuntu 10.04 Lucid Lynx (x86_64 desktop) and an A13-OLinuXino-WIFI board running Debian Wheezy (armhf). Bash versions are 4.1.5 for the desktop and 4.2.20 for the arm board.
I tried gtkdialog 0.8.3 tarball on both platforms and on desktop I also tried svn rev 514. All kept growing.
P.S. Those "clear" actions were added for testing, it leaks without them as well. The timer was originally 500 ms, I sped it up to maybe get it to leak more.
Additional info: Thunor did a timer example. The shell may be important.
Thunor used the bash 3.0 shell.
Ubuntu uses dash.
http://code.google.com/p/gtkdialog/sour ... n493&r=493
________________________________________
Thunor used the bash 3.0 shell.
Ubuntu uses dash.
http://code.google.com/p/gtkdialog/sour ... n493&r=493
________________________________________