/pidgin/main: 53bf180b9eb1: Use GtkStyleContext instead of GtkSt...

Elliott Sales de Andrade qulogic at pidgin.im
Wed Aug 15 04:28:34 EDT 2012


Changeset: 53bf180b9eb1018c675548c06440cf36ce52470d
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2012-08-15 04:28 -0400
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/53bf180b9eb1

Description:

Use GtkStyleContext instead of GtkStyle on GTK+3.

diffstat:

 pidgin/gtkblist.c                 |  84 +++++++++++++++++++++++---------------
 pidgin/gtkcellrendererexpander.c  |  23 +++++++---
 pidgin/gtkplugin.c                |   6 +-
 pidgin/gtkroomlist.c              |  45 +++++++++++---------
 pidgin/gtkstatusbox.c             |   7 +-
 pidgin/pidginstock.c              |   7 ++-
 pidgin/pidgintooltip.c            |   8 +-
 pidgin/plugins/disco/gtkdisco.c   |   8 +--
 pidgin/plugins/ticker/gtkticker.c |  11 +++++
 9 files changed, 121 insertions(+), 78 deletions(-)

diffs (truncated from 373 to 300 lines):

diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -2965,7 +2965,11 @@ static struct tooltip_data * create_tip_
 static gboolean
 pidgin_blist_paint_tip(GtkWidget *widget, cairo_t *cr, gpointer null)
 {
+#if GTK_CHECK_VERSION(3,0,0)
+	GtkStyleContext *context;
+#else
 	GtkStyle *style;
+#endif
 	int current_height, max_width;
 	int max_text_width;
 	int max_avatar_width;
@@ -2977,7 +2981,12 @@ pidgin_blist_paint_tip(GtkWidget *widget
 	if(gtkblist->tooltipdata == NULL)
 		return FALSE;
 
+#if GTK_CHECK_VERSION(3,0,0)
+	context = gtk_widget_get_style_context(gtkblist->tipwindow);
+	gtk_style_context_add_class(context, GTK_STYLE_CLASS_TOOLTIP);
+#else
 	style = gtk_widget_get_style(gtkblist->tipwindow);
+#endif
 
 	max_text_width = 0;
 	max_avatar_width = 0;
@@ -3007,27 +3016,34 @@ pidgin_blist_paint_tip(GtkWidget *widget
 		if (td->avatar && pidgin_gdk_pixbuf_is_opaque(td->avatar))
 		{
 #if GTK_CHECK_VERSION(3,0,0)
-			if (dir == GTK_TEXT_DIR_RTL)
-				gtk_paint_flat_box(style, cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-				                   gtkblist->tipwindow, "tooltip",
+			gtk_style_context_save(context);
+			gtk_style_context_add_class(context, GTK_STYLE_CLASS_FRAME);
+			if (dir == GTK_TEXT_DIR_RTL) {
+				gtk_render_frame(context, cr,
+				                 TOOLTIP_BORDER - 1, current_height - 1,
+				                 td->avatar_width + 2, td->avatar_height + 2);
+			} else {
+				gtk_render_frame(context, cr,
+				                 max_width - (td->avatar_width + TOOLTIP_BORDER) - 1,
+				                 current_height - 1,
+				                 td->avatar_width + 2, td->avatar_height + 2);
+			}
+			gtk_style_context_restore(context);
+#else
+			if (dir == GTK_TEXT_DIR_RTL) {
+				gtk_paint_flat_box(style, gtkblist->tipwindow->window,
+				                   GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+				                   NULL, gtkblist->tipwindow, "tooltip",
 				                   TOOLTIP_BORDER - 1, current_height - 1,
 				                   td->avatar_width + 2, td->avatar_height + 2);
-			else
-				gtk_paint_flat_box(style, cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-				                   gtkblist->tipwindow, "tooltip",
+			} else {
+				gtk_paint_flat_box(style, gtkblist->tipwindow->window,
+				                   GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+				                   NULL, gtkblist->tipwindow, "tooltip",
 				                   max_width - (td->avatar_width + TOOLTIP_BORDER) - 1,
-				                   current_height - 1,
-				                   td->avatar_width + 2, td->avatar_height + 2);
-#else
-			if (dir == GTK_TEXT_DIR_RTL)
-				gtk_paint_flat_box(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-				                   NULL, gtkblist->tipwindow, "tooltip",
-				                   TOOLTIP_BORDER -1, current_height -1, td->avatar_width +2, td->avatar_height + 2);
-			else
-				gtk_paint_flat_box(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-				                   NULL, gtkblist->tipwindow, "tooltip",
-				                   max_width - (td->avatar_width+ TOOLTIP_BORDER)-1,
-				                   current_height-1,td->avatar_width+2, td->avatar_height+2);
+				                   current_height - 1, td->avatar_width + 2,
+				                   td->avatar_height + 2);
+			}
 #endif
 		}
 
@@ -3067,14 +3083,13 @@ pidgin_blist_paint_tip(GtkWidget *widget
 		if (td->name_layout) {
 #if GTK_CHECK_VERSION(3,0,0)
 			if (dir == GTK_TEXT_DIR_RTL) {
-				gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE,
-				                 gtkblist->tipwindow, "tooltip",
-				                 max_width - (TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000),
-				                 current_height, td->name_layout);
+				gtk_render_layout(context, cr,
+				                  max_width - (TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000),
+				                  current_height, td->name_layout);
 			} else {
-				gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE,
-				                 gtkblist->tipwindow, "tooltip",
-				                 TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height, td->name_layout);
+				gtk_render_layout(context, cr,
+				                  TOOLTIP_BORDER + status_size + SMALL_SPACE,
+				                  current_height, td->name_layout);
 			}
 #else
 			if (dir == GTK_TEXT_DIR_RTL) {
@@ -3093,21 +3108,22 @@ pidgin_blist_paint_tip(GtkWidget *widget
 		if (td->layout) {
 #if GTK_CHECK_VERSION(3,0,0)
 			if (dir != GTK_TEXT_DIR_RTL) {
-				gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE,
-				                 gtkblist->tipwindow, "tooltip",
-				                 TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height + td->name_height, td->layout);
+				gtk_render_layout(context, cr,
+				                  TOOLTIP_BORDER + status_size + SMALL_SPACE,
+				                  current_height + td->name_height,
+				                  td->layout);
 			} else {
-				gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE,
-				                 gtkblist->tipwindow, "tooltip",
-				                 max_width - (TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000),
-				                 current_height + td->name_height,
-				                 td->layout);
+				gtk_render_layout(context, cr,
+				                  max_width - (TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000),
+				                  current_height + td->name_height,
+				                  td->layout);
 			}
 #else
 			if (dir != GTK_TEXT_DIR_RTL) {
 				gtk_paint_layout(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE,
 				                 NULL, gtkblist->tipwindow, "tooltip",
-				                 TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height + td->name_height, td->layout);
+				                 TOOLTIP_BORDER + status_size + SMALL_SPACE,
+				                 current_height + td->name_height, td->layout);
 			} else {
 				gtk_paint_layout(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE,
 				                 NULL, gtkblist->tipwindow, "tooltip",
diff --git a/pidgin/gtkcellrendererexpander.c b/pidgin/gtkcellrendererexpander.c
--- a/pidgin/gtkcellrendererexpander.c
+++ b/pidgin/gtkcellrendererexpander.c
@@ -271,6 +271,9 @@ pidgin_cell_renderer_expander_render(Gtk
 	gint ypad;
 	gboolean is_expanded;
 	GtkAllocation allocation;
+#if GTK_CHECK_VERSION(3,0,0)
+	GtkStyleContext *context;
+#endif
 
 	if (!cellexpander->is_expander)
 		return;
@@ -294,12 +297,18 @@ pidgin_cell_renderer_expander_render(Gtk
 	height -= ypad*2;
 
 #if GTK_CHECK_VERSION(3,0,0)
-	gtk_paint_expander(gtk_widget_get_style(widget),
-	                   cr, state,
-	                   widget, "treeview",
-	                   cell_area->x + xpad + (width / 2),
-	                   cell_area->y + ypad + (height / 2),
-	                   is_expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED);
+	if (is_expanded)
+		state |= GTK_STATE_ACTIVE;
+	else
+		state &= ~GTK_STATE_ACTIVE;
+
+	context = gtk_widget_get_style_context(widget);
+	gtk_style_context_add_class(context, GTK_STYLE_CLASS_VIEW);
+	gtk_style_context_add_class(context, GTK_STYLE_CLASS_EXPANDER);
+	gtk_style_context_set_state(context, state);
+	gtk_render_expander(context, cr,
+	                    cell_area->x + xpad, cell_area->y + ypad,
+	                    width, height);
 #else
 	gtk_paint_expander(gtk_widget_get_style(widget),
 	                   window, state,
@@ -315,7 +324,7 @@ pidgin_cell_renderer_expander_render(Gtk
 
 #if GTK_CHECK_VERSION(3,0,0)
 	if (is_expanded && !set)
-		gtk_paint_hline(gtk_widget_get_style(widget), cr, state, widget, NULL, 0,
+		gtk_render_line(context, cr, 0, cell_area->y + cell_area->height,
 		                allocation.width, cell_area->y + cell_area->height);
 #else
 	if (is_expanded && !set)
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -565,9 +565,9 @@ pidgin_plugins_paint_tooltip(GtkWidget *
 {
 	PangoLayout *layout = g_object_get_data(G_OBJECT(tipwindow), "tooltip-plugin");
 #if GTK_CHECK_VERSION(3,0,0)
-	gtk_paint_layout(gtk_widget_get_style(tipwindow), cr, GTK_STATE_NORMAL, FALSE,
-	                 tipwindow, "tooltip",
-	                 6, 6, layout);
+	GtkStyleContext *context = gtk_widget_get_style_context(tipwindow);
+	gtk_style_context_add_class(context, GTK_STYLE_CLASS_TOOLTIP);
+	gtk_render_layout(context, cr, 6, 6, layout);
 #else
 	gtk_paint_layout(tipwindow->style, tipwindow->window, GTK_STATE_NORMAL, FALSE,
 	                 NULL, tipwindow, "tooltip",
diff --git a/pidgin/gtkroomlist.c b/pidgin/gtkroomlist.c
--- a/pidgin/gtkroomlist.c
+++ b/pidgin/gtkroomlist.c
@@ -356,12 +356,19 @@ pidgin_roomlist_paint_tooltip(GtkWidget 
 {
 	PurpleRoomlist *list = user_data;
 	PidginRoomlist *grl = purple_roomlist_get_ui_data(list);
-	GtkStyle *style;
 	int current_height, max_width;
 	int max_text_width;
 	GtkTextDirection dir = gtk_widget_get_direction(GTK_WIDGET(grl->tree));
+#if GTK_CHECK_VERSION(3,0,0)
+	GtkStyleContext *context;
+
+	context = gtk_widget_get_style_context(grl->tipwindow);
+	gtk_style_context_add_class(context, GTK_STYLE_CLASS_TOOLTIP);
+#else
+	GtkStyle *style;
 
 	style = gtk_widget_get_style(grl->tipwindow);
+#endif
 
 	max_text_width = MAX(grl->tip_width, grl->tip_name_width);
 	max_width = TOOLTIP_BORDER + SMALL_SPACE + max_text_width + TOOLTIP_BORDER;
@@ -370,30 +377,26 @@ pidgin_roomlist_paint_tooltip(GtkWidget 
 
 #if GTK_CHECK_VERSION(3,0,0)
 	if (dir == GTK_TEXT_DIR_RTL) {
-		gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE,
-		                 grl->tipwindow, "tooltip",
-		                 max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000),
-		                 current_height,
-		                 grl->tip_name_layout);
+		gtk_render_layout(context, cr,
+		                  max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000),
+		                  current_height,
+		                  grl->tip_name_layout);
 	} else {
-		gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE,
-		                 grl->tipwindow, "tooltip",
-		                 TOOLTIP_BORDER + SMALL_SPACE,
-		                 current_height,
-		                 grl->tip_name_layout);
+		gtk_render_layout(context, cr,
+		                  TOOLTIP_BORDER + SMALL_SPACE,
+		                  current_height,
+		                  grl->tip_name_layout);
 	}
 	if (dir != GTK_TEXT_DIR_RTL) {
-		gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE,
-		                 grl->tipwindow, "tooltip",
-		                 TOOLTIP_BORDER + SMALL_SPACE,
-		                 current_height + grl->tip_name_height,
-		                 grl->tip_layout);
+		gtk_render_layout(context, cr,
+		                  TOOLTIP_BORDER + SMALL_SPACE,
+		                  current_height + grl->tip_name_height,
+		                  grl->tip_layout);
 	} else {
-		gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE,
-		                 grl->tipwindow, "tooltip",
-		                 max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000),
-		                 current_height + grl->tip_name_height,
-		                 grl->tip_layout);
+		gtk_render_layout(context, cr,
+		                  max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000),
+		                  current_height + grl->tip_name_height,
+		                  grl->tip_layout);
 	}
 #else
 	if (dir == GTK_TEXT_DIR_RTL) {
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -2120,11 +2120,12 @@ pidgin_status_box_draw(GtkWidget *widget
 
 	if (status_box->icon_box && status_box->icon_opaque) {
 		GtkAllocation allocation;
+		GtkStyleContext *context;
 
 		gtk_widget_get_allocation(status_box->icon_box, &allocation);
-		gtk_paint_box(gtk_widget_get_style(widget), cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-				status_box->icon_box, "button", allocation.x-1, allocation.y-1,
-				34, 34);
+		context = gtk_widget_get_style_context(widget);
+		gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
+		gtk_render_frame(context, cr, allocation.x-1, allocation.y-1, 34, 34);
 	}
 	return FALSE;
 }
diff --git a/pidgin/pidginstock.c b/pidgin/pidginstock.c
--- a/pidgin/pidginstock.c
+++ b/pidgin/pidginstock.c
@@ -520,8 +520,13 @@ pidgin_stock_load_stock_icon_theme(Pidgi
 
 		if (stock_icons[i].dir == NULL) {
 			/* GTK+ Stock icon */
+#if GTK_CHECK_VERSION(3,0,0)
+			iconset = gtk_style_context_lookup_icon_set(gtk_widget_get_style_context(win),
+			                                            stock_icons[i].filename);
+#else
 			iconset = gtk_style_lookup_icon_set(gtk_widget_get_style(win),
-					stock_icons[i].filename);



More information about the Commits mailing list