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 Mon 22 Sep 2014, 16:28
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
gtkdialog problem with filenames w brackets ( ) .. SOLVED
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [7 Posts]  
Author Message
sc0ttman


Joined: 16 Sep 2009
Posts: 2376
Location: UK

PostPosted: Wed 11 Sep 2013, 05:40    Post subject:  gtkdialog problem with filenames w brackets ( ) .. SOLVED
Subject description: how to solve? ... solved.
 

In gtkdialog GUIs, when I use a file called (for example) /root/File (blah).avi, then the brackets mess up gtkdialog, and the filenames are lost in the entry widgets of the GUI...

How do I solve this?

...I know I could do it myself, but I also know someone else double-fixed this in their own apps, but can't remember who..

While I am on the case, are there any other chars that mess up gtkdialog?

And.. Could we come up with a nice little func we could all use in our apps to get round this?

_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search

Last edited by sc0ttman on Mon 16 Sep 2013, 03:48; edited 1 time in total
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Wed 11 Sep 2013, 09:35    Post subject:  

Question
Code:
#! /bin/bash

ME=`readlink -f "$0"`
cd "${ME%/*}"
pwd

MUSINAME=`ls -1 *.avi | head -n1`
echo "$MUSINAME"

export MAIN_DIALOG="

<vbox>
  <frame Simple>
    <hbox>
      <entry>
        <variable>FILE</variable>
        <default>\"$MUSINAME\"</default>
      </entry>
      <button>
        <input file stock=\"gtk-open\"></input>
        <variable>FILE_BROWSE</variable>
        <action type=\"fileselect\">FILE</action>
      </button>
    </hbox>
  </frame>

altered /usr/share/doc/gtkdialog3/examples/16.00-fileselect with <default> tag and changed ' to " :
filenameswithspechialcharsworksforme.jpg
 Description   
 Filesize   115.66 KB
 Viewed   230 Time(s)

filenameswithspechialcharsworksforme.jpg

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


Joined: 05 Sep 2006
Posts: 9126
Location: Stratford, Ontario

PostPosted: Wed 11 Sep 2013, 11:17    Post subject:  

@sc0ttman: Is your problem with the brackets or the embedded space in your example /root/File (blah).avi?

Like Karl, I don't see a problem with brackets.
Back to top
View user's profile Send private message 
sc0ttman


Joined: 16 Sep 2009
Posts: 2376
Location: UK

PostPosted: Thu 12 Sep 2013, 18:15    Post subject:  

rcrsn51 wrote:
@sc0ttman: Is your problem with the brackets or the embedded space in your example /root/File (blah).avi?

Like Karl, I don't see a problem with brackets.

It's the brackets.. Using VLC-GTK will show what I mean...

Code:
# vlc-gtk
# sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `echo /mnt/sde1/Audio/BBC/Alan Partridge/Knowing Me, Knowing You/Knowing Knowing Me, Knowing You (Special Documentary.)mp3'


the config file, FILE causes it..
Code:
#VLC-GTK config file
#gui options
FILE="/mnt/sde1/Audio/BBC/Alan Partridge/Knowing Me, Knowing You/Knowing Knowing Me, Knowing You (Special Documentary).mp3"


It can be solved by escaping the brackets:
Code:
#VLC-GTK config file
#gui options
FILE="/mnt/sde1/Audio/BBC/Alan Partridge/Knowing Me, Knowing You/Knowing Knowing Me, Knowing You \(Special Documentary\).mp3"


The following chars also need to be escaped with a backslash ( ) < > & " ' ..
Code:
#VLC-GTK config file
#gui options
FILE="/mnt/sde1/Audio/BBC/Alan Partridge/Knowing Me, Knowing You/Knowing Knowing Me, Knowing You !£$%^\&*-=_+\({}~@:?\>\<\)Special Documentary.mp3"


EDIT: Even better, as per the example Rolling Eyes , forget the backslashes and change

Code:
      <entry>
         <variable>FILE</variable>
         <input>echo '${FILE}'</input>
         <action>enable:FILE_BTN</action>
      </entry>
to

Code:
      <entry>
         <variable>FILE</variable>
         <input>echo "'${FILE}'"</input>
         <action>enable:FILE_BTN</action>
      </entry>


(added double quotes around echo '${FILE}')

_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3289
Location: Ontario

PostPosted: Thu 12 Sep 2013, 19:03    Post subject:  

'ffmpeg' is another application that doesn't like special characters in
filenames.

_______________________________________
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Fri 13 Sep 2013, 06:43    Post subject:  

<default>\"$MUSINAME\"</default>

is the default coding style in Puppy gtkdialog , not something like

<default>'"$MUSINAME"'</default>
Back to top
View user's profile Send private message Visit poster's website 
sc0ttman


Joined: 16 Sep 2009
Posts: 2376
Location: UK

PostPosted: Fri 13 Sep 2013, 10:36    Post subject:  

Karl Godt wrote:
<default>\"$MUSINAME\"</default>

is the default coding style in Puppy gtkdialog , not something like

<default>'"$MUSINAME"'</default>

...depends whether you got your gui string in double or single quotes..

_________________
Akita Linux, VLC-GTK, Pup Search, Pup File Search
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [7 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.0676s ][ Queries: 12 (0.0041s) ][ GZIP on ]