aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/Makefile.am10
-rw-r--r--libempathy-gtk/empathy-call-window.c23
-rw-r--r--libempathy-gtk/empathy-call-window.h2
-rw-r--r--libempathy-gtk/empathy-chat-view.c54
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c36
-rw-r--r--libempathy-gtk/empathy-group-chat.glade302
-rw-r--r--libempathy-gtk/empathy-theme-boxes.c332
-rw-r--r--libempathy-gtk/empathy-theme-boxes.h4
-rw-r--r--libempathy-gtk/empathy-theme-irc.c270
-rw-r--r--libempathy-gtk/empathy-theme-manager.c146
-rw-r--r--libempathy-gtk/empathy-theme-utils.c90
-rw-r--r--libempathy-gtk/empathy-theme-utils.h40
-rw-r--r--libempathy-gtk/empathy-theme.c87
-rw-r--r--libempathy-gtk/empathy-theme.h119
-rw-r--r--libempathy-gtk/empathy-ui-utils.c48
-rw-r--r--libempathy-gtk/empathy-ui-utils.h7
16 files changed, 1006 insertions, 564 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 07336f55c..494e3c4ce 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -32,10 +32,11 @@ libempathy_gtk_la_SOURCES = \
empathy-contact-list-store.c \
empathy-contact-list-view.c \
empathy-preferences.c \
- empathy-theme.c \
+ empathy-theme.c \
empathy-theme-boxes.c \
- empathy-theme-irc.c \
+ empathy-theme-irc.c \
empathy-theme-manager.c \
+ empathy-theme-utils.c \
empathy-smiley-manager.c \
empathy-chat-window.c \
empathy-chat.c \
@@ -88,10 +89,11 @@ libempathy_gtk_headers = \
empathy-contact-list-store.h \
empathy-contact-list-view.h \
empathy-preferences.h \
- empathy-theme.h \
+ empathy-theme.h \
empathy-theme-boxes.h \
- empathy-theme-irc.h \
+ empathy-theme-irc.h \
empathy-theme-manager.h \
+ empathy-theme-utils.h \
empathy-smiley-manager.h \
empathy-chat-window.h \
empathy-chat.h \
diff --git a/libempathy-gtk/empathy-call-window.c b/libempathy-gtk/empathy-call-window.c
index a1c7bd799..baa169755 100644
--- a/libempathy-gtk/empathy-call-window.c
+++ b/libempathy-gtk/empathy-call-window.c
@@ -24,7 +24,6 @@
#include "config.h"
#include <gtk/gtk.h>
-#include <glib/gi18n.h>
#include <libempathy/empathy-debug.h>
@@ -105,20 +104,6 @@ call_window_capabilities_notify_cb (EmpathyContact *contact,
}
static void
-call_window_name_notify_cb (EmpathyContact *contact,
- GParamSpec *param,
- EmpathyCallWindow *window)
-{
- const gchar *name;
- gchar *title;
-
- name = empathy_contact_get_name (contact);
- title = g_strdup_printf (_("Call from %s"), name);
- gtk_window_set_title (GTK_WINDOW (window->window), title);
- g_free (title);
-}
-
-static void
call_window_status_notify_cb (EmpathyTpCall *call,
GParamSpec *param,
EmpathyCallWindow *window)
@@ -139,11 +124,7 @@ call_window_status_notify_cb (EmpathyTpCall *call,
g_signal_connect (contact, "notify::capabilities",
G_CALLBACK (call_window_capabilities_notify_cb),
window);
- g_signal_connect (contact, "notify::name",
- G_CALLBACK (call_window_name_notify_cb),
- window);
call_window_capabilities_notify_cb (contact, NULL, window);
- call_window_name_notify_cb (contact, NULL, window);
}
}
@@ -161,7 +142,7 @@ call_window_destroy_cb (GtkWidget *widget,
g_slice_free (EmpathyCallWindow, window);
}
-GtkWidget *
+void
empathy_call_window_show (EmpathyTpCall *call)
{
EmpathyCallWindow *window;
@@ -213,7 +194,5 @@ empathy_call_window_show (EmpathyTpCall *call)
window);
gtk_widget_show (window->window);
-
- return window->window;
}
diff --git a/libempathy-gtk/empathy-call-window.h b/libempathy-gtk/empathy-call-window.h
index c8c6d7f0e..ea310d622 100644
--- a/libempathy-gtk/empathy-call-window.h
+++ b/libempathy-gtk/empathy-call-window.h
@@ -28,7 +28,7 @@
G_BEGIN_DECLS
-GtkWidget * empathy_call_window_show (EmpathyTpCall *call);
+void empathy_call_window_show (EmpathyTpCall *call);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-chat-view.c b/libempathy-gtk/empathy-chat-view.c
index c7428e9df..947281590 100644
--- a/libempathy-gtk/empathy-chat-view.c
+++ b/libempathy-gtk/empathy-chat-view.c
@@ -68,6 +68,7 @@ struct _EmpathyChatViewPriv {
GtkTextBuffer *buffer;
EmpathyTheme *theme;
+ gpointer theme_context;
time_t last_timestamp;
BlockType last_block_type;
@@ -129,8 +130,7 @@ 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_notify_cb (EmpathyTheme *theme,
- GParamSpec *param,
+static void chat_view_theme_updated_cb (EmpathyTheme *theme,
EmpathyChatView *view);
G_DEFINE_TYPE (EmpathyChatView, empathy_chat_view, GTK_TYPE_TEXT_VIEW);
@@ -233,8 +233,12 @@ chat_view_finalize (GObject *object)
if (priv->theme) {
g_signal_handlers_disconnect_by_func (priv->theme,
- chat_view_theme_notify_cb,
+ chat_view_theme_updated_cb,
view);
+
+ empathy_theme_detach_from_view (priv->theme, priv->theme_context,
+ view);
+
g_object_unref (priv->theme);
}
@@ -792,7 +796,8 @@ empathy_chat_view_append_message (EmpathyChatView *view,
chat_view_maybe_trim_buffer (view);
- empathy_theme_append_message (priv->theme, view, msg);
+ empathy_theme_append_message (priv->theme, priv->theme_context,
+ view, msg);
if (bottom) {
empathy_chat_view_scroll_down (view);
@@ -815,7 +820,9 @@ empathy_chat_view_append_event (EmpathyChatView *view,
chat_view_maybe_trim_buffer (view);
- empathy_theme_append_event (priv->theme, view, str);
+ empathy_theme_append_event (priv->theme,
+ priv->theme_context,
+ view, str);
if (bottom) {
empathy_chat_view_scroll_down (view);
@@ -845,10 +852,13 @@ empathy_chat_view_append_button (EmpathyChatView *view,
bottom = chat_view_is_scrolled_down (view);
- empathy_theme_append_timestamp (priv->theme, view, NULL, TRUE, TRUE);
+ empathy_theme_append_timestamp (priv->theme, priv->theme_context,
+ view, NULL,
+ TRUE, TRUE);
if (message) {
- empathy_theme_append_text (priv->theme, view, message, tag, NULL);
+ empathy_theme_append_text (priv->theme, priv->theme_context,
+ view, message, tag, NULL);
}
gtk_text_buffer_get_end_iter (priv->buffer, &iter);
@@ -996,6 +1006,8 @@ 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;
}
@@ -1358,11 +1370,16 @@ empathy_chat_view_get_theme (EmpathyChatView *view)
}
static void
-chat_view_theme_notify_cb (EmpathyTheme *theme,
- GParamSpec *param,
- EmpathyChatView *view)
+chat_view_theme_updated_cb (EmpathyTheme *theme, EmpathyChatView *view)
{
- empathy_theme_update_view (theme, 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);
}
void
@@ -1377,19 +1394,24 @@ empathy_chat_view_set_theme (EmpathyChatView *view, EmpathyTheme *theme)
if (priv->theme) {
g_signal_handlers_disconnect_by_func (priv->theme,
- chat_view_theme_notify_cb,
+ chat_view_theme_updated_cb,
view);
+ empathy_theme_detach_from_view (priv->theme, priv->theme_context,
+ view);
+
g_object_unref (priv->theme);
}
priv->theme = g_object_ref (theme);
- empathy_theme_update_view (theme, view);
- g_signal_connect (priv->theme, "notify",
- G_CALLBACK (chat_view_theme_notify_cb),
+ g_signal_connect (priv->theme,
+ "updated",
+ G_CALLBACK (chat_view_theme_updated_cb),
view);
- /* FIXME: Redraw all messages using the new theme */
+ priv->theme_context = empathy_theme_setup_with_view (theme, view);
+
+ /* FIXME: Possibly redraw the function and make it a property */
}
void
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 9b6a98a6a..73afd299a 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -1034,21 +1034,27 @@ contact_list_view_cell_set_background (EmpathyContactListView *view,
style = gtk_widget_get_style (GTK_WIDGET (view));
- if (!is_group && is_active) {
- color = style->bg[GTK_STATE_SELECTED];
-
- /* Here we take the current theme colour and add it to
- * the colour for white and average the two. This
- * gives a colour which is inline with the theme but
- * slightly whiter.
- */
- color.red = (color.red + (style->white).red) / 2;
- color.green = (color.green + (style->white).green) / 2;
- color.blue = (color.blue + (style->white).blue) / 2;
-
- g_object_set (cell,
- "cell-background-gdk", &color,
- NULL);
+ if (!is_group) {
+ if (is_active) {
+ color = style->bg[GTK_STATE_SELECTED];
+
+ /* Here we take the current theme colour and add it to
+ * the colour for white and average the two. This
+ * gives a colour which is inline with the theme but
+ * slightly whiter.
+ */
+ color.red = (color.red + (style->white).red) / 2;
+ color.green = (color.green + (style->white).green) / 2;
+ color.blue = (color.blue + (style->white).blue) / 2;
+
+ g_object_set (cell,
+ "cell-background-gdk", &color,
+ NULL);
+ } else {
+ g_object_set (cell,
+ "cell-background-gdk", NULL,
+ NULL);
+ }
} else {
g_object_set (cell,
"cell-background-gdk", NULL,
diff --git a/libempathy-gtk/empathy-group-chat.glade b/libempathy-gtk/empathy-group-chat.glade
index 5b40dc375..5cb6fc3ef 100644
--- a/libempathy-gtk/empathy-group-chat.glade
+++ b/libempathy-gtk/empathy-group-chat.glade
@@ -1,123 +1,183 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--*- mode: xml -*-->
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
<glade-interface>
- <widget class="GtkWindow" id="group_chat_window">
- <property name="border_width">6</property>
- <property name="title" translatable="yes">Group Chat</property>
- <property name="default_width">1000</property>
- <property name="default_height">800</property>
- <property name="icon_name">system-users</property>
- <child>
- <widget class="GtkVBox" id="group_chat_widget">
- <property name="visible">True</property>
- <property name="border_width">4</property>
- <property name="spacing">6</property>
- <child>
- <widget class="GtkHBox" id="hbox_topic">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <widget class="GtkLabel" id="label80">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">&lt;b&gt;Topic:&lt;/b&gt;</property>
- <property name="use_markup">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="label_topic">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="xalign">0</property>
- <property name="use_markup">True</property>
- <property name="wrap">True</property>
- <property name="selectable">True</property>
- <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
- <property name="single_line_mode">True</property>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHPaned" id="hpaned">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <child>
- <widget class="GtkVBox" id="vbox_left">
- <property name="width_request">600</property>
- <property name="height_request">500</property>
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <widget class="GtkScrolledWindow" id="scrolled_window_chat">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <child>
- <placeholder/>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkScrolledWindow" id="scrolled_window_input">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="vscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="resize">True</property>
- <property name="shrink">True</property>
- </packing>
- </child>
- <child>
- <widget class="GtkScrolledWindow" id="scrolled_window_contacts">
- <property name="width_request">200</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="shadow_type">GTK_SHADOW_IN</property>
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="resize">True</property>
- <property name="shrink">True</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
+
+<widget class="GtkWindow" id="group_chat_window">
+ <property name="border_width">6</property>
+ <property name="title" translatable="yes">Group Chat</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="default_width">600</property>
+ <property name="default_height">400</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="icon_name">system-users</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+
+ <child>
+ <widget class="GtkVBox" id="group_chat_widget">
+ <property name="border_width">4</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox_topic">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkLabel" id="label80">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Topic:&lt;/b&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label_topic">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">True</property>
+ <property name="selectable">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">True</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">2</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHPaned" id="hpaned">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox_left">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolled_window_chat">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolled_window_input">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="vscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="shrink">True</property>
+ <property name="resize">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolled_window_contacts">
+ <property name="width_request">0</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_IN</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="shrink">False</property>
+ <property name="resize">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c
index 87eac87d5..2905f2bec 100644
--- a/libempathy-gtk/empathy-theme-boxes.c
+++ b/libempathy-gtk/empathy-theme-boxes.c
@@ -29,6 +29,7 @@
#include "empathy-ui-utils.h"
#include "empathy-main-window.h"
+#include "empathy-theme-utils.h"
#include "empathy-theme-boxes.h"
#define DEBUG_DOMAIN "FancyTheme"
@@ -65,20 +66,32 @@ static void theme_boxes_set_property (GObject *object,
GParamSpec *pspec);
static void theme_boxes_define_theme_tags (EmpathyTheme *theme,
EmpathyChatView *view);
-static void theme_boxes_update_view (EmpathyTheme *theme,
+static EmpathyThemeContext *
+theme_boxes_setup_with_view (EmpathyTheme *theme,
EmpathyChatView *view);
+static void theme_boxes_detach_from_view (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view);
+static void theme_boxes_view_cleared (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view);
+
static void theme_boxes_append_message (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message);
static void theme_boxes_append_event (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
const gchar *str);
static void theme_boxes_append_timestamp (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message,
gboolean show_date,
gboolean show_time);
static void theme_boxes_append_spacing (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view);
enum {
@@ -116,7 +129,9 @@ empathy_theme_boxes_class_init (EmpathyThemeBoxesClass *class)
object_class->get_property = theme_boxes_get_property;
object_class->set_property = theme_boxes_set_property;
- theme_class->update_view = theme_boxes_update_view;
+ theme_class->setup_with_view = theme_boxes_setup_with_view;
+ theme_class->detach_from_view = theme_boxes_detach_from_view;
+ theme_class->view_cleared = theme_boxes_view_cleared;
theme_class->append_message = theme_boxes_append_message;
theme_class->append_event = theme_boxes_append_event;
theme_class->append_timestamp = theme_boxes_append_timestamp;
@@ -295,9 +310,9 @@ theme_boxes_get_property (GObject *object,
}
static void
theme_boxes_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
EmpathyThemeBoxesPriv *priv;
@@ -307,57 +322,46 @@ theme_boxes_set_property (GObject *object,
case PROP_HEADER_FOREGROUND:
g_free (priv->header_foreground);
priv->header_foreground = g_value_dup_string (value);
- g_object_notify (object, "header-foreground");
break;
case PROP_HEADER_BACKGROUND:
g_free (priv->header_background);
priv->header_background = g_value_dup_string (value);
- g_object_notify (object, "header-background");
break;
case PROP_HEADER_LINE_BACKGROUND:
g_free (priv->header_line_background);
priv->header_line_background = g_value_dup_string (value);
- g_object_notify (object, "header-line_background");
break;
case PROP_TEXT_FOREGROUND:
g_free (priv->text_foreground);
priv->text_foreground = g_value_dup_string (value);
- g_object_notify (object, "text-foreground");
break;
case PROP_TEXT_BACKGROUND:
g_free (priv->text_background);
priv->text_background = g_value_dup_string (value);
- g_object_notify (object, "text-background");
break;
case PROP_ACTION_FOREGROUND:
g_free (priv->action_foreground);
priv->action_foreground = g_value_dup_string (value);
- g_object_notify (object, "action-foreground");
break;
case PROP_HIGHLIGHT_FOREGROUND:
g_free (priv->highlight_foreground);
priv->highlight_foreground = g_value_dup_string (value);
- g_object_notify (object, "highlight-foreground");
break;
case PROP_TIME_FOREGROUND:
g_free (priv->time_foreground);
priv->time_foreground = g_value_dup_string (value);
- g_object_notify (object, "time-foreground");
break;
case PROP_EVENT_FOREGROUND:
g_free (priv->event_foreground);
priv->event_foreground = g_value_dup_string (value);
- g_object_notify (object, "event-foreground");
break;
case PROP_INVITE_FOREGROUND:
g_free (priv->invite_foreground);
priv->invite_foreground = g_value_dup_string (value);
- g_object_notify (object, "invite-foreground");
break;
case PROP_LINK_FOREGROUND:
g_free (priv->link_foreground);
priv->link_foreground = g_value_dup_string (value);
- g_object_notify (object, "link-foreground");
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -369,42 +373,53 @@ static void
theme_boxes_define_theme_tags (EmpathyTheme *theme, EmpathyChatView *view)
{
EmpathyThemeBoxesPriv *priv;
- GtkTextBuffer *buffer;
- GtkTextTag *tag;
+ GtkTextBuffer *buffer;
+ GtkTextTagTable *table;
+ GtkTextTag *tag;
priv = GET_PRIV (theme);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
- empathy_text_buffer_tag_set (buffer, "fancy-spacing",
- "size", 3000,
- "pixels-above-lines", 8,
- NULL);
-
- tag = empathy_text_buffer_tag_set (buffer, "fancy-header",
- "weight", PANGO_WEIGHT_BOLD,
- "pixels-above-lines", HEADER_PADDING,
- "pixels-below-lines", HEADER_PADDING,
- NULL);
+ table = gtk_text_buffer_get_tag_table (buffer);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "fancy-spacing");
+ g_object_set (tag,
+ "size", 3000,
+ "pixels-above-lines", 8,
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table,
+ "fancy-header");
+ g_object_set (tag,
+ "weight", PANGO_WEIGHT_BOLD,
+ "pixels-above-lines", HEADER_PADDING,
+ "pixels-below-lines", HEADER_PADDING,
+ NULL);
if (priv->header_foreground) {
g_object_set (tag,
"foreground", priv->header_foreground,
"paragraph-background", priv->header_background,
NULL);
}
+ empathy_theme_utils_add_tag (table, tag);
- tag = empathy_text_buffer_tag_set (buffer, "fancy-header-line",
- "size", 1,
- NULL);
+ tag = empathy_theme_utils_init_tag_by_name (table, "fancy-header-line");
+ g_object_set (tag,
+ "size", 1,
+ NULL);
if (priv->header_line_background) {
g_object_set (tag,
"paragraph-background", priv->header_line_background,
NULL);
}
- tag = empathy_text_buffer_tag_set (buffer, "fancy-body",
- "pixels-above-lines", 4,
- NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "fancy-body");
+ g_object_set (tag,
+ "pixels-above-lines", 4,
+ NULL);
if (priv->text_background) {
g_object_set (tag,
"paragraph-background", priv->text_background,
@@ -416,11 +431,13 @@ theme_boxes_define_theme_tags (EmpathyTheme *theme, EmpathyChatView *view)
"foreground", priv->text_foreground,
NULL);
}
+ empathy_theme_utils_add_tag (table, tag);
- tag = empathy_text_buffer_tag_set (buffer, "fancy-action",
- "style", PANGO_STYLE_ITALIC,
- "pixels-above-lines", 4,
- NULL);
+ tag = empathy_theme_utils_init_tag_by_name (table, "fancy-action");
+ g_object_set (tag,
+ "style", PANGO_STYLE_ITALIC,
+ "pixels-above-lines", 4,
+ NULL);
if (priv->text_background) {
g_object_set (tag,
@@ -432,12 +449,16 @@ theme_boxes_define_theme_tags (EmpathyTheme *theme, EmpathyChatView *view)
g_object_set (tag,
"foreground", priv->action_foreground,
NULL);
- }
+ }
+
+ empathy_theme_utils_add_tag (table, tag);
- tag = empathy_text_buffer_tag_set (buffer, "fancy-highlight",
- "weight", PANGO_WEIGHT_BOLD,
- "pixels-above-lines", 4,
- NULL);
+ tag = empathy_theme_utils_init_tag_by_name (table,
+ "fancy-highlight");
+ g_object_set (tag,
+ "weight", PANGO_WEIGHT_BOLD,
+ "pixels-above-lines", 4,
+ NULL);
if (priv->text_background) {
g_object_set (tag,
"paragraph-background", priv->text_background,
@@ -450,55 +471,106 @@ theme_boxes_define_theme_tags (EmpathyTheme *theme, EmpathyChatView *view)
"foreground", priv->highlight_foreground,
NULL);
}
+ empathy_theme_utils_add_tag (table, tag);
- tag = empathy_text_buffer_tag_set (buffer, "fancy-time",
- "justification", GTK_JUSTIFY_CENTER,
- NULL);
+ tag = empathy_theme_utils_init_tag_by_name (table, "fancy-time");
+ g_object_set (tag,
+ "justification", GTK_JUSTIFY_CENTER,
+ NULL);
if (priv->time_foreground) {
g_object_set (tag,
"foreground", priv->time_foreground,
NULL);
}
+ empathy_theme_utils_add_tag (table, tag);
- tag = empathy_text_buffer_tag_set (buffer, "fancy-event",
- "justification", GTK_JUSTIFY_LEFT,
- NULL);
+ tag = empathy_theme_utils_init_tag_by_name (table, "fancy-event");
+ g_object_set (tag,
+ "justification", GTK_JUSTIFY_LEFT,
+ NULL);
if (priv->event_foreground) {
g_object_set (tag,
"foreground", priv->event_foreground,
NULL);
}
+ empathy_theme_utils_add_tag (table, tag);
- tag = empathy_text_buffer_tag_set (buffer, "invite", NULL);
+ tag = empathy_theme_utils_init_tag_by_name (table, "invite");
if (priv->invite_foreground) {
g_object_set (tag,
"foreground", priv->invite_foreground,
NULL);
}
+ empathy_theme_utils_add_tag (table, tag);
- tag = empathy_text_buffer_tag_set (buffer, "fancy-link",
- "underline", PANGO_UNDERLINE_SINGLE,
- NULL);
+ tag = empathy_theme_utils_init_tag_by_name (table, "fancy-link");
+ g_object_set (tag,
+ "underline", PANGO_UNDERLINE_SINGLE,
+ NULL);
if (priv->link_foreground) {
g_object_set (tag,
"foreground", priv->link_foreground,
NULL);
}
+ empathy_theme_utils_add_tag (table, tag);
}
static void
-theme_boxes_update_view (EmpathyTheme *theme, EmpathyChatView *view)
+theme_boxes_fixup_tag_table (EmpathyTheme *theme, EmpathyChatView *view)
+{
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ /* "Fancy" style tags. */
+ empathy_theme_utils_ensure_tag_by_name (buffer, "fancy-header");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "fancy-header-line");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "fancy-body");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "fancy-action");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "fancy-highlight");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "fancy-spacing");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "fancy-time");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "fancy-event");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "fancy-link");
+}
+
+typedef struct {
+ BlockType last_block_type;
+ time_t last_timestamp;
+} FancyContext;
+
+static EmpathyThemeContext *
+theme_boxes_setup_with_view (EmpathyTheme *theme, EmpathyChatView *view)
{
EmpathyThemeBoxesPriv *priv;
- g_return_if_fail (EMPATHY_IS_THEME_BOXES (theme));
- g_return_if_fail (EMPATHY_IS_CHAT_VIEW (view));
+ g_return_val_if_fail (EMPATHY_IS_THEME_BOXES (theme), NULL);
priv = GET_PRIV (theme);
+ theme_boxes_fixup_tag_table (theme, view);
+
theme_boxes_define_theme_tags (theme, view);
empathy_chat_view_set_margin (view, MARGIN);
+
+ return NULL;
+}
+
+static void
+theme_boxes_detach_from_view (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view)
+{
+ /* FIXME: Free the context */
+}
+
+static void
+theme_boxes_view_cleared (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view)
+{
+ /* FIXME: clear the context data */
}
static void
@@ -523,6 +595,7 @@ table_size_allocate_cb (GtkWidget *view,
static void
theme_boxes_maybe_append_header (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *msg)
{
@@ -581,7 +654,7 @@ theme_boxes_maybe_append_header (EmpathyTheme *theme,
return;
}
- empathy_theme_append_spacing (theme, view);
+ empathy_theme_append_spacing (theme, context, view);
gtk_text_buffer_get_end_iter (buffer, &iter);
gtk_text_buffer_insert_with_tags_by_name (buffer,
@@ -620,8 +693,7 @@ theme_boxes_maybe_append_header (EmpathyTheme *theme,
"xalign", 0.0,
NULL);
- parse_success = priv->header_foreground &&
- gdk_color_parse (priv->header_foreground, &color);
+ parse_success = gdk_color_parse (priv->header_foreground, &color);
if (parse_success) {
gtk_widget_modify_fg (label1, GTK_STATE_NORMAL, &color);
@@ -685,13 +757,14 @@ theme_boxes_maybe_append_header (EmpathyTheme *theme,
static void
theme_boxes_append_message (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message)
{
EmpathyContact *sender;
- empathy_theme_maybe_append_date_and_time (theme, view, message);
- theme_boxes_maybe_append_header (theme, view, message);
+ empathy_theme_maybe_append_date_and_time (theme, context, view, message);
+ theme_boxes_maybe_append_header (theme, context, view, message);
sender = empathy_message_get_sender (message);
@@ -701,10 +774,10 @@ theme_boxes_append_message (EmpathyTheme *theme,
body = g_strdup_printf (" * %s %s",
empathy_contact_get_name (sender),
empathy_message_get_body (message));
- empathy_theme_append_text (theme, view, body,
+ empathy_theme_append_text (theme, context, view, body,
"fancy-action", "fancy-link");
} else {
- empathy_theme_append_text (theme, view,
+ empathy_theme_append_text (theme, context, view,
empathy_message_get_body (message),
"fancy-body", "fancy-link");
}
@@ -720,6 +793,7 @@ theme_boxes_append_message (EmpathyTheme *theme,
static void
theme_boxes_append_event (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
const gchar *str)
{
@@ -729,7 +803,7 @@ theme_boxes_append_event (EmpathyTheme *theme,
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- empathy_theme_maybe_append_date_and_time (theme, view, NULL);
+ empathy_theme_maybe_append_date_and_time (theme, context, view, NULL);
gtk_text_buffer_get_end_iter (buffer, &iter);
@@ -746,6 +820,7 @@ theme_boxes_append_event (EmpathyTheme *theme,
static void
theme_boxes_append_timestamp (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message,
gboolean show_date,
@@ -768,7 +843,9 @@ theme_boxes_append_timestamp (EmpathyTheme *theme,
str = g_string_new (NULL);
if (show_time || show_date) {
- empathy_theme_append_spacing (theme, view);
+ empathy_theme_append_spacing (theme,
+ context,
+ view);
g_string_append (str, "- ");
}
@@ -814,6 +891,7 @@ theme_boxes_append_timestamp (EmpathyTheme *theme,
static void
theme_boxes_append_spacing (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view)
{
GtkTextBuffer *buffer;
@@ -834,3 +912,125 @@ theme_boxes_append_spacing (EmpathyTheme *theme,
NULL);
}
+static void
+theme_boxes_setup_clean (EmpathyTheme *theme)
+{
+ g_object_set (theme,
+ "header-foreground", "black",
+ "header-background", "#efefdf",
+ "header_line_background", "#e3e3d3",
+ "action_foreground", "brown4",
+ "time_foreground", "darkgrey",
+ "event_foreground", "darkgrey",
+ "invite_foreground", "sienna",
+ "link_foreground","#49789e",
+ NULL);
+}
+
+static void
+theme_boxes_gdk_color_to_hex (GdkColor *gdk_color, gchar *str_color)
+{
+ g_snprintf (str_color, 10,
+ "#%02x%02x%02x",
+ gdk_color->red >> 8,
+ gdk_color->green >> 8,
+ gdk_color->blue >> 8);
+}
+
+static void
+theme_boxes_setup_themed (EmpathyTheme *theme)
+{
+ EmpathyThemeBoxesPriv *priv;
+ GtkWidget *widget;
+ GtkStyle *style;
+ gchar color[10];
+
+ priv = GET_PRIV (theme);
+
+ widget = gtk_entry_new ();
+ style = gtk_widget_get_style (widget);
+ gtk_widget_destroy (widget);
+
+ theme_boxes_gdk_color_to_hex (&style->base[GTK_STATE_SELECTED], color);
+
+ g_object_set (theme,
+ "action-foreground", color,
+ "link-foreground", color,
+ NULL);
+
+ theme_boxes_gdk_color_to_hex (&style->bg[GTK_STATE_SELECTED], color);
+
+ g_object_set (theme,
+ "header-background", color,
+ NULL);
+
+ theme_boxes_gdk_color_to_hex (&style->dark[GTK_STATE_SELECTED], color);
+
+ g_object_set (theme,
+ "header_line-background", color,
+ NULL);
+
+ theme_boxes_gdk_color_to_hex (&style->fg[GTK_STATE_SELECTED], color);
+
+ g_object_set (theme,
+ "header-foreground", color,
+ NULL);
+}
+
+static void
+theme_boxes_theme_changed_cb (GtkWidget *widget,
+ GtkStyle *previous_style,
+ gpointer user_data)
+{
+ theme_boxes_setup_themed (EMPATHY_THEME (user_data));
+
+ g_signal_emit_by_name (G_OBJECT (user_data), "updated");
+}
+
+static void
+theme_boxes_setup_blue (EmpathyTheme *theme)
+{
+ g_object_set (theme,
+ "header_foreground", "black",
+ "header_background", "#88a2b4",
+ "header_line_background", "#7f96a4",
+ "text_foreground", "black",
+ "text_background", "#adbdc8",
+ "highlight_foreground", "black",
+ "action_foreground", "brown4",
+ "time_foreground", "darkgrey",
+ "event_foreground", "#7f96a4",
+ "invite_foreground", "sienna",
+ "link_foreground", "#49789e",
+ NULL);
+}
+
+EmpathyTheme *
+empathy_theme_boxes_new (const gchar *name)
+{
+ EmpathyTheme *theme;
+ EmpathyThemeBoxesPriv *priv;
+
+ theme = g_object_new (EMPATHY_TYPE_THEME_BOXES, NULL);
+ priv = GET_PRIV (theme);
+
+ if (strcmp (name, "clean") == 0) {
+ theme_boxes_setup_clean (theme);
+ }
+ else if (strcmp (name, "simple") == 0) {
+ /* FIXME: Make an actual accessor function */
+ g_signal_connect (empathy_main_window_show (),
+ "style-set",
+ G_CALLBACK (theme_boxes_theme_changed_cb),
+ theme);
+
+ theme_boxes_setup_themed (theme);
+ }
+ else if (strcmp (name, "blue") == 0) {
+ theme_boxes_setup_blue (theme);
+ }
+
+ return theme;
+}
+
+
diff --git a/libempathy-gtk/empathy-theme-boxes.h b/libempathy-gtk/empathy-theme-boxes.h
index b1f0033f3..a54283693 100644
--- a/libempathy-gtk/empathy-theme-boxes.h
+++ b/libempathy-gtk/empathy-theme-boxes.h
@@ -45,7 +45,9 @@ struct _EmpathyThemeBoxesClass {
EmpathyThemeClass parent_class;
};
-GType empathy_theme_boxes_get_type (void) G_GNUC_CONST;
+GType empathy_theme_boxes_get_type (void) G_GNUC_CONST;
+
+EmpathyTheme * empathy_theme_boxes_new (const gchar *name);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-theme-irc.c b/libempathy-gtk/empathy-theme-irc.c
index 7cd9588bb..afe71e5ea 100644
--- a/libempathy-gtk/empathy-theme-irc.c
+++ b/libempathy-gtk/empathy-theme-irc.c
@@ -24,7 +24,7 @@
#include <libempathy/empathy-debug.h>
#include "empathy-chat.h"
-#include "empathy-ui-utils.h"
+#include "empathy-theme-utils.h"
#include "empathy-theme-irc.h"
#define DEBUG_DOMAIN "Theme"
@@ -37,21 +37,37 @@ struct _EmpathyThemeIrcPriv {
gint my_prop;
};
-static void theme_irc_finalize (GObject *object);
-static void theme_irc_update_view (EmpathyTheme *theme,
+static void theme_irc_finalize (GObject *object);
+static void theme_irc_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void theme_irc_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static EmpathyThemeContext *
+theme_irc_setup_with_view (EmpathyTheme *theme,
EmpathyChatView *view);
+static void theme_irc_detach_from_view (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view);
static void theme_irc_append_message (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message);
static void theme_irc_append_event (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
const gchar *str);
static void theme_irc_append_timestamp (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message,
gboolean show_date,
gboolean show_time);
static void theme_irc_append_spacing (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view);
@@ -72,13 +88,25 @@ empathy_theme_irc_class_init (EmpathyThemeIrcClass *class)
theme_class = EMPATHY_THEME_CLASS (class);
object_class->finalize = theme_irc_finalize;
+ object_class->get_property = theme_irc_get_property;
+ object_class->set_property = theme_irc_set_property;
- theme_class->update_view = theme_irc_update_view;
+ theme_class->setup_with_view = theme_irc_setup_with_view;
+ theme_class->detach_from_view = theme_irc_detach_from_view;
theme_class->append_message = theme_irc_append_message;
theme_class->append_event = theme_irc_append_event;
theme_class->append_timestamp = theme_irc_append_timestamp;
theme_class->append_spacing = theme_irc_append_spacing;
+ g_object_class_install_property (object_class,
+ PROP_MY_PROP,
+ g_param_spec_int ("my-prop",
+ "",
+ "",
+ 0, 1,
+ 1,
+ G_PARAM_READWRITE));
+
g_type_class_add_private (object_class, sizeof (EmpathyThemeIrcPriv));
}
@@ -101,82 +129,183 @@ theme_irc_finalize (GObject *object)
}
static void
+theme_irc_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyThemeIrcPriv *priv;
+
+ priv = GET_PRIV (object);
+
+ switch (param_id) {
+ case PROP_MY_PROP:
+ g_value_set_int (value, priv->my_prop);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+static void
+theme_irc_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyThemeIrcPriv *priv;
+
+ priv = GET_PRIV (object);
+
+ switch (param_id) {
+ case PROP_MY_PROP:
+ priv->my_prop = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+theme_irc_fixup_tag_table (EmpathyTheme *theme, EmpathyChatView *view)
+{
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ /* IRC style tags. */
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-nick-self");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-body-self");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-action-self");
+
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-nick-other");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-body-other");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-action-other");
+
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-nick-highlight");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-spacing");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-time");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-event");
+ empathy_theme_utils_ensure_tag_by_name (buffer, "irc-link");
+}
+
+static void
theme_irc_apply_theme_classic (EmpathyTheme *theme, EmpathyChatView *view)
{
EmpathyThemeIrcPriv *priv;
- GtkTextBuffer *buffer;
+ GtkTextBuffer *buffer;
+ GtkTextTagTable *table;
+ GtkTextTag *tag;
priv = GET_PRIV (theme);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
- empathy_text_buffer_tag_set (buffer, "irc-spacing",
- "size", 2000,
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "irc-nick-self",
- "foreground", "sea green",
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "irc-body-self",
- /* To get the default theme color: */
- "foreground-set", FALSE,
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "irc-action-self",
- "foreground", "brown4",
- "style", PANGO_STYLE_ITALIC,
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "irc-nick-highlight",
- "foreground", "indian red",
- "weight", PANGO_WEIGHT_BOLD,
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "irc-nick-other",
- "foreground", "skyblue4",
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "irc-body-other",
- /* To get the default theme color: */
- "foreground-set", FALSE,
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "irc-action-other",
- "foreground", "brown4",
- "style", PANGO_STYLE_ITALIC,
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "irc-time",
- "foreground", "darkgrey",
- "justification", GTK_JUSTIFY_CENTER,
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "irc-event",
- "foreground", "PeachPuff4",
- "justification", GTK_JUSTIFY_LEFT,
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "invite",
- "foreground", "sienna",
- NULL);
-
- empathy_text_buffer_tag_set (buffer, "irc-link",
- "foreground", "steelblue",
- "underline", PANGO_UNDERLINE_SINGLE,
- NULL);
+ table = gtk_text_buffer_get_tag_table (buffer);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-spacing");
+ g_object_set (tag,
+ "size", 2000,
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-nick-self");
+ g_object_set (tag,
+ "foreground", "sea green",
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-body-self");
+ g_object_set (tag,
+ /* To get the default theme color: */
+ "foreground-set", FALSE,
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-action-self");
+ g_object_set (tag,
+ "foreground", "brown4",
+ "style", PANGO_STYLE_ITALIC,
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-nick-highlight");
+ g_object_set (tag,
+ "foreground", "indian red",
+ "weight", PANGO_WEIGHT_BOLD,
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-nick-other");
+ g_object_set (tag,
+ "foreground", "skyblue4",
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-body-other");
+ g_object_set (tag,
+ /* To get the default theme color: */
+ "foreground-set", FALSE,
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-action-other");
+ g_object_set (tag,
+ "foreground", "brown4",
+ "style", PANGO_STYLE_ITALIC,
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-time");
+ g_object_set (tag,
+ "foreground", "darkgrey",
+ "justification", GTK_JUSTIFY_CENTER,
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-event");
+ g_object_set (tag,
+ "foreground", "PeachPuff4",
+ "justification", GTK_JUSTIFY_LEFT,
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "invite");
+ g_object_set (tag,
+ "foreground", "sienna",
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
+
+ tag = empathy_theme_utils_init_tag_by_name (table, "irc-link");
+ g_object_set (tag,
+ "foreground", "steelblue",
+ "underline", PANGO_UNDERLINE_SINGLE,
+ NULL);
+ empathy_theme_utils_add_tag (table, tag);
}
-static void
-theme_irc_update_view (EmpathyTheme *theme, EmpathyChatView *view)
+static EmpathyThemeContext *
+theme_irc_setup_with_view (EmpathyTheme *theme, EmpathyChatView *view)
{
+ theme_irc_fixup_tag_table (theme, view);
theme_irc_apply_theme_classic (theme, view);
empathy_chat_view_set_margin (view, 3);
+
+ return NULL;
+}
+
+static void
+theme_irc_detach_from_view (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view)
+{
+ /* Free the context */
}
static void
theme_irc_append_message (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message)
{
@@ -188,7 +317,7 @@ theme_irc_append_message (EmpathyTheme *theme,
gchar *tmp;
EmpathyContact *contact;
- empathy_theme_maybe_append_date_and_time (theme, view, message);
+ empathy_theme_maybe_append_date_and_time (theme, context, view, message);
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
@@ -205,7 +334,7 @@ theme_irc_append_message (EmpathyTheme *theme,
tmp = g_strdup_printf (" * %s %s",
empathy_contact_get_name (contact),
empathy_message_get_body (message));
- empathy_theme_append_text (theme, view, tmp,
+ empathy_theme_append_text (theme, context, view, tmp,
body_tag, "irc-link");
g_free (tmp);
return;
@@ -238,13 +367,14 @@ theme_irc_append_message (EmpathyTheme *theme,
g_free (tmp);
/* The text body. */
- empathy_theme_append_text (theme, view,
+ empathy_theme_append_text (theme, context, view,
empathy_message_get_body (message),
body_tag, "irc-link");
}
static void
theme_irc_append_event (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
const gchar *str)
{
@@ -254,7 +384,7 @@ theme_irc_append_event (EmpathyTheme *theme,
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- empathy_theme_maybe_append_date_and_time (theme, view, NULL);
+ empathy_theme_maybe_append_date_and_time (theme, context, view, NULL);
gtk_text_buffer_get_end_iter (buffer, &iter);
@@ -268,6 +398,7 @@ theme_irc_append_event (EmpathyTheme *theme,
static void
theme_irc_append_timestamp (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message,
gboolean show_date,
@@ -286,7 +417,9 @@ theme_irc_append_timestamp (EmpathyTheme *theme,
str = g_string_new (NULL);
if (show_time || show_date) {
- empathy_theme_append_spacing (theme, view);
+ empathy_theme_append_spacing (theme,
+ context,
+ view);
g_string_append (str, "- ");
}
@@ -330,6 +463,7 @@ theme_irc_append_timestamp (EmpathyTheme *theme,
static void
theme_irc_append_spacing (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view)
{
GtkTextBuffer *buffer;
diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c
index 6bece7506..6feea2fc4 100644
--- a/libempathy-gtk/empathy-theme-manager.c
+++ b/libempathy-gtk/empathy-theme-manager.c
@@ -50,7 +50,7 @@ typedef struct {
EmpathyTheme *blue_theme;
EmpathyTheme *classic_theme;
- GtkSettings *settings;
+ gboolean irc_style;
} EmpathyThemeManagerPriv;
static void theme_manager_finalize (GObject *object);
@@ -85,114 +85,6 @@ static const gchar *themes[] = {
G_DEFINE_TYPE (EmpathyThemeManager, empathy_theme_manager, G_TYPE_OBJECT);
static void
-theme_manager_gdk_color_to_hex (GdkColor *gdk_color, gchar *str_color)
-{
- g_snprintf (str_color, 10,
- "#%02x%02x%02x",
- gdk_color->red >> 8,
- gdk_color->green >> 8,
- gdk_color->blue >> 8);
-}
-
- static void
-theme_manager_color_hash_notify_cb (EmpathyThemeManager *manager)
-{
- EmpathyThemeManagerPriv *priv;
- GtkStyle *style;
- gchar color[10];
-
- priv = GET_PRIV (manager);
-
- style = gtk_widget_get_default_style ();
-
- g_object_freeze_notify (G_OBJECT (priv->simple_theme));
-
- theme_manager_gdk_color_to_hex (&style->base[GTK_STATE_SELECTED], color);
- g_object_set (priv->simple_theme,
- "action-foreground", color,
- "link-foreground", color,
- NULL);
-
- theme_manager_gdk_color_to_hex (&style->bg[GTK_STATE_SELECTED], color);
- g_object_set (priv->simple_theme,
- "header-background", color,
- NULL);
-
- theme_manager_gdk_color_to_hex (&style->dark[GTK_STATE_SELECTED], color);
- g_object_set (priv->simple_theme,
- "header-line-background", color,
- NULL);
-
- theme_manager_gdk_color_to_hex (&style->fg[GTK_STATE_SELECTED], color);
- g_object_set (priv->simple_theme,
- "header-foreground", color,
- NULL);
-
- g_object_thaw_notify (G_OBJECT (priv->simple_theme));
-
-#if 0
-
-FIXME: Make that work, it should update color when theme changes but it
- doesnt seems to work with all themes.
-
- g_object_get (priv->settings,
- "color-hash", &color_hash,
- NULL);
-
- /*
- * base_color: #ffffffffffff
- * fg_color: #000000000000
- * bg_color: #e6e6e7e7e8e8
- * text_color: #000000000000
- * selected_bg_color: #58589a9adbdb
- * selected_fg_color: #ffffffffffff
- */
-
- color = g_hash_table_lookup (color_hash, "base_color");
- if (color) {
- theme_manager_gdk_color_to_hex (color, color_str);
- g_object_set (priv->simple_theme,
- "action-foreground", color_str,
- "link-foreground", color_str,
- NULL);
- }
-
- color = g_hash_table_lookup (color_hash, "selected_bg_color");
- if (color) {
- theme_manager_gdk_color_to_hex (color, color_str);
- g_object_set (priv->simple_theme,
- "header-background", color_str,
- NULL);
- }
-
- color = g_hash_table_lookup (color_hash, "bg_color");
- if (color) {
- GdkColor tmp;
-
- tmp = *color;
- tmp.red /= 2;
- tmp.green /= 2;
- tmp.blue /= 2;
- theme_manager_gdk_color_to_hex (&tmp, color_str);
- g_object_set (priv->simple_theme,
- "header-line-background", color_str,
- NULL);
- }
-
- color = g_hash_table_lookup (color_hash, "selected_fg_color");
- if (color) {
- theme_manager_gdk_color_to_hex (color, color_str);
- g_object_set (priv->simple_theme,
- "header-foreground", color_str,
- NULL);
- }
-
- g_hash_table_unref (color_hash);
-
-#endif
-}
-
-static void
empathy_theme_manager_class_init (EmpathyThemeManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -246,39 +138,9 @@ empathy_theme_manager_init (EmpathyThemeManager *manager)
EMPATHY_PREFS_UI_SHOW_AVATARS,
&priv->show_avatars);
- priv->settings = gtk_settings_get_default ();
- g_signal_connect_swapped (priv->settings, "notify::color-hash",
- G_CALLBACK (theme_manager_color_hash_notify_cb),
- manager);
-
- priv->simple_theme = g_object_new (EMPATHY_TYPE_THEME_BOXES, NULL);
- theme_manager_color_hash_notify_cb (manager);
-
- priv->clean_theme = g_object_new (EMPATHY_TYPE_THEME_BOXES,
- "header-foreground", "black",
- "header-background", "#efefdf",
- "header_line_background", "#e3e3d3",
- "action_foreground", "brown4",
- "time_foreground", "darkgrey",
- "event_foreground", "darkgrey",
- "invite_foreground", "sienna",
- "link_foreground","#49789e",
- NULL);
-
- priv->blue_theme = g_object_new (EMPATHY_TYPE_THEME_BOXES,
- "header_foreground", "black",
- "header_background", "#88a2b4",
- "header_line_background", "#7f96a4",
- "text_foreground", "black",
- "text_background", "#adbdc8",
- "highlight_foreground", "black",
- "action_foreground", "brown4",
- "time_foreground", "darkgrey",
- "event_foreground", "#7f96a4",
- "invite_foreground", "sienna",
- "link_foreground", "#49789e",
- NULL);
-
+ priv->clean_theme = empathy_theme_boxes_new ("clean");
+ priv->simple_theme = empathy_theme_boxes_new ("simple");
+ priv->blue_theme = empathy_theme_boxes_new ("blue");
priv->classic_theme = g_object_new (EMPATHY_TYPE_THEME_IRC, NULL);
}
diff --git a/libempathy-gtk/empathy-theme-utils.c b/libempathy-gtk/empathy-theme-utils.c
new file mode 100644
index 000000000..56b758e2a
--- /dev/null
+++ b/libempathy-gtk/empathy-theme-utils.c
@@ -0,0 +1,90 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <gtk/gtktexttag.h>
+
+#include "empathy-theme-utils.h"
+
+void
+empathy_theme_utils_ensure_tag_by_name (GtkTextBuffer *buffer, const gchar *name)
+{
+ GtkTextTagTable *table;
+ GtkTextTag *tag;
+
+ table = gtk_text_buffer_get_tag_table (buffer);
+ tag = gtk_text_tag_table_lookup (table, name);
+
+ if (!tag) {
+ gtk_text_buffer_create_tag (buffer,
+ name,
+ NULL);
+ }
+}
+
+GtkTextTag *
+empathy_theme_utils_init_tag_by_name (GtkTextTagTable *table, const gchar *name)
+{
+ GtkTextTag *tag;
+
+ tag = gtk_text_tag_table_lookup (table, name);
+
+ if (!tag) {
+ return gtk_text_tag_new (name);
+ }
+
+ /* Clear the old values so that we don't affect the new theme. */
+ g_object_set (tag,
+ "background-set", FALSE,
+ "foreground-set", FALSE,
+ "invisible-set", FALSE,
+ "justification-set", FALSE,
+ "paragraph-background-set", FALSE,
+ "pixels-above-lines-set", FALSE,
+ "pixels-below-lines-set", FALSE,
+ "rise-set", FALSE,
+ "scale-set", FALSE,
+ "size-set", FALSE,
+ "style-set", FALSE,
+ "weight-set", FALSE,
+ NULL);
+
+ return tag;
+}
+
+void
+empathy_theme_utils_add_tag (GtkTextTagTable *table, GtkTextTag *tag)
+{
+ gchar *name;
+ GtkTextTag *check_tag;
+
+ g_object_get (tag, "name", &name, NULL);
+ check_tag = gtk_text_tag_table_lookup (table, name);
+ g_free (name);
+ if (check_tag) {
+ return;
+ }
+
+ gtk_text_tag_table_add (table, tag);
+
+ g_object_unref (tag);
+}
+
diff --git a/libempathy-gtk/empathy-theme-utils.h b/libempathy-gtk/empathy-theme-utils.h
new file mode 100644
index 000000000..af970775f
--- /dev/null
+++ b/libempathy-gtk/empathy-theme-utils.h
@@ -0,0 +1,40 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2007 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __EMPATHY_THEME_UTILS_H__
+#define __EMPATHY_THEME_UTILS_H__
+
+#include <gtk/gtktextbuffer.h>
+#include <gtk/gtktexttag.h>
+
+G_BEGIN_DECLS
+
+void empathy_theme_utils_ensure_tag_by_name (GtkTextBuffer *buffer,
+ const gchar *name);
+GtkTextTag * empathy_theme_utils_init_tag_by_name (GtkTextTagTable *table,
+ const gchar *name);
+void empathy_theme_utils_add_tag (GtkTextTagTable *table,
+ GtkTextTag *tag);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_THEME_UTILS_H__ */
+
+
diff --git a/libempathy-gtk/empathy-theme.c b/libempathy-gtk/empathy-theme.c
index 1895b8ccb..c465ae69a 100644
--- a/libempathy-gtk/empathy-theme.c
+++ b/libempathy-gtk/empathy-theme.c
@@ -31,6 +31,7 @@
#include "empathy-chat.h"
#include "empathy-preferences.h"
+#include "empathy-theme-utils.h"
#include "empathy-theme.h"
#include "empathy-smiley-manager.h"
@@ -66,6 +67,13 @@ enum {
PROP_SHOW_AVATARS
};
+enum {
+ UPDATED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
static void
empathy_theme_class_init (EmpathyThemeClass *class)
{
@@ -77,7 +85,8 @@ empathy_theme_class_init (EmpathyThemeClass *class)
object_class->get_property = theme_get_property;
object_class->set_property = theme_set_property;
- class->update_view = NULL;
+ class->setup_with_view = NULL;
+ class->view_cleared = NULL;
class->append_message = NULL;
class->append_event = NULL;
class->append_timestamp = NULL;
@@ -90,6 +99,16 @@ 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));
}
@@ -149,8 +168,7 @@ theme_set_property (GObject *object,
switch (param_id) {
case PROP_SHOW_AVATARS:
- empathy_theme_set_show_avatars (EMPATHY_THEME (object),
- g_value_get_boolean (value));
+ priv->show_avatars = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -160,6 +178,7 @@ theme_set_property (GObject *object,
void
empathy_theme_maybe_append_date_and_time (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message)
{
@@ -188,24 +207,61 @@ empathy_theme_maybe_append_date_and_time (EmpathyTheme *theme,
}
if (append_time || append_date) {
- empathy_theme_append_timestamp (theme, view, message,
+ empathy_theme_append_timestamp (theme, context,
+ 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_update_view (EmpathyTheme *theme,
- EmpathyChatView *view)
+empathy_theme_detach_from_view (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view)
{
- if (!EMPATHY_THEME_GET_CLASS(theme)->update_view) {
- g_error ("Theme must override update_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;
}
- return EMPATHY_THEME_GET_CLASS(theme)->update_view (theme, view);
+ EMPATHY_THEME_GET_CLASS(theme)->view_cleared (theme, context, view);
}
void
empathy_theme_append_message (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message)
{
@@ -214,7 +270,8 @@ empathy_theme_append_message (EmpathyTheme *theme,
return;
}
- EMPATHY_THEME_GET_CLASS(theme)->append_message (theme, view, message);
+ EMPATHY_THEME_GET_CLASS(theme)->append_message (theme, context, view,
+ message);
}
static void
@@ -252,6 +309,7 @@ theme_insert_text_with_emoticons (GtkTextBuffer *buf,
void
empathy_theme_append_text (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
const gchar *body,
const gchar *tag,
@@ -352,6 +410,7 @@ empathy_theme_append_text (EmpathyTheme *theme,
void
empathy_theme_append_event (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
const gchar *str)
{
@@ -359,23 +418,25 @@ empathy_theme_append_event (EmpathyTheme *theme,
return;
}
- EMPATHY_THEME_GET_CLASS(theme)->append_event (theme, view, str);
+ EMPATHY_THEME_GET_CLASS(theme)->append_event (theme, context, 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, view);
+ EMPATHY_THEME_GET_CLASS(theme)->append_spacing (theme, context, view);
}
void
empathy_theme_append_timestamp (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
EmpathyChatView *view,
EmpathyMessage *message,
gboolean show_date,
@@ -385,7 +446,7 @@ empathy_theme_append_timestamp (EmpathyTheme *theme,
return;
}
- EMPATHY_THEME_GET_CLASS(theme)->append_timestamp (theme, view,
+ EMPATHY_THEME_GET_CLASS(theme)->append_timestamp (theme, context, view,
message, show_date,
show_time);
}
diff --git a/libempathy-gtk/empathy-theme.h b/libempathy-gtk/empathy-theme.h
index 34875bcb4..b05342aa7 100644
--- a/libempathy-gtk/empathy-theme.h
+++ b/libempathy-gtk/empathy-theme.h
@@ -42,54 +42,89 @@ struct _EmpathyTheme {
GObject parent;
};
+typedef void EmpathyThemeContext;
+
struct _EmpathyThemeClass {
GObjectClass parent_class;
/* <vtable> */
- void (*update_view) (EmpathyTheme *theme,
- EmpathyChatView *view);
- void (*append_message) (EmpathyTheme *theme,
- EmpathyChatView *view,
- EmpathyMessage *message);
- void (*append_event) (EmpathyTheme *theme,
- EmpathyChatView *view,
- const gchar *str);
- void (*append_timestamp) (EmpathyTheme *theme,
- EmpathyChatView *view,
- EmpathyMessage *message,
- gboolean show_date,
- gboolean show_time);
- void (*append_spacing) (EmpathyTheme *theme,
- EmpathyChatView *view);
+ EmpathyThemeContext * (*setup_with_view) (EmpathyTheme *theme,
+ EmpathyChatView *view);
+ void (*detach_from_view) (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view);
+ void (*view_cleared) (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view);
+ void (*append_message) (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view,
+ EmpathyMessage *message);
+ void (*append_event) (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view,
+ const gchar *str);
+ void (*append_timestamp) (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view,
+ EmpathyMessage *message,
+ gboolean show_date,
+ gboolean show_time);
+ void (*append_spacing) (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view);
+ void (*update_show_avatars) (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view,
+ gboolean show);
};
-GType empathy_theme_get_type (void) G_GNUC_CONST;
-void empathy_theme_update_view (EmpathyTheme *theme,
- EmpathyChatView *view);
-void empathy_theme_append_message (EmpathyTheme *theme,
- EmpathyChatView *view,
- EmpathyMessage *msg);
-void empathy_theme_append_text (EmpathyTheme *theme,
- EmpathyChatView *view,
- const gchar *body,
- const gchar *tag,
- const gchar *link_tag);
-void empathy_theme_append_spacing (EmpathyTheme *theme,
- EmpathyChatView *view);
-void empathy_theme_append_event (EmpathyTheme *theme,
- EmpathyChatView *view,
- const gchar *str);
-void empathy_theme_append_timestamp (EmpathyTheme *theme,
- EmpathyChatView *view,
- EmpathyMessage *message,
- gboolean show_date,
- gboolean show_time);
-void empathy_theme_maybe_append_date_and_time (EmpathyTheme *theme,
- EmpathyChatView *view,
- EmpathyMessage *message);
-gboolean empathy_theme_get_show_avatars (EmpathyTheme *theme);
-void empathy_theme_set_show_avatars (EmpathyTheme *theme,
- gboolean show);
+GType empathy_theme_get_type (void) G_GNUC_CONST;
+
+EmpathyTheme * empathy_theme_new (void);
+
+EmpathyThemeContext *
+empathy_theme_setup_with_view (EmpathyTheme *theme,
+ EmpathyChatView *view);
+void empathy_theme_detach_from_view (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view);
+void empathy_theme_view_cleared (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view);
+
+void empathy_theme_append_message (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view,
+ EmpathyMessage *msg);
+void empathy_theme_append_text (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view,
+ const gchar *body,
+ const gchar *tag,
+ const gchar *link_tag);
+void empathy_theme_append_spacing (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view);
+void empathy_theme_append_event (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view,
+ const gchar *str);
+void empathy_theme_append_timestamp (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view,
+ EmpathyMessage *message,
+ gboolean show_date,
+ gboolean show_time);
+
+void
+empathy_theme_maybe_append_date_and_time (EmpathyTheme *theme,
+ EmpathyThemeContext *context,
+ EmpathyChatView *view,
+ EmpathyMessage *message);
+gboolean empathy_theme_get_show_avatars (EmpathyTheme *theme);
+void empathy_theme_set_show_avatars (EmpathyTheme *theme,
+ gboolean show);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 2989ce2ac..6f1b5a857 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -1376,51 +1376,3 @@ empathy_toggle_button_set_state_quietly (GtkWidget *widget,
g_signal_handlers_unblock_by_func (widget, callback, user_data);
}
-GtkTextTag *
-empathy_text_buffer_tag_set (GtkTextBuffer *buffer,
- const gchar *tag_name,
- const gchar *first_property_name,
- ...)
-{
- GtkTextTagTable *table;
- GtkTextTag *tag;
-
- g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
- g_return_val_if_fail (tag_name != NULL, NULL);
-
- table = gtk_text_buffer_get_tag_table (buffer);
- tag = gtk_text_tag_table_lookup (table, tag_name);
-
- if (!tag) {
- tag = gtk_text_tag_new (tag_name);
- gtk_text_tag_table_add (table, tag);
- g_object_unref (tag);
- } else {
- /* Clear the old values so that we don't affect the new theme. */
- g_object_set (tag,
- "background-set", FALSE,
- "foreground-set", FALSE,
- "invisible-set", FALSE,
- "justification-set", FALSE,
- "paragraph-background-set", FALSE,
- "pixels-above-lines-set", FALSE,
- "pixels-below-lines-set", FALSE,
- "rise-set", FALSE,
- "scale-set", FALSE,
- "size-set", FALSE,
- "style-set", FALSE,
- "weight-set", FALSE,
- NULL);
- }
-
- if (first_property_name) {
- va_list list;
-
- va_start (list, first_property_name);
- g_object_set_valist (G_OBJECT (tag), first_property_name, list);
- va_end (list);
- }
-
- return tag;
-}
-
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index fd1f7c633..eb189545a 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -106,12 +106,9 @@ void empathy_toggle_button_set_state_quietly (GtkWidget *widge
GCallback callback,
gpointer user_data,
gboolean active);
-GtkWidget * empathy_link_button_new (const gchar *url,
+GtkWidget *empathy_link_button_new (const gchar *url,
const gchar *title);
-GtkTextTag *empathy_text_buffer_tag_set (GtkTextBuffer *buffer,
- const gchar *tag_name,
- const gchar *first_property_name,
- ...);
+
G_END_DECLS