aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-09-05 18:17:58 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2013-09-05 18:17:58 +0200
commit44d14782870339fb1702ba42d26f43755c064e0d (patch)
treecc5647c8704548b636a437fa99979f7a82622c0b /src
parent9360d9d049592357e544fa3ab85ab603145cf989 (diff)
downloadayatana-indicator-messages-44d14782870339fb1702ba42d26f43755c064e0d.tar.gz
ayatana-indicator-messages-44d14782870339fb1702ba42d26f43755c064e0d.tar.bz2
ayatana-indicator-messages-44d14782870339fb1702ba42d26f43755c064e0d.zip
Use serialized icons for messages and sources
The D-Bus protocol is not part of the public API, so it's okay to change it.
Diffstat (limited to 'src')
-rw-r--r--src/im-application-list.c50
-rw-r--r--src/im-desktop-menu.c14
-rw-r--r--src/im-phone-menu.c6
-rw-r--r--src/im-phone-menu.h2
4 files changed, 47 insertions, 25 deletions
diff --git a/src/im-application-list.c b/src/im-application-list.c
index bbe4be3..96ef5fd 100644
--- a/src/im-application-list.c
+++ b/src/im-application-list.c
@@ -467,7 +467,7 @@ im_application_list_class_init (ImApplicationListClass *klass)
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
- G_TYPE_STRING);
+ G_TYPE_VARIANT);
signals[SOURCE_CHANGED] = g_signal_new ("source-changed",
IM_TYPE_APPLICATION_LIST,
@@ -505,7 +505,7 @@ im_application_list_class_init (ImApplicationListClass *klass)
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
- G_TYPE_STRING,
+ G_TYPE_VARIANT,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
@@ -768,16 +768,20 @@ im_application_list_source_added (Application *app,
{
const gchar *id;
const gchar *label;
- const gchar *iconstr;
+ GVariant *maybe_serialized_icon;
guint32 count;
gint64 time;
const gchar *string;
gboolean draws_attention;
+ GVariant *serialized_icon = NULL;
GVariant *state;
GSimpleAction *action;
- g_variant_get (source, "(&s&s&sux&sb)",
- &id, &label, &iconstr, &count, &time, &string, &draws_attention);
+ g_variant_get (source, "(&s&s@avux&sb)",
+ &id, &label, &maybe_serialized_icon, &count, &time, &string, &draws_attention);
+
+ if (g_variant_n_children (maybe_serialized_icon) == 1)
+ g_variant_get_child (maybe_serialized_icon, 0, "v", &serialized_icon);
state = g_variant_new ("(uxsb)", count, time, string, draws_attention);
action = g_simple_action_new_stateful (id, G_VARIANT_TYPE_BOOLEAN, state);
@@ -785,7 +789,7 @@ im_application_list_source_added (Application *app,
g_action_map_add_action (G_ACTION_MAP(app->source_actions), G_ACTION (action));
- g_signal_emit (app->list, signals[SOURCE_ADDED], 0, app->id, id, label, iconstr);
+ g_signal_emit (app->list, signals[SOURCE_ADDED], 0, app->id, id, label, serialized_icon);
if (draws_attention)
app->draws_attention = TRUE;
@@ -793,6 +797,9 @@ im_application_list_source_added (Application *app,
im_application_list_update_draws_attention (app->list);
g_object_unref (action);
+ if (serialized_icon)
+ g_variant_unref (serialized_icon);
+ g_variant_unref (maybe_serialized_icon);
}
static void
@@ -801,25 +808,33 @@ im_application_list_source_changed (Application *app,
{
const gchar *id;
const gchar *label;
- const gchar *iconstr;
+ GVariant *maybe_serialized_icon;
guint32 count;
gint64 time;
const gchar *string;
gboolean draws_attention;
+ GVariant *serialized_icon = NULL;
gboolean visible;
- g_variant_get (source, "(&s&s&sux&sb)",
- &id, &label, &iconstr, &count, &time, &string, &draws_attention);
+ g_variant_get (source, "(&s&s@avux&sb)",
+ &id, &label, &maybe_serialized_icon, &count, &time, &string, &draws_attention);
+
+ if (g_variant_n_children (maybe_serialized_icon) == 1)
+ g_variant_get_child (maybe_serialized_icon, 0, "v", &serialized_icon);
g_action_group_change_action_state (G_ACTION_GROUP (app->source_actions), id,
g_variant_new ("(uxsb)", count, time, string, draws_attention));
visible = count > 0;
- g_signal_emit (app->list, signals[SOURCE_CHANGED], 0, app->id, id, label, iconstr, visible);
+ g_signal_emit (app->list, signals[SOURCE_CHANGED], 0, app->id, id, label, serialized_icon, visible);
app->draws_attention = visible && draws_attention;
im_application_list_update_draws_attention (app->list);
+
+ if (serialized_icon)
+ g_variant_unref (serialized_icon);
+ g_variant_unref (maybe_serialized_icon);
}
static void
@@ -885,20 +900,24 @@ im_application_list_message_added (Application *app,
GVariant *message)
{
const gchar *id;
- const gchar *iconstr;
+ GVariant *maybe_serialized_icon;
const gchar *title;
const gchar *subtitle;
const gchar *body;
gint64 time;
GVariantIter *action_iter;
gboolean draws_attention;
+ GVariant *serialized_icon = NULL;
GSimpleAction *action;
GIcon *app_icon;
gchar *app_iconstr = NULL;
GVariant *actions = NULL;
- g_variant_get (message, "(&s&s&s&s&sxaa{sv}b)",
- &id, &iconstr, &title, &subtitle, &body, &time, &action_iter, &draws_attention);
+ g_variant_get (message, "(&s@av&s&s&sxaa{sv}b)",
+ &id, &maybe_serialized_icon, &title, &subtitle, &body, &time, &action_iter, &draws_attention);
+
+ if (g_variant_n_children (maybe_serialized_icon) == 1)
+ serialized_icon = g_variant_get_child_value (maybe_serialized_icon, 0);
app_icon = g_app_info_get_icon (G_APP_INFO (app->info));
if (app_icon)
@@ -981,12 +1000,15 @@ im_application_list_message_added (Application *app,
im_application_list_update_draws_attention (app->list);
g_signal_emit (app->list, signals[MESSAGE_ADDED], 0,
- app->id, app_iconstr, id, iconstr, title,
+ app->id, app_iconstr, id, serialized_icon, title,
subtitle, body, actions, time, draws_attention);
g_variant_iter_free (action_iter);
g_free (app_iconstr);
g_object_unref (action);
+ if (serialized_icon)
+ g_object_unref (serialized_icon);
+ g_variant_unref (maybe_serialized_icon);
}
static void
diff --git a/src/im-desktop-menu.c b/src/im-desktop-menu.c
index 5707390..923ad91 100644
--- a/src/im-desktop-menu.c
+++ b/src/im-desktop-menu.c
@@ -109,7 +109,7 @@ static void
im_desktop_menu_source_section_insert_source (GMenu *source_section,
const gchar *source_id,
const gchar *label,
- const gchar *icon,
+ GVariant *serialized_icon,
gint pos)
{
GMenuItem *item;
@@ -119,8 +119,8 @@ im_desktop_menu_source_section_insert_source (GMenu *source_section,
item = g_menu_item_new (label, NULL);
g_menu_item_set_action_and_target_value (item, action, NULL);
g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.messages.source");
- if (icon && *icon)
- g_menu_item_set_attribute (item, "icon", "s", icon);
+ if (serialized_icon)
+ g_menu_item_set_attribute_value (item, "icon", serialized_icon);
if (pos >= 0)
g_menu_insert_item (source_section, pos, item);
@@ -169,7 +169,7 @@ im_desktop_menu_source_added (ImApplicationList *applist,
const gchar *app_id,
const gchar *source_id,
const gchar *label,
- const gchar *icon,
+ GVariant *serialized_icon,
gpointer user_data)
{
ImDesktopMenu *menu = user_data;
@@ -178,7 +178,7 @@ im_desktop_menu_source_added (ImApplicationList *applist,
source_section = g_hash_table_lookup (menu->source_sections, app_id);
g_return_if_fail (source_section != NULL);
- im_desktop_menu_source_section_insert_source (source_section, source_id, label, icon, -1);
+ im_desktop_menu_source_section_insert_source (source_section, source_id, label, serialized_icon, -1);
}
static void
@@ -204,7 +204,7 @@ im_desktop_menu_source_changed (ImApplicationList *applist,
const gchar *app_id,
const gchar *source_id,
const gchar *label,
- const gchar *icon,
+ GVariant *serialized_icon,
gboolean visible,
gpointer user_data)
{
@@ -221,7 +221,7 @@ im_desktop_menu_source_changed (ImApplicationList *applist,
g_menu_remove (section, pos);
if (visible)
- im_desktop_menu_source_section_insert_source (section, source_id, label, icon, pos);
+ im_desktop_menu_source_section_insert_source (section, source_id, label, serialized_icon, pos);
}
static void
diff --git a/src/im-phone-menu.c b/src/im-phone-menu.c
index a9c5977..54e32be 100644
--- a/src/im-phone-menu.c
+++ b/src/im-phone-menu.c
@@ -153,7 +153,7 @@ im_phone_menu_add_message (ImPhoneMenu *menu,
const gchar *app_id,
const gchar *app_icon,
const gchar *id,
- const gchar *iconstr,
+ GVariant *serialized_icon,
const gchar *title,
const gchar *subtitle,
const gchar *body,
@@ -179,8 +179,8 @@ im_phone_menu_add_message (ImPhoneMenu *menu,
g_menu_item_set_attribute (item, "x-canonical-text", "s", body);
g_menu_item_set_attribute (item, "x-canonical-time", "x", time);
- if (iconstr)
- g_menu_item_set_attribute (item, "icon", "s", iconstr);
+ if (serialized_icon)
+ g_menu_item_set_attribute_value (item, "icon", serialized_icon);
if (app_icon)
g_menu_item_set_attribute (item, "x-canonical-app-icon", "s", app_icon);
diff --git a/src/im-phone-menu.h b/src/im-phone-menu.h
index 9742f61..728ecaa 100644
--- a/src/im-phone-menu.h
+++ b/src/im-phone-menu.h
@@ -39,7 +39,7 @@ void im_phone_menu_add_message (ImPhoneMenu *men
const gchar *app_id,
const gchar *app_icon,
const gchar *id,
- const gchar *iconstr,
+ GVariant *serialized_icon,
const gchar *title,
const gchar *subtitle,
const gchar *body,