[empathy] Avoid warning spam from GtkStyleContext with GTK+ 3.19
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] Avoid warning spam from GtkStyleContext with GTK+ 3.19
- Date: Sat, 16 Jan 2016 13:20:58 +0000 (UTC)
commit bc7c5e9025ece52d2bf7c1a5bc1bed8a0214d90a
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sat Jan 16 07:19:37 2016 -0600
Avoid warning spam from GtkStyleContext with GTK+ 3.19
Not *necessarily* the best fix, but let's avoid any behavior change.
(lt-empathy-chat:21101): Gtk-WARNING **: State 0 for GtkBox 0x1d8e120
doesn't match state 192 set via gtk_style_context_set_state ()
(lt-empathy-chat:21101): Gtk-WARNING **: State 0 for GtkBox 0x1d8e120
doesn't match state 192 set via gtk_style_context_set_state ()
(lt-empathy-chat:21101): Gtk-WARNING **: State 0 for GtkBox 0x1d8e120
doesn't match state 192 set via gtk_style_context_set_state ()
(lt-empathy-chat:21101): Gtk-WARNING **: State 0 for GtkBox 0x1d8e120
doesn't match state 192 set via gtk_style_context_set_state ()
(lt-empathy-chat:21101): Gtk-WARNING **: State 0 for GtkBox 0x1d8e120
doesn't match state 192 set via gtk_style_context_set_state ()
libempathy-gtk/empathy-cell-renderer-text.c | 8 +++++++-
libempathy-gtk/empathy-individual-view.c | 3 +++
src/empathy-chat-window.c | 15 ++++++++++-----
3 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/libempathy-gtk/empathy-cell-renderer-text.c b/libempathy-gtk/empathy-cell-renderer-text.c
index 5ce735f..ff663fd 100644
--- a/libempathy-gtk/empathy-cell-renderer-text.c
+++ b/libempathy-gtk/empathy-cell-renderer-text.c
@@ -330,9 +330,13 @@ cell_renderer_text_update_text (EmpathyCellRendererText *cell,
attr_list = pango_attr_list_new ();
+ gtk_style_context_save (style);
+
+ gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL,
"font", &font_desc,
NULL);
+
font_size = pango_font_description_get_size (font_desc);
pango_font_description_free (font_desc);
attr_size = pango_attr_size_new (font_size / 1.2);
@@ -343,7 +347,7 @@ cell_renderer_text_update_text (EmpathyCellRendererText *cell,
if (!selected) {
GdkRGBA color;
- gtk_style_context_get_color (style, 0, &color);
+ gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &color);
attr_color = pango_attr_foreground_new (color.red * 0xffff,
color.green * 0xffff,
@@ -353,6 +357,8 @@ cell_renderer_text_update_text (EmpathyCellRendererText *cell,
pango_attr_list_insert (attr_list, attr_color);
}
+ gtk_style_context_restore (style);
+
if (priv->compact) {
if (TPAW_STR_EMPTY (priv->status)) {
str = g_strdup (priv->name);
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index 9e64f4b..b8ef8d1 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -1102,8 +1102,11 @@ individual_view_cell_set_background (EmpathyIndividualView *view,
style = gtk_widget_get_style_context (GTK_WIDGET (view));
+ gtk_style_context_save (style);
+ gtk_style_context_set_state (style, GTK_STATE_FLAG_SELECTED);
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED,
&color);
+ gtk_style_context_restore (style);
/* Here we take the current theme colour and add it to
* the colour for white and average the two. This
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index b496356..ba23b74 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -380,21 +380,26 @@ chat_tab_style_updated_cb (GtkWidget *hbox,
{
GtkWidget *button;
int char_width, h, w;
- PangoContext *context;
+ GtkStyleContext *style_context;
+ PangoContext *pango_context;
PangoFontDescription *font_desc;
PangoFontMetrics *metrics;
button = g_object_get_data (G_OBJECT (user_data),
"chat-window-tab-close-button");
- context = gtk_widget_get_pango_context (hbox);
+ style_context = gtk_widget_get_style_context (hbox);
+ pango_context = gtk_widget_get_pango_context (hbox);
- gtk_style_context_get (gtk_widget_get_style_context (hbox),
+ gtk_style_context_save (style_context);
+ gtk_style_context_set_state (style_context, GTK_STATE_FLAG_NORMAL);
+ gtk_style_context_get (style_context,
GTK_STATE_FLAG_NORMAL,
"font", &font_desc,
NULL);
+ gtk_style_context_restore (style_context);
- metrics = pango_context_get_metrics (context, font_desc,
- pango_context_get_language (context));
+ metrics = pango_context_get_metrics (pango_context, font_desc,
+ pango_context_get_language (pango_context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]