From 11998bfc8d952c346f2eb0318db9a6f3ea93fd14 Mon Sep 17 00:00:00 2001 From: Jason Conti Date: Sat, 14 May 2011 16:17:13 -0400 Subject: Added the icon to the indicator. Currently using a hardcoded path, will grab from the icon theme later, but need to add the local path to the icon theme for testing. --- src/Makefile.am | 1 + src/indicator-notifications.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 7d3cf35..fc973f4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,4 @@ +AM_CPPFLAGS = -DICONS_DIR='"$(INDICATORICONSDIR)"' libexec_PROGRAMS = indicator-notifications-service diff --git a/src/indicator-notifications.c b/src/indicator-notifications.c index 32807e4..905bbf2 100644 --- a/src/indicator-notifications.c +++ b/src/indicator-notifications.c @@ -32,6 +32,7 @@ with this program. If not, see . #include #include #include +#include /* Indicator Stuff */ #include @@ -67,6 +68,7 @@ struct _IndicatorNotifications { }; struct _IndicatorNotificationsPrivate { + GtkImage *image; GtkLabel *label; IndicatorServiceManager *sm; @@ -86,6 +88,7 @@ static void indicator_notifications_init(IndicatorNotifications *self); static void indicator_notifications_dispose(GObject *object); static void indicator_notifications_finalize(GObject *object); static GtkLabel *get_label(IndicatorObject *io); +static GtkImage *get_image(IndicatorObject *io); static GtkMenu *get_menu(IndicatorObject *io); static const gchar *get_accessible_desc(IndicatorObject *io); static void update_label(IndicatorNotifications *io); @@ -110,6 +113,7 @@ indicator_notifications_class_init(IndicatorNotificationsClass *klass) IndicatorObjectClass *io_class = INDICATOR_OBJECT_CLASS(klass); + io_class->get_image = get_image; io_class->get_label = get_label; io_class->get_menu = get_menu; io_class->get_accessible_desc = get_accessible_desc; @@ -312,6 +316,32 @@ update_text_gravity(GtkWidget *widget, GdkScreen *previous_screen, gpointer data pango_context_set_base_gravity(context, PANGO_GRAVITY_AUTO); } +static GtkImage * +get_image(IndicatorObject *io) +{ + IndicatorNotifications *self = INDICATOR_NOTIFICATIONS(io); + + if(self->priv->image == NULL) { + self->priv->image = GTK_IMAGE(gtk_image_new()); + + GError *error = NULL; + + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_scale(ICONS_DIR "/notification-read.svg", 22, 22, FALSE, &error); + + if(error != NULL) { + g_error("Failed to load icon: %s", error->message); + return NULL; + } + + gtk_image_set_from_pixbuf(self->priv->image, pixbuf); + g_object_unref(pixbuf); + + gtk_widget_show(GTK_WIDGET(self->priv->image)); + } + + return self->priv->image; +} + /* Grabs the label. Creates it if it doesn't exist already */ static GtkLabel * -- cgit v1.2.3