pidgin/android/android

Use GtkStyleContext instead of GtkStyle on GTK+3.
default
2012-08-15, Elliott Sales de Andrade
53bf180b9eb1
Parents a6493d38dc28
Children af1a4f6d8da2
Use GtkStyleContext instead of GtkStyle on GTK+3.
--- a/pidgin/gtkblist.c Wed Aug 15 03:12:27 2012 -0400
+++ b/pidgin/gtkblist.c Wed Aug 15 04:28:21 2012 -0400
@@ -2965,7 +2965,11 @@
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 @@
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 @@
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 @@
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 @@
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",
--- a/pidgin/gtkcellrendererexpander.c Wed Aug 15 03:12:27 2012 -0400
+++ b/pidgin/gtkcellrendererexpander.c Wed Aug 15 04:28:21 2012 -0400
@@ -271,6 +271,9 @@
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 @@
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 @@
#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)
--- a/pidgin/gtkplugin.c Wed Aug 15 03:12:27 2012 -0400
+++ b/pidgin/gtkplugin.c Wed Aug 15 04:28:21 2012 -0400
@@ -565,9 +565,9 @@
{
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",
--- a/pidgin/gtkroomlist.c Wed Aug 15 03:12:27 2012 -0400
+++ b/pidgin/gtkroomlist.c Wed Aug 15 04:28:21 2012 -0400
@@ -356,12 +356,19 @@
{
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 @@
#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) {
--- a/pidgin/gtkstatusbox.c Wed Aug 15 03:12:27 2012 -0400
+++ b/pidgin/gtkstatusbox.c Wed Aug 15 04:28:21 2012 -0400
@@ -2120,11 +2120,12 @@
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;
}
--- a/pidgin/pidginstock.c Wed Aug 15 03:12:27 2012 -0400
+++ b/pidgin/pidginstock.c Wed Aug 15 04:28:21 2012 -0400
@@ -520,8 +520,13 @@
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);
+ stock_icons[i].filename);
+#endif
} else {
filename = find_file(stock_icons[i].dir, stock_icons[i].filename);
--- a/pidgin/pidgintooltip.c Wed Aug 15 03:12:27 2012 -0400
+++ b/pidgin/pidgintooltip.c Wed Aug 15 04:28:21 2012 -0400
@@ -109,10 +109,10 @@
gtk_widget_get_allocation(widget, &allocation);
if (pidgin_tooltip.paint_tooltip) {
- gtk_paint_flat_box(gtk_widget_get_style(widget), cr,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- widget, "tooltip",
- 0, 0, allocation.width, allocation.height);
+ GtkStyleContext *context = gtk_widget_get_style_context(widget);
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_TOOLTIP);
+ gtk_render_background(context, cr,
+ 0, 0, allocation.width, allocation.height);
pidgin_tooltip.paint_tooltip(widget, cr, data);
}
return FALSE;
--- a/pidgin/plugins/disco/gtkdisco.c Wed Aug 15 03:12:27 2012 -0400
+++ b/pidgin/plugins/disco/gtkdisco.c Wed Aug 15 04:28:21 2012 -0400
@@ -431,11 +431,9 @@
{
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(gtk_widget_get_style(tipwindow),
gtk_widget_get_window(tipwindow),
--- a/pidgin/plugins/ticker/gtkticker.c Wed Aug 15 03:12:27 2012 -0400
+++ b/pidgin/plugins/ticker/gtkticker.c Wed Aug 15 04:28:21 2012 -0400
@@ -294,7 +294,11 @@
GdkWindowAttr attributes;
gint attributes_mask;
GdkWindow *window;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *context;
+#else
GtkStyle *style;
+#endif
GtkAllocation allocation;
g_return_if_fail (widget != NULL);
@@ -327,9 +331,16 @@
gtk_widget_set_window (widget, window);
gdk_window_set_user_data (window, widget);
+#if GTK_CHECK_VERSION(3,0,0)
+ context = gtk_widget_get_style_context(widget);
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_BACKGROUND);
+ gtk_style_context_set_state(context, GTK_STATE_NORMAL);
+ gtk_style_context_set_background(context, window);
+#else
style = gtk_style_attach (gtk_widget_get_style (widget), window);
gtk_widget_set_style (widget, style);
gtk_style_set_background (style, window, GTK_STATE_NORMAL);
+#endif
}
#if GTK_CHECK_VERSION(3,0,0)