Gtkdialog Development
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
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].
gtkdialog-C-example
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/
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
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.
thanks
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.
Any ideas?#! /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
thanks
This is what you need, I believe:oldyeller wrote:When I hit a button the menu stays open. How do I close it after hitting a button?
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
[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]
[b][color=green]Omnia mea mecum porto.[/color][/b]
Hello again
I am have been trying to view+ and view- for my text but not sure if the code is right
Thanks
I am have been trying to view+ and view- for my text but not sure if the code is right
Any help would be great#!/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
Thanks
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.
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.
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.
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?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.
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Hello,
I didn't verify and am not sure at all, but is the export line not missing?
I didn't verify and am not sure at all, but is the export line not missing?
Cordialement.#!/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
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
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:Argolance wrote:I didn't verify and am not sure at all, but is the export line not missing
.
Code: Select all
. Function.file
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].
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.
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.
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Greetings everyone
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:
Best regards,
Thunor
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.
Best regards,
Thunor
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
Here is a package for Slacko use only
Just some notes:
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
- 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