#include <glib/gi18n-lib.h>
#include <webkit/webkit.h>
-#include <telepathy-glib/dbus.h>
-#include <telepathy-glib/util.h>
+#include <telepathy-glib/telepathy-glib.h>
#include <pango/pango.h>
#include <gdk/gdk.h>
GPtrArray *strings_to_free;
};
-static void theme_adium_iface_init (EmpathyChatViewIface *iface);
-
static gchar * adium_info_dup_path_for_variant (GHashTable *info,
const gchar *variant);
PROP_VARIANT,
};
-G_DEFINE_TYPE_WITH_CODE (EmpathyThemeAdium, empathy_theme_adium,
- WEBKIT_TYPE_WEB_VIEW,
- G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CHAT_VIEW,
- theme_adium_iface_init));
+G_DEFINE_TYPE (EmpathyThemeAdium, empathy_theme_adium,
+ WEBKIT_TYPE_WEB_VIEW)
enum
{
}
static void
-theme_adium_append_event_escaped (EmpathyChatView *view,
+theme_adium_append_event_escaped (EmpathyThemeAdium *self,
const gchar *escaped)
{
- EmpathyThemeAdium *self = EMPATHY_THEME_ADIUM (view);
-
theme_adium_append_html (self, "appendMessage",
self->priv->data->status_html, escaped, NULL, NULL, NULL,
NULL, "event", empathy_time_get_current (), FALSE, FALSE);
theme_adium_remove_focus_marks (self, nodes);
}
-static void
-theme_adium_append_message (EmpathyChatView *view,
+void
+empathy_theme_adium_append_message (EmpathyThemeAdium *self,
EmpathyMessage *msg,
gboolean should_highlight)
{
- EmpathyThemeAdium *self = EMPATHY_THEME_ADIUM (view);
EmpathyContact *sender;
TpMessage *tp_msg;
TpAccount *account;
sender = empathy_message_get_sender (msg);
account = empathy_contact_get_account (sender);
service_name = empathy_protocol_name_to_display_name
- (tp_account_get_protocol (account));
+ (tp_account_get_protocol_name (account));
if (service_name == NULL)
- service_name = tp_account_get_protocol (account);
+ service_name = tp_account_get_protocol_name (account);
timestamp = empathy_message_get_timestamp (msg);
body_escaped = theme_adium_parse_body (self,
empathy_message_get_body (msg),
g_string_free (message_classes, TRUE);
}
-static void
-theme_adium_append_event (EmpathyChatView *view,
+void
+empathy_theme_adium_append_event (EmpathyThemeAdium *self,
const gchar *str)
{
- EmpathyThemeAdium *self = EMPATHY_THEME_ADIUM (view);
gchar *str_escaped;
if (self->priv->pages_loading != 0)
}
str_escaped = g_markup_escape_text (str, -1);
- theme_adium_append_event_escaped (view, str_escaped);
+ theme_adium_append_event_escaped (self, str_escaped);
g_free (str_escaped);
}
-static void
-theme_adium_append_event_markup (EmpathyChatView *view,
+void
+empathy_theme_adium_append_event_markup (EmpathyThemeAdium *self,
const gchar *markup_text,
const gchar *fallback_text)
{
- theme_adium_append_event_escaped (view, markup_text);
+ theme_adium_append_event_escaped (self, markup_text);
}
-static void
-theme_adium_edit_message (EmpathyChatView *view,
+void
+empathy_theme_adium_edit_message (EmpathyThemeAdium *self,
EmpathyMessage *message)
{
- EmpathyThemeAdium *self = EMPATHY_THEME_ADIUM (view);
WebKitDOMDocument *doc;
WebKitDOMElement *span;
gchar *id, *parsed_body;
empathy_message_get_supersedes (message));
/* we don't pass a token here, because doing so will return another
* <span> element, and we don't want nested <span> elements */
- parsed_body = theme_adium_parse_body (EMPATHY_THEME_ADIUM (view),
+ parsed_body = theme_adium_parse_body (self,
empathy_message_get_body (message), NULL);
/* find the element */
- doc = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
+ doc = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (self));
span = webkit_dom_document_get_element_by_id (doc, id);
if (span == NULL)
g_free (parsed_body);
}
-static void
-theme_adium_scroll (EmpathyChatView *view,
+void
+empathy_theme_adium_scroll (EmpathyThemeAdium *self,
gboolean allow_scrolling)
{
- EmpathyThemeAdium *self = EMPATHY_THEME_ADIUM (view);
-
self->priv->allow_scrolling = allow_scrolling;
if (allow_scrolling)
- empathy_chat_view_scroll_down (view);
+ empathy_theme_adium_scroll_down (self);
}
-static void
-theme_adium_scroll_down (EmpathyChatView *view)
+void
+empathy_theme_adium_scroll_down (EmpathyThemeAdium *self)
{
- webkit_web_view_execute_script (WEBKIT_WEB_VIEW (view), "alignChat(true);");
+ webkit_web_view_execute_script (WEBKIT_WEB_VIEW (self), "alignChat(true);");
}
-static gboolean
-theme_adium_get_has_selection (EmpathyChatView *view)
+gboolean
+empathy_theme_adium_get_has_selection (EmpathyThemeAdium *self)
{
- return webkit_web_view_has_selection (WEBKIT_WEB_VIEW (view));
+ return webkit_web_view_has_selection (WEBKIT_WEB_VIEW (self));
}
-static void
-theme_adium_clear (EmpathyChatView *view)
+void
+empathy_theme_adium_clear (EmpathyThemeAdium *self)
{
- EmpathyThemeAdium *self = EMPATHY_THEME_ADIUM (view);
-
- theme_adium_load_template (EMPATHY_THEME_ADIUM (view));
+ theme_adium_load_template (self);
/* Clear last contact to avoid trying to add a 'joined'
* message when we don't have an insertion point. */
}
}
-static gboolean
-theme_adium_find_previous (EmpathyChatView *view,
+gboolean
+empathy_theme_adium_find_previous (EmpathyThemeAdium *self,
const gchar *search_criteria,
gboolean new_search,
gboolean match_case)
{
/* FIXME: Doesn't respect new_search */
- return webkit_web_view_search_text (WEBKIT_WEB_VIEW (view),
+ return webkit_web_view_search_text (WEBKIT_WEB_VIEW (self),
search_criteria, match_case, FALSE, TRUE);
}
-static gboolean
-theme_adium_find_next (EmpathyChatView *view,
+gboolean
+empathy_theme_adium_find_next (EmpathyThemeAdium *self,
const gchar *search_criteria,
gboolean new_search,
gboolean match_case)
{
/* FIXME: Doesn't respect new_search */
- return webkit_web_view_search_text (WEBKIT_WEB_VIEW (view),
+ return webkit_web_view_search_text (WEBKIT_WEB_VIEW (self),
search_criteria, match_case, TRUE, TRUE);
}
-static void
-theme_adium_find_abilities (EmpathyChatView *view,
+void
+empathy_theme_adium_find_abilities (EmpathyThemeAdium *self,
const gchar *search_criteria,
gboolean match_case,
gboolean *can_do_previous,
*can_do_next = TRUE;
}
-static void
-theme_adium_highlight (EmpathyChatView *view,
+void
+empathy_theme_adium_highlight (EmpathyThemeAdium *self,
const gchar *text,
gboolean match_case)
{
- webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (view));
- webkit_web_view_mark_text_matches (WEBKIT_WEB_VIEW (view),
+ webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (self));
+ webkit_web_view_mark_text_matches (WEBKIT_WEB_VIEW (self),
text, match_case, 0);
- webkit_web_view_set_highlight_text_matches (WEBKIT_WEB_VIEW (view),
+ webkit_web_view_set_highlight_text_matches (WEBKIT_WEB_VIEW (self),
TRUE);
}
-static void
-theme_adium_copy_clipboard (EmpathyChatView *view)
+void
+empathy_theme_adium_copy_clipboard (EmpathyThemeAdium *self)
{
- webkit_web_view_copy_clipboard (WEBKIT_WEB_VIEW (view));
+ webkit_web_view_copy_clipboard (WEBKIT_WEB_VIEW (self));
}
static void
theme_adium_remove_mark_from_message (self, id);
}
-static void
-theme_adium_focus_toggled (EmpathyChatView *view,
+void
+empathy_theme_adium_focus_toggled (EmpathyThemeAdium *self,
gboolean has_focus)
{
- EmpathyThemeAdium *self = EMPATHY_THEME_ADIUM (view);
-
self->priv->has_focus = has_focus;
if (!self->priv->has_focus)
{
/* We've lost focus, so let's make sure all the acked
* messages have lost their unread marker. */
g_queue_foreach (&self->priv->acked_messages,
- theme_adium_remove_acked_message_unread_mark_foreach, view);
+ theme_adium_remove_acked_message_unread_mark_foreach, self);
g_queue_clear (&self->priv->acked_messages);
self->priv->has_unread_message = FALSE;
}
}
-static void
-theme_adium_message_acknowledged (EmpathyChatView *view,
+void
+empathy_theme_adium_message_acknowledged (EmpathyThemeAdium *self,
EmpathyMessage *message)
{
- EmpathyThemeAdium *self = (EmpathyThemeAdium *) view;
TpMessage *tp_msg;
guint32 id;
gboolean valid;
empathy_theme_adium_parent_class)->button_press_event (widget, event);
}
-static void
-theme_adium_set_show_avatars (EmpathyChatView *view,
+void
+empathy_theme_adium_set_show_avatars (EmpathyThemeAdium *self,
gboolean show_avatars)
{
- EmpathyThemeAdium *self = EMPATHY_THEME_ADIUM (view);
-
self->priv->show_avatars = show_avatars;
}
-static void
-theme_adium_iface_init (EmpathyChatViewIface *iface)
-{
- iface->append_message = theme_adium_append_message;
- iface->append_event = theme_adium_append_event;
- iface->append_event_markup = theme_adium_append_event_markup;
- iface->edit_message = theme_adium_edit_message;
- iface->scroll = theme_adium_scroll;
- iface->scroll_down = theme_adium_scroll_down;
- iface->get_has_selection = theme_adium_get_has_selection;
- iface->clear = theme_adium_clear;
- iface->find_previous = theme_adium_find_previous;
- iface->find_next = theme_adium_find_next;
- iface->find_abilities = theme_adium_find_abilities;
- iface->highlight = theme_adium_highlight;
- iface->copy_clipboard = theme_adium_copy_clipboard;
- iface->focus_toggled = theme_adium_focus_toggled;
- iface->message_acknowledged = theme_adium_message_acknowledged;
- iface->set_show_avatars = theme_adium_set_show_avatars;
-}
-
static void
theme_adium_load_finished_cb (WebKitWebView *view,
WebKitWebFrame *frame,
gpointer user_data)
{
EmpathyThemeAdium *self = EMPATHY_THEME_ADIUM (view);
- EmpathyChatView *chat_view = EMPATHY_CHAT_VIEW (view);
GList *l;
DEBUG ("Page loaded");
switch (item->type)
{
case QUEUED_MESSAGE:
- theme_adium_append_message (chat_view, item->msg,
+ empathy_theme_adium_append_message (self, item->msg,
item->should_highlight);
break;
case QUEUED_EDIT:
- theme_adium_edit_message (chat_view, item->msg);
+ empathy_theme_adium_edit_message (self, item->msg);
break;
case QUEUED_EVENT:
- theme_adium_append_event (chat_view, item->str);
+ empathy_theme_adium_append_event (self, item->str);
break;
}
g_object_unref (self->priv->gsettings_chat);
g_object_unref (self->priv->gsettings_desktop);
+ g_free (self->priv->variant);
+
G_OBJECT_CLASS (empathy_theme_adium_parent_class)->finalize (object);
}
{
gboolean ret;
gchar *file;
+ gchar **tmp;
+ const gchar *dir;
if (path[0] != '/')
return FALSE;
+ /* The directory has to be *.AdiumMessageStyle per the Adium spec */
+ tmp = g_strsplit (path, "/", 0);
+ if (tmp == NULL)
+ return FALSE;
+
+ dir = tmp[g_strv_length (tmp) - 1];
+
+ if (!g_str_has_suffix (dir, ".AdiumMessageStyle"))
+ {
+ g_strfreev (tmp);
+ return FALSE;
+ }
+
+ g_strfreev (tmp);
+
/* The theme is not valid if there is no Info.plist */
file = g_build_filename (path, "Contents", "Info.plist",
NULL);