GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun May 19, 2013 11:49 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Filechooser on windows GTK
PostPosted: Tue Jan 13, 2009 3:15 am 
Offline
Familiar Face

Joined: Mon Jan 12, 2009 1:09 am
Posts: 7
Hi I'm developing gtk+ on windows platform and i got a weird output of filechooser on a window I am wondering if it's a bug or maybe i did something wrong here is the code and tested it on linux its working just fine but when i used it on vc++ 2008 the weird problem occur the black line when there is a declaration of filter but when i remove it it work's fine

Image

here is a part of the code:
Quote:
GtkFileFilter *f;
GtkWidget *dialog;

dialogmap = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_widget_set_size_request(GTK_WIDGET(dialogmap), 600, 400);
gtk_widget_queue_draw(GTK_WIDGET(dialogmap));

if(strcmp(recording_list.rec_path, ".") == 0)
#if WIN32
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialogmap), "C:\\");
#else
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialogmap), "/home/");
#endif
else
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialogmap), recording_list.rec_path);

f = gtk_file_filter_new();
gtk_file_filter_set_name(GTK_FILE_FILTER(f), "LAS Files");
gtk_file_filter_add_pattern(GTK_FILE_FILTER(f), "*.las");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialogmap), f);


and to show it i usedgtk_widget_show() for each widget rather than using gtk_widget_show_all(). [/quote]

i will be including the image to the next post


Top
 Profile  
 
 Post subject: Re: Filechooser on windows GTK
PostPosted: Tue Jan 13, 2009 2:06 pm 
Offline
GTK+ Geek

Joined: Wed Dec 19, 2007 9:15 pm
Posts: 61
Location: Glasgow, Scotland
spynx wrote:
Code:
GtkFileFilter *f;
GtkWidget *dialog;

dialogmap = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_widget_set_size_request(GTK_WIDGET(dialogmap), 600, 400);
gtk_widget_queue_draw(GTK_WIDGET(dialogmap));

if(strcmp(recording_list.rec_path, ".") == 0)
   #if WIN32
         gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialogmap), "C:\");
   #else
         gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialogmap), "/home/");
   #endif
else
   gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialogmap), recording_list.rec_path);

f = gtk_file_filter_new();
gtk_file_filter_set_name(GTK_FILE_FILTER(f), "LAS Files");
gtk_file_filter_add_pattern(GTK_FILE_FILTER(f), "*.las");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialogmap), f);


and to show it i usedgtk_widget_show() for each widget rather than using gtk_widget_show_all().


A few comments:
    Don't call gtk_widget_set_size_request unless you have a good reason to.
    Don't call gtk_widget_queue_draw.
    Use g_get_home_dir to set the default directory.
    There's no need to cast things if they already the right type (GtkFIleFilter in this case).
    Don't call gtk_widget_show on every widget individually, it's pointless compared to gtk_widget_show_all.

Code:
GtkFileFilter *filter;
GtkWidget *dialog;

dialogmap = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialogmap), g_get_home_dir);

f = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, "LAS Files");
gtk_file_filter_add_pattern (filter, "*.las");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialogmap), filter);

_________________
Jabber – bcowan [at] fastmail.co.uk.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group