Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 30 Jul 2014, 01:11
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Gtkdialog Development
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 32 of 55 [821 Posts]   Goto page: Previous 1, 2, 3, ..., 30, 31, 32, 33, 34, ..., 53, 54, 55 Next
Author Message
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Tue 14 Aug 2012, 13:14    Post subject:  

Greetings everyone Very Happy

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 Razz

Best regards,
Thunor
Back to top
View user's profile Send private message Visit poster's website 
oldyeller


Joined: 15 Nov 2011
Posts: 772
Location: Mishawaka IN

PostPosted: Tue 14 Aug 2012, 13:17    Post subject:  

this is my menu I did for Manna is there a way to make it better
Quote:
#! /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
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 5649
Location: Valåmoen, Norway

PostPosted: Tue 14 Aug 2012, 14:34    Post subject:  

Thank you Thunor
Thank you very much


Sigmund

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
01micko


Joined: 11 Oct 2008
Posts: 7785
Location: qld

PostPosted: Tue 14 Aug 2012, 17:17    Post subject:  

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.
gtkdialog4-348-s.pet
Description 
pet

 Download 
Filename  gtkdialog4-348-s.pet 
Filesize  78.72 KB 
Downloaded  213 Time(s) 
gtkdialog4_DOC-348-s.pet
Description 
pet

 Download 
Filename  gtkdialog4_DOC-348-s.pet 
Filesize  187 KB 
Downloaded  205 Time(s) 
update-gtkdialog.gz
Description 
gz

 Download 
Filename  update-gtkdialog.gz 
Filesize  707 Bytes 
Downloaded  218 Time(s) 

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
8-bit


Joined: 03 Apr 2007
Posts: 3357
Location: Oregon

PostPosted: Wed 15 Aug 2012, 00:06    Post subject:  

mistake! Sorry Embarassed
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 1803
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Wed 15 Aug 2012, 05:39    Post subject:  

Yes, thank you thunor for your great work. This is surely, day after day, giving a new face to Puppy...

With all our gratitude!

Cordialement.

_________________

Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5649
Location: Valåmoen, Norway

PostPosted: Wed 15 Aug 2012, 07:51    Post subject:  

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.

Quote:
>> 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:
Code:
<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>

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


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
Code:
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


Sigmund

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Wed 15 Aug 2012, 13:29    Post subject:  

zigbert wrote:

Code:
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


Sigmund

Hi Sigmund

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:

#!/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

I checked-out gtkdialog to test this, ./autogen.sh, make, copied the above program into the src folder and ran it from there. When I click the checkbox I get:
Code:

CHECK1=true
CHECK1=false
CHECK1=false
CHECK1=false

which is as expected (the checkbox never visibly becomes true because it is refreshing itself to false). I get the same result using "<input file>/tmp/CHECK1</input>" which is faster too because it's only opening a file.

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, 17:56; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website 
8-bit


Joined: 03 Apr 2007
Posts: 3357
Location: Oregon

PostPosted: Wed 15 Aug 2012, 13:33    Post subject:
Subject description: example text_advanced questions
 

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?
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 5649
Location: Valåmoen, Norway

PostPosted: Wed 15 Aug 2012, 18:45    Post subject:  

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

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Wed 15 Aug 2012, 19:41    Post subject:  

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

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.

Code:
#!/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


The class hierarchy of the checkbox is GtkButton->GtkToggleButton->GtkCheckButton so if you remove the little box then I guess the checkbox is basically the same thing as the basic togglebutton.
condwidgrefr.png
 Description   
 Filesize   6.07 KB
 Viewed   802 Time(s)

condwidgrefr.png


Last edited by thunor on Sat 18 Aug 2012, 10:33; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5649
Location: Valåmoen, Norway

PostPosted: Thu 16 Aug 2012, 02:35    Post subject:  

thunor
The example works great, but I guess everyone trying it without reading the explanation in chapter 4 will find it really awkward. Smile

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

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 5649
Location: Valåmoen, Norway

PostPosted: Thu 16 Aug 2012, 11:39    Post subject:  

Dynamic title in window heading works fine

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
technosaurus


Joined: 18 May 2008
Posts: 4284

PostPosted: Thu 16 Aug 2012, 16:03    Post subject:  

I hate having to refresh icons...
Code:
--- 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));

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
thunor


Joined: 14 Oct 2010
Posts: 350
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings

PostPosted: Fri 17 Aug 2012, 12:26    Post subject:  

zigbert wrote:
Dynamic title in window heading works fine

Looks nice. When I was updating the window widget I was thinking at the time that you'd be making use of that for your track titles Smile

technosaurus: I'll look into that, thanks. Yeah, I'll add a custom tag attribute for it.
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 32 of 55 [821 Posts]   Goto page: Previous 1, 2, 3, ..., 30, 31, 32, 33, 34, ..., 53, 54, 55 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1621s ][ Queries: 13 (0.0181s) ][ GZIP on ]