[evolution/gnome-3-20] Bug 763796 - Excessive runtime warnings from gtk_style_context_get_...()



commit 58919ef0b5f1a005a7a960fdf3e07b382c0bdd2d
Author: Milan Crha <mcrha redhat com>
Date:   Wed Mar 23 10:53:23 2016 +0100

    Bug 763796 - Excessive runtime warnings from gtk_style_context_get_...()

 e-util/e-calendar-item.c            |   19 +++++++++++++------
 e-util/e-calendar.c                 |   14 ++++++++++----
 e-util/e-cell-combo.c               |    7 +++++--
 e-util/e-html-editor-view.c         |   12 +++++++++++-
 e-util/e-reflow.c                   |    2 +-
 e-util/e-table-header-utils.c       |    1 +
 e-util/e-web-view.c                 |   20 ++++++++++++++++++--
 e-util/ea-calendar-item.c           |    4 +++-
 modules/mail/e-mail-shell-sidebar.c |    4 +++-
 9 files changed, 65 insertions(+), 18 deletions(-)
---
diff --git a/e-util/e-calendar-item.c b/e-util/e-calendar-item.c
index fcd9726..e63a714 100644
--- a/e-util/e-calendar-item.c
+++ b/e-util/e-calendar-item.c
@@ -946,6 +946,7 @@ e_calendar_item_update (GnomeCanvasItem *item,
        gint rows, cols, xthickness, ythickness, old_month_width;
        PangoContext *pango_context;
        PangoFontMetrics *font_metrics;
+       GtkStyleContext *style_context;
        GtkBorder padding;
 
        item_class = GNOME_CANVAS_ITEM_CLASS (e_calendar_item_parent_class);
@@ -953,7 +954,8 @@ e_calendar_item_update (GnomeCanvasItem *item,
                item_class->update (item, i2c, flags);
 
        calitem = E_CALENDAR_ITEM (item);
-       gtk_style_context_get_padding (gtk_widget_get_style_context (GTK_WIDGET (item->canvas)), 0, &padding);
+       style_context = gtk_widget_get_style_context (GTK_WIDGET (item->canvas));
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
        xthickness = padding.left;
        ythickness = padding.top;
 
@@ -1115,8 +1117,7 @@ e_calendar_item_draw (GnomeCanvasItem *canvas_item,
 
        e_utils_get_theme_color (widget, "theme_bg_color", E_UTILS_DEFAULT_THEME_BG_COLOR, &bg_color);
 
-       gtk_style_context_get_border (
-               style_context, GTK_STATE_NORMAL, &border);
+       gtk_style_context_get_border (style_context, gtk_style_context_get_state (style_context), &border);
 
        /* Clear the entire background. */
        cairo_save (cr);
@@ -1226,6 +1227,7 @@ e_calendar_item_draw_month (ECalendarItem *calitem,
        PangoContext *pango_context;
        PangoFontMetrics *font_metrics;
        PangoLayout *layout;
+       GtkStyleContext *style_context;
        GtkBorder padding;
        PangoFontDescription *font_desc;
        GdkRGBA rgba;
@@ -1251,7 +1253,8 @@ e_calendar_item_draw_month (ECalendarItem *calitem,
        char_height =
                PANGO_PIXELS (pango_font_metrics_get_ascent (font_metrics)) +
                PANGO_PIXELS (pango_font_metrics_get_descent (font_metrics));
-       gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding);
+       style_context = gtk_widget_get_style_context (widget);
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
        xthickness = padding.left;
        ythickness = padding.top;
        arrow_button_size =
@@ -2116,11 +2119,13 @@ e_calendar_item_recalc_sizes (ECalendarItem *calitem)
        PangoLayout *layout;
        GDateWeekday weekday;
        GtkWidget *widget;
+       GtkStyleContext *style_context;
        GtkBorder padding;
 
        canvas_item = GNOME_CANVAS_ITEM (calitem);
        widget = GTK_WIDGET (canvas_item->canvas);
-       gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding);
+       style_context = gtk_widget_get_style_context (widget);
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
 
        /* Set up Pango prerequisites */
        font_desc = calitem->font_desc;
@@ -2644,6 +2649,7 @@ e_calendar_item_convert_position_to_day (ECalendarItem *calitem,
 {
        GnomeCanvasItem *item;
        GtkWidget *widget;
+       GtkStyleContext *style_context;
        GtkBorder padding;
        gint xthickness, ythickness, char_height;
        gint x, y, row, col, cells_x, cells_y, day_row, day_col;
@@ -2654,7 +2660,8 @@ e_calendar_item_convert_position_to_day (ECalendarItem *calitem,
 
        item = GNOME_CANVAS_ITEM (calitem);
        widget = GTK_WIDGET (item->canvas);
-       gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding);
+       style_context = gtk_widget_get_style_context (widget);
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
 
        pango_context = gtk_widget_create_pango_context (widget);
        font_metrics = pango_context_get_metrics (
diff --git a/e-util/e-calendar.c b/e-util/e-calendar.c
index 1e4f496..b28c191 100644
--- a/e-util/e-calendar.c
+++ b/e-util/e-calendar.c
@@ -373,13 +373,15 @@ e_calendar_get_preferred_width (GtkWidget *widget,
                                 gint *natural)
 {
        ECalendar *cal;
+       GtkStyleContext *style_context;
        GtkBorder padding;
        gint col_width;
 
        cal = E_CALENDAR (widget);
 
        g_object_get ((cal->calitem), "column_width", &col_width, NULL);
-       gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding);
+       style_context = gtk_widget_get_style_context (widget);
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
 
        *minimum = *natural = col_width * cal->min_cols + padding.left * 2;
 }
@@ -390,13 +392,15 @@ e_calendar_get_preferred_height (GtkWidget *widget,
                                  gint *natural)
 {
        ECalendar *cal;
+       GtkStyleContext *style_context;
        GtkBorder padding;
        gint row_height;
 
        cal = E_CALENDAR (widget);
 
        g_object_get ((cal->calitem), "row_height", &row_height, NULL);
-       gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding);
+       style_context = gtk_widget_get_style_context (widget);
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
 
        *minimum = *natural = row_height * cal->min_rows + padding.top * 2;
 }
@@ -406,6 +410,7 @@ e_calendar_size_allocate (GtkWidget *widget,
                           GtkAllocation *allocation)
 {
        ECalendar *cal;
+       GtkStyleContext *style_context;
        GtkBorder padding;
        GtkAllocation old_allocation;
        PangoContext *pango_context;
@@ -415,7 +420,8 @@ e_calendar_size_allocate (GtkWidget *widget,
        gboolean is_rtl;
 
        cal = E_CALENDAR (widget);
-       gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding);
+       style_context = gtk_widget_get_style_context (widget);
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
        xthickness = padding.left;
        ythickness = padding.top;
 
@@ -565,7 +571,7 @@ e_calendar_get_border_size (ECalendar *cal,
        if (style_context) {
                GtkBorder padding;
 
-               gtk_style_context_get_padding (style_context, 0, &padding);
+               gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), 
&padding);
 
                *top    = padding.top;
                *bottom = padding.top;
diff --git a/e-util/e-cell-combo.c b/e-util/e-cell-combo.c
index 22d48f3..966f97a 100644
--- a/e-util/e-cell-combo.c
+++ b/e-util/e-cell-combo.c
@@ -471,6 +471,7 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc,
        GtkScrolledWindow *popup;
        GtkRequisition requisition;
        GtkRequisition list_requisition;
+       GtkStyleContext *style_context;
        gboolean show_vscroll = FALSE, show_hscroll = FALSE;
        gint avail_height, avail_width, min_height, work_height, screen_width;
        gint column_width, row_height, scrollbar_width;
@@ -533,10 +534,12 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc,
                list_requisition.height += E_CELL_COMBO_LIST_EMPTY_HEIGHT;
 
        popwin_child = gtk_bin_get_child (popwin);
-       gtk_style_context_get_padding (gtk_widget_get_style_context (popwin_child), 0, &popwin_padding);
+       style_context = gtk_widget_get_style_context (popwin_child);
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), 
&popwin_padding);
 
        popup_child = gtk_bin_get_child (GTK_BIN (popup));
-       gtk_style_context_get_padding (gtk_widget_get_style_context (popup_child), 0, &popup_padding);
+       style_context = gtk_widget_get_style_context (popup_child);
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), 
&popup_padding);
 
        /* Calculate the desired width. */
        *width = list_requisition.width
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index dce3f15..2cccd76 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -10861,6 +10861,9 @@ get_color_from_context (GtkStyleContext *context,
 
        if (color == NULL) {
                gboolean is_visited = strstr (name, "visited") != NULL;
+               #if GTK_CHECK_VERSION(3,12,0)
+               GtkStateFlags state;
+               #endif
 
                out_color->alpha = 1;
                out_color->red = is_visited ? 1 : 0;
@@ -10868,7 +10871,14 @@ get_color_from_context (GtkStyleContext *context,
                out_color->blue = is_visited ? 0 : 1;
 
                #if GTK_CHECK_VERSION(3,12,0)
-               gtk_style_context_get_color (context, is_visited ? GTK_STATE_FLAG_VISITED : 
GTK_STATE_FLAG_LINK, out_color);
+               state = gtk_style_context_get_state (context);
+               state = state & (~(GTK_STATE_FLAG_VISITED | GTK_STATE_FLAG_LINK));
+               state = state | (is_visited ? GTK_STATE_FLAG_VISITED : GTK_STATE_FLAG_LINK);
+
+               gtk_style_context_save (context);
+               gtk_style_context_set_state (context, state);
+               gtk_style_context_get_color (context, state, out_color);
+               gtk_style_context_restore (context);
                #endif
        } else {
                out_color->alpha = 1;
diff --git a/e-util/e-reflow.c b/e-util/e-reflow.c
index 1a8a9fa..ec4cd81 100644
--- a/e-util/e-reflow.c
+++ b/e-util/e-reflow.c
@@ -1312,7 +1312,7 @@ e_reflow_draw (GnomeCanvasItem *item,
                cairo_save (cr);
 
                gtk_style_context_get_color (
-                       style_context, GTK_STATE_FLAG_NORMAL, &color);
+                       style_context, gtk_style_context_get_state (style_context), &color);
                gdk_cairo_set_source_rgba (cr, &color);
 
                for (; i < reflow->column_count; i++) {
diff --git a/e-util/e-table-header-utils.c b/e-util/e-table-header-utils.c
index eb4d8fe..0bd747b 100644
--- a/e-util/e-table-header-utils.c
+++ b/e-util/e-table-header-utils.c
@@ -46,6 +46,7 @@ get_button_padding (GtkWidget *widget,
 
        gtk_style_context_save (context);
        gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
+       gtk_style_context_set_state (context, state_flags);
        gtk_style_context_get_padding (context, state_flags, padding);
 
        gtk_style_context_restore (context);
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index 4bdeccf..42af88f 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -2870,6 +2870,7 @@ e_web_view_update_fonts (EWebView *web_view)
        if (link == NULL) {
                #if GTK_CHECK_VERSION(3,12,0)
                GdkRGBA rgba;
+               GtkStateFlags state;
                #endif
 
                link = g_slice_new0 (GdkColor);
@@ -2881,7 +2882,14 @@ e_web_view_update_fonts (EWebView *web_view)
                rgba.green = 0;
                rgba.blue = 1;
 
-               gtk_style_context_get_color (context, GTK_STATE_FLAG_LINK, &rgba);
+               state = gtk_style_context_get_state (context);
+               state = state & (~(GTK_STATE_FLAG_VISITED | GTK_STATE_FLAG_LINK));
+               state = state | GTK_STATE_FLAG_LINK;
+
+               gtk_style_context_save (context);
+               gtk_style_context_set_state (context, state);
+               gtk_style_context_get_color (context, state, &rgba);
+               gtk_style_context_restore (context);
 
                e_rgba_to_color (&rgba, link);
                #endif
@@ -2890,6 +2898,7 @@ e_web_view_update_fonts (EWebView *web_view)
        if (visited == NULL) {
                #if GTK_CHECK_VERSION(3,12,0)
                GdkRGBA rgba;
+               GtkStateFlags state;
                #endif
 
                visited = g_slice_new0 (GdkColor);
@@ -2901,7 +2910,14 @@ e_web_view_update_fonts (EWebView *web_view)
                rgba.green = 0;
                rgba.blue = 0;
 
-               gtk_style_context_get_color (context, GTK_STATE_FLAG_VISITED, &rgba);
+               state = gtk_style_context_get_state (context);
+               state = state & (~(GTK_STATE_FLAG_VISITED | GTK_STATE_FLAG_LINK));
+               state = state | GTK_STATE_FLAG_VISITED;
+
+               gtk_style_context_save (context);
+               gtk_style_context_set_state (context, state);
+               gtk_style_context_get_color (context, state, &rgba);
+               gtk_style_context_restore (context);
 
                e_rgba_to_color (&rgba, visited);
                #endif
diff --git a/e-util/ea-calendar-item.c b/e-util/ea-calendar-item.c
index 79bf1cb..b620777 100644
--- a/e-util/ea-calendar-item.c
+++ b/e-util/ea-calendar-item.c
@@ -1186,6 +1186,7 @@ e_calendar_item_get_day_extents (ECalendarItem *calitem,
        GnomeCanvasItem *item;
        GtkWidget *widget;
        GtkBorder padding;
+       GtkStyleContext *style_context;
        PangoContext *pango_context;
        PangoFontMetrics *font_metrics;
        gint char_height, xthickness, ythickness, text_y;
@@ -1199,7 +1200,8 @@ e_calendar_item_get_day_extents (ECalendarItem *calitem,
 
        item = GNOME_CANVAS_ITEM (calitem);
        widget = GTK_WIDGET (item->canvas);
-       gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding);
+       style_context = gtk_widget_get_style_context (widget);
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
 
        /* Set up Pango prerequisites */
        pango_context = gtk_widget_get_pango_context (widget);
diff --git a/modules/mail/e-mail-shell-sidebar.c b/modules/mail/e-mail-shell-sidebar.c
index 2b45a31..8638d16 100644
--- a/modules/mail/e-mail-shell-sidebar.c
+++ b/modules/mail/e-mail-shell-sidebar.c
@@ -266,6 +266,7 @@ mail_shell_sidebar_get_preferred_width (GtkWidget *widget,
        PangoLayout *layout;
        PangoRectangle ink_rect;
        GtkBorder padding;
+       GtkStyleContext *style_context;
        gint border;
        gint sidebar_width;
        gint screen_width;
@@ -281,7 +282,8 @@ mail_shell_sidebar_get_preferred_width (GtkWidget *widget,
        pango_layout_get_pixel_extents (layout, &ink_rect, NULL);
        g_object_unref (layout);
 
-       gtk_style_context_get_padding (gtk_widget_get_style_context (widget), 0, &padding);
+       style_context = gtk_widget_get_style_context (widget);
+       gtk_style_context_get_padding (style_context, gtk_style_context_get_state (style_context), &padding);
 
        screen_width = guess_screen_width (sidebar);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]