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 23 Apr 2014, 06:12
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff)
Bookmarks viewer
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
disciple

Joined: 20 May 2006
Posts: 6378
Location: Auckland, New Zealand

PostPosted: Sat 18 Sep 2010, 10:08    Post subject:  Bookmarks viewer
Subject description: Show Rox filer and GTK bookmarks
 

Forum administrators - feel free to move this to a subcategory... I really don't know whether it belongs in Desktop or Filesystem or Utilities or wherever...
------------------------

This script shows all your GTK and Rox Filer bookmarks(see screenshot below).
Change the FILER variable at the top if you want them to open in something other than Rox when you click on them.
Put it in the menu, on a taskbar button, or wherever.
What should we call it? Pbookmark?

Code:
#!/bin/sh
# Todo:
# Ability to edit the bookmarks?  (or at least open the relevant file)
# Make code more elegant/faster
# Make filer an input argument - this could also enable it to be called e.g. instead of a drop-down bookmarks menu (e.g. pburn)
# Only show folders that exist?
# this would be consistent with the way the GTK open/save dialogue works,
# but not the rox bookmarks menu.  And it might be GOOD to discover broken bookmarks.

# Which filer shall we use?
FILER="rox"
# Should we close the dialogue after calling the filer?
EXIT_ON_CLICK="no"

if [ "$EXIT_ON_CLICK" = "yes" ]
 then ACTION="<action type=\"exit\">done</action>"
 else ACTION=""
fi

if [ -d "$HOME/Desktop" ]
 then DESKTOP="
 <button xalign=\"0\" tooltip-text=\"$HOME\/Desktop\">
 <label>Desktop</label>
 <action>"$FILER" \"$HOME/Desktop\"</action>
 $ACTION
 </button>"
 else DESKTOP=""
fi

# Start of dialogue
BOOKMARK_LIST="<window title=\"Open bookmarks:\" icon-name=\"gtk-directory\">
<hbox><frame GTK Bookmarks>
 <button xalign=\"0\" tooltip-text=\"$HOME\">
  <label>`basename \"$HOME\"`</label>
  <action>"$FILER" \"$HOME\"</action>
  $ACTION
 </button>
 $DESKTOP
 <button xalign=\"0\" tooltip-text=\"\/\">
  <label>Filesystem</label>
  <action>"$FILER" /</action>
  $ACTION
 </button>"

# GTK bookmarks
if [ -r "$HOME/.gtk-bookmarks" ]; then
if [ "`grep -m1 file \"$HOME/.gtk-bookmarks\"`" = "" ]
 then BOOKMARK_LIST="$BOOKMARK_LIST
 <text>
  <label>No bookmarks in $HOME/.gtk-bookmarks</label>
 </text>"
else
# Buttons for each bookmarks
while read FILE_PATH FILE_NAME
do FILE_PATH=`echo ${FILE_PATH#file://}|sed 's/%20/ /g'`
 BOOKMARK_LIST="$BOOKMARK_LIST
 <button xalign=\"0\" tooltip-text=\"$FILE_PATH\">
  <label>`[ -n "$FILE_NAME" ]&&echo $FILE_NAME||basename "$FILE_PATH"`</label>
  <action>"$FILER" \"$FILE_PATH\"</action>
  $ACTION
 </button>"
done < "$HOME/.gtk-bookmarks"
fi

# NO GTK bookmarks file
else
BOOKMARK_LIST="$BOOKMARK_LIST
 <text>
  <label>$HOME/.gtk-bookmarks does not exist</label>
 </text>"
fi

# Middle of dialogue
export BOOKMARK_LIST="$BOOKMARK_LIST
</frame>
<frame Rox Filer bookmarks>"

# Rox Filer bookmarks
if [ -r "$HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml" ]; then
if [ "`grep -m1 title \"$HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml\"`" = "" ]
 then BOOKMARK_LIST="$BOOKMARK_LIST
 <text>
  <label>No bookmarks in $HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml</label>
 </text>"
else
# Make sure each bookmark is on a new line
sed 's/></>\n</g' "$HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml" >/dev/null
# Buttons for each bookmark
while read I
do if [ "`echo $I|grep title`" != "" ]
then FILE_PATH=`echo $I |cut -d \> -f 2|cut -d \< -f 1`
 FILE_NAME=`echo $I |cut -d \" -f 2`
 BOOKMARK_LIST="$BOOKMARK_LIST
 <button xalign=\"0\" tooltip-text=\"$FILE_PATH\">
  <label>$FILE_NAME</label>
  <action>"$FILER" \"$FILE_PATH\"</action>
  $ACTION
 </button>"
fi
done < "$HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml"
fi

# NO ROX Filer bookmarks
else
BOOKMARK_LIST="$BOOKMARK_LIST
 <text>
  <label>$HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml does not exist</label>
 </text>"
fi

# End of dialogue
export BOOKMARK_LIST="$BOOKMARK_LIST
</frame></hbox>
</window>"

gtkdialog3 -p BOOKMARK_LIST
screenshot.png
 Description   
 Filesize   5.51 KB
 Viewed   944 Time(s)

screenshot.png


_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 3809
Location: Gatineau (Qc), Canada

PostPosted: Fri 18 Oct 2013, 00:58    Post subject:  

Hello, disciple.

Thanks for this script. I just chanced upon it.

Would there be a way to make a long bookmarks listing either scroll down
the panel or display on a second panel?

Thanks in advance.

Best regards.

musher0
Long_PBookmarks_Listing.jpg
 Description   Example
 Filesize   34.94 KB
 Viewed   177 Time(s)

Long_PBookmarks_Listing.jpg


_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
disciple

Joined: 20 May 2006
Posts: 6378
Location: Auckland, New Zealand

PostPosted: Sat 19 Oct 2013, 04:11    Post subject:  

Yes, now it is possible, unless you have an old Puppy with an old gtkdialog.
I've also tried to make the code a bit prettier, made it use the new "$XDG_CONFIG_HOME/gtk-3.0/bookmarks" file if it exists, and done a few other small fixes. Just set the four variables in the second block according to your preference.

Code:
#!/bin/sh
# Todo:
# Ability to edit the bookmarks?  (or at least open the relevant file).
# Make code more elegant/faster.
# Make filer an input argument - this could also enable it to be called e.g. instead of a drop-down bookmarks menu (e.g. pburn).
# Only show folders that exist?
# - this would be consistent with the way the GTK open/save dialogue works,
# - but not the rox bookmarks menu.  And it might be GOOD to discover broken bookmarks.
# Show mounted drives like the GTK file dialog does.

# Which filer shall we use?
FILER="rox"
# Should we close the dialogue after calling the filer?
EXIT_ON_CLICK="no"
# If you have too many bookmarks to fit on the screen, choose "together" or "separate" to choose how to scroll the two lists.
# If you leave it as "" you won't get any scrollbars so you will need to drag the window up with alt-click to see the ones that don't fit on the screen.
SCROLLABLE=""
# If $SCROLLABLE above is "together" or "separate", you should also edit this to suit your screen size and panel and window decoration size.
SCROLLABLEWINDOWSIZING="--geometry 1276x969"

if [ "$EXIT_ON_CLICK" = "yes" ]
then
 ACTION="<action type=\"exit\">done</action>"
else
 ACTION=""
fi

SCROLLABLEHBOXTAG="scrollable=\"false\""
case  "$SCROLLABLE" in
 separate)
  SCROLLABLEVBOXOPENTAG="<vbox scrollable=\"true\">"
  SCROLLABLEVBOXCLOSETAG="</vbox>"
 ;;
 together)
  SCROLLABLEHBOXTAG="scrollable=\"true\""
 ;;
 *)
  SCROLLABLEWINDOWSIZING=""
 ;;
esac

# Like the GTK file dialog, include the Desktop folder if it exists (as well as the home folder and /, in "Start of dialog", below).
if [ -d "$HOME/Desktop" ]
then
 DESKTOP="
          <button xalign=\"0\" tooltip-text=\"$HOME/Desktop\">
           <label>Desktop</label>
           <action>"$FILER" \"$HOME/Desktop\"</action>
           $ACTION
          </button>"
else
 DESKTOP=""
fi

# Start of dialogue
BOOKMARK_LIST="
                      <window title=\"Open bookmarks:\" icon-name=\"gtk-jump-to-ltr\">
                       <hbox $SCROLLABLEHBOXTAG>
                        <frame GTK Bookmarks>
                         $SCROLLABLEVBOXOPENTAG
                          <button xalign=\"0\" tooltip-text=\"$HOME (this user's home folder)\">
                           <label>`basename \"$HOME\"`</label>
                           <action>"$FILER" \"$HOME\"</action>
                           $ACTION
                          </button>
                          $DESKTOP
                          <button xalign=\"0\" tooltip-text=\"\/\">
                           <label>Filesystem</label>
                           <action>"$FILER" /</action>
                           $ACTION
                          </button>"

# GTK bookmarks
GTK_BOOKMARKS="$XDG_CONFIG_HOME/gtk-3.0/bookmarks"
if [ ! -r "$GTK_BOOKMARKS" ]
then
 GTK_BOOKMARKS="$HOME/.gtk-bookmarks"
fi
if [ -r "$GTK_BOOKMARKS" ]
then
 if [ "`grep -m1 :// \"$GTK_BOOKMARKS\"`" = "" ]
 then
  BOOKMARK_LIST="$BOOKMARK_LIST
                          <text>
                           <label>No bookmarks in $GTK_BOOKMARKS</label>
                          </text>"
 else
  # Buttons for each bookmark
  while read FILE_PATH FILE_NAME
  do
   # need to do this magic to support filers like rox which don't understand gvfs uris
   # it allows non file:// uris through unmodified - these will work with filers like pcmanfm, but not rox
   # e.g. " computer:///", "trash:///", "network:///", "smb://green%20room/Puppy", "menu://applications/"
   # if using one of these filers you might want to add an entry to "Start of dialog" (above) for "recently used" ("recent:///")
   FILE_PATH=`echo ${FILE_PATH#file://}|sed 's/%20/ /g'`
   BOOKMARK_LIST="$BOOKMARK_LIST
                          <button xalign=\"0\" tooltip-text=\"$FILE_PATH\">
                           <label>`[ -n "$FILE_NAME" ]&&echo $FILE_NAME||basename "$FILE_PATH"`</label>
                           <action>"$FILER" \"$FILE_PATH\"</action>
                           $ACTION
                          </button>"
  done < "$GTK_BOOKMARKS"
 fi

# No GTK bookmarks file
else
 BOOKMARK_LIST="$BOOKMARK_LIST
                          <text>
                           <label>$GTK_BOOKMARKS or $XDG_CONFIG_HOME/gtk-3.0/bookmarks does not exist</label>
                          </text>"
fi

# Middle of dialogue
BOOKMARK_LIST="$BOOKMARK_LIST
                         $SCROLLABLEVBOXCLOSETAG
                        </frame>
                        <frame Rox Filer bookmarks>
                         $SCROLLABLEVBOXOPENTAG"

# Rox Filer bookmarks
if [ -r "$XDG_CONFIG_HOME/rox.sourceforge.net/ROX-Filer/Bookmarks.xml" ]
then
 if [ "`grep -m1 title \"$XDG_CONFIG_HOME/rox.sourceforge.net/ROX-Filer/Bookmarks.xml\"`" = "" ]
 then
  BOOKMARK_LIST="$BOOKMARK_LIST
                          <text>
                           <label>No bookmarks in $HOME/.config/rox.sourceforge.net/ROX-Filer/Bookmarks.xml</label>
                          </text>"
 else
  # Make sure each bookmark is on a new line
  sed 's/></>\n</g' "$XDG_CONFIG_HOME/rox.sourceforge.net/ROX-Filer/Bookmarks.xml" >/dev/null
  # Buttons for each bookmark
  while read I
  do
   if [ "`echo $I|grep title`" != "" ]
   then
    FILE_PATH=`echo $I |cut -d \> -f 2|cut -d \< -f 1`
    FILE_NAME=`echo $I |cut -d \" -f 2`
    BOOKMARK_LIST="$BOOKMARK_LIST
                          <button xalign=\"0\" tooltip-text=\"$FILE_PATH\">
                           <label>$FILE_NAME</label>
                           <action>"$FILER" \"$FILE_PATH\"</action>
                           $ACTION
                          </button>"
   fi
  done < "$XDG_CONFIG_HOME/rox.sourceforge.net/ROX-Filer/Bookmarks.xml"
 fi

# No Rox Filer bookmarks
else
 BOOKMARK_LIST="$BOOKMARK_LIST
                          <text>
                           <label>$XDG_CONFIG_HOME/rox.sourceforge.net/ROX-Filer/Bookmarks.xml does not exist</label>
                          </text>"
fi

# End of dialogue
export BOOKMARK_LIST="$BOOKMARK_LIST
                         $SCROLLABLEVBOXCLOSETAG
                        </frame>
                       </hbox>
                      </window>"

gtkdialog3 -p BOOKMARK_LIST $SCROLLABLEWINDOWSIZING

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff)
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.0895s ][ Queries: 12 (0.0092s) ][ GZIP on ]