]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-theme-manager.c
individual_view_drag_end: remove the auto scroll
[empathy.git] / libempathy-gtk / empathy-theme-manager.c
index 2a6c393f25957abf5f3a61541894ff9807b0aaea..1233509ecc6f1753b43508a139ab559acc190110 100644 (file)
 #include "empathy-chat-text-view.h"
 #include "empathy-theme-boxes.h"
 #include "empathy-theme-irc.h"
-
-#ifdef HAVE_WEBKIT
 #include "empathy-theme-adium.h"
-#endif
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
 #include <libempathy/empathy-debug.h>
@@ -56,12 +53,10 @@ typedef struct {
        guint        emit_changed_idle;
        gboolean     in_constructor;
 
-#ifdef HAVE_WEBKIT
        EmpathyAdiumData *adium_data;
        gchar *adium_variant;
        /* list of weakref to EmpathyThemeAdium objects */
        GList *adium_views;
-#endif
 } EmpathyThemeManagerPriv;
 
 enum {
@@ -85,7 +80,6 @@ static gboolean
 theme_manager_emit_changed_idle_cb (gpointer manager)
 {
        EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
-#ifdef HAVE_WEBKIT
        const gchar *adium_path = NULL;
 
        if (priv->adium_data) {
@@ -94,7 +88,6 @@ theme_manager_emit_changed_idle_cb (gpointer manager)
        DEBUG ("Emit theme-changed with: name='%s' adium_path='%s' "
               "adium_variant='%s'", priv->name, adium_path,
               priv->adium_variant);
-#endif /* HAVE_WEBKIT */
 
        g_signal_emit (manager, signals[THEME_CHANGED], 0, NULL);
        priv->emit_changed_idle = 0;
@@ -195,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)
 {
@@ -207,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;
 }
 
@@ -305,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);
@@ -340,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,
@@ -371,7 +374,6 @@ theme_manager_update_boxes_theme (EmpathyThemeManager *manager,
        }
 }
 
-#ifdef HAVE_WEBKIT
 static EmpathyThemeAdium *
 theme_manager_create_adium_view (EmpathyThemeManager *manager)
 {
@@ -451,7 +453,6 @@ theme_manager_notify_adium_variant_cb (GSettings   *gsettings_chat,
                        priv->adium_variant);
        }
 }
-#endif /* HAVE_WEBKIT */
 
 EmpathyChatView *
 empathy_theme_manager_create_view (EmpathyThemeManager *manager)
@@ -463,11 +464,9 @@ empathy_theme_manager_create_view (EmpathyThemeManager *manager)
 
        DEBUG ("Using theme %s", priv->name);
 
-#ifdef HAVE_WEBKIT
        if (strcmp (priv->name, "adium") == 0 && priv->adium_data != NULL)  {
                return EMPATHY_CHAT_VIEW (theme_manager_create_adium_view (manager));
        }
-#endif
 
        if (strcmp (priv->name, "classic") == 0)  {
                return EMPATHY_CHAT_VIEW (theme_manager_create_irc_view (manager));
@@ -583,11 +582,9 @@ theme_manager_finalize (GObject *object)
 
        clear_list_of_views (&priv->boxes_views);
 
-#ifdef HAVE_WEBKIT
        clear_list_of_views (&priv->adium_views);
        g_free (priv->adium_variant);
        tp_clear_pointer (&priv->adium_data, empathy_adium_data_unref);
-#endif
 
        G_OBJECT_CLASS (empathy_theme_manager_parent_class)->finalize (object);
 }
@@ -603,7 +600,7 @@ empathy_theme_manager_class_init (EmpathyThemeManagerClass *klass)
                              G_SIGNAL_RUN_LAST,
                              0,
                              NULL, NULL,
-                             g_cclosure_marshal_VOID__VOID,
+                             g_cclosure_marshal_generic,
                              G_TYPE_NONE,
                              0);
 
@@ -632,7 +629,6 @@ empathy_theme_manager_init (EmpathyThemeManager *manager)
                                      EMPATHY_PREFS_CHAT_THEME,
                                      manager);
 
-#ifdef HAVE_WEBKIT
        /* Take the adium path/variant and track changes */
        g_signal_connect (priv->gsettings_chat,
                          "changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH,
@@ -649,7 +645,6 @@ empathy_theme_manager_init (EmpathyThemeManager *manager)
        theme_manager_notify_adium_variant_cb (priv->gsettings_chat,
                                               EMPATHY_PREFS_CHAT_THEME_VARIANT,
                                               manager);
-#endif
        priv->in_constructor = FALSE;
 }
 
@@ -674,7 +669,6 @@ empathy_theme_manager_get_themes (void)
        return themes;
 }
 
-#ifdef HAVE_WEBKIT
 static void
 find_themes (GList **list, const gchar *dirpath)
 {
@@ -705,12 +699,10 @@ find_themes (GList **list, const gchar *dirpath)
                g_error_free (error);
        }
 }
-#endif /* HAVE_WEBKIT */
 
 GList *
 empathy_theme_manager_get_adium_themes (void)
 {
-#ifdef HAVE_WEBKIT
        GList *themes_list = NULL;
        gchar *userpath = NULL;
        const gchar *const *paths = NULL;
@@ -729,7 +721,4 @@ empathy_theme_manager_get_adium_themes (void)
        }
 
        return themes_list;
-#else
-       return NULL;
-#endif /* HAVE_WEBKIT */
 }