GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Displaying only certain files with a listView

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
hungerfish



Joined: 20 Apr 2007
Posts: 4

PostPosted: Sun Jul 15, 2007 1:30 am    Post subject: Displaying only certain files with a listView Reply with quote

Hello,
I'm writing an app. in which I want to display the contents of a folder (selected via filechooserdiag) in a listView. However I only want 'certain' filetypes to be displayed.
Now while I can do this using standard c-functions to analyise the filename and select only those files with the correct type(ending), I wonder if there is a way of doing this through GTK or GDK?

Also, on a side note, how can I include subfolders when 'opening' a directory with ' g_dir_open' & 'g_dir_read_name'?

ThanX
Back to top
openldev
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 386
Location: Fairfax, Virginia

PostPosted: Sun Jul 15, 2007 5:29 pm    Post subject: Reply with quote

To display sub folders, you need to use g_file_test() to check whether the current file is a file or folder. Create a recursive parsing function.

As for file types, GVFS is coming in the next few releases of GLib, which checks mime types. For now, you can either check the file extension by searching the filename string, or using GnomeVFS.
Back to top
hungerfish



Joined: 20 Apr 2007
Posts: 4

PostPosted: Sun Jul 15, 2007 11:29 pm    Post subject: Reply with quote

Thank you for your help. I'll look into using GnomeVFS, however I want to keep dependencies low, so I'll probably stick with checking strings.

Quote:
To display sub folders, you need to use g_file_test() to check whether the current file is a file or folder.


How obvious, now why didn't I realise this... :oops:
Back to top
forward83



Joined: 09 Mar 2008
Posts: 2

PostPosted: Sun Mar 09, 2008 4:44 pm    Post subject: Reply with quote

Hi, I'm looking to implement something similar but is a total noob.
Do you have some code/sample to share? Thanks.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP