From db1705669d63a7d688e1e6507509906c9fc9d668 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Mon, 3 Apr 2017 16:13:44 +0200 Subject: matekbd-indicator: don't use deprecated gdk_cairo_create Expose event is changed to draw partial taken from: https://git.gnome.org/browse/libgnomekbd/commit/?id=16c6c2b --- libmatekbd/matekbd-indicator.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'libmatekbd') diff --git a/libmatekbd/matekbd-indicator.c b/libmatekbd/matekbd-indicator.c index 0273c77..40bee1e 100644 --- a/libmatekbd/matekbd-indicator.c +++ b/libmatekbd/matekbd-indicator.c @@ -251,35 +251,28 @@ matekbd_indicator_button_pressed (GtkWidget * } static void -flag_exposed (GtkWidget * flag, GdkEventExpose * event, GdkPixbuf * image) +draw_flag (GtkWidget * flag, cairo_t * cr, GdkPixbuf * image) { /* Image width and height */ int iw = gdk_pixbuf_get_width (image); int ih = gdk_pixbuf_get_height (image); GtkAllocation allocation; double xwiratio, ywiratio, wiratio; - cairo_t *cr; gtk_widget_get_allocation (flag, &allocation); - cr = gdk_cairo_create (event->window); - gdk_cairo_region (cr, event->region); - cairo_clip (cr); - /* widget-to-image scales, X and Y */ xwiratio = 1.0 * allocation.width / iw; ywiratio = 1.0 * allocation.height / ih; wiratio = xwiratio < ywiratio ? xwiratio : ywiratio; - /* transform cairo context */ - cairo_translate (cr, allocation.width / 2.0, allocation.height / 2.0); - cairo_scale (cr, wiratio, wiratio); - cairo_translate (cr, - iw / 2.0, - ih / 2.0); - - gdk_cairo_set_source_pixbuf (cr, image, 0, 0); - cairo_paint (cr); + /* transform cairo context */ + cairo_translate (cr, allocation.width / 2.0, allocation.height / 2.0); + cairo_scale (cr, wiratio, wiratio); + cairo_translate (cr, - iw / 2.0, - ih / 2.0); - cairo_destroy (cr); + gdk_cairo_set_source_pixbuf (cr, image, 0, 0); + cairo_paint (cr); } gchar * @@ -382,8 +375,8 @@ matekbd_indicator_prepare_drawing (MatekbdIndicator * gki, int group) flag = gtk_drawing_area_new (); gtk_widget_add_events (GTK_WIDGET (flag), GDK_BUTTON_PRESS_MASK); - g_signal_connect (G_OBJECT (flag), "expose_event", - G_CALLBACK (flag_exposed), image); + g_signal_connect (G_OBJECT (flag), "draw", + G_CALLBACK (draw_flag), image); gtk_container_add (GTK_CONTAINER (ebox), flag); } else { char *lbl_title = NULL; -- cgit v1.2.1