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
=== modified file '.bzrignore'
--- .bzrignore 2009-08-25 11:56:31 +0000
+++ .bzrignore 2010-04-07 18:13:20 +0000
@@ -197,3 +197,4 @@
197tests/*.gcno197tests/*.gcno
198tests/*.gcda198tests/*.gcda
199tests/*.gcov199tests/*.gcov
200examples/icon-updating
200201
=== modified file 'examples/Makefile.am'
--- examples/Makefile.am 2009-08-21 12:44:54 +0000
+++ examples/Makefile.am 2010-04-07 18:13:20 +0000
@@ -20,7 +20,8 @@
20 summary-body \20 summary-body \
21 summary-only \21 summary-only \
22 append-hint-example \22 append-hint-example \
23 update-notifications23 update-notifications \
24 icon-updating
2425
25icon_only_SOURCES = example-util.c example-util.h icon-only.c26icon_only_SOURCES = example-util.c example-util.h icon-only.c
26sync_icon_only_SOURCES = sync-icon-only.c example-util.h example-util.c27sync_icon_only_SOURCES = sync-icon-only.c example-util.h example-util.c
@@ -31,6 +32,7 @@
31summary_only_SOURCES = summary-only.c example-util.c example-util.h32summary_only_SOURCES = summary-only.c example-util.c example-util.h
32append_hint_example_SOURCES = append-hint-example.c example-util.c example-util.h33append_hint_example_SOURCES = append-hint-example.c example-util.c example-util.h
33update_notifications_SOURCES = update-notifications.c example-util.c example-util.h34update_notifications_SOURCES = update-notifications.c example-util.c example-util.h
35icon_updating_SOURCES = icon-updating.c example-util.c example-util.h
3436
35icon_only_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`37icon_only_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
36sync_icon_only_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`38sync_icon_only_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
@@ -41,6 +43,7 @@
41summary_only_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`43summary_only_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
42append_hint_example_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`44append_hint_example_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
43update_notifications_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`45update_notifications_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
46icon_updating_CFLAGS = -I. -O0 -ggdb -Wall -Werror `pkg-config --cflags libnotify glib-2.0`
4447
45icon_only_LDFLAGS = `pkg-config --libs libnotify glib-2.0`48icon_only_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
46sync_icon_only_LDFLAGS = `pkg-config --libs libnotify glib-2.0`49sync_icon_only_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
@@ -51,6 +54,7 @@
51summary_only_LDFLAGS = `pkg-config --libs libnotify glib-2.0`54summary_only_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
52append_hint_example_LDFLAGS = `pkg-config --libs libnotify glib-2.0`55append_hint_example_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
53update_notifications_LDFLAGS = `pkg-config --libs libnotify glib-2.0`56update_notifications_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
57icon_updating_LDFLAGS = `pkg-config --libs libnotify glib-2.0`
54endif58endif
5559
56if BUILD_MONO_EXAMPLES60if BUILD_MONO_EXAMPLES
5761
=== added file 'examples/icon-updating.c'
--- examples/icon-updating.c 1970-01-01 00:00:00 +0000
+++ examples/icon-updating.c 2010-04-07 18:13:20 +0000
@@ -0,0 +1,126 @@
1/*******************************************************************************
2**3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
3** 10 20 30 40 50 60 70 80
4**
5** Info:
6** Example of how to use libnotify correctly and at the same time comply to
7** the new jaunty notification spec (read: visual guidelines)
8**
9** Compile:
10** gcc -O0 -ggdb -Wall -Werror `pkg-config --cflags --libs libnotify \
11** glib-2.0` icon-updating.c example-util.c -o icon-updating
12**
13** Copyright 2010 Canonical Ltd.
14**
15** Author:
16** Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
17**
18** This program is free software: you can redistribute it and/or modify it
19** under the terms of the GNU General Public License version 3, as published
20** by the Free Software Foundation.
21**
22** This program is distributed in the hope that it will be useful, but
23** WITHOUT ANY WARRANTY; without even the implied warranties of
24** MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
25** PURPOSE. See the GNU General Public License for more details.
26**
27** You should have received a copy of the GNU General Public License along
28** with this program. If not, see <http://www.gnu.org/licenses/>.
29**
30*******************************************************************************/
31
32#include "example-util.h"
33
34int
35main (int argc,
36 char** argv)
37{
38 NotifyNotification* notification = NULL;
39 gboolean success;
40 GError* error = NULL;
41 GdkPixbuf* pixbuf = NULL;
42
43 if (!notify_init ("icon-updating"))
44 return 1;
45
46 // call this so we can savely use has_cap(CAP_SOMETHING) later
47 init_caps ();
48
49 // show what's supported
50 print_caps ();
51
52 // create new notification, set icon using hint "image_path"
53 notification = notify_notification_new (
54 "Test 1/3",
55 "Set icon via hint \"image_path\" to logo-icon.",
56 NULL,
57 NULL);
58 notify_notification_set_hint_string (
59 notification,
60 "image_path",
61 "/usr/share/icons/Humanity/places/64/distributor-logo.svg");
62 error = NULL;
63 success = notify_notification_show (notification, &error);
64 if (!success)
65 {
66 g_print ("Could not show notification: \"%s\".\n",
67 error->message);
68 g_error_free (error);
69 }
70 g_signal_connect (G_OBJECT (notification),
71 "closed",
72 G_CALLBACK (closed_handler),
73 NULL);
74 sleep (4); // wait a bit
75
76 // update notification using hint image_data
77 notify_notification_clear_hints (notification);
78 success = notify_notification_update (
79 notification,
80 "Test 2/3",
81 "Set icon via hint \"image_data\" to avatar-photo.",
82 NULL);
83 error = NULL;
84 pixbuf = gdk_pixbuf_new_from_file ("../icons/avatar.png", &error);
85 if (!pixbuf)
86 {
87 g_print ("Could not load image: \"%s\".\n", error->message);
88 g_error_free (error);
89 }
90 notify_notification_set_icon_from_pixbuf (notification, pixbuf);
91 g_object_unref (pixbuf);
92 error = NULL;
93 success = notify_notification_show (notification, &error);
94 if (!success)
95 {
96 g_print ("Could not show notification: \"%s\".\n",
97 error->message);
98 g_error_free (error);
99 }
100 sleep (4); // wait a bit
101
102 // update notification using icon-parameter directly
103 notify_notification_clear_hints (notification);
104 success = notify_notification_update (
105 notification,
106 "Test 3/3",
107 "Set icon via icon-parameter directly to totem-icon.",
108 "totem");
109 error = NULL;
110 success = notify_notification_show (notification, &error);
111 if (!success)
112 {
113 g_print ("Could not show notification: \"%s\".\n",
114 error->message);
115 g_error_free (error);
116 }
117 g_signal_connect (G_OBJECT (notification),
118 "closed",
119 G_CALLBACK (closed_handler),
120 NULL);
121
122 notify_uninit ();
123
124 return 0;
125}
126
0127
=== modified file 'src/bubble.c'
--- src/bubble.c 2010-04-01 09:07:06 +0000
+++ src/bubble.c 2010-04-07 18:13:20 +0000
@@ -2393,6 +2393,15 @@
23932393
2394 priv = GET_PRIVATE (self);2394 priv = GET_PRIVATE (self);
23952395
2396 // check if an app tries to set the same file as icon again, this check
2397 // avoids superfluous regeneration of the tile/blur-cache for the icon,
2398 // thus it improves performance in update- and append-cases
2399 if (!g_strcmp0 (priv->old_icon_filename->str, filepath))
2400 return;
2401
2402 // store the new icon-basename
2403 g_string_assign (priv->old_icon_filename, filepath);
2404
2396 if (priv->icon_pixbuf)2405 if (priv->icon_pixbuf)
2397 {2406 {
2398 g_object_unref (priv->icon_pixbuf);2407 g_object_unref (priv->icon_pixbuf);
@@ -2528,6 +2537,9 @@
25282537
2529 priv = GET_PRIVATE (self);2538 priv = GET_PRIVATE (self);
25302539
2540 // "reset" the stored the icon-filename, fixes LP: #451086
2541 g_string_assign (priv->old_icon_filename, "\0");
2542
2531 if (priv->icon_pixbuf)2543 if (priv->icon_pixbuf)
2532 {2544 {
2533 g_object_unref (priv->icon_pixbuf);2545 g_object_unref (priv->icon_pixbuf);

Subscribers

People subscribed via source and target branches

to all changes: