diff options
author | Monsta <[email protected]> | 2015-11-02 21:36:22 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2015-11-03 12:18:05 +0300 |
commit | 67bf7d4bd806e0c1f5ebf3bf228d9a6ba03e5ba6 (patch) | |
tree | 0ee1bce0f5141419f8adcf33f043d013c0e0ed8d /src | |
parent | e686f2cd08ce1f1657536df5016b0024cf31b18c (diff) | |
download | eom-67bf7d4bd806e0c1f5ebf3bf228d9a6ba03e5ba6.tar.bz2 eom-67bf7d4bd806e0c1f5ebf3bf228d9a6ba03e5ba6.tar.xz |
refactor draw/expose code a bit
Diffstat (limited to 'src')
-rw-r--r-- | src/eom-print-preview.c | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/src/eom-print-preview.c b/src/eom-print-preview.c index 5410ebb..f9f005f 100644 --- a/src/eom-print-preview.c +++ b/src/eom-print-preview.c @@ -469,7 +469,7 @@ static gboolean key_press_event_cb (GtkWidget *widget, GdkEventKey *event, #if GTK_CHECK_VERSION (3, 0, 0) static gboolean draw_cb (GtkDrawingArea *drawing_area, cairo_t *cr, gpointer user_data); #else -static void expose_event_cb (GtkDrawingArea *drawing_area, GdkEventExpose *eev, gpointer user_data); +static gboolean expose_event_cb (GtkDrawingArea *drawing_area, GdkEventExpose *eev, gpointer user_data); #endif static void size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data); @@ -530,13 +530,13 @@ eom_print_preview_new (void) /* update_relative_sizes (preview); */ + g_signal_connect (G_OBJECT (area), #if GTK_CHECK_VERSION (3, 0, 0) - g_signal_connect (G_OBJECT (area), "draw", - G_CALLBACK (draw_cb), preview); + "draw", G_CALLBACK (draw_cb), #else - g_signal_connect (G_OBJECT (area), "expose-event", - G_CALLBACK (expose_event_cb), preview); + "expose-event", G_CALLBACK (expose_event_cb), #endif + preview); g_signal_connect (G_OBJECT (area), "motion-notify-event", G_CALLBACK (motion_notify_event_cb), preview); @@ -556,47 +556,38 @@ eom_print_preview_new (void) return GTK_WIDGET (preview); } -#if GTK_CHECK_VERSION (3, 0, 0) static gboolean +#if GTK_CHECK_VERSION (3, 0, 0) draw_cb (GtkDrawingArea *drawing_area, - cairo_t *cr, - gpointer user_data) -{ - update_relative_sizes (EOM_PRINT_PREVIEW (user_data)); - - eom_print_preview_draw (EOM_PRINT_PREVIEW (user_data), cr); - - if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) { - fprintf (stderr, "Cairo is unhappy: %s\n", - cairo_status_to_string (cairo_status (cr))); - } - return TRUE; -} + cairo_t *cr, #else -static void expose_event_cb (GtkDrawingArea *drawing_area, GdkEventExpose *eev, +#endif gpointer user_data) { - GtkWidget *widget; - cairo_t *cr; - - widget = GTK_WIDGET (drawing_area); - update_relative_sizes (EOM_PRINT_PREVIEW (user_data)); - cr = gdk_cairo_create (gtk_widget_get_window (widget)); + +#if !GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *widget = GTK_WIDGET (drawing_area); + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#endif eom_print_preview_draw (EOM_PRINT_PREVIEW (user_data), cr); if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) { fprintf (stderr, "Cairo is unhappy: %s\n", - cairo_status_to_string (cairo_status (cr))); + cairo_status_to_string (cairo_status (cr))); } + +#if !GTK_CHECK_VERSION (3, 0, 0) cairo_destroy (cr); gdk_window_get_pointer (gtk_widget_get_window (widget), NULL, NULL, NULL); -} #endif + return TRUE; +} + /** * get_current_image_coordinates: * @preview: an #EomPrintPreview |