Gtkdialog Development

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#451 Post by Argolance »

Merci... :)

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#452 Post by technosaurus »

I switched out the find_pixmap code in my compile with this - speeds up not finding missing images with locate (especially if it is missing) and gives a convenient way to tell where the global gtkdialog images are (using an environment variable - GTKDIALOG_PIXMAP_DIR) - better suggestions welcome though
char *find_pixmap(char *filename)
{
char tmp[128];
static char *line = NULL;
static uint length = 0;
FILE *locate;

if (access(filename, R_OK) == 0)
return filename;

//snprintf(tmp, 127, "/usr/share/icons/Bluecurve/16x16/stock/%s",
snprintf(tmp, 127, "/usr/share/pixmaps/%s", filename);
tmp[127] = '\0';
if (access(tmp, R_OK) == 0)
return strdup(tmp);

snprintf(tmp, 127, "/usr/share/mini-icons/%s", filename);
tmp[127] = '\0';
if (access(tmp, R_OK) == 0)
return strdup(tmp);


snprintf(tmp, 127, "%s/%s",getenv("GTKDIALOG_PIXMAP_DIR"), filename);
tmp[127] = '\0';
if (access(tmp, R_OK) == 0)
return strdup(tmp);

return 0;
}
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

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

#453 Post by Argolance »

Hello,
Did not test this yet... but guess that, at first sight, the small "amateur" I am finds these code lines impressive and somewhat "hermetic"... :shock: !

Thank you a lot!

sklimkin
Posts: 157
Joined: Wed 11 Jul 2012, 21:21
Location: Russia Moscow

gtkdialog-C-example

#454 Post by sklimkin »

The site http://code.google.com/p/gtkdialog/ wasn't updated for a long time.
Can be here will on a subject.
gtkdialog has many good examples bash-script.
The author Laszlo Pere has given possibility to do the program and in C-language, but an example of such program only one (and very small).
Program possibilities gtkdialog in this case are much poorer, than at bash-script.
Some users can write on bash-script worse, than on C-language (as I for example).
Considering it I has made an example in C-language.
Designs gtkdialog for C-language don't allow for example such things:
<window window_position = "1" title = "System Tools">
Or:
<action when = "file-activated"> echo File: $FILE </action>
It managed to be bypassed in such a way:
"<action> cat [echo $FILE] | zenity - text-info - width=720 - height=400 - title $FILE </action>"
But even with such restrictions it was interesting to me to make the program which doesn't demand heavy libraries (so I anyway think).
If will consider it possible add my example in/gtkdialog/examples/
Attachments
gtkdialog-c-lang.png
(89.2 KiB) Downloaded 1217 times
gtkdialog-C-example-32bit.tar.gz
gtkdialog example code C-language
(95.22 KiB) Downloaded 395 times

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#455 Post by oldyeller »

Hello Everyone,

I made me a notebook like menu for Manna OS, but iI have one problem that I need help with.

When I hit a button the menu stays open. How do I close it after hitting a button?

Code.
#! /bin/bash

export MAIN_DIALOG='
<window title="Manna Menu" icon-name="Bible">
<vbox>
<notebook labels="Bible Software|Books|Dictionaries">
<frame>
<hbox>
<button>
<input file>/usr/share/icons/hicolor/48x48/apps/bibletime.png</input>
<label>bibletime</label>
<action type="exec">bibletime</action>
</button>
<vbox>
<text wrap="true" width-chars="50"><label>An excellent stand alone program. There are a lot of books one can get for this and maps as well.</label></text>
</vbox>
</hbox>
<hbox>
<button>
<input file>/usr/share/pixmaps/75DE_BibleAnalyzer4.0.png</input>
<label>BibleAnalyzer</label>
<action type="exec">bibleanalyzer4.sh</action>
</button>
<vbox>
<text wrap="true" width-chars="50"><label>An excellent program to disect the Word and get more out of it. It has many ways in which one can do this. This has others resources one can buy.</label></text>
</vbox>
</hbox>
<hbox>
<button>
<input file>/usr/share/pixmaps/esword.png</input>
<label>e-sword</label>
<action type="exec">/usr/bin/e-Sword.sh</action>
</button>
<vbox>
<text wrap="true" width-chars="50"><label>There is a lot of free Bibles and other resources plus you can get step books (examples) as well. There is also bibles and books you can buy too.</label></text>
</vbox>
</hbox>
<hbox>
<button>
<input file>/usr/share/pixmaps/CB2C_theword.0.png</input>
<label>theWord</label>
<action type="exec">theword.sh</action>
</button>
<vbox>
<text wrap="true" width-chars="50"><label>This program is one in which you can open up more than just one book, bible or any other window. There is a lot of resources for this program on line to get.</label></text>
</vbox>
</hbox>
</frame>
<frame>
<vbox>
<text wrap="true" width-chars="50"><label>Books will be coming soon.</label></text>
</vbox>
</frame>
<frame>
<vbox>
<text wrap="true" width-chars="50"><label>Dictionaries will be coming soon as well. There will be more stuff added as time goes by.</label></text>
</vbox>
</frame>
</notebook>
<hbox>
<button cancel></button>
<button ok></button>
</hbox>
</vbox>
</window>
'

gtkdialog --program=MAIN_DIALOG
Any ideas?

thanks

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

#456 Post by SFR »

oldyeller wrote:When I hit a button the menu stays open. How do I close it after hitting a button?
This is what you need, I believe:

Code: Select all

#! /bin/bash 

export MAIN_DIALOG=' 
  <button>
    <label>Launch Abiword</label>
    <action>abiword &</action>
    <action type="exit">exiting completed</action>
  </button>
'
gtkdialog --program=MAIN_DIALOG
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
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#457 Post by oldyeller »

Thanks SFR,

That worked!!! but didn't need to put launch in the <label>

Thanks

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#458 Post by oldyeller »

Hello again

I am have been trying to view+ and view- for my text but not sure if the code is right
#!/bin/sh

GTKDIALOG=gtkdialog

funcbtnCreate() {
echo '<button>
<label>'"$2"'</label>
<input file stock="'$3'"></input>
<action>echo "'"$4"' '$1'"</action>
<action type="'"$2"'">'$1'</action>
</button>'
}

export MAIN_DIALOG='
<window title="Text Advanced" resizable="false">
<vbox>
<vbox border-width="10" spacing="10">
<text use-markup="true">
<label>"<span fgcolor='"'black'"' bgcolor='"'white'"'> Text from file inside a scrollable vbox </span>"</label>
</text>
<vbox scrollable="true" width="600" height="300">
<text wrap="false" xalign="0">
<variable>txt0</variable>
<label>This is a static text.</label>
<input file>'/usr/local/Manna/t.txt'</input>
</text>
</vbox>
<hbox homogeneous="true">

'"$(funcbtnCreate txt0 viewmag gtk-view Bigger)"'
'"$(funcbtnCreate txt0 Enable gtk-yes Enabling)"'
'"$(funcbtnCreate txt0 Clear gtk-clear Clearing)"'
'"$(funcbtnCreate txt0 Fileselect gtk-file "Inserting into")"'
'"$(funcbtnCreate txt0 Refresh gtk-refresh Refreshing)"'
</hbox>

</vbox>
<hseparator></hseparator>
<hbox homogeneous="true">

<button use-stock="true" label="gtk-ok" has-focus="true"></button>
</hbox>
</vbox>
</window>
'

case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac
Any help would be great

Thanks

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#459 Post by 8-bit »

I tried running your script from a terminal to see what was happening after changing the inputfile line to a file I had.
It displayed that file fine in the text window.
But... Instead of displaying the contents of a file from the File Selection button, it returns and displays the file name and that is being used as the input.
So that is strange.
Also, the $ variables I would have thought were command line variables given externally to the script.
But I have not worked with gtkdialog in a while, so take this reply for a grain of salt.

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#460 Post by oldyeller »

Hi 8-bit,

this code is form an example that I messed around with and had know idea what I was doing.

Here is my thought I want to be able to have books/text in a window that would be able to zoom-out/in so it could be read.

I am slowly learning how to do all of this though.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#461 Post by 8-bit »

I see that that code was derived from one of the examples in gtkdialog.
But to me, it appears to be missing something in that using the "fileselect" one would think that it would display the contents of that file in the txt0 window. It instead only displays the filename (with path) returned by fileselect in the txt0 window.
If I change the "$0" in line 25 to "$1" and start the text_advanced script from a terminal with a filename as a parameter, it does display the file in the scrollable box.
It just bugs me that the fileselect button does not display the contents of the file chosen.

As to the display of the file contents, are you wanting to be able to change the font size of the display for those with poor eyesight?
There appears to be no controls in the script for that currently.

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#462 Post by oldyeller »

8-bit wrote:I see that that code was derived from one of the examples in gtkdialog.
But to me, it appears to be missing something in that using the "fileselect" one would think that it would display the contents of that file in the txt0 window. It instead only displays the filename (with path) returned by fileselect in the txt0 window.
If I change the "$0" in line 25 to "$1" and start the text_advanced script from a terminal with a filename as a parameter, it does display the file in the scrollable box.
It just bugs me that the fileselect button does not display the contents of the file chosen.

As to the display of the file contents, are you wanting to be able to change the font size of the display for those with poor eyesight?
There appears to be no controls in the script for that currently.
Yes that is what I would like to do, but do not know how? any ideas?

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

#463 Post by Argolance »

Hello,
I didn't verify and am not sure at all, but is the export line not missing?
#!/bin/sh

GTKDIALOG=gtkdialog

funcbtnCreate() {
echo '<button>
<label>'"$2"'</label>
<input file stock="'$3'"></input>
<action>echo "'"$4"' '$1'"</action>
<action type="'"$2"'">'$1'</action>
</button>'
}

export -f funcbtnCreate
Cordialement.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#464 Post by technosaurus »

Argolance wrote:I didn't verify and am not sure at all, but is the export line not missing
.
just an FYI. It is more portable to put all of the functions in a separate file and source it in the main script with:

Code: Select all

. Function.file
then use gtkdialog's include parameter ... Otherwise you are stuck using bash (busybox ash is up to 10 times faster, depending on the operation) unfortunately everyone keeps passing on the unportable export method, so there is a lot of bash dependent code that has a #!/bin/sh when it really should be #!/bin/bash
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#465 Post by 8-bit »

As to sizing, if you want a bigger display window for the text, just change line 15 from resizable="false" to resizable="true".
You can then grab a corner of the window and drag it to the size you want.
That is the full display window and not just the text window on it.
But as I previously stated, the fileselect returns and displays the file name with path into the text window where one would have thought it should display the contents of the selected file in the window.

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#466 Post by thunor »

Greetings everyone :D

I updated gtkdialog with jamesbond's ARM patch and then continued implementing as much as I could from the issues list, so now you've got loads of new toys to play with.

This is what I've added recently up to revision 348:
  • Applied jamesbond's fix for the incorrectly ordered widgets on the Raspberry Pi (ARM).
  • radiobutton: added support for <input>, <input file>, <output file>, refresh, save and clear.
  • checkbox: added support for <input file>, <output file> and save.
  • Added a check when launch-ing that the window contains the required matching variable directive with a warning being displayed if missing.
  • Added examples/miscellaneous/launch_and_closewindow.
  • timer: added support for <input>, <input file> and refresh (you're inputting the timer's active state).
  • window: added support for <input>, <input file>, <output file>, refresh, save and clear ("title" is the item of data that is being manipulated).
  • window: added the "image-name" custom tag attribute to set the title bar icon from a full path and filename.
  • Added support for the envvar GTKDIALOG_PIXMAP_PATH: gtkdialog will search this colon seperated list of directories when loading an image file that was found to be missing (see examples/miscellaneous/show_and_hide at file bottom).
  • Added KEY_VAL, KEY_SYM (both are listed in gdk/gdkkeysyms.h), KEY_UNI (the Unicode character if applicable), KEY_MOD (GdkModifierType) and KEY_RAW (hardware) envvars on key_press_event and key_release_event (see following example).
  • Added PTR_X and PTR_Y (widget relative), PTR_MOD (GdkModifierType), PTR_BTN (equivalent to the existing BUTTON), PTR_X_ROOT and PTR_Y_ROOT (screen relative) envvars on button_press_event and button_release_event (see following example).
  • Added examples/miscellaneous/press_and_release_events.
  • Added show and hide action functions (see following example) and added support for them to the existing widgets.
  • Added examples/miscellaneous/show_and_hide.
  • frame: added support for <input>, <input file>, <output file>, enable, disable, show, hide, refresh, save and clear.
  • hbox: added support for a few directives and enable, disable, show and hide.
  • vbox: added support for a few directives and enable, disable, show and hide.
  • menubar: added support for tag attributes, a few directives and enable, disable, show and hide.
  • Fixed a bug that caused applications that included a menu to fail to close via the window manager (title bar) and in fact closewindow too (this is the bug that was dealt with using <action signal="hide">exit:Exit</action> on the window widget), so now it's recommended to remove that fix because if you decide to hide the window then you will close it.
  • Fixed a bug that caused a parser error when using multiple launched windows: the envvar that contained the program was being overwritten.
It would be nice if you could play with it and let me know if everything's ok. I'm going to add the GtkFontButton and the GtkEventBox next and then see what else I can pick at :P

Best regards,
Thunor

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#467 Post by oldyeller »

this is my menu I did for Manna is there a way to make it better
#! /bin/bash

export MAIN_DIALOG='
<window title="MannaMenu" icon-name="Com">
<vbox>
<notebook labels="Information|BibleSoftware|Books|Dictionaries">
<frame>
<vbox>
<text justify="3" height-request="100" width-request="475">
<label>Manna OS would like to thank Rick Meyer creator of e-sword, Tim Morton creator of BibleAnalyzer and Costas Stergiou creator of theWord for their permission to pre-install their Bible Software. We had no input or part of making any of their software.</label>
</text>
</vbox>
</frame>
<frame>
<hbox>
<button height-request="0" width-request="0">
<input file>/usr/share/pixmaps/75DE_BibleAnalyzer4.0.png</input><height>25</height><width>55</width>

<action>bibleanalyzer4.sh</action>
<action type="exit">exiting completed</action>
</button>
<vbox>
<text justify="" height-request="33" width-request="450"><label>BibleAnalyzer: An excellent program to disect the Word.</label></text>
</vbox>
</hbox>
<hbox>
<button height-request="0" width-request="0">
<input file>/usr/share/icons/hicolor/48x48/apps/bibletime.png</input><height>25</height><width>55</width>

<action>bibletime</action>
<action type="exit">exiting completed</action>
</button>
<vbox>
<text justify="" height-request="33" width-request="450"><label>bibletime: There are a lot of books one can get and maps as well.</label></text>
</vbox>
</hbox>
<hbox>
<button height-request="" width-request="0">
<input file>/usr/share/pixmaps/esword.png</input><height>25</height><width>55</width>

<action>/usr/bin/e-Sword.sh</action>
<action type="exit">exiting completed</action>
</button>
<vbox>
<text justify="" height-request="33" width-request="450"><label>e-sword: You can get step books (examples are from LightByDesign).</label></text>
</vbox>
</hbox>
<hbox>
<button height-request="0" width-request="0">
<input file>/usr/share/pixmaps/CB2C_theword.0.png</input><height>25</height><width>55</width>

<action>theword.sh</action>
<action type="exit">exiting completed</action>
</button>
<vbox>
<text justify="" height-request="33" width-request="450"><label>theWord: There is a lot of resources for this program on line to get.</label></text>
</vbox>
</hbox>
</frame>
<frame>
<hbox>
<button height-request="0" width-request="0">
<input file>/usr/share/icons/Book.png</input><height>25</height><width>55</width>

<action>epdfview /usr/local/Manna/Mary-Rose.pdf</action>
<action type="exit">exiting completed</action>
</button>
<hbox>
<text justify="3" height-request="33" width-request="450"><label>the Crusie of The Mary Rose: About the lives of Missionaries in the Pacific.</label></text>
</hbox>
</hbox>
</frame>
<frame>
<vbox>
<text wrap="true" width-chars="50"><label>Dictionaries will be coming soon as well. There will be more stuff added as time goes by.</label></text>
</vbox>
</frame>
</notebook>
<hbox>
<button>
<input file>/usr/local/lib/X11/pixmaps/home24.png</input><height>15</height><width>45</width>
<label>Home</label>
<action>rox</action>
<action type="exit">exiting completed</action>
</button>
<button>
<input file>/usr/local/PupMenu/icons/menu20.png</input><height>15</height><width>45</width>
<label>PupMenu</label>
<action>PupMenu</action>
<action type="exit">exiting completed</action>
</button>
<button>
<input file>/usr/local/PupApps/icons/applications20.png</input><height>15</height><width>45</width>
<label>PupApps</label>
<action>PupApps</action>
<action type="exit">exiting completed</action>
</button>
<button>
<input file>/usr/local/PupControl/icons/control-panel_20.png</input><height>15</height><width>45</width>
<label>PupControl</label>
<action>PupControl</action>
<action type="exit">exiting completed</action>
</button>
<button>
<input file>/usr/local/PupShutdown/icons/shutdown20.png</input><height>15</height><width>45</width>
<label>PupShutdown</label>
<action>PupShutdown</action>
<action type="exit">exiting completed</action>
</button>

<button>
<label>Exit</label>
<action type="exit">exiting completed</action>
</button>
</hbox>
</vbox>
</window>
'

gtkdialog --center --program=MAIN_DIALOG

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

#468 Post by zigbert »

Thank you Thunor
Thank you very much


Sigmund

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

#469 Post by 01micko »

Here is a package for Slacko use only

Just some notes:
  • > the pinstall should offer to keep gtkdialog3 if installed
    > the main binary is gtkdialog, gtkdialog4 and gtkdialog3 are symlinks made via the pinstall.sh
    > the pinstall.sh is woof compliant
    > all conflicts I marked as "mc" in the svn update (my conflict)
    > if in doubt, backup your old gtkdialog binary before installing this package
I'd forgotten that I totally automated the build from a script, I'll post that too.
Attachments
gtkdialog4-348-s.pet
(78.72 KiB) Downloaded 567 times
gtkdialog4_DOC-348-s.pet
(187 KiB) Downloaded 595 times
update-gtkdialog.gz
(707 Bytes) Downloaded 605 times
Puppy Linux Blog - contact me for access

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#470 Post by 8-bit »

mistake! Sorry :oops:

Post Reply