From 98d76879d49bbe8acddaa0b3f056ea556bda6b70 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sat, 29 Dec 2007 15:49:21 +0000 Subject: Simplify chat theme system svn path=/trunk/; revision=507 --- libempathy-gtk/empathy-chat-view.c | 54 +++++++++++--------------------------- 1 file changed, 16 insertions(+), 38 deletions(-) (limited to 'libempathy-gtk/empathy-chat-view.c') diff --git a/libempathy-gtk/empathy-chat-view.c b/libempathy-gtk/empathy-chat-view.c index 947281590..c7428e9df 100644 --- a/libempathy-gtk/empathy-chat-view.c +++ b/libempathy-gtk/empathy-chat-view.c @@ -68,7 +68,6 @@ struct _EmpathyChatViewPriv { GtkTextBuffer *buffer; EmpathyTheme *theme; - gpointer theme_context; time_t last_timestamp; BlockType last_block_type; @@ -130,7 +129,8 @@ static void chat_view_clear_view_cb (GtkMenuItem * static gboolean chat_view_is_scrolled_down (EmpathyChatView *view); static void chat_view_theme_changed_cb (EmpathyThemeManager *manager, EmpathyChatView *view); -static void chat_view_theme_updated_cb (EmpathyTheme *theme, +static void chat_view_theme_notify_cb (EmpathyTheme *theme, + GParamSpec *param, EmpathyChatView *view); G_DEFINE_TYPE (EmpathyChatView, empathy_chat_view, GTK_TYPE_TEXT_VIEW); @@ -233,12 +233,8 @@ chat_view_finalize (GObject *object) if (priv->theme) { g_signal_handlers_disconnect_by_func (priv->theme, - chat_view_theme_updated_cb, + chat_view_theme_notify_cb, view); - - empathy_theme_detach_from_view (priv->theme, priv->theme_context, - view); - g_object_unref (priv->theme); } @@ -796,8 +792,7 @@ empathy_chat_view_append_message (EmpathyChatView *view, chat_view_maybe_trim_buffer (view); - empathy_theme_append_message (priv->theme, priv->theme_context, - view, msg); + empathy_theme_append_message (priv->theme, view, msg); if (bottom) { empathy_chat_view_scroll_down (view); @@ -820,9 +815,7 @@ empathy_chat_view_append_event (EmpathyChatView *view, chat_view_maybe_trim_buffer (view); - empathy_theme_append_event (priv->theme, - priv->theme_context, - view, str); + empathy_theme_append_event (priv->theme, view, str); if (bottom) { empathy_chat_view_scroll_down (view); @@ -852,13 +845,10 @@ empathy_chat_view_append_button (EmpathyChatView *view, bottom = chat_view_is_scrolled_down (view); - empathy_theme_append_timestamp (priv->theme, priv->theme_context, - view, NULL, - TRUE, TRUE); + empathy_theme_append_timestamp (priv->theme, view, NULL, TRUE, TRUE); if (message) { - empathy_theme_append_text (priv->theme, priv->theme_context, - view, message, tag, NULL); + empathy_theme_append_text (priv->theme, view, message, tag, NULL); } gtk_text_buffer_get_end_iter (priv->buffer, &iter); @@ -1006,8 +996,6 @@ empathy_chat_view_clear (EmpathyChatView *view) */ priv = GET_PRIV (view); - empathy_theme_view_cleared (priv->theme, priv->theme_context, view); - priv->last_block_type = BLOCK_TYPE_NONE; priv->last_timestamp = 0; } @@ -1370,16 +1358,11 @@ empathy_chat_view_get_theme (EmpathyChatView *view) } static void -chat_view_theme_updated_cb (EmpathyTheme *theme, EmpathyChatView *view) +chat_view_theme_notify_cb (EmpathyTheme *theme, + GParamSpec *param, + EmpathyChatView *view) { - EmpathyChatViewPriv *priv; - - priv = GET_PRIV (view); - - empathy_theme_detach_from_view (priv->theme, priv->theme_context, - view); - - priv->theme_context = empathy_theme_setup_with_view (theme, view); + empathy_theme_update_view (theme, view); } void @@ -1394,24 +1377,19 @@ empathy_chat_view_set_theme (EmpathyChatView *view, EmpathyTheme *theme) if (priv->theme) { g_signal_handlers_disconnect_by_func (priv->theme, - chat_view_theme_updated_cb, + chat_view_theme_notify_cb, view); - empathy_theme_detach_from_view (priv->theme, priv->theme_context, - view); - g_object_unref (priv->theme); } priv->theme = g_object_ref (theme); - g_signal_connect (priv->theme, - "updated", - G_CALLBACK (chat_view_theme_updated_cb), + empathy_theme_update_view (theme, view); + g_signal_connect (priv->theme, "notify", + G_CALLBACK (chat_view_theme_notify_cb), view); - priv->theme_context = empathy_theme_setup_with_view (theme, view); - - /* FIXME: Possibly redraw the function and make it a property */ + /* FIXME: Redraw all messages using the new theme */ } void -- cgit v1.2.3