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 Thu 23 Oct 2014, 11:11
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How do I put a comboboxentry in the right click menu?SOLVED
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [11 Posts]  
Author Message
oldyeller


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

PostPosted: Thu 20 Jun 2013, 16:14    Post subject:  How do I put a comboboxentry in the right click menu?SOLVED  

Hello Everyone,

I have a question can the comboboxentry be put into the menubar? If so how, I have tried and it does not work.

Any ideas?

Code:

<comboboxentry has-focus="true" wrap-width="2">
    <variable>ITEM</variable>
     <input>ls '"$NOTES_DIR"'</input>
     <action>ln -f "/root/my-documents/Manna/$ITEM" '"$WORKDIR"'/note</action>
      <action>refresh:EDITOR</action>
   </comboboxentry>


I tried doing this
Code:

<menubar>
<menuitem>
<comboboxentry has-focus="true" wrap-width="2">
    <variable>ITEM</variable>
     <input>ls '"$NOTES_DIR"'</input>
     <action>ln -f "/root/my-documents/Manna/$ITEM" '"$WORKDIR"'/note</action>
      <action>refresh:EDITOR</action>
   </comboboxentry>
</menuitem>
</menubar>


I also tried with the menu tag still nothing.

Thanks for any help

Last edited by oldyeller on Mon 24 Jun 2013, 11:32; edited 2 times in total
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5037
Location: Arizona, U.S.A.

PostPosted: Fri 21 Jun 2013, 13:37    Post subject:  

GTK+ supports all kinds of stuff like combos in menus.

But I don`t think a combo can be directly on the menu bar.

GtkDialog does not support lots of what GTK+ can do.
It`s complicated to try to enable all combinations of controls.
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Fri 21 Jun 2013, 14:05    Post subject:  

I have used a combo in menus - but only for right-click menus


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


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

PostPosted: Fri 21 Jun 2013, 14:30    Post subject:  

@ sunburnt Thanks for the info.

@zigbert How would I go about doing one in right click menu for the editor?


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


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

PostPosted: Fri 21 Jun 2013, 15:11    Post subject:  

What is 'the editor' ?
_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
oldyeller


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

PostPosted: Fri 21 Jun 2013, 15:40    Post subject:  

The editor is Manna-Editor

Code:

#!/bin/bash
#130617 i18n started


if [ "`which gtkdialog4`" ]; then
 GTKDIALOG=gtkdialog4
elif [ "`which gtkdialog3`" ]; then
 GTKDIALOG=gtkdialog3
else
 GTKDIALOG=gtkdialog
fi

WORKDIR="/usr/local/mannaeditor"
NOTES_DIR="/root/my-documents/Manna"

export TEXTDOMAIN=Editor
export OUTPUT_CHARSET=UTF-8


#define special Sans-12 font for Editor
READER_FONTSIZE=`cat $WORKDIR/font_size`
[ "$READER_FONTSIZE" = "" ] && READER_FONTSIZE="12" && echo "12" > $WORKDIR/font_size

echo "style \"specialsize\"
{
  font_name=\"Sans $READER_FONTSIZE\"
}
widget \"*\" style \"specialsize\"
class \"*\" style \"specialsize\"" > "$WORKDIR/gtkrc_size"

export GTK2_RC_FILES="$WORKDIR/gtkrc_size:${HOME}/.gtkrc-2.0"

#define icon for current fontsize
if [ "$READER_FONTSIZE" = "12" ]; then
 FONTSIZE12_ICON='stock-id="gtk-apply"'
 FONTSIZE14_ICON=''
 FONTSIZE16_ICON=''
 FONTSIZE18_ICON=''
elif [ "$READER_FONTSIZE" = "14" ]; then
 FONTSIZE12_ICON=''
 FONTSIZE14_ICON='stock-id="gtk-apply"'
 FONTSIZE16_ICON=''
 FONTSIZE18_ICON=''
elif [ "$READER_FONTSIZE" = "16" ]; then
 FONTSIZE12_ICON=''
 FONTSIZE14_ICON=''
 FONTSIZE16_ICON='stock-id="gtk-apply"'
 FONTSIZE18_ICON=''
elif [ "$READER_FONTSIZE" = "18" ]; then
 FONTSIZE12_ICON=''
 FONTSIZE14_ICON=''
 FONTSIZE16_ICON=''
 FONTSIZE18_ICON='stock-id="gtk-apply"'
fi


add_note () {
NOTENAME=`echo "$NOTENAME" | tr '/' '_'`   # replace '/' with '_'
[ ${#NOTENAME} -eq 0 ] && Xdialog --timeout 5 --title "Reader Error" --msgbox "Error: Empty note name!" 0 0 && return
[ -f "$NOTES_DIR"/"$NOTENAME" ] && Xdialog --timeout 5 --title "Reader Error" --msgbox "Error: Note already exists!" 0 0 && return
touch "$NOTES_DIR"/"$NOTENAME"
}
export -f add_note

#About dlg...
echo '#!/bin/sh' > /tmp/Editor-help
echo 'export EDITORHELP_DIALOG="
<window title=\"About\" icon-name=\"Com\" resizable=\"false\">
 <vbox>
 <notebook labels=\"About|License|Translations\">
 <vbox>
  <text height-request=\"2\"><label>\" \"</label></text>
  <pixmap><input file>/usr/local/Manna/icons/Com.png</input></pixmap>
  <text height-request=\"2\"><label>\" \"</label></text>
  <text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>Manna Editor 2.2</span></b>\"</label></text>
  <text><label>\"    This is a basic text Editor for making notes or Teachings
    and can be exported to Abiword. The user interface
    supports the display of text in multiple font sizes for
    general viewing comfort.
   \"</label></text>

  <text><label>\"Copyright © 2013 GPL
  \"</label></text>
</vbox>
 <vbox>
 <text height-request=\"8\"><label>\" \"</label></text>
 <text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>Manna Editor</span></b>\"</label></text>
  <text use-markup=\"true\"><label>\"Is released under the <b>GNU General Public License</b> (GPL). You have the right to use and modify this software in any way you like, so long as any derivative works remain under a GPL license.\"</label></text>
   <text use-markup=\"true\"><label>\"This program is distributed in the hope that it will be useful, but <b><span color='"'red'"'>WITHOUT ANY WARRANTY</span></b>. See the GNU General Public License homepage for more details.\"</label></text>
    <hbox>
     <button>
      <label>\"http://www.gnu.org/licenses/\"</label>
      <action>defaultbrowser http:\/\/www.gnu.org\/licenses\/</action>
     </button>
    </hbox>
    </vbox>
   <vbox>
   <text height-request=\"8\"><label>\" \"</label></text>
   <text><label>\" German \"</label></text>
   <text><label>\" Spanish \"</label></text>
   </vbox>
  </notebook>
   <hbox homogeneous=\"true\">
     <button height-request=\"35\" width-request=\"100\">
      <label>\"Close\"</label>
     <input file stock=\"gtk-close\"></input>
     <action type=\"exit\">quit_now</action>
     </button>
   </hbox>
 </vbox>
</window>"
gtkdialog --center --program=EDITORHELP_DIALOG' >> /tmp/Editor-help
chmod 777 /tmp/Editor-help

export ADD_FILE='
  <window title="'$( gettext "Add Note")'" modal="true" icon-name="gtk-add" resizable="false">
    <vbox>
      <frame "'$(gettext "Note name:")'">
        <entry>
          <variable>NOTENAME</variable>
        </entry>
        <hbox>
          <button ok>
            <action>add_note</action>
            <action>clear:ITEM</action>
            <action>refresh:ITEM</action>
            <action type="closewindow">NOTENAME</action>
          </button>
          <button cancel>
            <action type="closewindow">NOTENAME</action>
          </button>
        </hbox>
      </frame>
    </vbox>
  </window>
'

export DEL_FILE='
  <window title="'$(gettext "Del Note")'" modal="true" icon-name="gtk-remove" resizable="false">
    <vbox>
      <text><label>"'$(gettext "Are you sure you want to delete:")'"</label></text>
         <text><input>echo "$ITEM"</input></text>
      <hbox>
        <button ok>
          <variable>CONFIRM</variable>
          <action>rm "$NOTES_DIR"/"$ITEM"</action>
          <action>clear:ITEM</action>
          <action>refresh:ITEM</action>
          <action type="closewindow">CONFIRM</action>
        </button>
        <button cancel>
          <action type="closewindow">CONFIRM</action>
        </button>
      </hbox>
    </vbox>
  </window>
'



export MAIN_DIALOG='
<window title="'$(gettext "Manna Editor")'" icon-name="Com" resizable="false">

<frame>
<vbox spacing="0">
<menubar>
<menu use-underline="true">
<menuitem stock-id="gtk-new">
<action>launch:ADD_FILE</action>
</menuitem>
<menuitem stock-id="gtk-save">
<action>Save:EDITOR</action>
<action>Save:Saving</action>
<action>refresh:EDITOR</action>
</menuitem>
<menuitem stock-id="gtk-refresh">
<action>refresh:EDITOR</action>
</menuitem>
<menuitem stock-id="gtk-delete">
<action>launch:DEL_FILE</action>
</menuitem>
<menuitem stock-id="gtk-quit">
<action>exit:Quit</action>
</menuitem>
<label>"'$(gettext "_File")'"</label>
</menu>
<menu label="'$(gettext "_Edit")'" use-underline="true">
<menuitem stock-id="gtk-edit" label="'$(gettext "Send to Abiword")'">
      <action>defaultwordprocessor '"$WORKDIR"'/notes &</action>
     </menuitem>
</menu>
<menu label="'$(gettext "_View")'" use-underline="true" tooltip-text="'$(gettext " Change font size ")'">
      <menuitem '$FONTSIZE12_ICON' label="12">
      <action>echo "12" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
      <menuitem '$FONTSIZE14_ICON' label="14">
      <action>echo "14" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
      <menuitem '$FONTSIZE16_ICON' label="16">
      <action>echo "16" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
      <menuitem '$FONTSIZE18_ICON' label="18">
      <action>echo "18" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
    </menu>
    <menu label="'$(gettext "_Help")'" use-underline="true">
     <menuitem stock-id="gtk-info" label="'$(gettext "Help")'">
      <action>defaultbrowser '$WORKDIR'/editor-docs/MannaEditorHelp.html &</action>
     </menuitem>
     <menuitem stock-id="gtk-info" label="'$(gettext "About")'">
      <action>/tmp/Editor-help &</action>
     </menuitem>
    </menu>
</menubar>




   <comboboxentry has-focus="true" wrap-width="2">
    <variable>ITEM</variable>
     <input>ls '"$NOTES_DIR"'</input>
     <action>ln -f "/root/my-documents/Manna/$ITEM" '"$WORKDIR"'/note</action>
      <action>refresh:EDITOR</action>
   </comboboxentry>

  <hseparator></hseparator>

  <hbox>
   <edit editable="true" accepts-tab="true" indent="" justification="0" left-margin="12" right-margin="15" wrap-mode="2">
     <variable>EDITOR</variable>
     <height>600</height>
     <width>780</width>
     <input file>'"$WORKDIR"'/note</input>
     <output file>'"$WORKDIR"'/note</output>
   </edit>
  </hbox>
  </vbox>
 </frame>
<action signal="hide">exit:Exit</action>
</window>
'

MM1RET="`gtkdialog --program=MAIN_DIALOG`"
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Fri 21 Jun 2013, 17:49    Post subject:  

oldyeller
This is not a final solution, but a showcase how I set up my external menus. In addition to the new function show_menu, see line 13, 14 and the <edit> code. The menus in pMusic are located in separate files, so it is easy to see more complex examples. Ie. /usr/local/pmusic/menu_sourcelist

Code:
#!/bin/bash
#130617 i18n started


if [ "`which gtkdialog4`" ]; then
 GTKDIALOG=gtkdialog4
elif [ "`which gtkdialog3`" ]; then
 GTKDIALOG=gtkdialog3
else
 GTKDIALOG=gtkdialog
fi

export WORKDIR="/usr/local/mannaeditor"
export NOTES_DIR="/root/my-documents/Manna"

export TEXTDOMAIN=Editor
export OUTPUT_CHARSET=UTF-8


#define special Sans-12 font for Editor
READER_FONTSIZE=`cat $WORKDIR/font_size`
[ "$READER_FONTSIZE" = "" ] && READER_FONTSIZE="12" && echo "12" > $WORKDIR/font_size

echo "style \"specialsize\"
{
  font_name=\"Sans $READER_FONTSIZE\"
}
widget \"*\" style \"specialsize\"
class \"*\" style \"specialsize\"" > "$WORKDIR/gtkrc_size"

export GTK2_RC_FILES="$WORKDIR/gtkrc_size:${HOME}/.gtkrc-2.0"

#define icon for current fontsize
if [ "$READER_FONTSIZE" = "12" ]; then
 FONTSIZE12_ICON='stock-id="gtk-apply"'
 FONTSIZE14_ICON=''
 FONTSIZE16_ICON=''
 FONTSIZE18_ICON=''
elif [ "$READER_FONTSIZE" = "14" ]; then
 FONTSIZE12_ICON=''
 FONTSIZE14_ICON='stock-id="gtk-apply"'
 FONTSIZE16_ICON=''
 FONTSIZE18_ICON=''
elif [ "$READER_FONTSIZE" = "16" ]; then
 FONTSIZE12_ICON=''
 FONTSIZE14_ICON=''
 FONTSIZE16_ICON='stock-id="gtk-apply"'
 FONTSIZE18_ICON=''
elif [ "$READER_FONTSIZE" = "18" ]; then
 FONTSIZE12_ICON=''
 FONTSIZE14_ICON=''
 FONTSIZE16_ICON=''
 FONTSIZE18_ICON='stock-id="gtk-apply"'
fi


add_note () {
NOTENAME=`echo "$NOTENAME" | tr '/' '_'`   # replace '/' with '_'
[ ${#NOTENAME} -eq 0 ] && Xdialog --timeout 5 --title "Reader Error" --msgbox "Error: Empty note name!" 0 0 && return
[ -f "$NOTES_DIR"/"$NOTENAME" ] && Xdialog --timeout 5 --title "Reader Error" --msgbox "Error: Note already exists!" 0 0 && return
touch "$NOTES_DIR"/"$NOTENAME"
}

show_menu () {
MENUITEMS="`find "$NOTES_DIR" -type f -printf "<menuitem><label>\\\"%f\\\"</label><action>ln -f \\\"/root/my-documents/Manna/%f\\\" '"$WORKDIR"'/note</action><action>EXIT:exit</action></menuitem>\n" | sort`"
[ ! "$MENUITEMS" ] && MENUITEMS='<menuitem><label>"no files found"</label></menuitem>'
echo '
<window decorated="false" skip_taskbar_hint="true" resizable="false" height-request="50" width-request="240" modal="true">
 <hbox scrollable="true" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  <text width-request="1" space-expand="false" space-fill="false"><label>""</label></text>
  <vbox spacing="2">
   <text height-request="2" space-expand="false" space-fill="false"><label>""</label></text>
   <hbox height-request="22" spacing="2">
   <pixmap height-request="20" icon_size="1" space-expand="false" space-fill="false"><input file stock="gtk-open"></input></pixmap>
    <entry>
     <variable>ITEM</variable>
     <input>ls '"$NOTES_DIR"'</input>
     <action signal="activate">ln -f "/root/my-documents/Manna/$ITEM" '"$WORKDIR"'/note</action>
     <action signal="activate">EXIT:exit</action>
    </entry>
    <menubar>
     <menu>
     '"$MENUITEMS"'
     <label>..</label>
     </menu>
    </menubar>
   </hbox>
  </vbox>
 </hbox>
 <action signal="focus-out-event">EXIT:exit</action>
</window>' | gtkdialog -s -G +"$(($PTR_X_ROOT-5))"+"$(($PTR_Y_ROOT-5))" > /dev/null
}

export -f add_note show_menu

#About dlg...
echo '#!/bin/sh' > /tmp/Editor-help
echo 'export EDITORHELP_DIALOG="
<window title=\"About\" icon-name=\"Com\" resizable=\"false\">
 <vbox>
 <notebook labels=\"About|License|Translations\">
 <vbox>
  <text height-request=\"2\"><label>\" \"</label></text>
  <pixmap><input file>/usr/local/Manna/icons/Com.png</input></pixmap>
  <text height-request=\"2\"><label>\" \"</label></text>
  <text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>Manna Editor 2.2</span></b>\"</label></text>
  <text><label>\"    This is a basic text Editor for making notes or Teachings
    and can be exported to Abiword. The user interface
    supports the display of text in multiple font sizes for
    general viewing comfort.
   \"</label></text>

  <text><label>\"Copyright © 2013 GPL
  \"</label></text>
</vbox>
 <vbox>
 <text height-request=\"8\"><label>\" \"</label></text>
 <text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>Manna Editor</span></b>\"</label></text>
  <text use-markup=\"true\"><label>\"Is released under the <b>GNU General Public License</b> (GPL). You have the right to use and modify this software in any way you like, so long as any derivative works remain under a GPL license.\"</label></text>
   <text use-markup=\"true\"><label>\"This program is distributed in the hope that it will be useful, but <b><span color='"'red'"'>WITHOUT ANY WARRANTY</span></b>. See the GNU General Public License homepage for more details.\"</label></text>
    <hbox>
     <button>
      <label>\"http://www.gnu.org/licenses/\"</label>
      <action>defaultbrowser http:\/\/www.gnu.org\/licenses\/</action>
     </button>
    </hbox>
    </vbox>
   <vbox>
   <text height-request=\"8\"><label>\" \"</label></text>
   <text><label>\" German \"</label></text>
   <text><label>\" Spanish \"</label></text>
   </vbox>
  </notebook>
   <hbox homogeneous=\"true\">
     <button height-request=\"35\" width-request=\"100\">
      <label>\"Close\"</label>
     <input file stock=\"gtk-close\"></input>
     <action type=\"exit\">quit_now</action>
     </button>
   </hbox>
 </vbox>
</window>"
gtkdialog --center --program=EDITORHELP_DIALOG' >> /tmp/Editor-help
chmod 777 /tmp/Editor-help

export ADD_FILE='
  <window title="'$( gettext "Add Note")'" modal="true" icon-name="gtk-add" resizable="false">
    <vbox>
      <frame "'$(gettext "Note name:")'">
        <entry>
          <variable>NOTENAME</variable>
        </entry>
        <hbox>
          <button ok>
            <action>add_note</action>
            <action>clear:ITEM</action>
            <action>refresh:ITEM</action>
            <action type="closewindow">NOTENAME</action>
          </button>
          <button cancel>
            <action type="closewindow">NOTENAME</action>
          </button>
        </hbox>
      </frame>
    </vbox>
  </window>
'

export DEL_FILE='
  <window title="'$(gettext "Del Note")'" modal="true" icon-name="gtk-remove" resizable="false">
    <vbox>
      <text><label>"'$(gettext "Are you sure you want to delete:")'"</label></text>
         <text><input>echo "$ITEM"</input></text>
      <hbox>
        <button ok>
          <variable>CONFIRM</variable>
          <action>rm "$NOTES_DIR"/"$ITEM"</action>
          <action>clear:ITEM</action>
          <action>refresh:ITEM</action>
          <action type="closewindow">CONFIRM</action>
        </button>
        <button cancel>
          <action type="closewindow">CONFIRM</action>
        </button>
      </hbox>
    </vbox>
  </window>
'



export MAIN_DIALOG='
<window title="'$(gettext "Manna Editor")'" icon-name="Com" resizable="false">

<frame>
<vbox spacing="0">
<menubar>
<menu use-underline="true">
<menuitem stock-id="gtk-new">
<action>launch:ADD_FILE</action>
</menuitem>
<menuitem stock-id="gtk-save">
<action>Save:EDITOR</action>
<action>Save:Saving</action>
<action>refresh:EDITOR</action>
</menuitem>
<menuitem stock-id="gtk-refresh">
<action>refresh:EDITOR</action>
</menuitem>
<menuitem stock-id="gtk-delete">
<action>launch:DEL_FILE</action>
</menuitem>
<menuitem stock-id="gtk-quit">
<action>exit:Quit</action>
</menuitem>
<label>"'$(gettext "_File")'"</label>
</menu>
<menu label="'$(gettext "_Edit")'" use-underline="true">
<menuitem stock-id="gtk-edit" label="'$(gettext "Send to Abiword")'">
      <action>defaultwordprocessor '"$WORKDIR"'/notes &</action>
     </menuitem>
</menu>
<menu label="'$(gettext "_View")'" use-underline="true" tooltip-text="'$(gettext " Change font size ")'">
      <menuitem '$FONTSIZE12_ICON' label="12">
      <action>echo "12" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
      <menuitem '$FONTSIZE14_ICON' label="14">
      <action>echo "14" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
      <menuitem '$FONTSIZE16_ICON' label="16">
      <action>echo "16" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
      <menuitem '$FONTSIZE18_ICON' label="18">
      <action>echo "18" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
    </menu>
    <menu label="'$(gettext "_Help")'" use-underline="true">
     <menuitem stock-id="gtk-info" label="'$(gettext "Help")'">
      <action>defaultbrowser '$WORKDIR'/editor-docs/MannaEditorHelp.html &</action>
     </menuitem>
     <menuitem stock-id="gtk-info" label="'$(gettext "About")'">
      <action>/tmp/Editor-help &</action>
     </menuitem>
    </menu>
</menubar>

  <hbox>
   <edit editable="true" accepts-tab="true" indent="" justification="0" left-margin="12" right-margin="15" wrap-mode="2" file-monitor="true" auto-refresh="true">
     <variable>EDITOR</variable>
     <height>600</height>
     <width>780</width>
     <input file>'"$WORKDIR"'/note</input>
     <output file>'"$WORKDIR"'/note</output>
     <action signal="button-press-event">if [ $PTR_BTN -eq 3 ]; then show_menu; fi</action>
   </edit>
  </hbox>
  </vbox>
 </frame>
<action signal="hide">exit:Exit</action>
</window>
'

MM1RET="`gtkdialog --program=MAIN_DIALOG`"

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


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

PostPosted: Fri 21 Jun 2013, 18:19    Post subject:  

Hi zigbert,

I'll copy the code and look at it and will also look at yours too. Will report back


Cheers
Back to top
View user's profile Send private message 
oldyeller


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

PostPosted: Fri 21 Jun 2013, 21:23    Post subject:  

@zigbert The only thing I have notice is that it does not refresh the editor. If I want to split up my code and put them in other files how do I do that?

I know that you said
Quote:

oldyeller
This is not a final solution, but a showcase how I set up my external menus. In addition to the new function show_menu, see line 13, 14 and the <edit> code. The menus in pMusic are located in separate files, so it is easy to see more complex examples. Ie. /usr/local/pmusic/menu_sourcelist


Also this file /usr/local/pmusic/menu_sourcelist is not in the pmusic that I have pMusic 3.2.3

look forward to learning more thanks
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Sat 22 Jun 2013, 02:16    Post subject:  

Hi again
It seems the <edit> widget fails with the file-monitor attribute.
We have to use another workaround. See line 15, 267 and the show_menu fundtion.
Code:
#!/bin/bash
#130617 i18n started


if [ "`which gtkdialog4`" ]; then
 GTKDIALOG=gtkdialog4
elif [ "`which gtkdialog3`" ]; then
 GTKDIALOG=gtkdialog3
else
 GTKDIALOG=gtkdialog
fi

export WORKDIR="/usr/local/mannaeditor"
export NOTES_DIR="/root/my-documents/Manna"
echo false > /tmp/UPDATE_EDITOR

export TEXTDOMAIN=Editor
export OUTPUT_CHARSET=UTF-8


#define special Sans-12 font for Editor
READER_FONTSIZE=`cat $WORKDIR/font_size`
[ "$READER_FONTSIZE" = "" ] && READER_FONTSIZE="12" && echo "12" > $WORKDIR/font_size

echo "style \"specialsize\"
{
  font_name=\"Sans $READER_FONTSIZE\"
}
widget \"*\" style \"specialsize\"
class \"*\" style \"specialsize\"" > "$WORKDIR/gtkrc_size"

export GTK2_RC_FILES="$WORKDIR/gtkrc_size:${HOME}/.gtkrc-2.0"

#define icon for current fontsize
if [ "$READER_FONTSIZE" = "12" ]; then
 FONTSIZE12_ICON='stock-id="gtk-apply"'
 FONTSIZE14_ICON=''
 FONTSIZE16_ICON=''
 FONTSIZE18_ICON=''
elif [ "$READER_FONTSIZE" = "14" ]; then
 FONTSIZE12_ICON=''
 FONTSIZE14_ICON='stock-id="gtk-apply"'
 FONTSIZE16_ICON=''
 FONTSIZE18_ICON=''
elif [ "$READER_FONTSIZE" = "16" ]; then
 FONTSIZE12_ICON=''
 FONTSIZE14_ICON=''
 FONTSIZE16_ICON='stock-id="gtk-apply"'
 FONTSIZE18_ICON=''
elif [ "$READER_FONTSIZE" = "18" ]; then
 FONTSIZE12_ICON=''
 FONTSIZE14_ICON=''
 FONTSIZE16_ICON=''
 FONTSIZE18_ICON='stock-id="gtk-apply"'
fi


add_note () {
NOTENAME=`echo "$NOTENAME" | tr '/' '_'`   # replace '/' with '_'
[ ${#NOTENAME} -eq 0 ] && Xdialog --timeout 5 --title "Reader Error" --msgbox "Error: Empty note name!" 0 0 && return
[ -f "$NOTES_DIR"/"$NOTENAME" ] && Xdialog --timeout 5 --title "Reader Error" --msgbox "Error: Note already exists!" 0 0 && return
touch "$NOTES_DIR"/"$NOTENAME"
}

show_menu () {
MENUITEMS="`find "$NOTES_DIR" -type f -printf "<menuitem><label>\\\"%f\\\"</label><action>ln -f \\\"/root/my-documents/Manna/%f\\\" '"$WORKDIR"'/note</action><action>echo true > /tmp/UPDATE_EDITOR</action><action>EXIT:exit</action></menuitem>\n" | sort`"
[ ! "$MENUITEMS" ] && MENUITEMS='<menuitem><label>"no files found"</label></menuitem>'
echo '
<window decorated="false" skip_taskbar_hint="true" resizable="false" height-request="50" width-request="240" modal="true">
 <hbox scrollable="true" hscrollbar-policy="2" vscrollbar-policy="2" space-expand="true" space-fill="true">
  <text width-request="1" space-expand="false" space-fill="false"><label>""</label></text>
  <vbox spacing="2">
   <text height-request="2" space-expand="false" space-fill="false"><label>""</label></text>
   <hbox height-request="22" spacing="2">
   <pixmap height-request="20" icon_size="1" space-expand="false" space-fill="false"><input file stock="gtk-open"></input></pixmap>
    <entry>
     <variable>ITEM</variable>
     <input>ls '"$NOTES_DIR"'</input>
     <action signal="activate">ln -f "/root/my-documents/Manna/$ITEM" '"$WORKDIR"'/note</action>
     <action>echo true > /tmp/UPDATE_EDITOR</action><action>echo true > /tmp/UPDATE_EDITOR</action>
     <action signal="activate">EXIT:exit</action>
    </entry>
    <menubar>
     <menu>
     '"$MENUITEMS"'
     <label>..</label>
     </menu>
    </menubar>
   </hbox>
  </vbox>
 </hbox>
 <action signal="focus-out-event">EXIT:exit</action>
</window>' | gtkdialog -s -G +"$(($PTR_X_ROOT-5))"+"$(($PTR_Y_ROOT-5))" > /dev/null
}

export -f add_note show_menu

#About dlg...
echo '#!/bin/sh' > /tmp/Editor-help
echo 'export EDITORHELP_DIALOG="
<window title=\"About\" icon-name=\"Com\" resizable=\"false\">
 <vbox>
 <notebook labels=\"About|License|Translations\">
 <vbox>
  <text height-request=\"2\"><label>\" \"</label></text>
  <pixmap><input file>/usr/local/Manna/icons/Com.png</input></pixmap>
  <text height-request=\"2\"><label>\" \"</label></text>
  <text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>Manna Editor 2.2</span></b>\"</label></text>
  <text><label>\"    This is a basic text Editor for making notes or Teachings
    and can be exported to Abiword. The user interface
    supports the display of text in multiple font sizes for
    general viewing comfort.
   \"</label></text>

  <text><label>\"Copyright © 2013 GPL
  \"</label></text>
</vbox>
 <vbox>
 <text height-request=\"8\"><label>\" \"</label></text>
 <text use-markup=\"true\"><label>\"<b><span size='"'x-large'"'>Manna Editor</span></b>\"</label></text>
  <text use-markup=\"true\"><label>\"Is released under the <b>GNU General Public License</b> (GPL). You have the right to use and modify this software in any way you like, so long as any derivative works remain under a GPL license.\"</label></text>
   <text use-markup=\"true\"><label>\"This program is distributed in the hope that it will be useful, but <b><span color='"'red'"'>WITHOUT ANY WARRANTY</span></b>. See the GNU General Public License homepage for more details.\"</label></text>
    <hbox>
     <button>
      <label>\"http://www.gnu.org/licenses/\"</label>
      <action>defaultbrowser http:\/\/www.gnu.org\/licenses\/</action>
     </button>
    </hbox>
    </vbox>
   <vbox>
   <text height-request=\"8\"><label>\" \"</label></text>
   <text><label>\" German \"</label></text>
   <text><label>\" Spanish \"</label></text>
   </vbox>
  </notebook>
   <hbox homogeneous=\"true\">
     <button height-request=\"35\" width-request=\"100\">
      <label>\"Close\"</label>
     <input file stock=\"gtk-close\"></input>
     <action type=\"exit\">quit_now</action>
     </button>
   </hbox>
 </vbox>
</window>"
gtkdialog --center --program=EDITORHELP_DIALOG' >> /tmp/Editor-help
chmod 777 /tmp/Editor-help

export ADD_FILE='
  <window title="'$( gettext "Add Note")'" modal="true" icon-name="gtk-add" resizable="false">
    <vbox>
      <frame "'$(gettext "Note name:")'">
        <entry>
          <variable>NOTENAME</variable>
        </entry>
        <hbox>
          <button ok>
            <action>add_note</action>
            <action>clear:ITEM</action>
            <action>refresh:ITEM</action>
            <action type="closewindow">NOTENAME</action>
          </button>
          <button cancel>
            <action type="closewindow">NOTENAME</action>
          </button>
        </hbox>
      </frame>
    </vbox>
  </window>
'

export DEL_FILE='
  <window title="'$(gettext "Del Note")'" modal="true" icon-name="gtk-remove" resizable="false">
    <vbox>
      <text><label>"'$(gettext "Are you sure you want to delete:")'"</label></text>
         <text><input>echo "$ITEM"</input></text>
      <hbox>
        <button ok>
          <variable>CONFIRM</variable>
          <action>rm "$NOTES_DIR"/"$ITEM"</action>
          <action>clear:ITEM</action>
          <action>refresh:ITEM</action>
          <action type="closewindow">CONFIRM</action>
        </button>
        <button cancel>
          <action type="closewindow">CONFIRM</action>
        </button>
      </hbox>
    </vbox>
  </window>
'



export MAIN_DIALOG='
<window title="'$(gettext "Manna Editor")'" icon-name="Com" resizable="false">

<frame>
<vbox spacing="0">
<menubar>
<menu use-underline="true">
<menuitem stock-id="gtk-new">
<action>launch:ADD_FILE</action>
</menuitem>
<menuitem stock-id="gtk-save">
<action>Save:EDITOR</action>
<action>Save:Saving</action>
<action>refresh:EDITOR</action>
</menuitem>
<menuitem stock-id="gtk-refresh">
<action>refresh:EDITOR</action>
</menuitem>
<menuitem stock-id="gtk-delete">
<action>launch:DEL_FILE</action>
</menuitem>
<menuitem stock-id="gtk-quit">
<action>exit:Quit</action>
</menuitem>
<label>"'$(gettext "_File")'"</label>
</menu>
<menu label="'$(gettext "_Edit")'" use-underline="true">
<menuitem stock-id="gtk-edit" label="'$(gettext "Send to Abiword")'">
      <action>defaultwordprocessor '"$WORKDIR"'/notes &</action>
     </menuitem>
</menu>
<menu label="'$(gettext "_View")'" use-underline="true" tooltip-text="'$(gettext " Change font size ")'">
      <menuitem '$FONTSIZE12_ICON' label="12">
      <action>echo "12" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
      <menuitem '$FONTSIZE14_ICON' label="14">
      <action>echo "14" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
      <menuitem '$FONTSIZE16_ICON' label="16">
      <action>echo "16" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
      <menuitem '$FONTSIZE18_ICON' label="18">
      <action>echo "18" > '$WORKDIR'/font_size</action>
      <action>'$WORKDIR'/Editor &</action>
      <action type="exit">quit_now</action>
      </menuitem>
    </menu>
    <menu label="'$(gettext "_Help")'" use-underline="true">
     <menuitem stock-id="gtk-info" label="'$(gettext "Help")'">
      <action>defaultbrowser '$WORKDIR'/editor-docs/MannaEditorHelp.html &</action>
     </menuitem>
     <menuitem stock-id="gtk-info" label="'$(gettext "About")'">
      <action>/tmp/Editor-help &</action>
     </menuitem>
    </menu>
</menubar>

  <hbox>
   <edit editable="true" accepts-tab="true" indent="" justification="0" left-margin="12" right-margin="15" wrap-mode="2">
     <variable>EDITOR</variable>
     <height>600</height>
     <width>780</width>
     <input file>'"$WORKDIR"'/note</input>
     <output file>'"$WORKDIR"'/note</output>
     <action signal="button-press-event">if [ $PTR_BTN -eq 3 ]; then show_menu; fi</action>
   </edit>
  </hbox>
  <checkbox visible="false" file-monitor="true" auto-refresh="true">
   <variable>UPDATE_EDITOR</variable>
   <input file>/tmp/UPDATE_EDITOR</input>
   <action>if true refresh:EDITOR</action>
   <action>if true echo false > /tmp/UPDATE_EDITOR</action>
   <action>if true refresh:UPDATE_EDITOR</action>
  </checkbox>

  </vbox>
 </frame>
<action signal="hide">exit:Exit</action>
</window>
'

MM1RET="`gtkdialog --program=MAIN_DIALOG`"

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


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

PostPosted: Sat 22 Jun 2013, 06:56    Post subject:  

Hi zigbert,

This code is not the easiest to learn but will get there. Now the Del_FILE don't work. I guess when improving one thing somethings can break and than ones needs to fix that as well.

Never ending chance at learning Very Happy Very Happy

I was thinking of taking this out, But not sure as of yet.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [11 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.1948s ][ Queries: 11 (0.0030s) ][ GZIP on ]