Gtkdialog Development
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
Hmmm.......
Pmusic doesn't work properly with the latest revision. After some digging I found the reason.... In the 'Tips and Tricks' thread I have explained how I update the widgets without using too much cpu.
Sigmund
Pmusic doesn't work properly with the latest revision. After some digging I found the reason.... In the 'Tips and Tricks' thread I have explained how I update the widgets without using too much cpu.
This technique does not work with the latest gtkdialog because <checkbox> won't refresh itself. The next example is not logical, but it shows the checkbox' structure in the above technique>> Both <timer> and <progressbar> widgets uses cpu-power, and in a complex gui this could be a real pitfall. Here follows an explanation of how it is solved in Pmusic. It is a way to update a complex gui on non-user actions. User-actions is mouse-clicks and key-entries, and is the common way to interact between user and gui. An example of updating the gui on a non-user-action in Pmusic is the loading of id3-tags for files shown in the file-browser....
When clicking on a directory, the browser field refreshes and shows the content of the new directory. Now, Pmusic continues with a background process to read the id3 information of the files. When finished, the browser field should be updated by the new info. - Without the user to click anywhere.
The solution is to either use a <progressbar> which runs its <action> when reaches 100% or a <timer> which acts at a given interval. Older Pmusic releases used the <progressbar> solution while recent code uses a <timer>. Both solutions has the downside that they uses an amount of cpu power. In a complex gui with several non-user actions this could end up with several cpu-hungry <timers> updating their unique widget(s) of the gui.
Pmusic has used 2 <timers> running constantly to update their defined gui-part. You might think that 1 <timer> would be enough, - it could refresh all wanted widgets - it wouldn't harm if the refreshing didn't change anything. BUT, refreshing has an effect on the focus handling. It simply resets the focus, which means that:
- scrolling in <table> is moved to top.
- what you are about to write in an <entry> is cleared.
- Your selected item in the <tree> is not selected anymore
- ...
The idea of Pmusic 2.4.0 was to update all kinds of trackinfo (meta-tags, lyrics, albumart, discography, ...) when a new track starts playing. This would not be possible with the underlaying event-handling in Pmusic because it would either suck you cpu-power (with several <timers>), or a global refreshing would make it impossible to be a user (because of focus issues). Also, there is a fact that too many refreshing <action> on a <timer> will increase cpu-usage as well.
So the solution has been to add ONE <timer>, which refreshes a small set of <checkboxes> that (if true) refreshes a single or group of widgets.
<checkboxes> can be set true or false by their <input file>, so we can simply 'echo true' to its <input file>. The <timer> runs its <actions> each second, and the <checkbox> will be refreshed by its <input file>. The code could look like this:All actions will run only if value is true. To avoid more than one refreshing we reset <input file> and the <checkbox> value to false. Now it will be silent until next time we 'echo true > inputfile'.Code: Select all
<checkbox visible="false"> <label>a</label> <variable>UPDATE_GUI</variable> <input>cat /path/UPDATE_GUI</input> <action>if true refresh:PLAYLIST</action> <action>if true refresh:ARTWORK</action> <action>if true refresh:BUTTON_PLAY</action> <action>if true echo false > /path/UPDATE_GUI</action> <action>if true refresh:UPDATE_GUI</action> </checkbox>
Code: Select all
echo false > /tmp/CHECK1
export S='
<window>
<vbox>
<checkbox>
<label>make me TRUE</label>
<variable>CHECK1</variable>
<input>cat /tmp/CHECK1</input>
<action>refresh:CHECK1</action>
</checkbox>
</vbox>
</window>'
gtkdialog -p S
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Hi Sigmundzigbert wrote:SigmundCode: Select all
echo false > /tmp/CHECK1 export S=' <window> <vbox> <checkbox> <label>make me TRUE</label> <variable>CHECK1</variable> <input>cat /tmp/CHECK1</input> <action>refresh:CHECK1</action> </checkbox> </vbox> </window>' gtkdialog -p S
I use a similar technique to this in my PlayMusic example application except I refresh on the toggle, so I understand the method.
I've modified your example slightly so that we can compare output:
Code: Select all
#!/bin/sh
echo false > /tmp/CHECK1
export S='
<window>
<vbox>
<checkbox>
<label>make me TRUE</label>
<variable>CHECK1</variable>
<action>echo CHECK1=$CHECK1</action>
<input>cat /tmp/CHECK1</input>
<action>refresh:CHECK1</action>
<action>echo CHECK1=$CHECK1</action>
</checkbox>
</vbox>
</window>'
./gtkdialog -p S
Code: Select all
CHECK1=true
CHECK1=false
CHECK1=false
CHECK1=false
Can you check-out a fresh copy, ./autogen.sh, make, copy the above program into src and run it please.
Regards,
Thunor
Last edited by thunor on Wed 15 Aug 2012, 21:56, edited 2 times in total.
In the example text_advanced, can one use a variable with input file to get it to display the contents of a file chosen with file select?
That example currently only returns and displays the file name with path of a file chosen with file select when one would have thought that input file would show the contents of the file chosen with file select.
Or am I missing something in my understanding of the example?
That example currently only returns and displays the file name with path of a file chosen with file select when one would have thought that input file would show the contents of the file chosen with file select.
Or am I missing something in my understanding of the example?
thunor
I fixed pMusic by adding 'false' to the input file at startup, and ensure refreshing only if checkbox is true.
I have now tried for 2 hours to reproduce the issue in an example script with no luck - let it go....
And I learned one smart thing: It is no reason to refresh the checkbox from itself - the timer will do..... cpu is saved.
I will look further on the improvements the next days.
Anyway, what is the different between
<checkbox draw_indicator="false">
and
<togglebutton>
Sigmund
I fixed pMusic by adding 'false' to the input file at startup, and ensure refreshing only if checkbox is true.
I have now tried for 2 hours to reproduce the issue in an example script with no luck - let it go....
And I learned one smart thing: It is no reason to refresh the checkbox from itself - the timer will do..... cpu is saved.
I will look further on the improvements the next days.
Anyway, what is the different between
<checkbox draw_indicator="false">
and
<togglebutton>
Sigmund
- thunor
- Posts: 350
- Joined: Thu 14 Oct 2010, 15:24
- Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
- Contact:
Thanks for trying. I spent this evening writing an example based upon your method but maybe now you've changed your mind about it. I can commit it to examples/miscellaneous if you want -- let me know.zigbert wrote:thunor
I fixed pMusic by adding 'false' to the input file at startup, and ensure refreshing only if checkbox is true.
I have now tried for 2 hours to reproduce the issue in an example script with no luck - let it go....
And I learned one smart thing: It is no reason to refresh the checkbox from itself - the timer will do..... cpu is saved.
I will look further on the improvements the next days.
Anyway, what is the different between
<checkbox draw_indicator="false">
and
<togglebutton>
Sigmund
Code: Select all
#!/bin/sh
GTKDIALOG=gtkdialog
export TMPDIR=/tmp/gtkdialog/examples/"$(basename $0)"
mkdir -p "$TMPDIR"
# Credit goes to zigbert of the Puppy Linux Forum for this method.
# See http://www.murga-linux.com/puppy/viewtopic.php?p=274035#274035
# towards the end of section 4 for an explanation.
echo false > "$TMPDIR"/chkSwitch
export MAIN_DIALOG='
<window title="Conditional Widget Refreshing">
<vbox>
<hbox>
<timer>
<action>refresh:chkSwitch</action>
</timer>
<checkbox sensitive="false">
<variable>chkSwitch</variable>
<input file>'"$TMPDIR"'/chkSwitch</input>
<action>if true refresh:entDate</action>
<action>if true echo false > '"$TMPDIR"'/chkSwitch</action>
<action>if true refresh:chkSwitch</action>
</checkbox>
</hbox>
<entry editable="false">
<variable>entDate</variable>
<input>date</input>
</entry>
<button>
<label>"Write true to checkbox input file causing
checkbox to refresh date & time via timer"</label>
<action>echo true > '"$TMPDIR"'/chkSwitch</action>
</button>
<hseparator></hseparator>
<hbox homogeneous="true" space-expand="false" space-fill="false">
<button use-stock="true" label="gtk-quit"></button>
</hbox>
</vbox>
</window>
'
case $1 in
-d | --dump) echo "$MAIN_DIALOG" ;;
*) $GTKDIALOG --space-expand=true --space-fill=true --program=MAIN_DIALOG ;;
esac
- Attachments
-
- condwidgrefr.png
- (6.07 KiB) Downloaded 2016 times
Last edited by thunor on Sat 18 Aug 2012, 14:33, edited 1 time in total.
thunor
The example works great, but I guess everyone trying it without reading the explanation in chapter 4 will find it really awkward.
It works even better without the line
<action>if true refresh:chkSwitch</action>
...Now you actually see that the checkbox are turned on. The timer turns it off.
Thank you
Sigmund
The example works great, but I guess everyone trying it without reading the explanation in chapter 4 will find it really awkward.
It works even better without the line
<action>if true refresh:chkSwitch</action>
...Now you actually see that the checkbox are turned on. The timer turns it off.
Thank you
Sigmund
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
I hate having to refresh icons...
Code: Select all
--- src/widget_pixmap.c 2012-08-16 13:39:53.411186793 +0800
+++ src/widget_pixmap.c.new 2012-08-16 13:38:44.243184974 +0800
@@ -61,6 +61,16 @@ void widget_pixmap_clear(variable *var)
/***********************************************************************
* Create *
***********************************************************************/
+
+#include <sys/inotify.h>
+void autorefresh(gpointer data, gint fd, GdkInputCondition c){
+ char buffer[sizeof (struct inotify_event)];
+ variable *var;
+ var = (variable *)data;
+ read( fd, buffer, sizeof(buffer) ); /* just clearing, don't care the type */
+ gtk_image_set_from_file( GTK_IMAGE(var->Widget), var->Name);
+} /* force redraw of image*/
+
GtkWidget *widget_pixmap_create(
AttributeSet *Attr, tag_attr *attr, gint Type)
{
@@ -75,6 +85,8 @@ GtkWidget *widget_pixmap_create(
gchar *stock_name = NULL;
gint width = -1, height = -1;
gint size = 32;
+ int watch, fd = inotify_init(); variable *var;
+ var = g_malloc(sizeof(variable));
#ifdef DEBUG_TRANSITS
fprintf(stderr, "%s(): Entering.\n", __func__);
@@ -136,6 +148,10 @@ GtkWidget *widget_pixmap_create(
widget = gtk_image_new_from_file("");
}
}
+/* Note that this autorefresh is on by default - should add another tag_attr */
+ watch = inotify_add_watch( fd,(char *) find_pixmap(file_name), IN_MODIFY );
+ var->Widget=widget;
+ strncpy(var->Name, find_pixmap(file_name), 512);
+ gdk_input_add( fd, GDK_INPUT_READ, autorefresh, (gpointer) var);
break; /* Only one image is required */
}
}
@@ -351,7 +367,6 @@ static void widget_pixmap_input_by_file(
width = atoi(attributeset_get_first(&element, var->Attributes, ATTR_WIDTH));
if (attributeset_is_avail(var->Attributes, ATTR_HEIGHT))
height = atoi(attributeset_get_first(&element, var->Attributes, ATTR_HEIGHT));
-
if (width == -1 && height == -1) {
/* Handle unscaled images */
gtk_image_set_from_file(GTK_IMAGE(var->Widget), find_pixmap(filename));
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].