From af58f8e28e5ab5ed29de518bd921f8ae699ac972 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Tue, 4 Dec 2012 12:31:33 +0000 Subject: Export symbolic application icons on messages This is implemented by appending '-symbolic' to the first icon name. The old icon name is kept as a fallback in case there's no symbolic icon installed. This doesn't work yet for applications that specify their icon as a filename. --- src/im-application-list.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'src/im-application-list.c') diff --git a/src/im-application-list.c b/src/im-application-list.c index c41c858..77c0e47 100644 --- a/src/im-application-list.c +++ b/src/im-application-list.c @@ -302,7 +302,8 @@ im_application_list_class_init (ImApplicationListClass *klass) NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, - 10, + 11, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, @@ -535,6 +536,33 @@ im_application_list_sources_listed (GObject *source_object, } } +static gchar * +get_symbolic_app_icon_string (GIcon *icon) +{ + const gchar * const *names; + gchar *symbolic_name; + GIcon *symbolic_icon; + gchar *str; + + if (!G_IS_THEMED_ICON (icon)) + return NULL; + + names = g_themed_icon_get_names (G_THEMED_ICON (icon)); + if (!names || !names[0]) + return NULL; + + symbolic_icon = g_themed_icon_new_from_names ((gchar **) names, -1); + + symbolic_name = g_strconcat (names[0], "-symbolic", NULL); + g_themed_icon_prepend_name (G_THEMED_ICON (symbolic_icon), symbolic_name); + + str = g_icon_to_string (symbolic_icon); + + g_free (symbolic_name); + g_object_unref (symbolic_icon); + return str; +} + static void im_application_list_message_added (Application *app, GVariant *message) @@ -550,13 +578,18 @@ im_application_list_message_added (Application *app, GSimpleAction *action; GIcon *app_icon; gchar *app_iconstr; + gchar *symbolic_app_iconstr; GVariant *actions = NULL; g_variant_get (message, "(&s&s&s&s&sxaa{sv}b)", &id, &iconstr, &title, &subtitle, &body, &time, &action_iter, &draws_attention); app_icon = g_app_info_get_icon (G_APP_INFO (app->info)); - app_iconstr = app_icon ? g_icon_to_string (app_icon) : NULL; + if (app_icon) + { + app_iconstr = g_icon_to_string (app_icon); + symbolic_app_iconstr = get_symbolic_app_icon_string (app_icon); + } action = g_simple_action_new (id, G_VARIANT_TYPE_BOOLEAN); g_signal_connect (action, "activate", G_CALLBACK (im_application_list_message_activated), app); @@ -629,10 +662,12 @@ im_application_list_message_added (Application *app, } g_signal_emit (app->list, signals[MESSAGE_ADDED], 0, - app->id, app_iconstr, id, iconstr, title, subtitle, body, actions, time, draws_attention); + app->id, app_iconstr, symbolic_app_iconstr, id, + iconstr, title, subtitle, body, actions, time, draws_attention); g_variant_iter_free (action_iter); g_free (app_iconstr); + g_free (symbolic_app_iconstr); g_object_unref (action); } -- cgit v1.2.3