diff options
author | Stefano Karapetsas <[email protected]> | 2014-04-30 23:25:08 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2014-04-30 23:25:08 +0200 |
commit | dca996e31089ce5b5d8acbe8a2fb735aaf18542f (patch) | |
tree | 5c6236d18b60eacdbe9658c87ec647b41f3510db /mate-screenshot/screenshot-dialog.c | |
parent | 36c964e0a6d1deaee624cd2a6a76ff5c73141865 (diff) | |
download | mate-utils-dca996e31089ce5b5d8acbe8a2fb735aaf18542f.tar.bz2 mate-utils-dca996e31089ce5b5d8acbe8a2fb735aaf18542f.tar.xz |
mate-screenshot: Add GTK3 support
Diffstat (limited to 'mate-screenshot/screenshot-dialog.c')
-rw-r--r-- | mate-screenshot/screenshot-dialog.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/mate-screenshot/screenshot-dialog.c b/mate-screenshot/screenshot-dialog.c index b5b2be56..e3a9b923 100644 --- a/mate-screenshot/screenshot-dialog.c +++ b/mate-screenshot/screenshot-dialog.c @@ -55,7 +55,7 @@ static gboolean on_toplevel_key_press_event (GtkWidget *widget, GdkEventKey *key) { - if (key->keyval == GDK_F1) + if (key->keyval == GDK_KEY_F1) { gtk_dialog_response (GTK_DIALOG (widget), GTK_RESPONSE_HELP); return TRUE; @@ -65,14 +65,18 @@ on_toplevel_key_press_event (GtkWidget *widget, } static void -on_preview_expose_event (GtkWidget *drawing_area, - GdkEventExpose *event, - gpointer data) +#if GTK_CHECK_VERSION (3, 0, 0) +on_preview_draw (GtkWidget *drawing_area, cairo_t *cr, gpointer data) +#else +on_preview_expose_event (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data) +#endif { ScreenshotDialog *dialog = data; GdkPixbuf *pixbuf = NULL; gboolean free_pixbuf = FALSE; +#if !GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr; +#endif /* Stolen from GtkImage. I really should just make the drawing area an * image some day */ @@ -85,7 +89,7 @@ on_preview_expose_event (GtkWidget *drawing_area, gtk_icon_source_set_size (source, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_icon_source_set_size_wildcarded (source, FALSE); - pixbuf = gtk_style_render_icon (drawing_area->style, + pixbuf = gtk_style_render_icon (gtk_widget_get_style (drawing_area), source, gtk_widget_get_direction (drawing_area), gtk_widget_get_state (drawing_area), @@ -100,14 +104,18 @@ on_preview_expose_event (GtkWidget *drawing_area, pixbuf = g_object_ref (dialog->preview_image); } - cr = gdk_cairo_create (drawing_area->window); +#if !GTK_CHECK_VERSION (3, 0, 0) + cr = gdk_cairo_create (gtk_widget_get_window (drawing_area)); gdk_cairo_region (cr, event->region); cairo_clip (cr); +#endif gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); cairo_paint (cr); +#if !GTK_CHECK_VERSION (3, 0, 0) cairo_destroy (cr); +#endif g_object_unref (pixbuf); } @@ -268,7 +276,11 @@ screenshot_dialog_new (GdkPixbuf *screenshot, (gfloat) gdk_pixbuf_get_height (screenshot), FALSE); g_signal_connect (toplevel, "key_press_event", G_CALLBACK (on_toplevel_key_press_event), dialog); +#if GTK_CHECK_VERSION (3, 0, 0) + g_signal_connect (preview_darea, "draw", G_CALLBACK (on_preview_draw), dialog); +#else g_signal_connect (preview_darea, "expose_event", G_CALLBACK (on_preview_expose_event), dialog); +#endif g_signal_connect (preview_darea, "button_press_event", G_CALLBACK (on_preview_button_press_event), dialog); g_signal_connect (preview_darea, "button_release_event", G_CALLBACK (on_preview_button_release_event), dialog); g_signal_connect (preview_darea, "configure_event", G_CALLBACK (on_preview_configure_event), dialog); @@ -388,12 +400,12 @@ screenshot_dialog_set_busy (ScreenshotDialog *dialog, GdkCursor *cursor; /* Change cursor to busy */ cursor = gdk_cursor_new (GDK_WATCH); - gdk_window_set_cursor (toplevel->window, cursor); + gdk_window_set_cursor (gtk_widget_get_window (toplevel), cursor); gdk_cursor_unref (cursor); } else { - gdk_window_set_cursor (toplevel->window, NULL); + gdk_window_set_cursor (gtk_widget_get_window (toplevel), NULL); } gtk_widget_set_sensitive (toplevel, ! busy); |