GtkFileChooser preview widget



Hi

I'm trying to add a preview widget that is a drawing area for cairo to
my file chooser but have encountered a couple of problems.

I have attached a configure-event signal to the drawing-area to redraw
when the widget resizes but this is causing problems on initialisation,
I get the following error:

Gtk-WARNING **: GtkDrawingArea 0x1700340 is mapped but visible=1 child_visible=1 parent GtkBox 0x1c1eba0 
mapped=0

I believe this is coming from a call to
gtk_file_chooser_set_preview_widget_active(w, FALSE) which is required
to prevent the file chooser from displaying an empty box for the preview
widget when the file chooser first starts.

After the initial error, the file chooser behaves correctly.

Below are the configure-event and update-preview callbacks. Any idea
what I'm doing wrong?

Cheers,
Franco

static cairo_surface_t *colour_scheme_preview_surface;

static gboolean
colour_scheme_update_preview_cb(GtkWidget *widget, gpointer data) {

    gboolean preview = FALSE;

    char *filename = gtk_file_chooser_get_preview_filename(GTK_FILE_CHOOSER(widget));

    if(filename){
        if(pegasus_colour_bar_init(DS_PREVIEW, colour_scheme_preview_surface, filename)){
            preview = TRUE;
            gtk_widget_queue_draw(GTK_WIDGET(data));
        }
        free(filename);
    }

    gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(widget), preview);

    return FALSE;
}

static gboolean
colour_scheme_configure_event_cb(GtkWidget *widget, GdkEventConfigure *event, gpointer data) {

    if(colour_scheme_preview_surface) cairo_surface_destroy(colour_scheme_preview_surface);

    gint width, height;
    width = gtk_widget_get_allocated_width(widget);
    height = gtk_widget_get_allocated_height(widget);

    colour_scheme_preview_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);

    colour_scheme_update_preview_cb(GTK_WIDGET(data), widget);

    return FALSE;
}




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