Page 40 of 42

Posted: Thu 02 May 2013, 10:47
by simargl
.

Posted: Thu 02 May 2013, 15:33
by thunor
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

Posted: Thu 02 May 2013, 15:41
by zigbert
Nifty :D

Posted: Thu 02 May 2013, 16:36
by thunor
zigbert wrote:Nifty :D
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.

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")
}
Anyway, since the eventbox interior in gtk2 appears to be solid by default and in gtk3 transparent by default you might have to override the user's theme.

I'm just throwing stuff in.

Using variables in dialogue

Posted: Sun 19 May 2013, 10:32
by guraknugen
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

Line continuation within tags

Posted: Sun 19 May 2013, 20:21
by DocSalvage
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
  • 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.)
SOLUTIONS
  • 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
• 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.

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

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
RESOURCES

Posted: Tue 11 Jun 2013, 00:08
by don570
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"'

Image

When I tested on Precise NOP note that the invisible entry box
is visible . The app can still be used.

Image
__________________________________________________

Posted: Tue 11 Jun 2013, 02:41
by scsijon
@don570, same result with the latest wary and racy. (Extra box appearing.)

Posted: Tue 11 Jun 2013, 20:38
by don570
Hmmm, I tested on Wolx which is Wary 5 (I believe) but has the
openbox window manager and it worked. I assumed that there wasn't
a problem with Wary5

Drat! A lot more work.

________________________________________

Posted: Wed 12 Jun 2013, 09:59
by vovchik
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

Posted: Wed 12 Jun 2013, 23:31
by don570
I tested on wary 5.4.9 and it's fine.
(see image)

That's why I think pwidgets is involved.

Image

__________________________________________

Posted: Thu 13 Jun 2013, 05:27
by scsijon
don570 wrote:I tested on wary 5.4.9 and it's fine.
(see image)

That's why I think pwidgets is involved.


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

EDIT: just found it, it's in the same topic. I shall download and test.

No, still there. Moving the problem to copyfast thread.

Posted: Fri 14 Jun 2013, 08:34
by simargl
.

GtkDialog Variables

Posted: Sat 27 Jul 2013, 17:10
by DocSalvage
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!

Posted: Wed 21 Aug 2013, 09:25
by recobayu
Hi All,
I want to ask a question. Now I make a simple menu, but i have a problem in adding button. Can I add 4 buttons when I input "4" in entrybox and press enter?
Something trick I do is close gtkdialog and then show new window that has 4 buttons. But, do anyone know something better?
Thank you.

Posted: Wed 21 Aug 2013, 19:45
by don570
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 8) )

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

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
In my example I do a deletion , in your case you would want to launch
gtkdialog again

Posted: Sat 19 Oct 2013, 09:29
by simargl7
Will there be stable Gtk3 based version soon?

In Gtk 3.10 icons from menus are removed without option for user to enable them, Gtk.Stock is deprecated. Icons on menus and buttons must be explicitly added by application's developer.

Posted: Sat 19 Oct 2013, 20:06
by don570
Thunor has looked into a GTK3 version but he
doesn't seem to feel there's a high priority.

________________________________________-

memory leak?

Posted: Fri 15 Nov 2013, 21:47
by jfi
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:

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
and watched it grow:

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.

Posted: Sat 16 Nov 2013, 20:49
by don570
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

________________________________________