LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-13-2006, 03:25 PM   #1
EnigmaX
Member
 
Registered: Jul 2003
Distribution: Fedora Core 4
Posts: 107

Rep: Reputation: 15
GTK File Selection Question


I'm having difficulty getting a File Selection box to work the way I'd like it to.

Everything works but one thing. I can select a folder with it, and then click open at the bottom, and it will close and return the folder as the filename. I don't want that. I need it to only select files. Heres the creation function.

OpenDiag = gtk_file_chooser_dialog_new (("Open"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, NULL);

Thanks in advance =)
 
Old 02-13-2006, 10:53 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
I don't thnk there's any way to do it...

In Java, the Swing JFileChooser() will let you filter which files or file types can be selected.

The GtkfileSelection widget, AFAIK, isn't that flexible. Sorry!
 
Old 02-13-2006, 11:00 PM   #3
EnigmaX
Member
 
Registered: Jul 2003
Distribution: Fedora Core 4
Posts: 107

Original Poster
Rep: Reputation: 15
It is; Theres filters.
But I doubt that has much to do with this.
I checked, and there is a C program that does this exact thing called GAIM. If no one answers, I'll have a lot of code digging to do I bet, but I'd like it if someone knows the answer ^_^
 
Old 02-14-2006, 12:02 AM   #4
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

Interesting - I'd never *heard* of GtkFileSelection filters before. but I fired up "devhelp", searched for "filter" ... and, sure enough! There it was.

ANYWAY ....

It looks like all you need to do is:
Code:
static int myfilter_proc(const GtkFileFilterInfo *filter_info, gpointer data) { ... }
...
  myfilter = gtk_file_filter_new();
  gtk_file_filter_set_name(mfilter, "some name");
  gtk_file_filter_add_custom(myfilter, MYFLAGS, myfilter_proc, ...);
  gtk_file_chooser_add_filter(filesel1, myfilter);
  gtk_file_chooser_set_filter(filesel1, myfilter);
Please look here:
http://cvs.sourceforge.net/viewcvs.p...le.c?rev=1.210

Search for:

gtk_file_filter_add_custom
... and ...
sound_files_only_filter

Thanx - I just learned something useful!

Sincerely .. PSM
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GTK Getting Filename From A File Selection Button HELP animehair Linux - Software 1 02-13-2006 10:58 PM
cant find gtk-config file or gtk-devel to install happychappy Linux - Software 2 02-16-2005 12:46 AM
I miss my lovely GTK+ file selection melinda_sayang Slackware 0 07-12-2004 10:55 PM
GTK tree view/model/selection question elluva Programming 8 05-22-2004 12:19 PM
How to get Source code of Gtk File Selection Widget chaits Linux - General 0 04-14-2004 09:43 AM


All times are GMT -5. The time now is 01:35 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration