Revision history for gtkdialogDocTips9.7
Additions:
[[HomePage]] > [[SoftwareIndex|Software Index]] > [[SoftwareDevelopment|Development]] > [[gtkdialog|gtkdialog]] > [[gtkdialogDocTips|Tips and Tricks]]
===@@**#%[[gtkdialogDocTips9.6|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips9.8|Next ❱❱❱]]#%**@@===
===@@**#%[[gtkdialogDocTips9.6|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips9.8|Next ❱❱❱]]#%**@@===
Deletions:
@@**#%[[gtkdialogDocTips9.6|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips9.8|Next ❱❱❱]]#%**@@
Additions:
**Move items in list by drag'n drop - OLD SOLUTION.**
For the record, we keep the old solution for this task...
move (){
PRESS_EVENT=$(cat /tmp/PRESS_EVENT)
[[ $PRESS_EVENT && $TREE || exit #exit if at least one of the 2 values is empty
[[ $PRESS_EVENT == $TREE && exit #exit if both are equal (=single or double click)
sed -i "/$PRESS_EVENT/d; /$TREE/ i\\$PRESS_EVENT" /tmp/list #remove PRESS_EVENT, then insert item PRESS_EVENT before item $TREE
}
export -f move
ls -1 /usr/share/backgrounds > /tmp/list
<tree rules_hint=\"true\" hover-selection=\"true\" tooltip-text=\"Drag'n drop items to move them in list\">
<label>Backgrounds</label>
<input>cat /tmp/list</input>
<variable>TREE</variable>
<height>300</height><width>200</width>
<action signal=\"button-press-event\">echo \$TREE > /tmp/PRESS_EVENT</action>
<action signal=\"button-release-event\">move</action>
<action signal=\"button-release-event\">refresh:TREE</action>
</tree>"
For the record, we keep the old solution for this task...
move (){
PRESS_EVENT=$(cat /tmp/PRESS_EVENT)
[[ $PRESS_EVENT && $TREE || exit #exit if at least one of the 2 values is empty
[[ $PRESS_EVENT == $TREE && exit #exit if both are equal (=single or double click)
sed -i "/$PRESS_EVENT/d; /$TREE/ i\\$PRESS_EVENT" /tmp/list #remove PRESS_EVENT, then insert item PRESS_EVENT before item $TREE
}
export -f move
ls -1 /usr/share/backgrounds > /tmp/list
<tree rules_hint=\"true\" hover-selection=\"true\" tooltip-text=\"Drag'n drop items to move them in list\">
<label>Backgrounds</label>
<input>cat /tmp/list</input>
<variable>TREE</variable>
<height>300</height><width>200</width>
<action signal=\"button-press-event\">echo \$TREE > /tmp/PRESS_EVENT</action>
<action signal=\"button-release-event\">move</action>
<action signal=\"button-release-event\">refresh:TREE</action>
</tree>"
Deletions:
Additions:
1. When moving an item in the list the ##PTR_Y## variable returns 0. A return value greater than 0 tells us that the user is clicking rather than moving.
2. Normally all ##<action>##s defined for a widget are processed __before__ built-in actions. The trick is to process a user defined ##<action>## __after__ a built-in action. An invisible button allows the code to run a user defined save action __after__ a built-in reorder action.
2. Normally all ##<action>##s defined for a widget are processed __before__ built-in actions. The trick is to process a user defined ##<action>## __after__ a built-in action. An invisible button allows the code to run a user defined save action __after__ a built-in reorder action.
Additions:
export test="
<entry>
<default>Drag a directory from Rox</default>
</entry>"
gtkdialog -p test
%%
Using the reorderable option in the ##<tree>## has some strange behavior. For example will items get swallowed when moving them onto another item. The workaround restores the list if the user moves item onto, instead of in between 2 other items... This code by [[MochiMoppel]] is a result of 2 cracked nuts:
<entry>
<default>Drag a directory from Rox</default>
</entry>"
gtkdialog -p test
%%
Using the reorderable option in the ##<tree>## has some strange behavior. For example will items get swallowed when moving them onto another item. The workaround restores the list if the user moves item onto, instead of in between 2 other items... This code by [[MochiMoppel]] is a result of 2 cracked nuts:
Additions:
Code below line 12 (##break## command) is activated when user move item in list
ls -1 /usr/share/backgrounds > /tmp/test
do_something () { Xdialog -info "Do something with\n$TREE" x 2000 ;} ; export -f do_something
echo '
<vbox>
<tree headers-clickable="false" reorderable="true">
<label>Backgrounds</label>
<input>cat /tmp/test</input>
<output file>/tmp/test</output>
<variable>TREE</variable>
<height>300</height><width>200</width>
<action>do_something &</action>
<action signal="button-release-event" condition="command_is_true( echo $PTR_Y )">break:</action>
<action signal="button-release-event">save:TREE</action>
<action signal="button-release-event">activate:BTN_SAVE</action>
</tree>
<button visible="false">
<variable>BTN_SAVE</variable>
<action>cp /tmp/test /tmp/testbackup</action>
<action>save:TREE</action>
<action condition="command_is_true([[ $(wc </tmp/test) != $(wc </tmp/testbackup) && sed \"s/^|*//\" /tmp/testbackup > /tmp/test && echo true )">refresh:TREE</action>
</button>
</vbox>' | gtkdialog -s
%%
ls -1 /usr/share/backgrounds > /tmp/test
do_something () { Xdialog -info "Do something with\n$TREE" x 2000 ;} ; export -f do_something
echo '
<vbox>
<tree headers-clickable="false" reorderable="true">
<label>Backgrounds</label>
<input>cat /tmp/test</input>
<output file>/tmp/test</output>
<variable>TREE</variable>
<height>300</height><width>200</width>
<action>do_something &</action>
<action signal="button-release-event" condition="command_is_true( echo $PTR_Y )">break:</action>
<action signal="button-release-event">save:TREE</action>
<action signal="button-release-event">activate:BTN_SAVE</action>
</tree>
<button visible="false">
<variable>BTN_SAVE</variable>
<action>cp /tmp/test /tmp/testbackup</action>
<action>save:TREE</action>
<action condition="command_is_true([[ $(wc </tmp/test) != $(wc </tmp/testbackup) && sed \"s/^|*//\" /tmp/testbackup > /tmp/test && echo true )">refresh:TREE</action>
</button>
</vbox>' | gtkdialog -s
%%
Deletions:
<entry>
<default>Drag a directory from Rox</default>
</entry>"
gtkdialog -p test
%%
Using the reorderable option in the ##<tree>## has some strange behavior. For example will items get swallowed when moving them onto another item. The workaround restores the list if the user moves item onto, instead of in between 2 other items... This code by [[MochiMoppel]] is a result of 2 cracked nuts:
1) When moving an item in the list the ##$PTR_Y## variable returns 0. A return value >0 gives us the info that the user is clicking rather than moving.
2) Normally ##<action>## defined for a widget are processed __before__ built-in actions. The trick is to process a user defined ##<action>## __after__ a built-in action. An invisible button allows the code to run a user defined save action __after__ a built-in reorder action.
Additions:
Using the reorderable option in the ##<tree>## has some strange behavior. For example will items get swallowed when moving them onto another item. The workaround restores the list if the user moves item onto, instead of in between 2 other items... This code by [[MochiMoppel]] is a result of 2 cracked nuts:
1) When moving an item in the list the ##$PTR_Y## variable returns 0. A return value >0 gives us the info that the user is clicking rather than moving.
2) Normally ##<action>## defined for a widget are processed __before__ built-in actions. The trick is to process a user defined ##<action>## __after__ a built-in action. An invisible button allows the code to run a user defined save action __after__ a built-in reorder action.
1) When moving an item in the list the ##$PTR_Y## variable returns 0. A return value >0 gives us the info that the user is clicking rather than moving.
2) Normally ##<action>## defined for a widget are processed __before__ built-in actions. The trick is to process a user defined ##<action>## __after__ a built-in action. An invisible button allows the code to run a user defined save action __after__ a built-in reorder action.
Additions:
**Drag from file browser to ##<entry>## widget.**
**Move items in list by drag'n drop.** ([[http://www.murga-linux.com/puppy/viewtopic.php?t=107816 More info in this thread]])
**Move items in list by drag'n drop.** ([[http://www.murga-linux.com/puppy/viewtopic.php?t=107816 More info in this thread]])
Deletions:
Additions:
====9.7 Drag'n drop====
Gtkdialog has limited support for drag'n drop. This is what we've learnt by now:
Drag from file browser to ##<entry>## widget.
export test="
<entry>
<default>Drag a directory from Rox</default>
</entry>"
gtkdialog -p test
@@**#%[[gtkdialogDocTips9.6|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips9.8|Next ❱❱❱]]#%**@@
Gtkdialog has limited support for drag'n drop. This is what we've learnt by now:
Drag from file browser to ##<entry>## widget.
export test="
<entry>
<default>Drag a directory from Rox</default>
</entry>"
gtkdialog -p test
@@**#%[[gtkdialogDocTips9.6|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips9.8|Next ❱❱❱]]#%**@@
Deletions:
Gtkdialog can refresh an image in a ##<pixmap>## widget without restarting the gui. Since the ##<input file>## is static, we must change its content (by copy another file), and then refresh.
export MAIN='
<window>
<pixmap>
<variable>IMAGE</variable>
<input file>/root/image1.png</input>
</pixmap>
<button>
<label>Change image</label>
<action>cp -f /root/image2.png /root/image1.png</action>
<action type="refresh">IMAGE</action>
</button>
</window>'
gtkdialog --center --program=MAIN
@@**#%[[gtkdialogDocTips9.5|❰❰❰ Previous]]#% #%[[gtkdialogDocTips|Index]]#% #%[[gtkdialogDocTips9.7|Next ❱❱❱]]#%**@@