From: Guillaume Desmottes Date: Fri, 25 Nov 2011 11:38:26 +0000 (+0100) Subject: Properly update the 'simple' theme X-Git-Url: https://git.0d.be/?p=empathy.git;a=commitdiff_plain;h=70025f47f3087f7b5295c4a32648bef9806f7a36 Properly update the 'simple' theme We have to call the callback manually to update the theme when it's changed. Also make sure that style-set signal is only connected once and we update the theme only if the 'simple' one is used. https://bugzilla.gnome.org/show_bug.cgi?id=664795 --- diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c index 28cbbf3b..1233509e 100644 --- a/libempathy-gtk/empathy-theme-manager.c +++ b/libempathy-gtk/empathy-theme-manager.c @@ -188,6 +188,8 @@ theme_manager_create_irc_view (EmpathyThemeManager *manager) return theme; } +static void on_style_set_cb (GtkWidget *widget, GtkStyle *previous_style, EmpathyThemeManager *self); + static EmpathyThemeBoxes * theme_manager_create_boxes_view (EmpathyThemeManager *manager) { @@ -200,6 +202,9 @@ theme_manager_create_boxes_view (EmpathyThemeManager *manager) theme_manager_view_weak_notify_cb, &priv->boxes_views); + g_signal_connect (G_OBJECT (theme), "style-set", + G_CALLBACK (on_style_set_cb), manager); + return theme; } @@ -298,14 +303,20 @@ theme_manager_update_boxes_tags (EmpathyThemeBoxes *theme, } static void -on_style_set_cb (GtkWidget *widget, GtkStyle *previous_style, gpointer data) +on_style_set_cb (GtkWidget *widget, GtkStyle *previous_style, EmpathyThemeManager *self) { + EmpathyThemeManagerPriv *priv = GET_PRIV (self); GtkStyle *style; gchar color1[10]; gchar color2[10]; gchar color3[10]; gchar color4[10]; + /* The simple theme depends on the current GTK+ theme so it has to be + * updated if the theme changes. */ + if (tp_strdiff (priv->name, "simple")) + return; + style = gtk_widget_get_style (GTK_WIDGET (widget)); theme_manager_gdk_color_to_hex (&style->base[GTK_STATE_SELECTED], color1); @@ -333,8 +344,7 @@ theme_manager_update_boxes_theme (EmpathyThemeManager *manager, EmpathyThemeManagerPriv *priv = GET_PRIV (manager); if (strcmp (priv->name, "simple") == 0) { - g_signal_connect (G_OBJECT (theme), "style-set", - G_CALLBACK (on_style_set_cb), theme); + on_style_set_cb (GTK_WIDGET (theme), NULL, manager); } else if (strcmp (priv->name, "clean") == 0) { theme_manager_update_boxes_tags (theme,