]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-theme.c
Simplify chat theme system
[empathy.git] / libempathy-gtk / empathy-theme.c
index c465ae69ad7ac3ee7260d3ca39bb9f0ff4a8e8df..1895b8ccb901b278e0f192aef72cc56c08dbe97c 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "empathy-chat.h"
 #include "empathy-preferences.h"
-#include "empathy-theme-utils.h"
 #include "empathy-theme.h"
 #include "empathy-smiley-manager.h"
 
@@ -67,13 +66,6 @@ enum {
        PROP_SHOW_AVATARS
 };
 
-enum {
-       UPDATED,
-       LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
 static void
 empathy_theme_class_init (EmpathyThemeClass *class)
 {
@@ -85,8 +77,7 @@ empathy_theme_class_init (EmpathyThemeClass *class)
        object_class->get_property = theme_get_property;
        object_class->set_property = theme_set_property;
 
-       class->setup_with_view  = NULL;
-       class->view_cleared     = NULL;
+       class->update_view      = NULL;
        class->append_message   = NULL;
        class->append_event     = NULL;
        class->append_timestamp = NULL;
@@ -99,16 +90,6 @@ empathy_theme_class_init (EmpathyThemeClass *class)
                                                               TRUE,
                                                               G_PARAM_READWRITE));
 
-       signals[UPDATED] =
-               g_signal_new ("updated",
-                             G_TYPE_FROM_CLASS (class),
-                             G_SIGNAL_RUN_LAST,
-                             0,
-                             NULL, NULL,
-                             empathy_marshal_VOID__VOID,
-                             G_TYPE_NONE, 
-                             0);
-
        g_type_class_add_private (object_class, sizeof (EmpathyThemePriv));
 }
 
@@ -168,7 +149,8 @@ theme_set_property (GObject      *object,
 
        switch (param_id) {
        case PROP_SHOW_AVATARS:
-               priv->show_avatars = g_value_get_boolean (value);
+               empathy_theme_set_show_avatars (EMPATHY_THEME (object),
+                                               g_value_get_boolean (value));
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -178,7 +160,6 @@ theme_set_property (GObject      *object,
 
 void
 empathy_theme_maybe_append_date_and_time (EmpathyTheme        *theme,
-                                        EmpathyThemeContext *context,
                                         EmpathyChatView     *view,
                                         EmpathyMessage      *message)
 {
@@ -207,61 +188,24 @@ empathy_theme_maybe_append_date_and_time (EmpathyTheme        *theme,
        }
 
        if (append_time || append_date) {
-               empathy_theme_append_timestamp (theme, context,
-                                              view, message,
+               empathy_theme_append_timestamp (theme, view, message,
                                               append_date, append_time);
        }
 }
 
-EmpathyTheme *
-empathy_theme_new (void)
-{
-       EmpathyTheme     *theme;
-
-       theme = g_object_new (EMPATHY_TYPE_THEME, NULL);
-
-       return theme;
-}
-
-EmpathyThemeContext *
-empathy_theme_setup_with_view (EmpathyTheme    *theme,
-                             EmpathyChatView *view)
-{
-       if (!EMPATHY_THEME_GET_CLASS(theme)->setup_with_view) {
-               g_error ("Theme must override setup_with_view");
-       }
-
-       return EMPATHY_THEME_GET_CLASS(theme)->setup_with_view (theme, view);
-}
-
 void
-empathy_theme_detach_from_view (EmpathyTheme        *theme,
-                              EmpathyThemeContext *context,
-                              EmpathyChatView     *view)
+empathy_theme_update_view (EmpathyTheme    *theme,
+                          EmpathyChatView *view)
 {
-       if (!EMPATHY_THEME_GET_CLASS(theme)->detach_from_view) {
-               g_error ("Theme must override detach_from_view");
-       }
-
-       return EMPATHY_THEME_GET_CLASS(theme)->detach_from_view (theme, context,
-                                                               view);
-}
-
-void
-empathy_theme_view_cleared (EmpathyTheme        *theme,
-                          EmpathyThemeContext *context,
-                          EmpathyChatView     *view)
-{
-       if (!EMPATHY_THEME_GET_CLASS(theme)->view_cleared) {
-               return;
+       if (!EMPATHY_THEME_GET_CLASS(theme)->update_view) {
+               g_error ("Theme must override update_view");
        }
 
-       EMPATHY_THEME_GET_CLASS(theme)->view_cleared (theme, context, view);
+       return EMPATHY_THEME_GET_CLASS(theme)->update_view (theme, view);
 }
 
 void
 empathy_theme_append_message (EmpathyTheme        *theme,
-                            EmpathyThemeContext *context,
                             EmpathyChatView     *view,
                             EmpathyMessage      *message)
 {
@@ -270,8 +214,7 @@ empathy_theme_append_message (EmpathyTheme        *theme,
                return;
        }
 
-       EMPATHY_THEME_GET_CLASS(theme)->append_message (theme, context, view,
-                                                      message);
+       EMPATHY_THEME_GET_CLASS(theme)->append_message (theme, view, message);
 }
 
 static void
@@ -309,7 +252,6 @@ theme_insert_text_with_emoticons (GtkTextBuffer *buf,
 
 void
 empathy_theme_append_text (EmpathyTheme        *theme,
-                         EmpathyThemeContext *context,
                          EmpathyChatView     *view,
                          const gchar        *body,
                          const gchar        *tag,
@@ -410,7 +352,6 @@ empathy_theme_append_text (EmpathyTheme        *theme,
 
 void 
 empathy_theme_append_event (EmpathyTheme        *theme,
-                          EmpathyThemeContext *context,
                           EmpathyChatView     *view,
                           const gchar        *str)
 {
@@ -418,25 +359,23 @@ empathy_theme_append_event (EmpathyTheme        *theme,
                return;
        }
 
-       EMPATHY_THEME_GET_CLASS(theme)->append_event (theme, context, view, str);
+       EMPATHY_THEME_GET_CLASS(theme)->append_event (theme, view, str);
 }
 
 void
 empathy_theme_append_spacing (EmpathyTheme        *theme, 
-                            EmpathyThemeContext *context,
                             EmpathyChatView     *view)
 {
        if (!EMPATHY_THEME_GET_CLASS(theme)->append_spacing) {
                return;
        }
 
-       EMPATHY_THEME_GET_CLASS(theme)->append_spacing (theme, context, view);
+       EMPATHY_THEME_GET_CLASS(theme)->append_spacing (theme, view);
 }
 
 
 void 
 empathy_theme_append_timestamp (EmpathyTheme        *theme,
-                              EmpathyThemeContext *context,
                               EmpathyChatView     *view,
                               EmpathyMessage      *message,
                               gboolean            show_date,
@@ -446,7 +385,7 @@ empathy_theme_append_timestamp (EmpathyTheme        *theme,
                return;
        }
 
-       EMPATHY_THEME_GET_CLASS(theme)->append_timestamp (theme, context, view,
+       EMPATHY_THEME_GET_CLASS(theme)->append_timestamp (theme, view,
                                                         message, show_date,
                                                         show_time);
 }