On Tue, 13 Sep 2011, Bernhard Schuster wrote:

Can you supply a minimal example where it fails? That would help to
find the culprit. I am atm at gtk 2.24.6 so if you can post that I
give it a run...

Thanks! I'm attaching a minimal case.

Allin Cottrell
/* Test program for adding multiple filters to a gtk file
   chooser dialog. I's seeing the combo that holds the
   filter names come out too narrow, so that the
   names are not leglible.

   Allin Cottrell, 2011-09-13
*/

#include <gtk/gtk.h>

static void filesel_add_filter (GtkWidget *dialog,
                                const char *name, 
                                const char *pattern)
{
    GtkFileFilter *filter = gtk_file_filter_new();

    gtk_file_filter_set_name(filter, name);
    gtk_file_filter_add_pattern(filter, pattern);
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
}

static void filesel (GtkWidget *button, gpointer data)
{
    GtkWidget *parent = data;
    GtkWidget *dialog;

    dialog = gtk_file_chooser_dialog_new(NULL, GTK_WINDOW(parent), 
                                         GTK_FILE_CHOOSER_ACTION_OPEN,
                                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                         GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
                                         NULL);

    filesel_add_filter(dialog, "CSV files (*.csv)", "*.csv");
    filesel_add_filter(dialog, "Text files (*.txt)", "*.txt");
    filesel_add_filter(dialog, "All files (*.*)", "*");

    gtk_dialog_run(GTK_DIALOG(dialog));
    gtk_widget_destroy(dialog);
}

int main (int argc, char *argv[])
{
    GtkWidget *w, *button;

    gtk_init(&argc, &argv);

    w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(w), "destroy",
                     G_CALLBACK(gtk_main_quit), NULL);

    button = gtk_button_new_from_stock(GTK_STOCK_OK);
    g_signal_connect(G_OBJECT(button), "clicked", 
                     G_CALLBACK(filesel), w);
    gtk_container_add(GTK_CONTAINER(w), button);

    gtk_widget_show_all(w);

    gtk_main();

    return 0;
}
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to