]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-theme-adium.c
individual_view_drag_end: remove the auto scroll
[empathy.git] / libempathy-gtk / empathy-theme-adium.c
index 8877a2796f4ee72bcb355d19b000ddfcd330510b..98df46b79a9de43ee019f56544b9a46e0a461e33 100644 (file)
@@ -132,13 +132,15 @@ typedef struct {
        guint type;
        EmpathyMessage *msg;
        char *str;
+       gboolean should_highlight;
 } QueuedItem;
 
 static QueuedItem *
 queue_item (GQueue *queue,
            guint type,
            EmpathyMessage *msg,
-           const char *str)
+           const char *str,
+           gboolean should_highlight)
 {
        QueuedItem *item = g_slice_new0 (QueuedItem);
 
@@ -146,6 +148,7 @@ queue_item (GQueue *queue,
        if (msg != NULL)
                item->msg = g_object_ref (msg);
        item->str = g_strdup (str);
+       item->should_highlight = should_highlight;
 
        g_queue_push_tail (queue, item);
 
@@ -775,14 +778,15 @@ theme_adium_remove_all_focus_marks (EmpathyThemeAdium *theme)
 
 static void
 theme_adium_append_message (EmpathyChatView *view,
-                           EmpathyMessage  *msg)
+                           EmpathyMessage  *msg,
+                           gboolean         should_highlight)
 {
        EmpathyThemeAdium     *theme = EMPATHY_THEME_ADIUM (view);
        EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
        EmpathyContact        *sender;
        TpMessage             *tp_msg;
        TpAccount             *account;
-       gchar                 *body_escaped;
+       gchar                 *body_escaped, *name_escaped;
        const gchar           *name;
        const gchar           *contact_id;
        EmpathyAvatar         *avatar;
@@ -797,7 +801,7 @@ theme_adium_append_message (EmpathyChatView *view,
        gboolean               action;
 
        if (priv->pages_loading != 0) {
-               queue_item (&priv->message_queue, QUEUED_MESSAGE, msg, NULL);
+               queue_item (&priv->message_queue, QUEUED_MESSAGE, msg, NULL, should_highlight);
                return;
        }
 
@@ -816,6 +820,8 @@ theme_adium_append_message (EmpathyChatView *view,
        contact_id = empathy_contact_get_id (sender);
        action = (empathy_message_get_tptype (msg) == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION);
 
+       name_escaped = g_markup_escape_text (name, -1);
+
        /* If this is a /me probably */
        if (action) {
                gchar *str;
@@ -823,7 +829,7 @@ theme_adium_append_message (EmpathyChatView *view,
                if (priv->data->version >= 4 || !priv->data->custom_template) {
                        str = g_strdup_printf ("<span class='actionMessageUserName'>%s</span>"
                                               "<span class='actionMessageBody'>%s</span>",
-                                              name, body_escaped);
+                                              name_escaped, body_escaped);
                } else {
                        str = g_strdup_printf ("*%s*", body_escaped);
                }
@@ -884,7 +890,7 @@ theme_adium_append_message (EmpathyChatView *view,
        } else {
                g_string_append (message_classes, " incoming");
        }
-       if (empathy_message_should_highlight (msg)) {
+       if (should_highlight) {
                g_string_append (message_classes, " mention");
        }
        if (empathy_message_get_tptype (msg) == TP_CHANNEL_TEXT_MESSAGE_TYPE_AUTO_REPLY) {
@@ -948,7 +954,7 @@ theme_adium_append_message (EmpathyChatView *view,
        }
 
        theme_adium_append_html (theme, func, html, body_escaped,
-                                avatar_filename, name, contact_id,
+                                avatar_filename, name_escaped, contact_id,
                                 service_name, message_classes->str,
                                 timestamp, is_backlog, empathy_contact_is_user (sender));
 
@@ -961,6 +967,7 @@ theme_adium_append_message (EmpathyChatView *view,
        priv->last_is_backlog = is_backlog;
 
        g_free (body_escaped);
+       g_free (name_escaped);
        g_string_free (message_classes, TRUE);
 }
 
@@ -972,7 +979,7 @@ theme_adium_append_event (EmpathyChatView *view,
        gchar *str_escaped;
 
        if (priv->pages_loading != 0) {
-               queue_item (&priv->message_queue, QUEUED_EVENT, NULL, str);
+               queue_item (&priv->message_queue, QUEUED_EVENT, NULL, str, FALSE);
                return;
        }
 
@@ -981,6 +988,14 @@ theme_adium_append_event (EmpathyChatView *view,
        g_free (str_escaped);
 }
 
+static void
+theme_adium_append_event_markup (EmpathyChatView *view,
+                                const gchar     *markup_text,
+                                const gchar     *fallback_text)
+{
+       theme_adium_append_event_escaped (view, markup_text);
+}
+
 static void
 theme_adium_edit_message (EmpathyChatView *view,
                          EmpathyMessage  *message)
@@ -994,7 +1009,7 @@ theme_adium_edit_message (EmpathyChatView *view,
        GError *error = NULL;
 
        if (priv->pages_loading != 0) {
-               queue_item (&priv->message_queue, QUEUED_EDIT, message, NULL);
+               queue_item (&priv->message_queue, QUEUED_EDIT, message, NULL, FALSE);
                return;
        }
 
@@ -1297,6 +1312,7 @@ 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;
@@ -1333,7 +1349,8 @@ theme_adium_load_finished_cb (WebKitWebView  *view,
                switch (item->type)
                {
                        case QUEUED_MESSAGE:
-                               theme_adium_append_message (chat_view, item->msg);
+                               theme_adium_append_message (chat_view, item->msg,
+                                       item->should_highlight);
                                break;
 
                        case QUEUED_EDIT:
@@ -1753,8 +1770,11 @@ adium_info_dup_path_for_variant (GHashTable *info,
                return g_strdup ("main.css");
        }
 
-       /* Verify the variant exists, fallback to the first one */
        variants = empathy_adium_info_get_available_variants (info);
+       if (variants->len == 0)
+               return g_strdup ("main.css");
+
+       /* Verify the variant exists, fallback to the first one */
        for (i = 0; i < variants->len; i++) {
                if (!tp_strdiff (variant, g_ptr_array_index (variants, i))) {
                        break;
@@ -1929,8 +1949,16 @@ empathy_adium_data_new_with_info (const gchar *path, GHashTable *info)
        /* template -> empathy's template */
        data->custom_template = (template_html != NULL);
        if (template_html == NULL) {
+               GError *error = NULL;
+
                tmp = empathy_file_lookup ("Template.html", "data");
-               g_file_get_contents (tmp, &template_html, NULL, NULL);
+
+               if (!g_file_get_contents (tmp, &template_html, NULL, &error)) {
+                       g_warning ("couldn't load Empathy's default theme "
+                               "template: %s", error->message);
+                       g_return_val_if_reached (data);
+               }
+
                g_free (tmp);
        }