Re: [gnome-love] New file selector?



El mar, 16-11-2004 a las 04:01, Jeramy Rutley escribió:
Hi,

Does anyone know of any documents on the web that show how to convert
programs to the new gtk+ file selectors?


This is from source code of Ghasher, it uses new file selector if gtk is
= than 2.4 instead uses old file selector, good for people still using
gtk 2.2:

        /* Create the selector , use the new gtkfilechooser if gtk >= 2.4.0*/
   
#if GTK_CHECK_VERSION(2,4,0)
        file_selector = gtk_file_chooser_dialog_new ("Select a file to digest. 
",GTK_WINDOW(app->window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_OPEN, GTK_RESPONSE_OK,GTK_STOCK_CANCEL, 
GTK_RESPONSE_CANCEL,NULL);
        if(g_path_is_absolute(filename)){ //seems to go mickey if not an absolute path
                gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file_selector),filename); 
        }
         gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(file_selector),TRUE); //we only handle kernel 
filesystems
#else

        file_selector = gtk_file_selection_new ("Select a file to digest.");
        gtk_window_set_transient_for(GTK_WINDOW(file_selector),GTK_WINDOW(app->window)); 
        gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_selector),filename);
#endif
   
        ret = gtk_dialog_run (GTK_DIALOG(file_selector));
        if(ret ==  GTK_RESPONSE_OK){
#if GTK_CHECK_VERSION(2,4,0)
                
gtk_entry_set_text(GTK_ENTRY(app->fileentry),gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_selector)));
#else
                
gtk_entry_set_text(GTK_ENTRY(app->fileentry),gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_selector)));
#endif
                gtk_entry_set_text(GTK_ENTRY(app->sumentry),""); //reset previous digest
        }

        gtk_widget_destroy(file_selector);
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]