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, 16:49
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
2 GTKdialog questions (answered)
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [12 Posts]  
Author Message
matiasbatero


Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Wed 28 Nov 2012, 01:38    Post subject:  2 GTKdialog questions (answered)  

Hi Everybody.
I have 2 questions about GTKDIALOG.

FIRST: I'm developing an ambitious CD/DVD burning software in bash with gtkdialog. I have interesting progress at this moment, but i need to know 2 things:

1) I have a TREE widget with items loaded by a function like this:

Code:
<tree space-fill="false" space-expand="false" headers-clickable="true">
   <label>Browser|Size</label>
   <input stock-column="index">'"cat $TEMP/list_dir.gtk"'</input>                        
   <variable>TREE</variable>
   <height>500</height>
   <action>'"next_dir"'</action>
   <action>refresh:TREE</action>
</tree>   


list_dir.gtk its a file like:
gtk-directory|Foldername|Folder|459KB|/home/downloads

But i have problems with files/folders with names containing | (the pipe symbol), because gtkdialog separate data item in columns in a wrong place.
¿It's posible to escape | symbol? ¿Ideas?
If not posible, its a limitation for my program.

2) ¿Can i start the GUI with hide widgets, avoiding use toogle buttons/radiobuttons/checkboxes?

Thanks so much for your help
PD: Sorry for my english, i speak spanish

Last edited by matiasbatero on Fri 30 Nov 2012, 14:22; edited 2 times in total
Back to top
View user's profile Send private message 
L18L

Joined: 19 Jun 2010
Posts: 2527
Location: Moved from Hosla to www.eussenheim.de

PostPosted: Wed 28 Nov 2012, 06:04    Post subject: Re: 1 GTKdialog question  

matiasbatero wrote:
... problems with files/folders with names containing | (the pipe symbol), ...

Hope this helps, a test on console wrote:
#
# ls bla*
bla|bla
#
# cat bla|bla
bash: bla: command not found
cat: bla: Datei oder Verzeichnis nicht gefunden
#
# cat "bla|bla"
Hola matiasbatero #
#

nicht gefunden is not found
I am sure you will get help for the other question, too.
Back to top
View user's profile Send private message 
matiasbatero


Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Wed 28 Nov 2012, 13:45    Post subject: Re: 1 GTKdialog question  

L18L wrote:
matiasbatero wrote:
... problems with files/folders with names containing | (the pipe symbol), ...

Hope this helps, a test on console wrote:
#
# ls bla*
bla|bla
#
# cat bla|bla
bash: bla: command not found
cat: bla: Datei oder Verzeichnis nicht gefunden
#
# cat "bla|bla"
Hola matiasbatero #
#

nicht gefunden is not found
I am sure you will get help for the other question, too.


Thanks for you answer!

Mmm, i not understand that very much.

Internally, the software have a function that: Explore a directory, then makes a list (files and folders) and exported to a "formated text file" to be readable for the input of the tree widget.

For example, if apply cat to that file:

Code:
cat "list_dir.gtk"

gtk-file|gnu.jpg|32KB|/home/user/images
gtk-file|linux.gif|12KB|/home/user/images


Then the file have 3 "|" (delimiters) for each line, and the tree widget shows a 4 columns.

1º column = Icon = (display icon)
2º column = Name file = gnu.jpg
3º column = Size file = 32KB
4º column = Path of file = /home/user/images

And it's right! this is the correct form to show the data in the widget.
Because (| symbol) is the delimiter between the data of each column.

The problem is when a filename have a "|" inside, for example:
Code:

pupp|ylinu|x.jpg


Then, the new cat "list_dir.gtk" is:
Code:

gtk-file|pupp|ylinu|x.jpg|32KB|/home/user/images


Here, you found 5 "|" (delimiters). And the final result is:

1º column = Icon = (display icon)
2º column = Name file = pupp
3º column = Size file = ylinu
4º column = Path of file = x.jpg

And it's wrong.
This problem is about | symbol in the input data for the tree widget, not for the internally function.

The question is: ¿it's posible escape the "| symbol" in the list_dir.gtk for solve this conflict?[/code]
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 3345
Location: Ontario

PostPosted: Wed 28 Nov 2012, 13:55    Post subject:  

I don't have any experience with trees but I have had some experience
printing special characters on the screen with gtkdialog.

A trick I've used is to make a variable with the special character
for example a tick symbol.

SPECIAL_CHARACTER="'"


Then I can place the special character into commands with
$SPECIAL_CHARACTER


It only works in unusual situations.

______________________________
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1078

PostPosted: Wed 28 Nov 2012, 14:46    Post subject: Re: 2 GTKdialog questions  

matiasbatero wrote:
2) ¿Can i start the GUI with hide widgets, avoiding use toogle buttons/radiobuttons/checkboxes?

If I understand correctly you want to have ability to hide/show some of widgets on demand?
Later Gtkdialog versions have <expander> widget:
https://code.google.com/p/gtkdialog/wiki/expander
http://gtkdialog.googlecode.com/svn/trunk/examples/expander/expander
But you need Gtkdialog >= 0.8.1 (or better >=0.8.2) in order to use this.

As for | as a delimiter, me personally never found a way to display it in <tree> nor <table> (but I don't claim there is no way to do so)...but on the other hand is | really so commonly used in dir/filenames..? Wink

Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Wed 28 Nov 2012, 15:41    Post subject:  

To hide a widget at startup, add the attribute visible="false".
ie. <button visible="false">
you can later toggle it with the function show:BUTTON_NAME


Sigmund

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


Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Wed 28 Nov 2012, 21:02    Post subject: Re: 2 GTKdialog questions  

SFR wrote:
matiasbatero wrote:
2) ¿Can i start the GUI with hide widgets, avoiding use toogle buttons/radiobuttons/checkboxes?

If I understand correctly you want to have ability to hide/show some of widgets on demand?
Later Gtkdialog versions have <expander> widget:
https://code.google.com/p/gtkdialog/wiki/expander
http://gtkdialog.googlecode.com/svn/trunk/examples/expander/expander
But you need Gtkdialog >= 0.8.1 (or better >=0.8.2) in order to use this.

As for | as a delimiter, me personally never found a way to display it in <tree> nor <table> (but I don't claim there is no way to do so)...but on the other hand is | really so commonly used in dir/filenames..? Wink

Greetings!


Thanks for you answer!
Yes, it's not commonly!! In a few weeks, i thought how to solve this.. and i had 3 ideas, 2 are difficult to implement, and the 3º was consider that the probabilities of find a file/folder with | symbol are less than 1% haha, so, this problem will be reported with an advertence dialog, and it will be a little limitation for my software.

regards!
Back to top
View user's profile Send private message 
matiasbatero


Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Wed 28 Nov 2012, 21:14    Post subject:  

zigbert wrote:
To hide a widget at startup, add the attribute visible="false".
ie. <button visible="false">
you can later toggle it with the function show:BUTTON_NAME


Sigmund


Thanks for the answer Sigmund.
That was my first attempt to start the gui with hide widgets, but when applied that attribute on a Button, and loaded the gui, the widget appears like "deactivated" and not hidden. I'm using gtkdialog v:0.8.2.

Regards!!
PD: Again, for all users: Sorry for my english.
Back to top
View user's profile Send private message 
zigbert


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

PostPosted: Thu 29 Nov 2012, 13:09    Post subject:  

matiasbatero wrote:
zigbert wrote:
To hide a widget at startup, add the attribute visible="false".
ie. <button visible="false">
you can later toggle it with the function show:BUTTON_NAME


Sigmund


Thanks for the answer Sigmund.
That was my first attempt to start the gui with hide widgets, but when applied that attribute on a Button, and loaded the gui, the widget appears like "deactivated" and not hidden. I'm using gtkdialog v:0.8.2.

Regards!!
PD: Again, for all users: Sorry for my english.
Please post an example script (short as possible). It is much easier for us to help you that way.


Sigmund

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


Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Thu 29 Nov 2012, 22:43    Post subject:  

zigbert wrote:
matiasbatero wrote:
zigbert wrote:
To hide a widget at startup, add the attribute visible="false".
ie. <button visible="false">
you can later toggle it with the function show:BUTTON_NAME


Sigmund


Thanks for the answer Sigmund.
That was my first attempt to start the gui with hide widgets, but when applied that attribute on a Button, and loaded the gui, the widget appears like "deactivated" and not hidden. I'm using gtkdialog v:0.8.2.

Regards!!
PD: Again, for all users: Sorry for my english.
Please post an example script (short as possible). It is much easier for us to help you that way.


Sigmund


Sigmund, i revised the code, and i saw that i put the incorrect attribute. You are right, the "visible tag" works perfectly.
What a bad luck!! I didn't realize about it!! When i saw that it doesn't work for me, i did a lot of experiments to emulate the effect using functions. haha, what a waste of time.

Thanks!

PD: For the first question.. you know how to show the "|" symbol, on tree items? Or is not possible?
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1078

PostPosted: Fri 30 Nov 2012, 08:12    Post subject:  

matiasbatero wrote:
PD: For the first question.. you know how to show the "|" symbol, on tree items? Or is not possible?

I found a kind of workaround for this.
Actually I used quite similar trick to display one or two problematic characters in my UniMap and forgot about this...

But two conditions must be fulfilled:
1. You must have access to each column's data separately, before displaying (to not replace the "needed" | by accident).
2. Unicode support must be present (this may be another limitation).

Everything is based on a lie:
| looks practically the same as ∣ ...isn't it?
But the second one is not Vertical Line, but Divides.

It's enough to replace all | occurrences with ∣ in a given string, concatenate all columns and display it in <tree>.
Then if user will press such a record, appropriate function can replace all ∣ with | back again, to avoid problems with accessing such a file/folder.

But again we have to consider that probability of ∣ (Divides) in dir/filenames is small enough...well, nothing's perfect. Wink
Maybe someone else will figure out a better way...

Here's working example:
Code:
#!/bin/bash

TEMPFILE=/tmp/temp_file_$$
SUBSTITUTE="`echo -e '\x00\xe2\x88\xa3'`"   # Divides (U+2223)

COLUMN1="A st|ring wi|th a few | in|side."
COLUMN2="Something else"


# Convert all "Vertical Line" symbols in COLUMN1 to "Divides" symbols
COLUMN1="${COLUMN1//|/$SUBSTITUTE}"

# Concatenate columns
echo "$COLUMN1""|""$COLUMN2" > $TEMPFILE


export MAIN='
<window width-request="400">
    <tree>
      <label>First column|Second column</label>
      <input>cat "'$TEMPFILE'"</input>
    </tree>
</window>
'

gtkdialog -p MAIN


Greetings!

_________________
[O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Back to top
View user's profile Send private message 
matiasbatero


Joined: 11 Oct 2012
Posts: 60
Location: Mar del Plata, Argentina

PostPosted: Fri 30 Nov 2012, 14:21    Post subject:  

SFR wrote:
matiasbatero wrote:
PD: For the first question.. you know how to show the "|" symbol, on tree items? Or is not possible?

I found a kind of workaround for this.
Actually I used quite similar trick to display one or two problematic characters in my UniMap and forgot about this...

But two conditions must be fulfilled:
1. You must have access to each column's data separately, before displaying (to not replace the "needed" | by accident).
2. Unicode support must be present (this may be another limitation).

Everything is based on a lie:
| looks practically the same as ∣ ...isn't it?
But the second one is not Vertical Line, but Divides.

It's enough to replace all | occurrences with ∣ in a given string, concatenate all columns and display it in <tree>.
Then if user will press such a record, appropriate function can replace all ∣ with | back again, to avoid problems with accessing such a file/folder.

But again we have to consider that probability of ∣ (Divides) in dir/filenames is small enough...well, nothing's perfect. Wink
Maybe someone else will figure out a better way...

Here's working example:
Code:
#!/bin/bash

TEMPFILE=/tmp/temp_file_$$
SUBSTITUTE="`echo -e '\x00\xe2\x88\xa3'`"   # Divides (U+2223)

COLUMN1="A st|ring wi|th a few | in|side."
COLUMN2="Something else"


# Convert all "Vertical Line" symbols in COLUMN1 to "Divides" symbols
COLUMN1="${COLUMN1//|/$SUBSTITUTE}"

# Concatenate columns
echo "$COLUMN1""|""$COLUMN2" > $TEMPFILE


export MAIN='
<window width-request="400">
    <tree>
      <label>First column|Second column</label>
      <input>cat "'$TEMPFILE'"</input>
    </tree>
</window>
'

gtkdialog -p MAIN


Greetings!


Hi SFR!!
I think that it's a very good solution!!! Really good!!
Yes, it's a ficticius-character! Excellent! I will do some experiments.
The first condition "access to each column's data separately" it is the base of my program.
All tree widget lists were built concatenating data columns.

For files, i will put a replacement function before the concatenation and after clicking the item tree.
The folders works different in the software, but, the double replacement for files, gives a permanent correct path.
Because, in the software, i always have a .txt with the correct path.
But, the last part it's floating. Ex: /home/user/documents/image.jpg
only "image.jpg" it's changed with the new value for each navigation. So, the double replacement for files "should be compatible" for folders too.

The topic it's solved. That example, shows that work perfectly. The rest is build the appropiate functions.

Thanks you very much for you answer!! Very usefull.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [12 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.1344s ][ Queries: 11 (0.0093s) ][ GZIP on ]