gtkdialog problem with filenames w brackets ( ) .. SOLVED

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

gtkdialog problem with filenames w brackets ( ) .. SOLVED

#1 Post by sc0ttman »

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?
Last edited by sc0ttman on Mon 16 Sep 2013, 07:48, edited 1 time in total.
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#2 Post by Karl Godt »

:?:

Code: Select all

#! /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 " :
Attachments
filenameswithspechialcharsworksforme.jpg
(115.66 KiB) Downloaded 1434 times

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#3 Post by rcrsn51 »

@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.

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#4 Post by sc0ttman »

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: Select all

# 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: Select all

#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: Select all

#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: Select all

#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 :roll: , forget the backslashes and change

Code: Select all

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

Code: Select all

		<entry>
			<variable>FILE</variable>
			<input>echo "'${FILE}'"</input>
			<action>enable:FILE_BTN</action>
		</entry>
(added double quotes around echo '${FILE}')
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#5 Post by don570 »

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

_______________________________________

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#6 Post by Karl Godt »

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

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

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

User avatar
sc0ttman
Posts: 2812
Joined: Wed 16 Sep 2009, 05:44
Location: UK

#7 Post by sc0ttman »

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..
[b][url=https://bit.ly/2KjtxoD]Pkg[/url], [url=https://bit.ly/2U6dzxV]mdsh[/url], [url=https://bit.ly/2G49OE8]Woofy[/url], [url=http://goo.gl/bzBU1]Akita[/url], [url=http://goo.gl/SO5ug]VLC-GTK[/url], [url=https://tiny.cc/c2hnfz]Search[/url][/b]

Post Reply