diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-02-14 22:25:39 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2013-02-14 22:25:39 +0000 |
commit | d05835eae4e47417fdd41a1d4fcaf6a2bcfd96ea (patch) | |
tree | 43995c9938a1039e251512d6f9ed71971b27a476 /libindicator/indicator-image-helper.c | |
parent | e7966480ecd14bd6cb4c4ec5f527cfe10a1a0b0f (diff) | |
parent | 40d7c42d5212dc97ce6b07f05828fb62440d0694 (diff) | |
download | libayatana-indicator-d05835eae4e47417fdd41a1d4fcaf6a2bcfd96ea.tar.gz libayatana-indicator-d05835eae4e47417fdd41a1d4fcaf6a2bcfd96ea.tar.bz2 libayatana-indicator-d05835eae4e47417fdd41a1d4fcaf6a2bcfd96ea.zip |
Add IndicatorNg.
IndicatorNg is an indicator object that reads an indicator service file and watches the bus for a corresponding service to appear. It turns the menus and actions exported by the service into an indicator entry. I think this is a good solution for the transition period in which we support both styles of indicators. (It means we don't need to copy templates around.)
An indicator service file must have an ".indicator" extension and contents simlilar to this:
[Indicator Service]
Name=indicator-test
BusName=com.canonical.indicator.test
ObjectPath=/com/canonical/indicator/test
For unity-panel-service, these files will be installed somewhere. The indicator-loader in this branch accepts a path to such a file as the first command line argument (instead of the .so file).
This can be tested with the example indicator in lp:~larsu/libunity/add-indicator (examples/indicator.vala).
Approved by Charles Kerr, Ted Gould.
Diffstat (limited to 'libindicator/indicator-image-helper.c')
-rw-r--r-- | libindicator/indicator-image-helper.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/libindicator/indicator-image-helper.c b/libindicator/indicator-image-helper.c index 63488a1..382d0c9 100644 --- a/libindicator/indicator-image-helper.c +++ b/libindicator/indicator-image-helper.c @@ -62,7 +62,12 @@ refresh_image (GtkImage * image) /* Grab the filename */ icon_filename = gtk_icon_info_get_filename(icon_info); } - g_return_if_fail(icon_filename != NULL); /* An error because we don't have a filename */ + + /* show a broken image if we don't have a filename */ + if (icon_filename == NULL) { + gtk_image_set_from_stock (image, GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_LARGE_TOOLBAR); + return; + } /* Build a pixbuf */ GError * error = NULL; @@ -132,7 +137,8 @@ indicator_image_helper (const gchar * name) /* Build us an image */ GtkImage * image = GTK_IMAGE(gtk_image_new()); - indicator_image_helper_update(image, name); + if (name) + indicator_image_helper_update(image, name); return image; } @@ -144,17 +150,27 @@ indicator_image_helper_update (GtkImage * image, const gchar * name) g_return_if_fail(name != NULL); g_return_if_fail(name[0] != '\0'); g_return_if_fail(GTK_IS_IMAGE(image)); - gboolean seen_previously = FALSE; /* Build us a GIcon */ GIcon * icon_names = g_themed_icon_new_with_default_fallbacks(name); g_warn_if_fail(icon_names != NULL); g_return_if_fail(icon_names != NULL); + indicator_image_helper_update_from_gicon (image, icon_names); + + g_object_unref (icon_names); + return; +} + +void +indicator_image_helper_update_from_gicon (GtkImage *image, GIcon *icon) +{ + gboolean seen_previously = FALSE; + seen_previously = (g_object_get_data(G_OBJECT(image), INDICATOR_NAMES_DATA) != NULL); /* Attach our names to the image */ - g_object_set_data_full(G_OBJECT(image), INDICATOR_NAMES_DATA, icon_names, g_object_unref); + g_object_set_data_full(G_OBJECT(image), INDICATOR_NAMES_DATA, g_object_ref (icon), g_object_unref); /* Put the pixbuf in */ refresh_image(image); |