[Commits] [SCM] claws branch, gtk3, updated. 3.16.0-378-g6329a84

ticho at claws-mail.org ticho at claws-mail.org
Fri Oct 5 22:23:27 CEST 2018


The branch, gtk3 has been updated
       via  6329a84e1794a9ef6a138432d5e175402270af93 (commit)
      from  59b75ea19ca65bb8ab0565d5dac33d4e6ccdac1d (commit)

Summary of changes:
 src/stock_pixmap.c |  144 ++++++++++------------------------------------------
 1 file changed, 28 insertions(+), 116 deletions(-)


- Log -----------------------------------------------------------------
commit 6329a84e1794a9ef6a138432d5e175402270af93
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Oct 5 22:19:38 2018 +0200

    Fixed stock icons to have correct size instead of 0x0.
    
    Also cleaned up unused, pre-gtk3 pixmap cruft from
    stock_pixmap.c.

diff --git a/src/stock_pixmap.c b/src/stock_pixmap.c
index 1e85a6c..2ca5a43 100644
--- a/src/stock_pixmap.c
+++ b/src/stock_pixmap.c
@@ -252,10 +252,6 @@ typedef struct _OverlayData OverlayData;
 
 struct _OverlayData
 {
-	gboolean is_pixmap;
-	cairo_surface_t *base_pixmap;
-	cairo_surface_t *overlay_pixmap;
-
 	GdkPixbuf *base_pixbuf;
 	GdkPixbuf *overlay_pixbuf;
 
@@ -894,11 +890,7 @@ static gboolean do_pix_draw(GtkWidget *widget, cairo_t *cr,
 	gint left = 0;
 	gint top = 0;
 
-	if (data->is_pixmap) {
-		cm_return_val_if_fail(data->base_pixmap != NULL, FALSE);
-	} else {
-		cm_return_val_if_fail(data->base_pixbuf != NULL, FALSE);
-	}
+	cm_return_val_if_fail(data->base_pixbuf != NULL, FALSE);
 
 	if (data->highlight) {
 		MainWindow *mw = NULL;
@@ -921,15 +913,8 @@ static gboolean do_pix_draw(GtkWidget *widget, cairo_t *cr,
 		}
 	}
 
-	if (data->is_pixmap) {
-		cairo_set_source_surface(cr, data->base_pixmap, data->border_x, data->border_y);
-		cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
-		cairo_rectangle(cr, data->border_x, data->border_y, data->base_width, data->base_height);
-		cairo_fill(cr);
-	} else {
-		gdk_cairo_set_source_pixbuf(cr, data->base_pixbuf, data->border_x, data->border_y);
-		cairo_paint(cr);
-	}
+	gdk_cairo_set_source_pixbuf(cr, data->base_pixbuf, data->border_x, data->border_y);
+	cairo_paint(cr);
 
 	if (data->position != OVERLAY_NONE) {
 
@@ -980,59 +965,25 @@ static gboolean do_pix_draw(GtkWidget *widget, cairo_t *cr,
 	}
 
 	if (data->position != OVERLAY_NONE) {
-		if (data->is_pixmap) {
-			cm_return_val_if_fail(data->overlay_pixmap != NULL, FALSE);
-			cairo_set_source_surface(cr, data->overlay_pixmap, left, top);
-			cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
-			cairo_rectangle (cr, left, top, data->overlay_width, data->overlay_height);
-			cairo_fill(cr);
-		} else {
-      cm_return_val_if_fail(data->overlay_pixbuf != NULL, FALSE);
-      gdk_cairo_set_source_pixbuf(cr, data->overlay_pixbuf, left, top);
-      cairo_paint(cr);
-		}
+     cm_return_val_if_fail(data->overlay_pixbuf != NULL, FALSE);
+     gdk_cairo_set_source_pixbuf(cr, data->overlay_pixbuf, left, top);
+     cairo_paint(cr);
 	}
 
 	return TRUE;
 }
 
-#if !GTK_CHECK_VERSION(3,0,0)
-static gboolean pixmap_with_overlay_expose_event_cb(GtkWidget *widget, GdkEventExpose *expose,
-                                                   OverlayData *data)
-#else
 static gboolean pixmap_with_overlay_expose_event_cb(GtkWidget *widget, cairo_t *cr,
 						    OverlayData *data)
-#endif
 {
-#if !GTK_CHECK_VERSION(3,0,0)
-	cairo_t *cr;
-	GdkWindow *drawable = gtk_widget_get_window(widget);
-	gboolean result;
-
-	cr = gdk_cairo_create(drawable);
-	gdk_window_clear_area (drawable, expose->area.x, expose->area.y,
-                               expose->area.width, expose->area.height);
-
-	result = do_pix_draw(widget, cr, data);
-	cairo_destroy(cr);
-	return result;
-#else
 	return do_pix_draw(widget, cr, data);
-#endif
 }
 
 static void pixmap_with_overlay_destroy_cb(GtkWidget *object, OverlayData *data)
 {
-	if (data->is_pixmap) {
-		cairo_surface_destroy(data->base_pixmap);
-		if (data->position != OVERLAY_NONE) {
-			cairo_surface_destroy(data->overlay_pixmap);
-		}
-	} else {
-		g_object_unref(data->base_pixbuf);
-		if (data->position != OVERLAY_NONE) {
-			g_object_unref(data->overlay_pixbuf);
-		}
+	g_object_unref(data->base_pixbuf);
+	if (data->position != OVERLAY_NONE) {
+		g_object_unref(data->overlay_pixbuf);
 	}
 	g_free(data);
 }
@@ -1054,72 +1005,39 @@ GtkWidget *stock_pixmap_widget_with_overlay(StockPixmap icon,
 					    StockPixmap overlay, OverlayPosition pos,
 					    gint border_x, gint border_y)
 {
-	cairo_surface_t *stock_pixmap = NULL;
 	GdkPixbuf *stock_pixbuf = NULL;
 	GtkWidget *widget = NULL;
 	GtkWidget *stock_wid = NULL;
-	GtkRequisition requisition;
+	gint height, width;
 	OverlayData *data = NULL;
 
 	data = g_new0(OverlayData, 1);
 
 	stock_wid = stock_pixmap_widget(icon);
 	g_object_ref_sink(stock_wid);
-	gtk_widget_get_preferred_height(stock_wid, NULL, &requisition.height);
-	gtk_widget_get_preferred_width(stock_wid, NULL, &requisition.width);
 
-#if !GTK_CHECK_VERSION(3, 0, 0)
-	if (gtk_image_get_storage_type(GTK_IMAGE(stock_wid)) == GTK_IMAGE_PIXMAP)
-		data->is_pixmap = TRUE;
-	else
-#endif
-		data->is_pixmap = FALSE;
-
-	if (data->is_pixmap) {
-		cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(stock_wid));
-		stock_pixmap = cairo_get_target(cr);
-		cairo_surface_reference(stock_pixmap);
-		cairo_destroy(cr);
-		data->base_pixmap = stock_pixmap;
-		data->base_height = requisition.height;
-		data->base_width  = requisition.width;
-		g_object_unref(stock_wid);
-
-		if (pos == OVERLAY_NONE) {
-			data->overlay_pixmap = NULL;
-		} else {
-			stock_wid = stock_pixmap_widget(overlay);
-			cr = gdk_cairo_create(gtk_widget_get_window(stock_wid));
-			stock_pixmap = cairo_get_target(cr);
-			cairo_surface_reference(stock_pixmap);
-			cairo_destroy(cr);
-			data->overlay_pixmap = stock_pixmap;
-			data->overlay_height = requisition.height;
-			data->overlay_width  = requisition.width;
+	stock_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(stock_wid));
+	g_object_ref(stock_pixbuf);
 
-			gtk_widget_destroy(stock_wid);
-		}
-	} else {
-		data->is_pixmap = FALSE;
+	height = gdk_pixbuf_get_height(stock_pixbuf);
+	width = gdk_pixbuf_get_width(stock_pixbuf);
+
+	data->base_pixbuf = stock_pixbuf;
+	data->base_height = height;
+	data->base_width  = width;
+	g_object_unref(stock_wid);
+
+	if (pos != OVERLAY_NONE) {
+		stock_wid = stock_pixmap_widget(overlay);
 		stock_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(stock_wid));
 		g_object_ref(stock_pixbuf);
-		data->base_pixbuf = stock_pixbuf;
-		data->base_height = requisition.height;
-		data->base_width  = requisition.width;
-		g_object_unref(stock_wid);
-		if (pos == OVERLAY_NONE) {
-			data->overlay_pixmap = NULL;
-		} else {
-			stock_wid = stock_pixmap_widget(overlay);
-			stock_pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(stock_wid));
-			g_object_ref(stock_pixbuf);
-			data->overlay_pixbuf = stock_pixbuf;
-			data->overlay_height = requisition.height;
-			data->overlay_width  = requisition.width;
-
-			gtk_widget_destroy(stock_wid);
-		}
+		data->overlay_pixbuf = stock_pixbuf;
+		data->overlay_height = height;
+		data->overlay_width  = width;
+
+		gtk_widget_destroy(stock_wid);
 	}
+
 	data->position = pos;
 	data->border_x = border_x;
 	data->border_y = border_y;
@@ -1128,16 +1046,10 @@ GtkWidget *stock_pixmap_widget_with_overlay(StockPixmap icon,
 	widget = gtk_drawing_area_new();
 	gtk_widget_set_size_request(widget, data->base_width + border_x * 2,
 			      data->base_height + border_y * 2);
-#if !GTK_CHECK_VERSION(3, 0, 0)
-	g_signal_connect(G_OBJECT(widget), "expose_event",
-			 G_CALLBACK(pixmap_with_overlay_expose_event_cb), data);
-#else
 	g_signal_connect(G_OBJECT(widget), "draw",
 			 G_CALLBACK(pixmap_with_overlay_expose_event_cb), data);
-#endif
 	g_signal_connect(G_OBJECT(widget), "destroy",
 			 G_CALLBACK(pixmap_with_overlay_destroy_cb), data);
 	g_object_set_data(G_OBJECT(widget), "highlight", &(data->highlight));
 	return widget;
-
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list