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 Tue 28 Mar 2017, 17:34
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
gtkdialog chooser
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [15 Posts]  
Author Message
trio


Joined: 21 Dec 2008
Posts: 2083
Location: अनुमोदना

PostPosted: Thu 28 Jul 2016, 04:42    Post subject:  gtkdialog chooser  

Hi,

Does anybody know what action signal for gtkdialog <chooser> as in Nathan's wallpaper setter, that can do action when scrolling with up/down arrow? it's kind of annoying having to click for the preview to change

Regards

_________________
My apps
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1227
Location: Japan

PostPosted: Thu 28 Jul 2016, 05:00    Post subject:  

update-preview and selection-changed
Back to top
View user's profile Send private message 
trio


Joined: 21 Dec 2008
Posts: 2083
Location: अनुमोदना

PostPosted: Thu 28 Jul 2016, 05:10    Post subject:  

MochiMoppel wrote:
update-preview and selection-changed


Thanks but they dont work. I tried,. or you can give working example?

_________________
My apps
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1227
Location: Japan

PostPosted: Thu 28 Jul 2016, 05:27    Post subject:  

They work, though syntax is not what you might expect.

In /usr/local/apps/Wallpaper/AppRun add 2 lines to the chooser dialog:

<action signal=\"button-release-event\" type=\"refresh\">PIXMAP</action>
<action when=\"update-preview\">swapimagefunc</action>
<action when=\"update-preview\">refresh:PIXMAP</action>
</chooser>
Back to top
View user's profile Send private message 
trio


Joined: 21 Dec 2008
Posts: 2083
Location: अनुमोदना

PostPosted: Thu 28 Jul 2016, 05:46    Post subject:  

Thanks mochi. The changing from type= "refresh" to refresh:PIXMAP did the trick. Wonder why
_________________
My apps
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 811

PostPosted: Fri 29 Jul 2016, 05:56    Post subject:  

trio wrote:
Thanks mochi. The changing from type= "refresh" to refresh:PIXMAP did the trick. Wonder why

"refresh:" including the colon is the function name.
PIXMAP is the target of the function, what it acts on.
You name targets in the script. It means this particular script defines PIXMAP.

_________________
Fatdog64-710|+Packages|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
trio


Joined: 21 Dec 2008
Posts: 2083
Location: अनुमोदना

PostPosted: Fri 29 Jul 2016, 07:22    Post subject:  

Hshaha.. maybe i was not clear

What puzzles me is the difference of
type= "refresh" >PIXMAP< to >refresh:PIXMAP<

as the first does not work

_________________
My apps
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Wed 26 Oct 2016, 01:57    Post subject:  

MochiMoppel wrote:
They work, though syntax is not what you might expect.

In /usr/local/apps/Wallpaper/AppRun add 2 lines to the chooser dialog:

<action signal=\"button-release-event\" type=\"refresh\">PIXMAP</action>
<action when=\"update-preview\">swapimagefunc</action>
<action when=\"update-preview\">refresh:PIXMAP</action>
</chooser>

Wow, this works?
What does actually when=\"update-preview\" do?
Does there exist any documentation?
What else is it capable of?

MochiMoppel
Are you willing to request this change to Woof-CE?
https://github.com/puppylinux-woof-CE/woof-CE/blob/testing/woof-code/rootfs-packages/wallpaper/usr/local/apps/Wallpaper/AppRun

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


Joined: 26 Jan 2011
Posts: 1227
Location: Japan

PostPosted: Sat 29 Oct 2016, 00:21    Post subject:  

zigbert wrote:
What does actually when=\"update-preview\" do?
It signals that a preview widget should be updated, typically when file selection has changed. Basically a preview widget can be added to a chooser dialog (see screenshot), but this is not supported in gtkdialog. The good news is that the update-preview signal is emitted anyway - and it works much better than the selection-changed signal. The selection-changed signal is emitted even before anything is selected at startup and it may generate errors when the user clicks in the left Places panel. The update-preview signal is fired only once for each selection change. Much more reliable.

zigbert wrote:
Does there exist any documentation?
For the Chooser widget? Apparently not (see remarks by Thunor in this example). Judging from other remarks in the source code Thunor wasn't very convinced of the Chooser widget:
Quote:
case WIDGET_CHOOSER:
/* Thunor: This widget is incredibly lacking in comparison to
* the fileselect action function and really needs a newer
* alternative (is anyone actually using this?) */


Fortunately not all remarks are correct. Chooser *does* support modes other than the default GTK_FILE_CHOOSER_ACTION_OPEN and there *is* access to a directory creation button. There is even an option to hide this button. File filters are not supported though.

zigbert wrote:
What else is it capable of?
Again not sure what you mean by "it". If you mean the Chooser widget itself: Compared to the fileselect action function it is simpler, doesn't need another widget to work and thanks to its update-preview signal it allows to arbitrarily select files or folders without the need to limit the choice to one of these two. It allows to hook different actions to click and double-click.

Interestingly it is capable of multiple selection. The tag attribute select-multiple="true" turns on multiple selection, BUT this has no practical use since the variable will return only 1 item.

Here the two tag attributes that I found do work:
Code:
Name                Description                             Possible values
-------------------------------------------------------------------------------
create-folders      show/hide "Create Folder" button        true (=default) or false
action              set action mode                         0 (GTK_FILE_CHOOSER_ACTION_OPEN=default)   
                                                            1 (GTK_FILE_CHOOSER_ACTION_SAVE)
                                                            2 (GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
                                                            3 (GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)

zigbert wrote:
Are you willing to request this change to Woof-CE?
No, thanks. My experience with Woof-CE was rather unpleasant. I deleted my account. Let's keep it this way.
  
  
  
chooser_with_integrated_preview.jpg
 Description   Example of chooser dialog in Inkscape
 Filesize   46.51 KB
 Viewed   427 Time(s)

chooser_with_integrated_preview.jpg

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


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

PostPosted: Sun 30 Oct 2016, 03:35    Post subject:  

MochiMoppel
A great explanation. - I am learning!

Sorry to hear that you won't apply to Woof-CE.
I've updated the wallpaper script with your code

Thanks a lot

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


Joined: 26 Jan 2011
Posts: 1227
Location: Japan

PostPosted: Sat 19 Nov 2016, 09:28    Post subject:  

zigbert wrote:
I've updated the wallpaper script with your code
The code was a quick shot Embarassed
To make the code more efficient and avoid calling the same functions twice the 2 lines I proposed should replace the 2 button-release-event actions instead of being added to them.
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Fri 25 Nov 2016, 03:07    Post subject:  

Sorry Embarassed
Fixed Very Happy

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


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

PostPosted: Sat 26 Nov 2016, 18:54    Post subject:  

Looking into the <chooser> widget trying to actually use it...

With the knowledge of the action="1", I am getting really close to a useful save-dialog. The final issue is that I can't get it to accept a <default> file - only a <default> folder.
Code:
echo '
<window>
<vbox>
   <chooser action="1">
      <default>/root/.jwmrc</default>
      <width>600</width>
      <height>400</height>
   </chooser>
   <checkbox>
      <label>My options</label>
   </checkbox>
   <hbox>
      <button ok></button>
      <button cancel></button>
   </hbox>
</vbox>
</window>
' | gtkdialog -s
Change /root/.jwmrc to /root, and it all works fine, but I find it user-unfriendly to not give the user the default filename. If the user first opens a file - that should be the default saved filename as well. Do anyone know something I don't.

Thanks for any help

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


Joined: 26 Jan 2011
Posts: 1227
Location: Japan

PostPosted: Wed 30 Nov 2016, 09:17    Post subject:  

zigbert wrote:
I find it user-unfriendly to not give the user the default filename

Not implemented in chooser - and not implemented in the fileselect function either, which Laszlo Pere developed 2 years later. I assume that there were always more important issues on the to-do list.

Leaving the field blank does not necessarily mean that the dialog is user-unfriendly. GTK_FILE_CHOOSER_ACTION_SAVE is also - and probably most often - used as the "Save" dialog for yet unsaved documents, in which case the field remains blank (Leafpad) or contains a dummy name like "untitled" (Geany).

<default> and fs-folder accept only folder paths and I agree that they should handle erraneously entered file paths more gracefully. Your example would pose another problem: .jwmrc is a hidden file and hidden files are not displayed by default (you can change the default, but that's a different story). Now try <default> with /root/.jwm, a hidden folder. Switch to the parent folder /root and - tataaa!! - hidden files are now displayed and when you right click you see that "Show Hidden Files" is checked. GtkFileChooser is full of surprises.

Here a small summary of the startup behavior:

Chooser startup folder
Code:
Tag                                     Chooser selects
-------------------------------------------------------------------------
none                                    Recently Used
<default>"/path/to/folder"</default>    If folder exists: folder
                                        If folder does not exist: parent folder of folder
                                        If folder is hidden: folder ("Show hidden files" property will be turned on)
                                        If folder is a regular file: nothing
<default>""</default>                   current folder (=folder of script file or folder of symlink pointing to script file)
For the fileselect function above behavior is the same when applied to the fs-folder attribute
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1227
Location: Japan

PostPosted: Wed 01 Feb 2017, 23:34    Post subject:  

Thunor's dislike for this widget ("I can't recommend using it") makes it even more appealing to me. Forbidden fruits taste sweet.
Tasting is now done here. I'm not sure where to put some of the nitty gritty stuff. Let's keep it here. I hope trio doesn't mind.

Some issues may still need clarification:

Signals
In order to use chooser effectively it is indispensible to understand its event handling.
Attaching actions to events can become challenging as chooser emits signals in a very bizarre fashion - or not at all.

Some examples:
    file-activated: emitted when user dbl-clicks a file, but this also emits almost all signals in the book. Complete bogus.
    confirm-overwrite: should be emitted for GTK_FILE_CHOOSER_ACTION_SAVE when user inputs existing file name. Does not seem to work.
    button-press-event: only recognized in the small bar in bottom left, containing + - buttons.
    focus and notify events: not recognized at all
    current-folder-changed: fires *before* the folder changes. <variable> returns folder before change
    key-press-event: Only recognized for modifier keys. Char keys will trigger search box. After opening search box corresponding key-release-event not recognized, not even for modifier keys.

Below script should help to better understand signals. It must be run from a console to see the output.
Code:
echo '
<vbox>
    <chooser  action="0" create-folders="true" >
        <variable>vCHOOSER</variable>
        <width>600</width>
        <height>400</height>
        <action>                                echo -e "default\t\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action when="confirm-overwrite">       echo -e "confirm-overwrite\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action when="current-folder-changed">  echo -e "current-folder-changed\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action when="file-activated">          echo -e "file-activated\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action when="update-preview">          echo -e "update-preview\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action when="selection-changed">       echo -e "selection-changed\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="button-press-event">    echo -e "button-press-event\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="button-release-event">  echo -e "button-release-event\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="button-release-event">  echo -e "(button codes PTR_BTN:$PTR_BTN PTR_X PTR_Y:$PTR_X $PTR_Y PTR_X_ROOT PTR_Y_ROOT:$PTR_X_ROOT $PTR_Y_ROOT )"</action>
        <action signal="key-press-event">       echo -e "key-press-even\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="key-press-event">       echo -e "(key codes KEY_VAL:$KEY_VAL KEY_SYM:$KEY_SYM KEY_MOD:$KEY_MOD KEY_RAW:$KEY_RAW )"</action>
        <action signal="key-release-event">     echo -e "key-release-event\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="key-release-event">     echo -e "(key codes KEY_VAL:$KEY_VAL KEY_SYM:$KEY_SYM KEY_MOD:$KEY_MOD KEY_RAW:$KEY_RAW )"</action>
        <action signal="hide">                  echo -e "hide\t\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="show">                  echo -e "show\t\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="realize">               echo -e "realize\t\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="map-event">             echo -e "map-event\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="unmap-event">           echo -e "unmap-event\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="configure-event">       echo -e "configure-event\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="enter-notify-event">    echo -e "enter-notify-event\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="leave-notify-event">    echo -e "leave-notify-event\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="focus-in-event">        echo -e "focus-in-event\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
        <action signal="focus-out-event">       echo -e "focus-out-event\t\t$(basename $vCHOOSER 2>/dev/null)"</action>
    </chooser>
    <hbox>
        <button label="Enable">     <action>Enable:vCHOOSER</action></button>
        <button label="Disable">    <action>Disable:vCHOOSER</action></button>
        <button label="Show">       <action>Show:vCHOOSER</action></button>
        <button label="Hide">       <action>Hide:vCHOOSER</action></button>
    </hbox>
    <hbox>
        <button label="Clear console"><action>clear</action></button>
        <button ok></button>
        <button cancel></button>
    </hbox>
</vbox>
' |  gtkdialog -s
mm_chooser_test.png
 Description   
 Filesize   189.47 KB
 Viewed   111 Time(s)

mm_chooser_test.png

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [15 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
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.0883s ][ Queries: 12 (0.0076s) ][ GZIP on ]