From f0bcfaeca30ae5a7992007bbc47406144851cf26 Mon Sep 17 00:00:00 2001 From: infirit Date: Mon, 27 Jul 2015 23:17:39 +0200 Subject: standard: Move the draw and expose-event handling from paint_window No functional change but this makes the code a bit cleaner and easier to read. --- src/themes/standard/theme.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'src/themes/standard') diff --git a/src/themes/standard/theme.c b/src/themes/standard/theme.c index a61a0d9..b91fe3e 100644 --- a/src/themes/standard/theme.c +++ b/src/themes/standard/theme.c @@ -474,18 +474,14 @@ static void draw_border(GtkWidget* widget, WindowData *windata, cairo_t* cr) cairo_stroke(cr); } -#if GTK_CHECK_VERSION(3, 0, 0) -static gboolean paint_window(GtkWidget* widget, cairo_t* cr, WindowData* windata) -#else -static gboolean paint_window(GtkWidget* widget, GdkEventExpose* event, WindowData* windata) -#endif +static void +paint_window (GtkWidget *widget, + cairo_t *cr, + WindowData *windata) { cairo_t* cr2; cairo_surface_t* surface; GtkAllocation allocation; -#if !GTK_CHECK_VERSION(3, 0, 0) - cairo_t* cr = gdk_cairo_create (event->window); -#endif gtk_widget_get_allocation(windata->win, &allocation); @@ -515,12 +511,28 @@ static gboolean paint_window(GtkWidget* widget, GdkEventExpose* event, WindowDat cairo_set_source_surface (cr, surface, 0, 0); cairo_paint(cr); cairo_surface_destroy(surface); +} + +static gboolean +#if GTK_CHECK_VERSION (3, 0, 0) +on_draw (GtkWidget *widget, cairo_t *cr, WindowData *windata) +{ + paint_window (widget, cr, windata); + + return FALSE; +} +#else +on_expose_event (GtkWidget *widget, GdkEventExpose *event, WindowData *windata) +{ + cairo_t *cr = gdk_cairo_create (event->window); + + paint_window (widget, cr, windata); + + cairo_destroy (cr); -#if !GTK_CHECK_VERSION (3, 0, 0) - cairo_destroy(cr); -#endif return FALSE; } +#endif static void destroy_windata(WindowData* windata) { @@ -675,9 +687,9 @@ GtkWindow* create_notification(UrlClickedCb url_clicked) gtk_container_set_border_width(GTK_CONTAINER(main_vbox), 1); #if GTK_CHECK_VERSION (3, 0, 0) - g_signal_connect(G_OBJECT(main_vbox), "draw", G_CALLBACK(paint_window), windata); + g_signal_connect (G_OBJECT (main_vbox), "draw", G_CALLBACK (on_draw), windata); #else - g_signal_connect(G_OBJECT(main_vbox), "expose_event", G_CALLBACK(paint_window), windata); + g_signal_connect (G_OBJECT (main_vbox), "expose_event", G_CALLBACK (on_expose_event), windata); #endif windata->top_spacer = gtk_image_new(); -- cgit v1.2.1