Merge lp:~macslow/notify-osd/fix-451086 into lp:notify-osd/lucid

Proposed by Mirco Müller
Status: Merged
Merged at revision: not available
Proposed branch: lp:~macslow/notify-osd/fix-451086
Merge into: lp:notify-osd/lucid
Diff against target: 207 lines (+144/-1)
4 files modified
.bzrignore (+1/-0)
examples/Makefile.am (+5/-1)
examples/icon-updating.c (+126/-0)
src/bubble.c (+12/-0)
To merge this branch: bzr merge lp:~macslow/notify-osd/fix-451086
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+22961@code.launchpad.net

Description of the change

This branch fixes LP: #451086 and adds a new C-example testing the correct working of all three methods to pass icons to notifications. To have the C-example compiled - in addition to notify-osd itself - make sure to pass --with-examples=c at the configure-run.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2009-08-25 11:56:31 +0000
3+++ .bzrignore 2010-04-07 18:13:20 +0000
4@@ -197,3 +197,4 @@
5 tests/*.gcno
6 tests/*.gcda
7 tests/*.gcov
8+examples/icon-updating
9
10=== modified file 'examples/Makefile.am'
11--- examples/Makefile.am 2009-08-21 12:44:54 +0000
12+++ examples/Makefile.am 2010-04-07 18:13:20 +0000
13@@ -20,7 +20,8 @@
14 summary-body \
15 summary-only \
16 append-hint-example \
17- update-notifications
18+ update-notifications \
19+ icon-updating
20
21 icon_only_SOURCES = example-util.c example-util.h icon-only.c
22 sync_icon_only_SOURCES = sync-icon-only.c example-util.h example-util.c
23@@ -31,6 +32,7 @@
24 summary_only_SOURCES = summary-only.c example-util.c example-util.h
25 append_hint_example_SOURCES = append-hint-example.c example-util.c example-util.h
26 update_notifications_SOURCES = update-notifications.c example-util.c example-util.h
27+icon_updating_SOURCES = icon-updating.c example-util.c example-util.h
28
29 icon_only_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
30 sync_icon_only_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
31@@ -41,6 +43,7 @@
32 summary_only_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
33 append_hint_example_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
34 update_notifications_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
35+icon_updating_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
36
37 icon_only_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
38 sync_icon_only_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
39@@ -51,6 +54,7 @@
40 summary_only_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
41 append_hint_example_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
42 update_notifications_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
43+icon_updating_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
44 endif
45
46 if BUILD_MONO_EXAMPLES
47
48=== added file 'examples/icon-updating.c'
49--- examples/icon-updating.c 1970-01-01 00:00:00 +0000
50+++ examples/icon-updating.c 2010-04-07 18:13:20 +0000
51@@ -0,0 +1,126 @@
52+/*******************************************************************************
53+**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
54+** 10 20 30 40 50 60 70 80
55+**
56+** Info:
57+** Example of how to use libnotify correctly and at the same time comply to
58+** the new jaunty notification spec (read: visual guidelines)
59+**
60+** Compile:
61+** gcc -O0 -ggdb -Wall -Werror `pkg-config --cflags --libs libnotify \
62+** glib-2.0` icon-updating.c example-util.c -o icon-updating
63+**
64+** Copyright 2010 Canonical Ltd.
65+**
66+** Author:
67+** Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
68+**
69+** This program is free software: you can redistribute it and/or modify it
70+** under the terms of the GNU General Public License version 3, as published
71+** by the Free Software Foundation.
72+**
73+** This program is distributed in the hope that it will be useful, but
74+** WITHOUT ANY WARRANTY; without even the implied warranties of
75+** MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
76+** PURPOSE. See the GNU General Public License for more details.
77+**
78+** You should have received a copy of the GNU General Public License along
79+** with this program. If not, see <http://www.gnu.org/licenses/>.
80+**
81+*******************************************************************************/
82+
83+#include "example-util.h"
84+
85+int
86+main (int argc,
87+ char** argv)
88+{
89+ NotifyNotification* notification = NULL;
90+ gboolean success;
91+ GError* error = NULL;
92+ GdkPixbuf* pixbuf = NULL;
93+
94+ if (!notify_init ("icon-updating"))
95+ return 1;
96+
97+ // call this so we can savely use has_cap(CAP_SOMETHING) later
98+ init_caps ();
99+
100+ // show what's supported
101+ print_caps ();
102+
103+ // create new notification, set icon using hint "image_path"
104+ notification = notify_notification_new (
105+ "Test 1/3",
106+ "Set icon via hint \"image_path\" to logo-icon.",
107+ NULL,
108+ NULL);
109+ notify_notification_set_hint_string (
110+ notification,
111+ "image_path",
112+ "/usr/share/icons/Humanity/places/64/distributor-logo.svg");
113+ error = NULL;
114+ success = notify_notification_show (notification, &error);
115+ if (!success)
116+ {
117+ g_print ("Could not show notification: \"%s\".\n",
118+ error->message);
119+ g_error_free (error);
120+ }
121+ g_signal_connect (G_OBJECT (notification),
122+ "closed",
123+ G_CALLBACK (closed_handler),
124+ NULL);
125+ sleep (4); // wait a bit
126+
127+ // update notification using hint image_data
128+ notify_notification_clear_hints (notification);
129+ success = notify_notification_update (
130+ notification,
131+ "Test 2/3",
132+ "Set icon via hint \"image_data\" to avatar-photo.",
133+ NULL);
134+ error = NULL;
135+ pixbuf = gdk_pixbuf_new_from_file ("../icons/avatar.png", &error);
136+ if (!pixbuf)
137+ {
138+ g_print ("Could not load image: \"%s\".\n", error->message);
139+ g_error_free (error);
140+ }
141+ notify_notification_set_icon_from_pixbuf (notification, pixbuf);
142+ g_object_unref (pixbuf);
143+ error = NULL;
144+ success = notify_notification_show (notification, &error);
145+ if (!success)
146+ {
147+ g_print ("Could not show notification: \"%s\".\n",
148+ error->message);
149+ g_error_free (error);
150+ }
151+ sleep (4); // wait a bit
152+
153+ // update notification using icon-parameter directly
154+ notify_notification_clear_hints (notification);
155+ success = notify_notification_update (
156+ notification,
157+ "Test 3/3",
158+ "Set icon via icon-parameter directly to totem-icon.",
159+ "totem");
160+ error = NULL;
161+ success = notify_notification_show (notification, &error);
162+ if (!success)
163+ {
164+ g_print ("Could not show notification: \"%s\".\n",
165+ error->message);
166+ g_error_free (error);
167+ }
168+ g_signal_connect (G_OBJECT (notification),
169+ "closed",
170+ G_CALLBACK (closed_handler),
171+ NULL);
172+
173+ notify_uninit ();
174+
175+ return 0;
176+}
177+
178
179=== modified file 'src/bubble.c'
180--- src/bubble.c 2010-04-01 09:07:06 +0000
181+++ src/bubble.c 2010-04-07 18:13:20 +0000
182@@ -2393,6 +2393,15 @@
183
184 priv = GET_PRIVATE (self);
185
186+ // check if an app tries to set the same file as icon again, this check
187+ // avoids superfluous regeneration of the tile/blur-cache for the icon,
188+ // thus it improves performance in update- and append-cases
189+ if (!g_strcmp0 (priv->old_icon_filename->str, filepath))
190+ return;
191+
192+ // store the new icon-basename
193+ g_string_assign (priv->old_icon_filename, filepath);
194+
195 if (priv->icon_pixbuf)
196 {
197 g_object_unref (priv->icon_pixbuf);
198@@ -2528,6 +2537,9 @@
199
200 priv = GET_PRIVATE (self);
201
202+ // "reset" the stored the icon-filename, fixes LP: #451086
203+ g_string_assign (priv->old_icon_filename, "\0");
204+
205 if (priv->icon_pixbuf)
206 {
207 g_object_unref (priv->icon_pixbuf);

Subscribers

People subscribed via source and target branches

to all changes: