~ubuntu-branches/ubuntu/maverick/gnome-power-manager/maverick

« back to all changes in this revision

Viewing changes to debian/patches/12-add-appindicators.patch

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-08-05 23:58:02 UTC
  • mfrom: (2.1.53 upstream)
  • Revision ID: james.westby@ubuntu.com-20100805235802-5mno7epkaqy0x8rp
Tags: 2.31.1-0ubuntu1
* New upstream version:
  - Port from DeviceKit-power to UPower.
  - Remove the use of HAL from gnome-power-manager.
  - Add new 6 hours period in power history stats.
  - Use the device names from the shared-icon-specification.
  - Use the symbolic icons present in some themes.
  - Show the primary device time remaining as the first entry in the context menu.
  - Provide a pkexec helper for systems that do not have xbacklight capability.
* Drop 00git-kernel-backlight-interface.patch and
  00git-port-to-libupower.patch: Upstream now. The first backport was buggy
  and broke the correct detection and signalling of brightness values.
* 12-add-appindicators.patch: Port to new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=609654
4
4
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/497870
5
5
 
6
 
Index: gnome-power-manager-2.30.1/configure.ac
 
6
Index: gnome-power-manager-2.31.1/configure.ac
7
7
===================================================================
8
 
--- gnome-power-manager-2.30.1.orig/configure.ac        2010-07-14 15:07:42.148486811 +0200
9
 
+++ gnome-power-manager-2.30.1/configure.ac     2010-07-14 15:07:42.288486376 +0200
 
8
--- gnome-power-manager-2.31.1.orig/configure.ac        2010-06-02 18:22:48.000000000 +0200
 
9
+++ gnome-power-manager-2.31.1/configure.ac     2010-08-05 23:50:36.591312002 +0200
10
10
@@ -122,6 +122,7 @@
11
11
 XRANDR_REQUIRED=1.2.0
12
12
 CANBERRA_REQUIRED=0.10
43
43
 AC_PATH_PROG(GCONFTOOL, gconftool-2)
44
44
 AM_GCONF_SOURCE_2
45
45
 
46
 
@@ -373,6 +395,7 @@
 
46
@@ -362,6 +384,7 @@
47
47
         Self test support:         ${have_tests}
48
48
         GConf default support:     ${have_gconfdefaults}
49
49
         Docbook support:           ${enable_docbook_docs}
51
51
         documentation dir:         $DOCDIR
52
52
         dbus-1 services dir:       $DBUS_SERVICES_DIR
53
53
         gconf-schema dir:          $GCONF_SCHEMA_FILE_DIR
54
 
Index: gnome-power-manager-2.30.1/src/Makefile.am
 
54
Index: gnome-power-manager-2.31.1/src/Makefile.am
55
55
===================================================================
56
 
--- gnome-power-manager-2.30.1.orig/src/Makefile.am     2010-07-14 15:07:42.228488737 +0200
57
 
+++ gnome-power-manager-2.30.1/src/Makefile.am  2010-07-14 15:08:00.082889995 +0200
 
56
--- gnome-power-manager-2.31.1.orig/src/Makefile.am     2010-08-05 23:50:36.551312002 +0200
 
57
+++ gnome-power-manager-2.31.1/src/Makefile.am  2010-08-05 23:50:36.591312002 +0200
58
58
@@ -20,6 +20,7 @@
59
59
        $(GSTREAMER_CFLAGS)                             \
60
60
        -DI_KNOW_THE_DEVICEKIT_POWER_API_IS_SUBJECT_TO_CHANGE \
61
61
        $(UPOWER_CFLAGS)                                \
62
62
+       $(APP_INDICATOR_CFLAGS)                         \
63
63
        -DBINDIR=\"$(bindir)\"                          \
 
64
        -DSBINDIR=\"$(sbindir)\"                         \
64
65
        -DGNOMELOCALEDIR=\""$(datadir)/locale"\"        \
65
 
        -DDATADIR=\"$(datadir)\"                        \
66
 
@@ -185,6 +186,7 @@
 
66
@@ -184,6 +185,7 @@
67
67
        $(X11_LIBS)                             \
68
68
        $(GSTREAMER_LIBS)                               \
69
69
        $(GNOME_LIBS)                                   \
71
71
        $(DBUS_LIBS)                                    \
72
72
        $(X11_LIBS)                                             \
73
73
        $(CANBERRA_LIBS)                                \
74
 
Index: gnome-power-manager-2.30.1/src/gpm-engine.c
75
 
===================================================================
76
 
--- gnome-power-manager-2.30.1.orig/src/gpm-engine.c    2010-07-14 15:07:42.158484660 +0200
77
 
+++ gnome-power-manager-2.30.1/src/gpm-engine.c 2010-07-14 15:07:42.288486376 +0200
78
 
@@ -75,6 +75,7 @@
79
 
        DISCHARGING,
80
 
        LOW_CAPACITY,
81
 
        PERHAPS_RECALL,
82
 
+        DEVICES_CHANGED,
83
 
        LAST_SIGNAL
84
 
 };
85
 
 
86
 
@@ -497,6 +498,8 @@
87
 
 
88
 
        gpm_engine_recalculate_state_icon (engine);
89
 
        gpm_engine_recalculate_state_summary (engine);
90
 
+
91
 
+       g_signal_emit (engine, signals [DEVICES_CHANGED], 0);
92
 
 }
93
 
 
94
 
 /**
95
 
@@ -1210,6 +1213,13 @@
96
 
                              G_STRUCT_OFFSET (GpmEngineClass, charge_critical),
97
 
                              NULL, NULL, g_cclosure_marshal_VOID__POINTER,
98
 
                              G_TYPE_NONE, 1, G_TYPE_POINTER);
99
 
+       signals [DEVICES_CHANGED] =
100
 
+               g_signal_new ("devices-changed",
101
 
+                             G_TYPE_FROM_CLASS (object_class),
102
 
+                             G_SIGNAL_RUN_LAST,
103
 
+                             G_STRUCT_OFFSET (GpmEngineClass, devices_changed),
104
 
+                             NULL, NULL, g_cclosure_marshal_VOID__VOID,
105
 
+                             G_TYPE_NONE, 0);
106
 
 }
107
 
 
108
 
 /**
109
 
Index: gnome-power-manager-2.30.1/src/gpm-engine.h
110
 
===================================================================
111
 
--- gnome-power-manager-2.30.1.orig/src/gpm-engine.h    2010-07-14 15:07:42.158484660 +0200
112
 
+++ gnome-power-manager-2.30.1/src/gpm-engine.h 2010-07-14 15:07:42.288486376 +0200
113
 
@@ -65,6 +65,7 @@
114
 
                                                 UpDevice       *device);
115
 
        void            (* discharging)         (GpmEngine      *engine,
116
 
                                                 UpDevice       *device);
117
 
+       void            (* devices_changed)     (GpmEngine      *engine);
118
 
 } GpmEngineClass;
119
 
 
120
 
 GType           gpm_engine_get_type            (void);
121
 
Index: gnome-power-manager-2.30.1/src/gpm-manager.c
122
 
===================================================================
123
 
--- gnome-power-manager-2.30.1.orig/src/gpm-manager.c   2010-07-14 15:07:42.168489283 +0200
124
 
+++ gnome-power-manager-2.30.1/src/gpm-manager.c        2010-07-14 15:07:42.288486376 +0200
125
 
@@ -476,7 +476,7 @@
 
74
Index: gnome-power-manager-2.31.1/src/gpm-manager.c
 
75
===================================================================
 
76
--- gnome-power-manager-2.31.1.orig/src/gpm-manager.c   2010-06-02 18:22:48.000000000 +0200
 
77
+++ gnome-power-manager-2.31.1/src/gpm-manager.c        2010-08-05 23:50:36.591312002 +0200
 
78
@@ -495,7 +495,7 @@
126
79
        gpm_manager_notify_close (manager, *notification_class);
127
80
 
128
81
        /* if the status icon is hidden, don't point at it */
129
82
-       if (gtk_status_icon_is_embedded (manager->priv->status_icon))
130
83
+       if (manager->priv->status_icon && gtk_status_icon_is_embedded (manager->priv->status_icon))
131
 
                notification = notify_notification_new_with_status_icon (title, message, icon, manager->priv->status_icon);
 
84
                notification = notify_notification_new_with_status_icon (title, message, icon_name, manager->priv->status_icon);
132
85
        else
133
 
                notification = notify_notification_new (title, message, icon, NULL);
134
 
@@ -2031,7 +2031,8 @@
 
86
                notification = notify_notification_new (title, message, icon_name, NULL);
 
87
@@ -2095,7 +2095,8 @@
135
88
        g_object_unref (manager->priv->backlight);
136
89
        g_object_unref (manager->priv->console);
137
90
        g_object_unref (manager->priv->client);
141
94
 
142
95
        G_OBJECT_CLASS (gpm_manager_parent_class)->finalize (object);
143
96
 }
144
 
Index: gnome-power-manager-2.30.1/src/gpm-tray-icon.c
 
97
Index: gnome-power-manager-2.31.1/src/gpm-tray-icon.c
145
98
===================================================================
146
 
--- gnome-power-manager-2.30.1.orig/src/gpm-tray-icon.c 2010-07-14 15:07:42.168489283 +0200
147
 
+++ gnome-power-manager-2.30.1/src/gpm-tray-icon.c      2010-07-14 15:07:42.298485621 +0200
 
99
--- gnome-power-manager-2.31.1.orig/src/gpm-tray-icon.c 2010-06-02 18:22:48.000000000 +0200
 
100
+++ gnome-power-manager-2.31.1/src/gpm-tray-icon.c      2010-08-05 23:51:01.000000000 +0200
148
101
@@ -41,6 +41,10 @@
149
102
 #include <gconf/gconf-client.h>
150
103
 #include <libupower-glib/upower.h>
156
109
 #include "egg-debug.h"
157
110
 
158
111
 #include "gpm-upower.h"
159
 
@@ -57,15 +61,19 @@
 
112
@@ -57,7 +61,11 @@
160
113
 {
161
114
        GConfClient             *conf;
162
115
        GpmEngine               *engine;
168
121
        gboolean                 show_actions;
169
122
 };
170
123
 
171
 
 G_DEFINE_TYPE (GpmTrayIcon, gpm_tray_icon, G_TYPE_OBJECT)
172
 
 
173
 
-/**
174
 
- * gpm_tray_icon_enable_actions:
175
 
- **/
176
 
+       /**
177
 
+        * gpm_tray_icon_enable_actions:
178
 
+        **/
179
 
 static void
180
 
 gpm_tray_icon_enable_actions (GpmTrayIcon *icon, gboolean enabled)
181
 
 {
182
124
@@ -81,7 +89,16 @@
183
125
 gpm_tray_icon_show (GpmTrayIcon *icon, gboolean enabled)
184
126
 {
196
138
 }
197
139
 
198
140
 /**
199
 
@@ -95,11 +112,13 @@
 
141
@@ -95,7 +112,9 @@
200
142
        g_return_val_if_fail (GPM_IS_TRAY_ICON (icon), FALSE);
201
143
        g_return_val_if_fail (tooltip != NULL, FALSE);
202
144
 
203
145
+#ifndef HAVE_APP_INDICATOR
204
 
 #if GTK_CHECK_VERSION(2,15,0)
205
146
        gtk_status_icon_set_tooltip_text (icon->priv->status_icon, tooltip);
206
 
 #else
207
 
        gtk_status_icon_set_tooltip (icon->priv->status_icon, tooltip);
208
 
 #endif
209
147
+#endif
210
148
        return TRUE;
211
149
 }
212
150
 
213
 
@@ -110,7 +129,11 @@
 
151
@@ -106,7 +125,11 @@
214
152
 gpm_tray_icon_get_status_icon (GpmTrayIcon *icon)
215
153
 {
216
154
        g_return_val_if_fail (GPM_IS_TRAY_ICON (icon), NULL);
222
160
 }
223
161
 
224
162
 /**
225
 
@@ -127,7 +150,11 @@
226
 
 
227
 
        if (filename != NULL) {
 
163
@@ -125,7 +148,11 @@
 
164
        if (gicon != NULL) {
 
165
                filename = g_icon_to_string (gicon);
228
166
                egg_debug ("Setting icon to %s", filename);
229
167
+#ifdef HAVE_APP_INDICATOR
230
168
+               app_indicator_set_icon (icon->priv->app_indicator, filename);
231
169
+#else
232
 
                gtk_status_icon_set_from_icon_name (icon->priv->status_icon, filename);
 
170
                gtk_status_icon_set_from_gicon (icon->priv->status_icon, gicon);
233
171
+#endif
234
172
 
235
173
                /* make sure that we are visible */
236
174
                gpm_tray_icon_show (icon, TRUE);
237
 
@@ -171,21 +198,6 @@
238
 
 }
239
 
 
240
 
 /**
241
 
- * gpm_tray_icon_popup_cleared_cd:
242
 
- * @widget: The popup Gtkwidget
243
 
- *
244
 
- * We have to re-enable the tooltip when the popup is removed
245
 
- **/
246
 
-static void
247
 
-gpm_tray_icon_popup_cleared_cd (GtkWidget *widget, GpmTrayIcon *icon)
248
 
-{
249
 
-       g_return_if_fail (GPM_IS_TRAY_ICON (icon));
250
 
-       egg_debug ("clear tray");
251
 
-       g_object_ref_sink (widget);
252
 
-       g_object_unref (widget);
253
 
-}
254
 
-
255
 
-/**
256
 
  * gpm_tray_icon_class_init:
257
 
  **/
258
 
 static void
259
 
@@ -208,9 +220,11 @@
260
 
        gchar *icon_name;
261
 
        gchar *label;
 
175
@@ -191,11 +218,13 @@
 
176
        guint added = 0;
 
177
        gchar *percentage_str;
262
178
        GtkWidget *item;
 
179
+#ifndef HAVE_APP_INDICATOR
 
180
+       GtkWidget *image;
 
181
        GtkWidget *label_title;
 
182
        GtkWidget *label_percentage;
263
183
-       GtkWidget *image;
 
184
        GtkWidget *hbox;
 
185
        GtkWidget *hbox_align;
 
186
+#endif
264
187
        const gchar *object_path;
265
 
+#ifndef HAVE_APP_INDICATOR
266
 
+       GtkWidget *image;
267
188
        const gchar *desc;
268
 
+#endif
269
189
        UpDevice *device;
270
 
        UpDeviceKind kind_tmp;
271
 
        gdouble percentage;
272
 
@@ -233,6 +247,10 @@
 
190
@@ -221,6 +250,10 @@
273
191
                added++;
274
192
 
275
 
                /* generate the label */
 
193
                /* generate the labels */
276
194
+#ifdef HAVE_APP_INDICATOR
277
 
+               label = gpm_upower_get_device_summary (device);
278
 
+               item = gtk_menu_item_new_with_label (label);
 
195
+               desc = gpm_upower_get_device_summary (device);
 
196
+               item = gtk_menu_item_new_with_label (desc);
279
197
+#else
280
 
                desc = gpm_device_kind_to_localised_text (kind, 1);
281
 
                label = g_strdup_printf ("%s (%.1f%%)", desc, percentage);
282
 
                item = gtk_image_menu_item_new_with_label (label);
283
 
@@ -242,6 +260,7 @@
284
 
                image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
 
198
                desc = gpm_device_kind_to_localised_string (kind, 1);
 
199
                percentage_str = g_strdup_printf ("%.0f%%", percentage);
 
200
 
 
201
@@ -250,6 +283,7 @@
 
202
                image = gtk_image_new_from_gicon (gicon, GTK_ICON_SIZE_MENU);
285
203
                gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
286
204
                gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
287
205
+#endif
288
206
 
289
207
                /* callback and add the the menu */
290
208
                g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (gpm_tray_icon_show_info_cb), icon);
291
 
@@ -257,14 +276,16 @@
292
 
 /**
293
 
  * gpm_tray_icon_create_menu:
294
 
  *
295
 
- * Display the popup menu.
296
 
+ * Create the popup menu.
297
 
  **/
298
 
-static void
299
 
-gpm_tray_icon_create_menu (GpmTrayIcon *icon, guint32 timestamp)
300
 
+static GtkMenu *
301
 
+gpm_tray_icon_create_menu (GpmTrayIcon *icon)
302
 
 {
303
 
        GtkMenu *menu = (GtkMenu*) gtk_menu_new ();
304
 
        GtkWidget *item;
305
 
+#ifndef HAVE_APP_INDICATOR
306
 
        GtkWidget *image;
307
 
+#endif
308
 
        guint dev_cnt = 0;
309
 
        GPtrArray *array;
310
 
 
311
 
@@ -289,14 +310,63 @@
 
209
@@ -339,9 +373,13 @@
312
210
        }
313
211
 
314
212
        /* preferences */
322
220
        g_signal_connect (G_OBJECT (item), "activate",
323
221
                          G_CALLBACK (gpm_tray_icon_show_preferences_cb), icon);
324
222
        gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
 
223
@@ -352,6 +390,21 @@
 
224
        return menu;
 
225
 }
325
226
 
326
 
 skip_prefs:
327
 
+       return menu;
328
 
+}
329
 
+
330
227
+#ifdef HAVE_APP_INDICATOR
331
228
+/**
332
229
+ * gpm_tray_icon_devices_changed_cb:
342
239
+       app_indicator_set_menu (icon->priv->app_indicator, menu);
343
240
+}
344
241
+#else
345
 
+/**
346
 
+ * gpm_tray_icon_popup_cleared_cd:
347
 
+ * @widget: The popup Gtkwidget
348
 
+ *
349
 
+ * We have to re-enable the tooltip when the popup is removed
350
 
+ **/
351
 
+static void
352
 
+gpm_tray_icon_popup_cleared_cd (GtkWidget *widget, GpmTrayIcon *icon)
353
 
+{
354
 
+       g_return_if_fail (GPM_IS_TRAY_ICON (icon));
355
 
+       egg_debug ("clear tray");
356
 
+       g_object_ref_sink (widget);
357
 
+       g_object_unref (widget);
358
 
+}
359
 
+
360
 
+/**
361
 
+ * gpm_tray_icon_popup_menu:
362
 
+ *
363
 
+ * Display the popup menu.
364
 
+ **/
365
 
+static void
366
 
+gpm_tray_icon_popup_menu (GpmTrayIcon *icon, guint32 timestamp)
367
 
+{
368
 
+       GtkMenu *menu;
369
 
+
370
 
+       menu = gpm_tray_icon_create_menu (icon);
371
 
+
372
 
        /* show the menu */
373
 
        gtk_widget_show_all (GTK_WIDGET (menu));
374
 
        gtk_menu_popup (GTK_MENU (menu), NULL, NULL,
375
 
@@ -316,7 +386,7 @@
376
 
 gpm_tray_icon_popup_menu_cb (GtkStatusIcon *status_icon, guint button, guint32 timestamp, GpmTrayIcon *icon)
377
 
 {
378
 
        egg_debug ("icon right clicked");
379
 
-       gpm_tray_icon_create_menu (icon, timestamp);
380
 
+       gpm_tray_icon_popup_menu (icon, timestamp);
381
 
 }
382
 
 
383
 
 
384
 
@@ -330,8 +400,9 @@
385
 
 gpm_tray_icon_activate_cb (GtkStatusIcon *status_icon, GpmTrayIcon *icon)
386
 
 {
387
 
        egg_debug ("icon left clicked");
388
 
-       gpm_tray_icon_create_menu (icon, gtk_get_current_event_time());
389
 
+       gpm_tray_icon_popup_menu (icon, gtk_get_current_event_time());
 
242
 /**
 
243
  * gpm_tray_icon_popup_cleared_cd:
 
244
  * @widget: The popup Gtkwidget
 
245
@@ -388,6 +441,7 @@
 
246
        g_signal_connect (GTK_WIDGET (menu), "hide",
 
247
                          G_CALLBACK (gpm_tray_icon_popup_cleared_cd), icon);
390
248
 }
391
249
+#endif
392
250
 
393
251
 /**
394
 
  * gpm_conf_gconf_key_changed_cb:
395
 
@@ -363,6 +434,9 @@
 
252
  * gpm_tray_icon_popup_menu_cb:
 
253
@@ -445,6 +499,9 @@
396
254
 gpm_tray_icon_init (GpmTrayIcon *icon)
397
255
 {
398
256
        gboolean allowed_in_menu;
402
260
 
403
261
        icon->priv = GPM_TRAY_ICON_GET_PRIVATE (icon);
404
262
 
405
 
@@ -376,6 +450,19 @@
 
263
@@ -458,6 +515,19 @@
406
264
                                 (GConfClientNotifyFunc) gpm_conf_gconf_key_changed_cb,
407
265
                                 icon, NULL, NULL);
408
266
 
422
280
        icon->priv->status_icon = gtk_status_icon_new ();
423
281
        g_signal_connect_object (G_OBJECT (icon->priv->status_icon),
424
282
                                 "popup_menu",
425
 
@@ -385,6 +472,7 @@
 
283
@@ -467,6 +537,7 @@
426
284
                                 "activate",
427
285
                                 G_CALLBACK (gpm_tray_icon_activate_cb),
428
286
                                 icon, 0);
430
288
 
431
289
        allowed_in_menu = gconf_client_get_bool (icon->priv->conf, GPM_CONF_UI_SHOW_ACTIONS, NULL);
432
290
        gpm_tray_icon_enable_actions (icon, allowed_in_menu);
433
 
@@ -404,7 +492,11 @@
 
291
@@ -486,7 +557,11 @@
434
292
 
435
293
        tray_icon = GPM_TRAY_ICON (object);
436
294