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);
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);
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;
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;
}
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;
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);
}
} 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) {
}
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));
priv->last_is_backlog = is_backlog;
g_free (body_escaped);
+ g_free (name_escaped);
g_string_free (message_classes, TRUE);
}
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;
}
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)
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;
}
{
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;
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:
g_object_notify (G_OBJECT (theme), "variant");
}
+void
+empathy_theme_adium_show_inspector (EmpathyThemeAdium *theme)
+{
+ WebKitWebView *web_view = WEBKIT_WEB_VIEW (theme);
+ WebKitWebInspector *inspector;
+
+ g_object_set (G_OBJECT (webkit_web_view_get_settings (web_view)),
+ "enable-developer-extras", TRUE,
+ NULL);
+
+ inspector = webkit_web_view_get_inspector (web_view);
+ webkit_web_inspector_show (inspector);
+}
+
gboolean
empathy_adium_path_is_valid (const gchar *path)
{
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;
/* 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);
}