GtkDialog File Selector Question

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
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

GtkDialog File Selector Question

#1 Post by RSH »

Hi.

How do I define a GtkDialog File Selector to let the user select multiple files.

Code used is:

Code: Select all

		<entry fs-title="'$FSDIRTITLE'">
			<default>'$IMGINDIR'</default>
			<variable>IMGINDIR</variable>
		</entry>
		<button tooltip-text="Click to select image directory">
			<input file stock="gtk-open"></input>
			<action type="fileselect">IMGINDIR</action>
		</button>
Thanks,

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post by amigo »

I believe the underlying gtk widget will only work for a single selection.

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#3 Post by zigbert »

I don't know the exact answer, but I have solved this in pBurn by building my own file-selector in the main gui.

The code is in /usr/local/pburn/func_gui (from line 260)


Sigmund

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#4 Post by mikeb »

yad file selector has the option for multiple file selection..you might want to check that out

mike

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#5 Post by RSH »

amigo wrote:I believe the underlying gtk widget will only work for a single selection.
Yes, I feared this already. Thanks.

Might be some work to do for the gtkdialog developers?
zigbert wrote:I don't know the exact answer, but I have solved this in pBurn by building my own file-selector in the main gui.

The code is in /usr/local/pburn/func_gui (from line 260)
This sounds great. Thanks!

Hopefully I'll be able to read and understand your program's code. :lol:
mikeb wrote:yad file selector has the option for multiple file selection..you might want to check that out
Also thank you. The yad option is already running and working. Just want to try to get off the yad dependency.

RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
zigbert
Posts: 6621
Joined: Wed 29 Mar 2006, 18:13
Location: Valåmoen, Norway
Contact:

#6 Post by zigbert »

Hopefully I'll be able to read and understand your program's code.
If any trouble, please ask.

simargl7

#7 Post by simargl7 »

maybe rewriting your program in Vala

8)

http://valadoc.org/#!api=gtk+-3.0/Gtk.FileChooserDialog

Code: Select all

		// The FileChooserDialog:
		Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog (
				"Select your favorite file", this, Gtk.FileChooserAction.OPEN,
				"_Cancel",
				Gtk.ResponseType.CANCEL,
				"_Open",
				Gtk.ResponseType.ACCEPT);

		// Multiple files can be selected:
		chooser.select_multiple = true;

User avatar
matiasbatero
Posts: 60
Joined: Fri 12 Oct 2012, 01:27
Location: Mar del Plata, Argentina

#8 Post by matiasbatero »

For i know, there is no way to do a multiple selection with built-in gtkdialog widgets. You have 2 solutions:

1) Build your own filebrowser using gtkdialog-tree (allows multiple selection) and passing arguments to buttons actions. The filebrowser can be so complex that you want. For example, i built one that draw 5 columns:
Specific-icon column (capturing file extension)
Name, Path, Size, Modified Date, filetype-mime

a) Folder/icon distintions browser can be performed using (while/read) (you can watch zigbert's lightweight approach). It's very clear code and very efficient. Here while/read works good.

b) I like the Specific-icon column, because is more similar that "chooser native dialog" .. and for stetic purposes!, but requires a correct implementation to run fast. It consists on: Export (ls) raw list by columns. Each column = one file. Then each files can be passed like argument to bash filter functions and concatenated in only a unique file with tree input format. This is my implementation. I have a program with +200 diferent filetype assignation and works like speed of light.

2) You can use mixed solution with Zenity or Yad.
You can draw a <button> that launch ( yad --file ) and then redirect output to the widget. Using file, and timer, or custom bash function.

3) You can build a Python script with pygtk, calling a chooser dialog, and passing+parsing values for gtkdialog widgets. Or using Vala, Perl, C++ to draw the widget.

4) If you use GTK2, you have gtk-server to do this implementation natively

Post Reply