aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2012-06-20 17:42:22 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-07-02 16:03:22 +0800
commitc7d5d6d78773d9e7cd933b326e7566a072b655d9 (patch)
tree614a669626748b84fcda4c48c7aea54f3299454d /libempathy-gtk
parent7f6f5faf1a3ac7109b690d33555c54db05a692fe (diff)
downloadgsoc2013-empathy-c7d5d6d78773d9e7cd933b326e7566a072b655d9.tar
gsoc2013-empathy-c7d5d6d78773d9e7cd933b326e7566a072b655d9.tar.gz
gsoc2013-empathy-c7d5d6d78773d9e7cd933b326e7566a072b655d9.tar.bz2
gsoc2013-empathy-c7d5d6d78773d9e7cd933b326e7566a072b655d9.tar.lz
gsoc2013-empathy-c7d5d6d78773d9e7cd933b326e7566a072b655d9.tar.xz
gsoc2013-empathy-c7d5d6d78773d9e7cd933b326e7566a072b655d9.tar.zst
gsoc2013-empathy-c7d5d6d78773d9e7cd933b326e7566a072b655d9.zip
Remove legacy themes code
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/Makefile.am4
-rw-r--r--libempathy-gtk/empathy-theme-boxes.c426
-rw-r--r--libempathy-gtk/empathy-theme-boxes.h61
-rw-r--r--libempathy-gtk/empathy-theme-irc.c143
-rw-r--r--libempathy-gtk/empathy-theme-irc.h62
-rw-r--r--libempathy-gtk/empathy-theme-manager.c374
6 files changed, 6 insertions, 1064 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index ac3d3c1c6..e11ee233f 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -88,8 +88,6 @@ libempathy_gtk_handwritten_source = \
empathy-spell.c \
empathy-status-preset-dialog.c \
empathy-string-parser.c \
- empathy-theme-boxes.c \
- empathy-theme-irc.c \
empathy-theme-manager.c \
empathy-tls-dialog.c \
empathy-ui-utils.c \
@@ -159,8 +157,6 @@ libempathy_gtk_headers = \
empathy-spell.h \
empathy-status-preset-dialog.h \
empathy-string-parser.h \
- empathy-theme-boxes.h \
- empathy-theme-irc.h \
empathy-theme-manager.h \
empathy-tls-dialog.h \
empathy-ui-utils.h \
diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c
deleted file mode 100644
index a678c3e1c..000000000
--- a/libempathy-gtk/empathy-theme-boxes.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007 Imendio AB
- * Copyright (C) 2008 Collabora Ltd.
- *
- * 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., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-
-#include <telepathy-glib/util.h>
-
-#include <libempathy/empathy-utils.h>
-#include "empathy-theme-boxes.h"
-#include "empathy-ui-utils.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
-
-#define MARGIN 4
-#define HEADER_PADDING 2
-
-/* "Join" consecutive messages with timestamps within five minutes */
-#define MESSAGE_JOIN_PERIOD 5*60
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyThemeBoxes)
-typedef struct {
- gboolean show_avatars;
-} EmpathyThemeBoxesPriv;
-
-static void chat_text_view_iface_init (EmpathyChatViewIface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (EmpathyThemeBoxes, empathy_theme_boxes,
- EMPATHY_TYPE_CHAT_TEXT_VIEW,
- G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CHAT_VIEW,
- chat_text_view_iface_init));
-
-static void
-theme_boxes_create_tags (EmpathyThemeBoxes *theme)
-{
- GtkTextBuffer *buffer;
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (theme));
-
- gtk_text_buffer_create_tag (buffer, EMPATHY_THEME_BOXES_TAG_HEADER,
- "pixels-above-lines", HEADER_PADDING,
- "pixels-below-lines", HEADER_PADDING,
- NULL);
-
- gtk_text_buffer_create_tag (buffer, EMPATHY_THEME_BOXES_TAG_HEADER_LINE, NULL);
-}
-
-/* Pads a pixbuf to the specified size, by centering it in a larger transparent
- * pixbuf. Returns a new ref.
- */
-static GdkPixbuf *
-theme_boxes_pad_to_size (GdkPixbuf *pixbuf,
- gint width,
- gint height,
- gint extra_padding_right)
-{
- gint src_width, src_height;
- GdkPixbuf *padded;
- gint x_offset, y_offset;
-
- src_width = gdk_pixbuf_get_width (pixbuf);
- src_height = gdk_pixbuf_get_height (pixbuf);
-
- x_offset = (width - src_width) / 2;
- y_offset = (height - src_height) / 2;
-
- padded = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (pixbuf),
- TRUE, /* alpha */
- gdk_pixbuf_get_bits_per_sample (pixbuf),
- width + extra_padding_right,
- height);
-
- gdk_pixbuf_fill (padded, 0);
-
- gdk_pixbuf_copy_area (pixbuf,
- 0, /* source coords */
- 0,
- src_width,
- src_height,
- padded,
- x_offset, /* dest coords */
- y_offset);
-
- return padded;
-}
-
-typedef struct {
- GdkPixbuf *pixbuf;
- gchar *filename;
-} AvatarData;
-
-static void
-theme_boxes_avatar_cache_data_free (gpointer ptr)
-{
- AvatarData *data = ptr;
-
- g_object_unref (data->pixbuf);
- g_free (data->filename);
- g_slice_free (AvatarData, data);
-}
-
-static GdkPixbuf *
-theme_boxes_get_avatar_pixbuf_with_cache (EmpathyContact *contact)
-{
- AvatarData *data;
- EmpathyAvatar *avatar;
- GdkPixbuf *tmp_pixbuf;
- GdkPixbuf *pixbuf = NULL;
-
- /* Check if avatar is in cache and if it's up to date */
- avatar = empathy_contact_get_avatar (contact);
- data = g_object_get_data (G_OBJECT (contact), "chat-view-avatar-cache");
- if (data) {
- if (avatar && !tp_strdiff (avatar->filename, data->filename)) {
- /* We have the avatar in cache */
- return data->pixbuf;
- }
- }
-
- /* Avatar not in cache, create pixbuf */
- tmp_pixbuf = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32);
- if (tmp_pixbuf) {
- pixbuf = theme_boxes_pad_to_size (tmp_pixbuf, 32, 32, 6);
- g_object_unref (tmp_pixbuf);
- }
- if (!pixbuf) {
- return NULL;
- }
-
- /* Insert new pixbuf in cache. We store the filename as it's unique
- * for each version of an avatar, so we can use it to perform change
- * detection (as above). */
- data = g_slice_new0 (AvatarData);
- data->filename = g_strdup (avatar->filename);
- data->pixbuf = pixbuf;
-
- g_object_set_data_full (G_OBJECT (contact), "chat-view-avatar-cache",
- data, theme_boxes_avatar_cache_data_free);
-
- return data->pixbuf;
-}
-
-static void
-table_size_allocate_cb (GtkWidget *view,
- GtkAllocation *allocation,
- GtkWidget *box)
-{
- gint width, height;
-
- gtk_widget_get_size_request (box, NULL, &height);
-
- width = allocation->width;
-
- width -= \
- gtk_text_view_get_right_margin (GTK_TEXT_VIEW (view)) - \
- gtk_text_view_get_left_margin (GTK_TEXT_VIEW (view));
- width -= 2 * MARGIN;
- width -= 2 * HEADER_PADDING;
-
- gtk_widget_set_size_request (box, width, height);
-}
-
-static void
-theme_boxes_maybe_append_header (EmpathyThemeBoxes *theme,
- EmpathyMessage *msg)
-{
- EmpathyChatTextView *view = EMPATHY_CHAT_TEXT_VIEW (theme);
- EmpathyThemeBoxesPriv*priv = GET_PRIV (theme);
- EmpathyContact *contact;
- EmpathyContact *last_contact;
- GdkPixbuf *avatar = NULL;
- GtkTextBuffer *buffer;
- const gchar *name;
- GtkTextIter iter;
- GtkWidget *label1, *label2;
- GtkTextChildAnchor *anchor;
- GtkWidget *box;
- gchar *str;
- gint64 time_;
- gchar *tmp;
- GtkTextIter start;
- gboolean color_set;
- GtkTextTagTable *table;
- GtkTextTag *tag;
- GString *str_obj;
- gboolean consecutive;
-
- contact = empathy_message_get_sender (msg);
- name = empathy_contact_get_logged_alias (contact);
- last_contact = empathy_chat_text_view_get_last_contact (view);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (theme));
- time_ = empathy_message_get_timestamp (msg);
- consecutive = (time_ - empathy_chat_text_view_get_last_timestamp (view)
- < MESSAGE_JOIN_PERIOD);
-
- DEBUG ("Maybe add fancy header");
-
- /* Only insert a header if
- * - the previously inserted block is not the same as this one.
- * - the delay between two messages is lower then MESSAGE_JOIN_PERIOD
- */
- if (empathy_contact_equal (last_contact, contact) && consecutive) {
- return;
- }
-
- empathy_chat_text_view_append_spacing (view);
-
- /* Insert header line */
- gtk_text_buffer_get_end_iter (buffer, &iter);
- gtk_text_buffer_insert_with_tags_by_name (buffer,
- &iter,
- "\n",
- -1,
- EMPATHY_THEME_BOXES_TAG_HEADER_LINE,
- NULL);
-
- gtk_text_buffer_get_end_iter (buffer, &iter);
- anchor = gtk_text_buffer_create_child_anchor (buffer, &iter);
-
- /* Create a hbox for the header and resize it when the view allocation
- * changes */
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- g_signal_connect_object (view, "size-allocate",
- G_CALLBACK (table_size_allocate_cb),
- box, 0);
-
- /* Add avatar to the box if needed */
- if (priv->show_avatars) {
- avatar = theme_boxes_get_avatar_pixbuf_with_cache (contact);
- if (avatar) {
- GtkWidget *image;
-
- image = gtk_image_new_from_pixbuf (avatar);
-
- gtk_box_pack_start (GTK_BOX (box), image,
- FALSE, TRUE, 2);
- }
- }
-
- /* Add contact alias */
- str = g_markup_printf_escaped ("<b>%s</b>", name);
- label1 = g_object_new (GTK_TYPE_LABEL,
- "label", str,
- "use-markup", TRUE,
- "xalign", 0.0,
- NULL);
- g_free (str);
-
- /* Add the message receive time */
- tmp = empathy_time_to_string_local (time_,
- EMPATHY_TIME_FORMAT_DISPLAY_SHORT);
- str = g_strdup_printf ("<i>%s</i>", tmp);
- label2 = g_object_new (GTK_TYPE_LABEL,
- "label", str,
- "use-markup", TRUE,
- "xalign", 1.0,
- NULL);
-
- str_obj = g_string_new ("\n- ");
- g_string_append (str_obj, name);
- g_string_append (str_obj, ", ");
- g_string_append (str_obj, tmp);
- g_string_append (str_obj, " -");
- g_free (tmp);
- g_free (str);
-
- /* Set foreground color of labels to the same color than the header tag. */
- table = gtk_text_buffer_get_tag_table (buffer);
- tag = gtk_text_tag_table_lookup (table, EMPATHY_THEME_BOXES_TAG_HEADER);
- g_object_get (tag, "foreground-set", &color_set, NULL);
- if (color_set) {
- GdkColor *color;
-
- g_object_get (tag, "foreground-gdk", &color, NULL);
- gtk_widget_modify_fg (label1, GTK_STATE_NORMAL, color);
- gtk_widget_modify_fg (label2, GTK_STATE_NORMAL, color);
- gdk_color_free (color);
- }
-
- /* Pack labels into the box */
- gtk_misc_set_alignment (GTK_MISC (label1), 0.0, 0.5);
- gtk_misc_set_alignment (GTK_MISC (label2), 1.0, 0.5);
- gtk_box_pack_start (GTK_BOX (box), label1, TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (box), label2, TRUE, TRUE, 0);
-
- /* Add the header box to the text view */
- g_object_set_data_full (G_OBJECT (box),
- "str_obj",
- g_string_free (str_obj, FALSE),
- g_free);
- gtk_text_view_add_child_at_anchor (GTK_TEXT_VIEW (view),
- box,
- anchor);
- gtk_widget_show_all (box);
-
- /* Insert a header line */
- gtk_text_buffer_get_end_iter (buffer, &iter);
- start = iter;
- gtk_text_iter_backward_char (&start);
- gtk_text_buffer_apply_tag_by_name (buffer,
- EMPATHY_THEME_BOXES_TAG_HEADER,
- &start, &iter);
- gtk_text_buffer_insert_with_tags_by_name (buffer,
- &iter,
- "\n",
- -1,
- EMPATHY_THEME_BOXES_TAG_HEADER,
- NULL);
- gtk_text_buffer_get_end_iter (buffer, &iter);
- gtk_text_buffer_insert_with_tags_by_name (buffer,
- &iter,
- "\n",
- -1,
- EMPATHY_THEME_BOXES_TAG_HEADER_LINE,
- NULL);
-}
-
-static void
-theme_boxes_append_message (EmpathyChatTextView *view,
- EmpathyMessage *message,
- gboolean should_highlight)
-{
- EmpathyContact *sender;
-
- theme_boxes_maybe_append_header (EMPATHY_THEME_BOXES (view), message);
-
- sender = empathy_message_get_sender (message);
- if (empathy_message_get_tptype (message) ==
- TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION) {
- gchar *body;
-
- body = g_strdup_printf (" * %s %s",
- empathy_contact_get_logged_alias (sender),
- empathy_message_get_body (message));
- empathy_chat_text_view_append_body (EMPATHY_CHAT_TEXT_VIEW (view),
- body,
- EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION);
- } else {
- empathy_chat_text_view_append_body (EMPATHY_CHAT_TEXT_VIEW (view),
- empathy_message_get_body (message),
- EMPATHY_CHAT_TEXT_VIEW_TAG_BODY);
- }
-}
-
-static void
-theme_boxes_set_show_avatars (EmpathyChatView *view,
- gboolean show_avatars)
-{
- EmpathyThemeBoxes *self = EMPATHY_THEME_BOXES (view);
- EmpathyThemeBoxesPriv *priv = GET_PRIV (self);
-
- priv->show_avatars = show_avatars;
-}
-
-static void
-empathy_theme_boxes_class_init (EmpathyThemeBoxesClass *class)
-{
- GObjectClass *object_class;
- EmpathyChatTextViewClass *chat_text_view_class;
-
- object_class = G_OBJECT_CLASS (class);
- chat_text_view_class = EMPATHY_CHAT_TEXT_VIEW_CLASS (class);
-
- chat_text_view_class->append_message = theme_boxes_append_message;
-
- g_type_class_add_private (object_class, sizeof (EmpathyThemeBoxesPriv));
-}
-
-static void
-empathy_theme_boxes_init (EmpathyThemeBoxes *theme)
-{
- EmpathyThemeBoxesPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (theme,
- EMPATHY_TYPE_THEME_BOXES, EmpathyThemeBoxesPriv);
-
- theme->priv = priv;
-
- /* Show avatars by default. */
- priv->show_avatars = TRUE;
-
- theme_boxes_create_tags (theme);
-
- /* Define margin */
- g_object_set (theme,
- "left-margin", MARGIN,
- "right-margin", MARGIN,
- NULL);
-}
-
-EmpathyThemeBoxes *
-empathy_theme_boxes_new (void)
-{
- return g_object_new (EMPATHY_TYPE_THEME_BOXES,
- "only-if-date", TRUE,
- NULL);
-}
-
-static void
-chat_text_view_iface_init (EmpathyChatViewIface *iface)
-{
- iface->set_show_avatars = theme_boxes_set_show_avatars;
-}
diff --git a/libempathy-gtk/empathy-theme-boxes.h b/libempathy-gtk/empathy-theme-boxes.h
deleted file mode 100644
index 53dd350ad..000000000
--- a/libempathy-gtk/empathy-theme-boxes.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007 Imendio AB
- * Copyright (C) 2008 Collabora Ltd.
- *
- * 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., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_THEME_BOXES_H__
-#define __EMPATHY_THEME_BOXES_H__
-
-#include <glib-object.h>
-
-#include "empathy-chat-text-view.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_THEME_BOXES (empathy_theme_boxes_get_type ())
-#define EMPATHY_THEME_BOXES(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_THEME_BOXES, EmpathyThemeBoxes))
-#define EMPATHY_THEME_BOXES_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_THEME_BOXES, EmpathyThemeBoxesClass))
-#define EMPATHY_IS_THEME_BOXES(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_THEME_BOXES))
-#define EMPATHY_IS_THEME_BOXES_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_THEME_BOXES))
-#define EMPATHY_THEME_BOXES_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_THEME_BOXES, EmpathyThemeBoxesClass))
-
-typedef struct _EmpathyThemeBoxes EmpathyThemeBoxes;
-typedef struct _EmpathyThemeBoxesClass EmpathyThemeBoxesClass;
-
-struct _EmpathyThemeBoxes {
- EmpathyChatTextView parent;
- gpointer priv;
-};
-
-struct _EmpathyThemeBoxesClass {
- EmpathyChatTextViewClass parent_class;
-};
-
-#define EMPATHY_THEME_BOXES_TAG_HEADER "fancy-header"
-#define EMPATHY_THEME_BOXES_TAG_HEADER_LINE "fancy-header-line"
-
-GType empathy_theme_boxes_get_type (void) G_GNUC_CONST;
-EmpathyThemeBoxes *empathy_theme_boxes_new (void);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_THEME_BOXES_H__ */
-
diff --git a/libempathy-gtk/empathy-theme-irc.c b/libempathy-gtk/empathy-theme-irc.c
deleted file mode 100644
index ed8e3b380..000000000
--- a/libempathy-gtk/empathy-theme-irc.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007 Imendio AB
- * Copyright (C) 2008 Collabora Ltd.
- *
- * 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., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#include "config.h"
-
-#include <glib/gi18n-lib.h>
-
-#include <libempathy/empathy-utils.h>
-#include "empathy-theme-irc.h"
-#include "empathy-ui-utils.h"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyThemeIrc)
-typedef struct {
- gpointer dummy;
-} EmpathyThemeIrcPriv;
-
-G_DEFINE_TYPE (EmpathyThemeIrc, empathy_theme_irc, EMPATHY_TYPE_CHAT_TEXT_VIEW);
-
-static void
-theme_irc_create_tags (EmpathyThemeIrc *theme)
-{
- GtkTextBuffer *buffer;
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (theme));
-
- gtk_text_buffer_create_tag (buffer, EMPATHY_THEME_IRC_TAG_NICK_SELF, NULL);
- gtk_text_buffer_create_tag (buffer, EMPATHY_THEME_IRC_TAG_NICK_OTHER, NULL);
- gtk_text_buffer_create_tag (buffer, EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT, NULL);
-}
-
-static void
-theme_irc_append_message (EmpathyChatTextView *view,
- EmpathyMessage *message,
- gboolean should_highlight)
-{
- GtkTextBuffer *buffer;
- const gchar *name;
- const gchar *nick_tag;
- GtkTextIter iter;
- gchar *tmp;
- EmpathyContact *contact;
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
-
- contact = empathy_message_get_sender (message);
- name = empathy_contact_get_logged_alias (contact);
-
- if (empathy_message_get_tptype (message) == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION) {
- tmp = g_strdup_printf (" * %s %s",
- empathy_contact_get_logged_alias (contact),
- empathy_message_get_body (message));
- empathy_chat_text_view_append_body (view, tmp,
- EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION);
- g_free (tmp);
- return;
- }
-
- if (empathy_contact_is_user (contact)) {
- nick_tag = EMPATHY_THEME_IRC_TAG_NICK_SELF;
- } else {
- if (should_highlight) {
- nick_tag = EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT;
- } else {
- nick_tag = EMPATHY_THEME_IRC_TAG_NICK_OTHER;
- }
- }
-
- gtk_text_buffer_get_end_iter (buffer, &iter);
-
- /* The nickname. */
- tmp = g_strdup_printf ("%s: ", name);
- gtk_text_buffer_insert_with_tags_by_name (buffer,
- &iter,
- tmp,
- -1,
- "cut",
- nick_tag,
- NULL);
- g_free (tmp);
-
- /* The text body. */
- empathy_chat_text_view_append_body (view,
- empathy_message_get_body (message),
- EMPATHY_CHAT_TEXT_VIEW_TAG_BODY);
-}
-
-static void
-empathy_theme_irc_class_init (EmpathyThemeIrcClass *class)
-{
- GObjectClass *object_class;
- EmpathyChatTextViewClass *chat_text_view_class;
-
- object_class = G_OBJECT_CLASS (class);
- chat_text_view_class = EMPATHY_CHAT_TEXT_VIEW_CLASS (class);
-
- chat_text_view_class->append_message = theme_irc_append_message;
-
- g_type_class_add_private (object_class, sizeof (EmpathyThemeIrcPriv));
-}
-
-static void
-empathy_theme_irc_init (EmpathyThemeIrc *theme)
-{
- EmpathyThemeIrcPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (theme,
- EMPATHY_TYPE_THEME_IRC, EmpathyThemeIrcPriv);
-
- theme->priv = priv;
-
- theme_irc_create_tags (theme);
-
- /* Define margin */
- g_object_set (theme,
- "left-margin", 3,
- "right-margin", 3,
- NULL);
-}
-
-EmpathyThemeIrc *
-empathy_theme_irc_new (void)
-{
- return g_object_new (EMPATHY_TYPE_THEME_IRC, NULL);
-}
-
diff --git a/libempathy-gtk/empathy-theme-irc.h b/libempathy-gtk/empathy-theme-irc.h
deleted file mode 100644
index 30bee6271..000000000
--- a/libempathy-gtk/empathy-theme-irc.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2007 Imendio AB
- * Copyright (C) 2008 Collabora Ltd.
- *
- * 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., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- */
-
-#ifndef __EMPATHY_THEME_IRC_H__
-#define __EMPATHY_THEME_IRC_H__
-
-#include <glib-object.h>
-
-#include "empathy-chat-text-view.h"
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_THEME_IRC (empathy_theme_irc_get_type ())
-#define EMPATHY_THEME_IRC(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_THEME_IRC, EmpathyThemeIrc))
-#define EMPATHY_THEME_IRC_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_THEME_IRC, EmpathyThemeIrcClass))
-#define EMPATHY_IS_THEME_IRC(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_THEME_IRC))
-#define EMPATHY_IS_THEME_IRC_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_THEME_IRC))
-#define EMPATHY_THEME_IRC_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_THEME_IRC, EmpathyThemeIrcClass))
-
-typedef struct _EmpathyThemeIrc EmpathyThemeIrc;
-typedef struct _EmpathyThemeIrcClass EmpathyThemeIrcClass;
-
-struct _EmpathyThemeIrc {
- EmpathyChatTextView parent;
- gpointer priv;
-};
-
-struct _EmpathyThemeIrcClass {
- EmpathyChatTextViewClass parent_class;
-};
-
-#define EMPATHY_THEME_IRC_TAG_NICK_SELF "irc-nick-self"
-#define EMPATHY_THEME_IRC_TAG_NICK_OTHER "irc-nick-other"
-#define EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT "irc-nick-highlight"
-
-GType empathy_theme_irc_get_type (void) G_GNUC_CONST;
-EmpathyThemeIrc *empathy_theme_irc_new (void);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_THEME_IRC_H__ */
-
diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c
index 1233509ec..a04a43a05 100644
--- a/libempathy-gtk/empathy-theme-manager.c
+++ b/libempathy-gtk/empathy-theme-manager.c
@@ -37,8 +37,6 @@
#include "empathy-theme-manager.h"
#include "empathy-chat-view.h"
#include "empathy-chat-text-view.h"
-#include "empathy-theme-boxes.h"
-#include "empathy-theme-irc.h"
#include "empathy-theme-adium.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
@@ -47,7 +45,6 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyThemeManager)
typedef struct {
GSettings *gsettings_chat;
- gchar *name;
GtkSettings *settings;
GList *boxes_views;
guint emit_changed_idle;
@@ -66,14 +63,6 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-static const gchar *themes[] = {
- "classic", N_("Classic"),
- "simple", N_("Simple"),
- "clean", N_("Clean"),
- "blue", N_("Blue"),
- NULL
-};
-
G_DEFINE_TYPE (EmpathyThemeManager, empathy_theme_manager, G_TYPE_OBJECT);
static gboolean
@@ -85,8 +74,8 @@ theme_manager_emit_changed_idle_cb (gpointer manager)
if (priv->adium_data) {
adium_path = empathy_adium_data_get_path (priv->adium_data);
}
- DEBUG ("Emit theme-changed with: name='%s' adium_path='%s' "
- "adium_variant='%s'", priv->name, adium_path,
+ DEBUG ("Emit theme-changed with: adium_path='%s' "
+ "adium_variant='%s'", adium_path,
priv->adium_variant);
g_signal_emit (manager, signals[THEME_CHANGED], 0, NULL);
@@ -127,6 +116,7 @@ clear_list_of_views (GList **views)
}
}
+#if 0
static void
theme_manager_gdk_color_to_hex (GdkColor *gdk_color, gchar *str_color)
{
@@ -136,243 +126,7 @@ theme_manager_gdk_color_to_hex (GdkColor *gdk_color, gchar *str_color)
gdk_color->green >> 8,
gdk_color->blue >> 8);
}
-
-static EmpathyThemeIrc *
-theme_manager_create_irc_view (EmpathyThemeManager *manager)
-{
- EmpathyChatTextView *view;
- EmpathyThemeIrc *theme;
-
- theme = empathy_theme_irc_new ();
- view = EMPATHY_CHAT_TEXT_VIEW (theme);
-
- /* Define base tags */
- empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING,
- "size", 2000,
- NULL);
- empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_TIME,
- "foreground", "darkgrey",
- "justification", GTK_JUSTIFY_CENTER,
- NULL);
- empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION,
- "foreground", "brown4",
- "style", PANGO_STYLE_ITALIC,
- NULL);
- empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_BODY,
- "foreground-set", FALSE,
- NULL);
- empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT,
- "foreground", "PeachPuff4",
- "justification", GTK_JUSTIFY_LEFT,
- NULL);
- empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK,
- "foreground", "steelblue",
- "underline", PANGO_UNDERLINE_SINGLE,
- NULL);
- empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_HIGHLIGHT,
- "background", "yellow",
- NULL);
-
- /* Define IRC tags */
- empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_SELF,
- "foreground", "sea green",
- NULL);
- empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_OTHER,
- "foreground", "skyblue4",
- NULL);
- empathy_chat_text_view_tag_set (view, EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT,
- "foreground", "indian red",
- "weight", PANGO_WEIGHT_BOLD,
- NULL);
-
- return theme;
-}
-
-static void on_style_set_cb (GtkWidget *widget, GtkStyle *previous_style, EmpathyThemeManager *self);
-
-static EmpathyThemeBoxes *
-theme_manager_create_boxes_view (EmpathyThemeManager *manager)
-{
- EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
- EmpathyThemeBoxes *theme;
-
- theme = empathy_theme_boxes_new ();
- priv->boxes_views = g_list_prepend (priv->boxes_views, theme);
- g_object_weak_ref (G_OBJECT (theme),
- 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;
-}
-
-static void
-theme_manager_update_boxes_tags (EmpathyThemeBoxes *theme,
- const gchar *header_foreground,
- const gchar *header_background,
- const gchar *header_line_background,
- const gchar *action_foreground,
- const gchar *time_foreground,
- const gchar *event_foreground,
- const gchar *link_foreground,
- const gchar *text_foreground,
- const gchar *text_background,
- const gchar *highlight_foreground)
-
-{
- EmpathyChatTextView *view = EMPATHY_CHAT_TEXT_VIEW (theme);
- GtkTextTag *tag;
-
- DEBUG ("Update view with new colors:\n"
- "header_foreground = %s\n"
- "header_background = %s\n"
- "header_line_background = %s\n"
- "action_foreground = %s\n"
- "time_foreground = %s\n"
- "event_foreground = %s\n"
- "link_foreground = %s\n"
- "text_foreground = %s\n"
- "text_background = %s\n"
- "highlight_foreground = %s\n",
- header_foreground, header_background, header_line_background,
- action_foreground, time_foreground, event_foreground,
- link_foreground, text_foreground, text_background,
- highlight_foreground);
-
-
- /* FIXME: GtkTextTag don't support to set color properties to NULL.
- * See bug #542523 */
-
- #define TAG_SET(prop, prop_set, value) \
- if (value != NULL) { \
- g_object_set (tag, prop, value, NULL); \
- } else { \
- g_object_set (tag, prop_set, FALSE, NULL); \
- }
-
- /* Define base tags */
- tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_HIGHLIGHT,
- "weight", PANGO_WEIGHT_BOLD,
- "pixels-above-lines", 4,
- NULL);
- TAG_SET ("paragraph-background", "paragraph-background-set", text_background);
- TAG_SET ("foreground", "foreground-set", highlight_foreground);
-
- empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_SPACING,
- "size", 3000,
- "pixels-above-lines", 8,
- NULL);
- tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_TIME,
- "justification", GTK_JUSTIFY_CENTER,
- NULL);
- TAG_SET ("foreground", "foreground-set", time_foreground);
- tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION,
- "style", PANGO_STYLE_ITALIC,
- "pixels-above-lines", 4,
- NULL);
- TAG_SET ("paragraph-background", "paragraph-background-set", text_background);
- TAG_SET ("foreground", "foreground-set", action_foreground);
- tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_BODY,
- "pixels-above-lines", 4,
- NULL);
- TAG_SET ("paragraph-background", "paragraph-background-set", text_background);
- TAG_SET ("foreground", "foreground-set", text_foreground);
- tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_EVENT,
- "justification", GTK_JUSTIFY_LEFT,
- NULL);
- TAG_SET ("foreground", "foreground-set", event_foreground);
- tag = empathy_chat_text_view_tag_set (view, EMPATHY_CHAT_TEXT_VIEW_TAG_LINK,
- "underline", PANGO_UNDERLINE_SINGLE,
- NULL);
- TAG_SET ("foreground", "foreground-set", link_foreground);
-
- /* Define BOXES tags */
- tag = empathy_chat_text_view_tag_set (view, EMPATHY_THEME_BOXES_TAG_HEADER,
- "weight", PANGO_WEIGHT_BOLD,
- NULL);
- TAG_SET ("foreground", "foreground-set", header_foreground);
- TAG_SET ("paragraph-background", "paragraph-background-set", header_background);
- tag = empathy_chat_text_view_tag_set (view, EMPATHY_THEME_BOXES_TAG_HEADER_LINE,
- "size", 1,
- NULL);
- TAG_SET ("paragraph-background", "paragraph-background-set", header_line_background);
-
- #undef TAG_SET
-}
-
-static void
-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);
- theme_manager_gdk_color_to_hex (&style->bg[GTK_STATE_SELECTED], color2);
- theme_manager_gdk_color_to_hex (&style->dark[GTK_STATE_SELECTED], color3);
- theme_manager_gdk_color_to_hex (&style->fg[GTK_STATE_SELECTED], color4);
-
- theme_manager_update_boxes_tags (EMPATHY_THEME_BOXES (widget),
- color4, /* header_foreground */
- color2, /* header_background */
- color3, /* header_line_background */
- color1, /* action_foreground */
- "darkgrey", /* time_foreground */
- "darkgrey", /* event_foreground */
- color1, /* link_foreground */
- NULL, /* text_foreground */
- NULL, /* text_background */
- NULL); /* highlight_foreground */
-}
-
-static void
-theme_manager_update_boxes_theme (EmpathyThemeManager *manager,
- EmpathyThemeBoxes *theme)
-{
- EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
-
- if (strcmp (priv->name, "simple") == 0) {
- on_style_set_cb (GTK_WIDGET (theme), NULL, manager);
- }
- else if (strcmp (priv->name, "clean") == 0) {
- theme_manager_update_boxes_tags (theme,
- "black", /* header_foreground */
- "#efefdf", /* header_background */
- "#e3e3d3", /* header_line_background */
- "brown4", /* action_foreground */
- "darkgrey", /* time_foreground */
- "darkgrey", /* event_foreground */
- "#49789e", /* link_foreground */
- NULL, /* text_foreground */
- NULL, /* text_background */
- NULL); /* highlight_foreground */
- }
- else if (strcmp (priv->name, "blue") == 0) {
- theme_manager_update_boxes_tags (theme,
- "black", /* header_foreground */
- "#88a2b4", /* header_background */
- "#7f96a4", /* header_line_background */
- "brown4", /* action_foreground */
- "darkgrey", /* time_foreground */
- "#7f96a4", /* event_foreground */
- "#49789e", /* link_foreground */
- "black", /* text_foreground */
- "#adbdc8", /* text_background */
- "black"); /* highlight_foreground */
- }
-}
+#endif
static EmpathyThemeAdium *
theme_manager_create_adium_view (EmpathyThemeManager *manager)
@@ -458,114 +212,14 @@ EmpathyChatView *
empathy_theme_manager_create_view (EmpathyThemeManager *manager)
{
EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
- EmpathyThemeBoxes *theme;
g_return_val_if_fail (EMPATHY_IS_THEME_MANAGER (manager), NULL);
- DEBUG ("Using theme %s", priv->name);
-
- if (strcmp (priv->name, "adium") == 0 && priv->adium_data != NULL) {
+ if (priv->adium_data != NULL) {
return EMPATHY_CHAT_VIEW (theme_manager_create_adium_view (manager));
}
- if (strcmp (priv->name, "classic") == 0) {
- return EMPATHY_CHAT_VIEW (theme_manager_create_irc_view (manager));
- }
-
- theme = theme_manager_create_boxes_view (manager);
- theme_manager_update_boxes_theme (manager, theme);
-
- return EMPATHY_CHAT_VIEW (theme);
-}
-
-static gboolean
-theme_manager_ensure_theme_exists (const gchar *name)
-{
- gint i;
-
- if (EMP_STR_EMPTY (name)) {
- return FALSE;
- }
-
- if (strcmp ("adium", name) == 0) {
- return TRUE;
- }
-
- for (i = 0; themes[i]; i += 2) {
- if (strcmp (themes[i], name) == 0) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-typedef enum {
- THEME_TYPE_IRC,
- THEME_TYPE_BOXED,
- THEME_TYPE_ADIUM,
-} ThemeType;
-
-static ThemeType
-theme_type (const gchar *name)
-{
- if (!tp_strdiff (name, "classic")) {
- return THEME_TYPE_IRC;
- } else if (!tp_strdiff (name, "adium")) {
- return THEME_TYPE_ADIUM;
- } else {
- return THEME_TYPE_BOXED;
- }
-}
-
-static void
-theme_manager_notify_name_cb (GSettings *gsettings_chat,
- const gchar *key,
- gpointer user_data)
-{
- EmpathyThemeManager *manager = EMPATHY_THEME_MANAGER (user_data);
- EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
- gchar *name;
- ThemeType old_type;
- ThemeType new_type;
-
- name = g_settings_get_string (gsettings_chat, key);
-
- /* Fallback to classic theme if current setting does not exist */
- if (!theme_manager_ensure_theme_exists (name)) {
- g_free (name);
- name = g_strdup ("classic");
- }
-
- /* If theme did not change, nothing to do */
- if (!tp_strdiff (priv->name, name)) {
- g_free (name);
- return;
- }
-
- old_type = theme_type (priv->name);
- g_free (priv->name);
- priv->name = name;
- new_type = theme_type (priv->name);
-
- if (new_type == THEME_TYPE_BOXED) {
- GList *l;
-
- /* The theme changes to a boxed one, we can update boxed views */
- for (l = priv->boxes_views; l; l = l->next) {
- theme_manager_update_boxes_theme (manager,
- EMPATHY_THEME_BOXES (l->data));
- }
- }
-
- /* Do not emit theme-changed if theme type didn't change. If theme
- * changed from a boxed to another boxed, all view are updated in place.
- * If theme changed from an adium to another adium, the signal will be
- * emited from theme_manager_notify_adium_path_cb ()
- */
- if (old_type != new_type) {
- theme_manager_emit_changed (manager);
- }
+ g_return_val_if_reached (NULL);
}
static void
@@ -574,7 +228,6 @@ theme_manager_finalize (GObject *object)
EmpathyThemeManagerPriv *priv = GET_PRIV (object);
g_object_unref (priv->gsettings_chat);
- g_free (priv->name);
if (priv->emit_changed_idle != 0) {
g_source_remove (priv->emit_changed_idle);
@@ -620,15 +273,6 @@ empathy_theme_manager_init (EmpathyThemeManager *manager)
priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
- /* Take the theme name and track changes */
- g_signal_connect (priv->gsettings_chat,
- "changed::" EMPATHY_PREFS_CHAT_THEME,
- G_CALLBACK (theme_manager_notify_name_cb),
- manager);
- theme_manager_notify_name_cb (priv->gsettings_chat,
- EMPATHY_PREFS_CHAT_THEME,
- manager);
-
/* Take the adium path/variant and track changes */
g_signal_connect (priv->gsettings_chat,
"changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH,
@@ -663,12 +307,6 @@ empathy_theme_manager_dup_singleton (void)
return g_object_ref (manager);
}
-const gchar **
-empathy_theme_manager_get_themes (void)
-{
- return themes;
-}
-
static void
find_themes (GList **list, const gchar *dirpath)
{