~ubuntu-branches/ubuntu/lucid/brasero/lucid-updates

« back to all changes in this revision

Viewing changes to debian/patches/012_appindicator.patch

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-03-04 11:30:57 UTC
  • Revision ID: james.westby@ubuntu.com-20100304113057-ibink4qkmpa64pp3
Tags: 2.29.91-0ubuntu2
* Add 012_appindicator.patch: Support application indicator, patch by Travis
  B. Hartwell. (LP: #497853)
* debian/control.in: Add libappindicator build dependency.
* Regenerate 99_autoconf.patch to pick up above patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Add appindicator support.
 
2
Author: Travis B. Hartwell <nafai@travishartwell.net>
 
3
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=606420
 
4
Bug-Ubuntu: https://launchpad.net/bugs/497853
 
5
 
 
6
Index: brasero-2.29.91/configure.in
 
7
===================================================================
 
8
--- brasero-2.29.91.orig/configure.in   2010-03-04 11:29:27.000000000 +0100
 
9
+++ brasero-2.29.91/configure.in        2010-03-04 11:29:17.000000000 +0100
 
10
@@ -369,6 +369,23 @@
 
11
 dnl fi
 
12
 dnl AM_CONDITIONAL(HAVE_LIBNOTIFY, test x"$build_libnotify" = "xyes")
 
13
 
 
14
+dnl ****************check for appindicators (optional) **************
 
15
+APPINDICATOR_REQUIRED=0.0.7
 
16
+
 
17
+AC_ARG_ENABLE(appindicator,
 
18
+                       AS_HELP_STRING([--enable-appindicator],[Build support for application indicators [[default=yes]]]),
 
19
+                       [enable_appindicator=$enableval],
 
20
+                       [enable_appindicator="yes"])
 
21
+
 
22
+if test x$enable_appindicator = xyes ; then
 
23
+       PKG_CHECK_MODULES(APP_INDICATOR,
 
24
+                       appindicator-0.1 >= $APPINDICATOR_REQUIRED)
 
25
+       AC_SUBST(APP_INDICATOR_CFLAGS)
 
26
+       AC_SUBST(APP_INDICATOR_LIBS)
 
27
+       AC_DEFINE(HAVE_APP_INDICATOR, 1, [Have AppIndicator])
 
28
+fi
 
29
+AM_CONDITIONAL(HAVE_APP_INDICATOR, test x"$enable_appindicator" = xyes)
 
30
+
 
31
 dnl ****************check for search (optional)**************
 
32
 BEAGLE_REQUIRED=0.3.0
 
33
 TRACKER_REQUIRED=0.7.0
 
34
@@ -638,6 +655,7 @@
 
35
        Build growisofs plugins : ${build_growisofs}
 
36
        Build libburnia plugins : ${build_libburnia}
 
37
        Build GObject-Introspection : ${found_introspection}
 
38
+       Build Application Indicators : ${enable_appindicator}
 
39
 "
 
40
 echo
 
41
 echo
 
42
Index: brasero-2.29.91/libbrasero-burn/Makefile.am
 
43
===================================================================
 
44
--- brasero-2.29.91.orig/libbrasero-burn/Makefile.am    2010-03-04 11:29:27.000000000 +0100
 
45
+++ brasero-2.29.91/libbrasero-burn/Makefile.am 2010-03-04 11:29:17.000000000 +0100
 
46
@@ -201,6 +201,12 @@
 
47
 libbrasero_burn_la_SOURCES += brasero-file-monitor.c brasero-file-monitor.h
 
48
 endif
 
49
 
 
50
+if HAVE_APP_INDICATOR
 
51
+libbrasero_burn_la_SOURCES += brasero-app-indicator.h brasero-app-indicator.c
 
52
+libbrasero_burn_la_LIBADD += @APP_INDICATOR_LIBS@
 
53
+INCLUDES += -DHAVE_APP_INDICATOR @APP_INDICATOR_CFLAGS@
 
54
+endif
 
55
+
 
56
 EXTRA_DIST =                   \
 
57
        libbrasero-marshal.list
 
58
 #      libbrasero-burn.symbols
 
59
Index: brasero-2.29.91/libbrasero-burn/brasero-app-indicator.c
 
60
===================================================================
 
61
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
62
+++ brasero-2.29.91/libbrasero-burn/brasero-app-indicator.c     2010-03-04 11:29:17.000000000 +0100
 
63
@@ -0,0 +1,364 @@
 
64
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
65
+/*
 
66
+ * Libbrasero-burn
 
67
+ * Copyright (C) Canonical 2010
 
68
+ *
 
69
+ * Libbrasero-burn is free software; you can redistribute it and/or modify
 
70
+ * it under the terms of the GNU General Public License as published by
 
71
+ * the Free Software Foundation; either version 2 of the License, or
 
72
+ * (at your option) any later version.
 
73
+ *
 
74
+ * The Libbrasero-burn authors hereby grant permission for non-GPL compatible
 
75
+ * GStreamer plugins to be used and distributed together with GStreamer
 
76
+ * and Libbrasero-burn. This permission is above and beyond the permissions granted
 
77
+ * by the GPL license by which Libbrasero-burn is covered. If you modify this code
 
78
+ * you may extend this exception to your version of the code, but you are not
 
79
+ * obligated to do so. If you do not wish to do so, delete this exception
 
80
+ * statement from your version.
 
81
+ *
 
82
+ * Libbrasero-burn is distributed in the hope that it will be useful,
 
83
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
84
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
85
+ * GNU Library General Public License for more details.
 
86
+ *
 
87
+ * You should have received a copy of the GNU General Public License
 
88
+ * along with this program; if not, write to:
 
89
+ *     The Free Software Foundation, Inc.,
 
90
+ *     51 Franklin Street, Fifth Floor
 
91
+ *     Boston, MA  02110-1301, USA.
 
92
+ */
 
93
+
 
94
+#ifdef HAVE_CONFIG_H
 
95
+#  include <config.h>
 
96
+#endif
 
97
+
 
98
+#include <glib.h>
 
99
+#include <glib/gi18n.h>
 
100
+
 
101
+#include <gtk/gtk.h>
 
102
+
 
103
+#include <libappindicator/app-indicator.h>
 
104
+
 
105
+#include "burn-basics.h"
 
106
+#include "brasero-app-indicator.h"
 
107
+
 
108
+static void brasero_app_indicator_class_init (BraseroAppIndicatorClass *klass);
 
109
+static void brasero_app_indicator_init (BraseroAppIndicator *sp);
 
110
+static void brasero_app_indicator_finalize (GObject *object);
 
111
+
 
112
+static void
 
113
+brasero_app_indicator_cancel_cb (GtkAction *action, BraseroAppIndicator *indicator);
 
114
+
 
115
+static void
 
116
+brasero_app_indicator_show_cb (GtkAction *action, BraseroAppIndicator *indicator);
 
117
+
 
118
+struct BraseroAppIndicatorPrivate {
 
119
+       AppIndicator *indicator;
 
120
+       BraseroBurnAction action;
 
121
+       gchar *action_string;
 
122
+
 
123
+       GtkUIManager *manager;
 
124
+
 
125
+       int rounded_percent;
 
126
+       int percent;
 
127
+};
 
128
+
 
129
+typedef enum {
 
130
+       CANCEL_SIGNAL,
 
131
+       CLOSE_AFTER_SIGNAL,
 
132
+       SHOW_DIALOG_SIGNAL,
 
133
+       LAST_SIGNAL
 
134
+} BraseroAppIndicatorSignalType;
 
135
 
136
+static guint brasero_app_indicator_signals[LAST_SIGNAL] = { 0 };
 
137
+static GObjectClass *parent_class = NULL;
 
138
+
 
139
+static GtkActionEntry entries[] = {
 
140
+       {"ContextualMenu", NULL, N_("Menu")},
 
141
+       {"Progress", NULL, "Progress"},
 
142
+       {"Cancel", GTK_STOCK_CANCEL, NULL, NULL, N_("Cancel ongoing burning"),
 
143
+        G_CALLBACK (brasero_app_indicator_cancel_cb)},
 
144
+};
 
145
+
 
146
+static GtkToggleActionEntry toggle_entries[] = {
 
147
+       {"Show", NULL, N_("Show _Dialog"), NULL, N_("Show dialog"),
 
148
+        G_CALLBACK (brasero_app_indicator_show_cb), TRUE,},
 
149
+};
 
150
+
 
151
+static const char *description = {
 
152
+       "<ui>"
 
153
+       "<popup action='ContextMenu'>"
 
154
+               "<menuitem action='Progress'/>"
 
155
+               "<separator/>"
 
156
+               "<menuitem action='Show'/>"
 
157
+               "<separator/>"
 
158
+               "<menuitem action='Cancel'/>"
 
159
+       "</popup>"
 
160
+       "</ui>"
 
161
+};
 
162
+
 
163
+G_DEFINE_TYPE (BraseroAppIndicator, brasero_app_indicator, G_TYPE_OBJECT);
 
164
+
 
165
+static void
 
166
+brasero_app_indicator_class_init (BraseroAppIndicatorClass *klass)
 
167
+{
 
168
+       GObjectClass *object_class = G_OBJECT_CLASS(klass);
 
169
+
 
170
+       parent_class = g_type_class_peek_parent(klass);
 
171
+       object_class->finalize = brasero_app_indicator_finalize;
 
172
+
 
173
+       brasero_app_indicator_signals[SHOW_DIALOG_SIGNAL] =
 
174
+           g_signal_new ("show_dialog",
 
175
+                         G_OBJECT_CLASS_TYPE (object_class),
 
176
+                         G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
 
177
+                         G_STRUCT_OFFSET (BraseroAppIndicatorClass,
 
178
+                                          show_dialog), NULL, NULL,
 
179
+                         g_cclosure_marshal_VOID__BOOLEAN,
 
180
+                         G_TYPE_NONE,
 
181
+                         1,
 
182
+                         G_TYPE_BOOLEAN);
 
183
+       brasero_app_indicator_signals[CANCEL_SIGNAL] =
 
184
+           g_signal_new ("cancel",
 
185
+                         G_OBJECT_CLASS_TYPE (object_class),
 
186
+                         G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
 
187
+                         G_STRUCT_OFFSET (BraseroAppIndicatorClass,
 
188
+                                          cancel), NULL, NULL,
 
189
+                         g_cclosure_marshal_VOID__VOID,
 
190
+                         G_TYPE_NONE,
 
191
+                         0);
 
192
+       brasero_app_indicator_signals[CLOSE_AFTER_SIGNAL] =
 
193
+           g_signal_new ("close_after",
 
194
+                         G_OBJECT_CLASS_TYPE (object_class),
 
195
+                         G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
 
196
+                         G_STRUCT_OFFSET (BraseroAppIndicatorClass,
 
197
+                                          close_after), NULL, NULL,
 
198
+                         g_cclosure_marshal_VOID__BOOLEAN,
 
199
+                         G_TYPE_NONE,
 
200
+                         1,
 
201
+                         G_TYPE_BOOLEAN);
 
202
+}
 
203
+
 
204
+static GtkWidget *
 
205
+brasero_app_indicator_build_menu (BraseroAppIndicator *indicator)
 
206
+{
 
207
+       GtkActionGroup *action_group;
 
208
+       GtkWidget *menu = NULL,
 
209
+               *menu_item = NULL;
 
210
+       GError *error = NULL;
 
211
+
 
212
+       action_group = gtk_action_group_new ("MenuAction");
 
213
+       gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
 
214
+       gtk_action_group_add_actions (action_group,
 
215
+                                     entries,
 
216
+                                     G_N_ELEMENTS (entries),
 
217
+                                     indicator);
 
218
+       gtk_action_group_add_toggle_actions (action_group,
 
219
+                                            toggle_entries,
 
220
+                                            G_N_ELEMENTS (toggle_entries),
 
221
+                                            indicator);
 
222
+
 
223
+       indicator->priv->manager = gtk_ui_manager_new ();
 
224
+       gtk_ui_manager_insert_action_group (indicator->priv->manager,
 
225
+                                           action_group,
 
226
+                                           0);
 
227
+
 
228
+       if (!gtk_ui_manager_add_ui_from_string (indicator->priv->manager,
 
229
+                                               description,
 
230
+                                               -1,
 
231
+                                               &error)) {
 
232
+               g_message ("building menus failed: %s", error->message);
 
233
+               g_error_free (error);
 
234
+       } else {
 
235
+               menu = gtk_ui_manager_get_widget (indicator->priv->manager, "/ContextMenu");
 
236
+               menu_item = gtk_ui_manager_get_widget (indicator->priv->manager, "/ContextMenu/Progress");
 
237
+               gtk_widget_set_sensitive (menu_item, FALSE);
 
238
+
 
239
+               menu_item = gtk_ui_manager_get_widget (indicator->priv->manager, "/ContextMenu/Cancel");
 
240
+               gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), GTK_WIDGET (gtk_image_new ()));
 
241
+       }
 
242
+
 
243
+       return menu;
 
244
+}
 
245
+
 
246
+void
 
247
+brasero_app_indicator_hide (BraseroAppIndicator *indicator)
 
248
+{
 
249
+       app_indicator_set_status (indicator->priv->indicator, APP_INDICATOR_STATUS_PASSIVE);
 
250
+}
 
251
+
 
252
+static void
 
253
+brasero_app_indicator_init (BraseroAppIndicator *obj)
 
254
+{
 
255
+       GtkWidget *indicator_menu;
 
256
+
 
257
+       obj->priv = g_new0 (BraseroAppIndicatorPrivate, 1);
 
258
+       indicator_menu =  brasero_app_indicator_build_menu (obj);
 
259
+
 
260
+       if (indicator_menu != NULL) {
 
261
+               obj->priv->indicator = app_indicator_new_with_path ("brasero",
 
262
+                                                                   "brasero-disc-00",
 
263
+                                                                   APP_INDICATOR_CATEGORY_APPLICATION_STATUS,
 
264
+                                                                   BRASERO_DATADIR "/icons");
 
265
+
 
266
+               app_indicator_set_status (obj->priv->indicator,
 
267
+                                         APP_INDICATOR_STATUS_ACTIVE);
 
268
+
 
269
+               app_indicator_set_menu (obj->priv->indicator, GTK_MENU (indicator_menu));
 
270
+       }
 
271
+}
 
272
+
 
273
+static void
 
274
+brasero_app_indicator_finalize (GObject *object)
 
275
+{
 
276
+       BraseroAppIndicator *cobj;
 
277
+
 
278
+       cobj = BRASERO_APPINDICATOR (object);
 
279
+
 
280
+       if (cobj->priv->action_string) {
 
281
+               g_free (cobj->priv->action_string);
 
282
+               cobj->priv->action_string = NULL;
 
283
+       }
 
284
+
 
285
+       g_object_unref (cobj->priv->indicator);
 
286
+       g_free (cobj->priv);
 
287
+       G_OBJECT_CLASS (parent_class)->finalize (object);
 
288
+}
 
289
+
 
290
+BraseroAppIndicator *
 
291
+brasero_app_indicator_new ()
 
292
+{
 
293
+       BraseroAppIndicator *obj;
 
294
+
 
295
+       obj = BRASERO_APPINDICATOR (g_object_new (BRASERO_TYPE_APPINDICATOR, NULL));
 
296
+
 
297
+       return obj;
 
298
+}
 
299
+
 
300
+static void
 
301
+brasero_app_indicator_set_progress_menu_text (BraseroAppIndicator *indicator,
 
302
+                                             glong remaining)
 
303
+{
 
304
+       gchar *text;
 
305
+       GtkWidget *progress;
 
306
+       const gchar *action_string;
 
307
+
 
308
+       if (!indicator->priv->action_string)
 
309
+               action_string = brasero_burn_action_to_string (indicator->priv->action);
 
310
+       else
 
311
+               action_string = indicator->priv->action_string;
 
312
+
 
313
+       if (remaining > 0) {
 
314
+               gchar *remaining_string;
 
315
+
 
316
+               remaining_string = brasero_units_get_time_string ((double) remaining * 1000000000, TRUE, FALSE);
 
317
+               text = g_strdup_printf (_("%s, %d%% done, %s remaining"),
 
318
+                                       action_string,
 
319
+                                       indicator->priv->percent,
 
320
+                                       remaining_string);
 
321
+               g_free (remaining_string);
 
322
+       }
 
323
+       else if (indicator->priv->percent > 0)
 
324
+               text = g_strdup_printf (_("%s, %d%% done"),
 
325
+                                       action_string,
 
326
+                                       indicator->priv->percent);
 
327
+       else
 
328
+               text = g_strdup (action_string);
 
329
+
 
330
+       /* Set the text on the menu */
 
331
+       progress = gtk_ui_manager_get_widget (indicator->priv->manager,
 
332
+                                             "/ContextMenu/Progress");
 
333
+       gtk_menu_item_set_label (GTK_MENU_ITEM (progress), text);
 
334
+       g_free (text);
 
335
+}
 
336
+
 
337
+void
 
338
+brasero_app_indicator_set_action (BraseroAppIndicator *indicator,
 
339
+                                 BraseroBurnAction action,
 
340
+                                 const gchar *string)
 
341
+{
 
342
+       indicator->priv->action = action;
 
343
+       if (indicator->priv->action_string)
 
344
+               g_free (indicator->priv->action_string);
 
345
+
 
346
+       if (string)
 
347
+               indicator->priv->action_string = g_strdup (string);
 
348
+       else
 
349
+               indicator->priv->action_string = NULL;
 
350
+
 
351
+       brasero_app_indicator_set_progress_menu_text (indicator, -1);
 
352
+}
 
353
+
 
354
+void
 
355
+brasero_app_indicator_set_progress (BraseroAppIndicator *indicator,
 
356
+                                   gdouble fraction,
 
357
+                                   glong remaining)
 
358
+{
 
359
+       gint percent;
 
360
+       gint remains;
 
361
+       gchar *icon_name;
 
362
+
 
363
+       percent = fraction * 100;
 
364
+       indicator->priv->percent = percent;
 
365
+
 
366
+       /* set the tooltip */
 
367
+       brasero_app_indicator_set_progress_menu_text (indicator, remaining);
 
368
+
 
369
+       /* change image if need be */
 
370
+       remains = percent % 5;
 
371
+       if (remains > 3)
 
372
+               percent += 5 - remains;
 
373
+       else
 
374
+               percent -= remains;
 
375
+
 
376
+       if (indicator->priv->rounded_percent == percent
 
377
+       ||  percent < 0 || percent > 100)
 
378
+               return;
 
379
+
 
380
+       indicator->priv->rounded_percent = percent;
 
381
+
 
382
+       icon_name = g_strdup_printf ("brasero-disc-%02i", percent);
 
383
+       app_indicator_set_icon(indicator->priv->indicator,
 
384
+                              icon_name);
 
385
+       g_free (icon_name);
 
386
+}
 
387
+
 
388
+static void
 
389
+brasero_app_indicator_change_show_dialog_state (BraseroAppIndicator *indicator)
 
390
+{
 
391
+       GtkAction *action;
 
392
+       gboolean active;
 
393
+
 
394
+       /* update menu */
 
395
+       action = gtk_ui_manager_get_action (indicator->priv->manager, "/ContextMenu/Show");
 
396
+       active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
 
397
+
 
398
+       /* signal show dialog was requested the dialog again */
 
399
+       g_signal_emit (indicator,
 
400
+                      brasero_app_indicator_signals [SHOW_DIALOG_SIGNAL],
 
401
+                      0,
 
402
+                      active);
 
403
+}
 
404
+
 
405
+static void
 
406
+brasero_app_indicator_cancel_cb (GtkAction *action, BraseroAppIndicator *indicator)
 
407
+{
 
408
+       g_signal_emit (indicator,
 
409
+                      brasero_app_indicator_signals [CANCEL_SIGNAL],
 
410
+                      0);
 
411
+}
 
412
+
 
413
+static void
 
414
+brasero_app_indicator_show_cb (GtkAction *action, BraseroAppIndicator *indicator)
 
415
+{
 
416
+       brasero_app_indicator_change_show_dialog_state (indicator);
 
417
+}
 
418
+
 
419
+void
 
420
+brasero_app_indicator_set_show_dialog (BraseroAppIndicator *indicator, gboolean show)
 
421
+{
 
422
+       GtkAction *action;
 
423
+
 
424
+       /* update menu */
 
425
+       action = gtk_ui_manager_get_action (indicator->priv->manager, "/ContextMenu/Show");
 
426
+       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show);
 
427
+}
 
428
Index: brasero-2.29.91/libbrasero-burn/brasero-app-indicator.h
 
429
===================================================================
 
430
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
 
431
+++ brasero-2.29.91/libbrasero-burn/brasero-app-indicator.h     2010-03-04 11:29:17.000000000 +0100
 
432
@@ -0,0 +1,88 @@
 
433
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
434
+/*
 
435
+ * Libbrasero-burn
 
436
+ * Copyright (C) Canonical 2010
 
437
+ *
 
438
+ * Libbrasero-burn is free software; you can redistribute it and/or modify
 
439
+ * it under the terms of the GNU General Public License as published by
 
440
+ * the Free Software Foundation; either version 2 of the License, or
 
441
+ * (at your option) any later version.
 
442
+ *
 
443
+ * The Libbrasero-burn authors hereby grant permission for non-GPL compatible
 
444
+ * GStreamer plugins to be used and distributed together with GStreamer
 
445
+ * and Libbrasero-burn. This permission is above and beyond the permissions granted
 
446
+ * by the GPL license by which Libbrasero-burn is covered. If you modify this code
 
447
+ * you may extend this exception to your version of the code, but you are not
 
448
+ * obligated to do so. If you do not wish to do so, delete this exception
 
449
+ * statement from your version.
 
450
+ * 
 
451
+ * Libbrasero-burn is distributed in the hope that it will be useful,
 
452
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
453
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
454
+ * GNU Library General Public License for more details.
 
455
+ * 
 
456
+ * You should have received a copy of the GNU General Public License
 
457
+ * along with this program; if not, write to:
 
458
+ *     The Free Software Foundation, Inc.,
 
459
+ *     51 Franklin Street, Fifth Floor
 
460
+ *     Boston, MA  02110-1301, USA.
 
461
+ */
 
462
+
 
463
+#ifndef APP_INDICATOR_H
 
464
+#define APP_INDICATOR_H
 
465
+
 
466
+#include <glib.h>
 
467
+#include <glib-object.h>
 
468
+
 
469
+#include <gtk/gtk.h>
 
470
+
 
471
+#include "burn-basics.h"
 
472
+
 
473
+G_BEGIN_DECLS
 
474
+
 
475
+#define BRASERO_TYPE_APPINDICATOR         (brasero_app_indicator_get_type ())
 
476
+#define BRASERO_APPINDICATOR(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), BRASERO_TYPE_APPINDICATOR, BraseroAppIndicator))
 
477
+#define BRASERO_APPINDICATOR_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), BRASERO_TYPE_APPINDICATOR, BraseroAppIndicatorClass))
 
478
+#define BRASERO_IS_APPINDICATOR(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), BRASERO_TYPE_APPINDICATOR))
 
479
+#define BRASERO_IS_APPINDICATOR_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), BRASERO_TYPE_APPINDICATOR))
 
480
+#define BRASERO_APPINDICATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), BRASERO_TYPE_APPINDICATOR, BraseroAppIndicatorClass))
 
481
+
 
482
+typedef struct BraseroAppIndicatorPrivate BraseroAppIndicatorPrivate;
 
483
+
 
484
+typedef struct {
 
485
+       GObject parent;
 
486
+       BraseroAppIndicatorPrivate *priv;
 
487
+} BraseroAppIndicator;
 
488
+
 
489
+typedef struct {
 
490
+       GObjectClass parent_class;
 
491
+
 
492
+       void            (*show_dialog)          (BraseroAppIndicator *indicator, gboolean show);
 
493
+       void            (*close_after)          (BraseroAppIndicator *indicator, gboolean close);
 
494
+       void            (*cancel)               (BraseroAppIndicator *indicator);
 
495
+
 
496
+} BraseroAppIndicatorClass;
 
497
+
 
498
+GType brasero_app_indicator_get_type (void);
 
499
+BraseroAppIndicator *brasero_app_indicator_new (void);
 
500
+
 
501
+void
 
502
+brasero_app_indicator_set_progress (BraseroAppIndicator *indicator,
 
503
+                                   gdouble fraction,
 
504
+                                   long remaining);
 
505
+
 
506
+void
 
507
+brasero_app_indicator_set_action (BraseroAppIndicator *indicator,
 
508
+                                 BraseroBurnAction action,
 
509
+                                 const gchar *string);
 
510
+
 
511
+void
 
512
+brasero_app_indicator_set_show_dialog (BraseroAppIndicator *indicator,
 
513
+                                      gboolean show);
 
514
+
 
515
+void
 
516
+brasero_app_indicator_hide (BraseroAppIndicator *indicator);
 
517
+
 
518
+G_END_DECLS
 
519
+
 
520
+#endif /* APP_INDICATOR_H */
 
521
Index: brasero-2.29.91/libbrasero-burn/brasero-burn-dialog.c
 
522
===================================================================
 
523
--- brasero-2.29.91.orig/libbrasero-burn/brasero-burn-dialog.c  2010-03-04 11:29:27.000000000 +0100
 
524
+++ brasero-2.29.91/libbrasero-burn/brasero-burn-dialog.c       2010-03-04 11:29:17.000000000 +0100
 
525
@@ -2,6 +2,7 @@
 
526
 /*
 
527
  * Libbrasero-burn
 
528
  * Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
 
529
+ * Copyright (C) Canonical 2010
 
530
  *
 
531
  * Libbrasero-burn is free software; you can redistribute it and/or modify
 
532
  * it under the terms of the GNU General Public License as published by
 
533
@@ -49,7 +50,11 @@
 
534
 
 
535
 #include "brasero-burn-dialog.h"
 
536
 
 
537
+#ifdef HAVE_APP_INDICATOR
 
538
+#include "brasero-app-indicator.h"
 
539
+#else
 
540
 #include "brasero-tray.h"
 
541
+#endif /* HAVE_APP_INDICATOR */
 
542
 #include "brasero-session-cfg.h"
 
543
 #include "brasero-session-helper.h"
 
544
 
 
545
@@ -75,6 +80,16 @@
 
546
 brasero_burn_dialog_cancel_clicked_cb (GtkWidget *button,
 
547
                                       BraseroBurnDialog *dialog);
 
548
 
 
549
+#ifdef HAVE_APP_INDICATOR
 
550
+static void
 
551
+brasero_burn_dialog_indicator_cancel_cb (BraseroAppIndicator *indicator,
 
552
+                                        BraseroBurnDialog *dialog);
 
553
+
 
554
+static void
 
555
+brasero_burn_dialog_indicator_show_dialog_cb (BraseroAppIndicator *indicator,
 
556
+                                             gboolean show,
 
557
+                                             GtkWidget *dialog);
 
558
+#else
 
559
 static void
 
560
 brasero_burn_dialog_tray_cancel_cb (BraseroTrayIcon *tray,
 
561
                                    BraseroBurnDialog *dialog);
 
562
@@ -83,6 +98,7 @@
 
563
 brasero_burn_dialog_tray_show_dialog_cb (BraseroTrayIcon *tray,
 
564
                                         gboolean show,
 
565
                                         GtkWidget *dialog);
 
566
+#endif /* HAVE_APP_INDICATOR */
 
567
 
 
568
 typedef struct BraseroBurnDialogPrivate BraseroBurnDialogPrivate;
 
569
 struct BraseroBurnDialogPrivate {
 
570
@@ -97,7 +113,12 @@
 
571
        GtkWidget *header;
 
572
        GtkWidget *cancel;
 
573
        GtkWidget *image;
 
574
+
 
575
+#ifdef HAVE_APP_INDICATOR
 
576
+       BraseroAppIndicator *indicator;
 
577
+#else
 
578
        BraseroTrayIcon *tray;
 
579
+#endif /* HAVE_APP_INDICATOR */
 
580
 
 
581
        /* for our final statistics */
 
582
        GTimer *total_time;
 
583
@@ -1196,9 +1217,15 @@
 
584
                                          mb_written,
 
585
                                          rate);
 
586
 
 
587
+#ifdef HAVE_APP_INDICATOR
 
588
+       brasero_app_indicator_set_progress (BRASERO_APPINDICATOR (priv->indicator),
 
589
+                                           task_progress,
 
590
+                                           remaining);
 
591
+#else
 
592
        brasero_tray_icon_set_progress (BRASERO_TRAYICON (priv->tray),
 
593
                                        task_progress,
 
594
                                        remaining);
 
595
+#endif /* HAVE_APP_INDICATOR */
 
596
 
 
597
        if (rate > 0 && priv->is_writing)
 
598
                priv->rates = g_slist_prepend (priv->rates, GINT_TO_POINTER ((gint) rate));
 
599
@@ -1249,9 +1276,15 @@
 
600
        brasero_burn_progress_set_action (BRASERO_BURN_PROGRESS (priv->progress),
 
601
                                          action,
 
602
                                          string);
 
603
+#ifdef HAVE_APP_INDICATOR
 
604
+       brasero_app_indicator_set_action (BRASERO_APPINDICATOR (priv->indicator),
 
605
+                                         action,
 
606
+                                         string);
 
607
+#else
 
608
        brasero_tray_icon_set_action (BRASERO_TRAYICON (priv->tray),
 
609
                                      action,
 
610
                                      string);
 
611
+#endif /* HAVE_APP_INDICATOR */
 
612
 }
 
613
 
 
614
 static void
 
615
@@ -1446,6 +1479,11 @@
 
616
                                          -1,
 
617
                                          -1,
 
618
                                          -1);
 
619
+
 
620
+#ifdef HAVE_APP_INDICATOR
 
621
+       brasero_app_indicator_hide (priv->indicator);
 
622
+#endif /* HAVE_APP_INDICATOR */
 
623
+
 
624
        /* Restore title */
 
625
        if (priv->initial_title)
 
626
                gtk_window_set_title (GTK_WINDOW (dialog), priv->initial_title);
 
627
@@ -1589,17 +1627,29 @@
 
628
                                          -1,
 
629
                                          -1);
 
630
 
 
631
+#ifdef HAVE_APP_INDICATOR
 
632
+       brasero_app_indicator_set_progress (BRASERO_APPINDICATOR (priv->indicator),
 
633
+                                           0.0,
 
634
+                                           -1);
 
635
+#else
 
636
        brasero_tray_icon_set_progress (BRASERO_TRAYICON (priv->tray),
 
637
                                        0.0,
 
638
                                        -1);
 
639
+#endif /* HAVE_APP_INDICATOR */
 
640
 
 
641
        brasero_burn_progress_set_action (BRASERO_BURN_PROGRESS (priv->progress),
 
642
                                          BRASERO_BURN_ACTION_NONE,
 
643
                                          NULL);
 
644
 
 
645
+#ifdef HAVE_APP_INDICATOR
 
646
+       brasero_app_indicator_set_action (BRASERO_APPINDICATOR (priv->indicator),
 
647
+                                         BRASERO_BURN_ACTION_NONE,
 
648
+                                         NULL);
 
649
+#else
 
650
        brasero_tray_icon_set_action (BRASERO_TRAYICON (priv->tray),
 
651
                                      BRASERO_BURN_ACTION_NONE,
 
652
                                      NULL);
 
653
+#endif /* HAVE_APP_INDICATOR */
 
654
 
 
655
        g_timer_continue (priv->total_time);
 
656
 
 
657
@@ -2468,7 +2518,12 @@
 
658
 
 
659
        priv = BRASERO_BURN_DIALOG_PRIVATE (widget);
 
660
 
 
661
+#ifdef HAVE_APP_INDICATOR
 
662
+       brasero_app_indicator_set_show_dialog (BRASERO_APPINDICATOR (priv->indicator),
 
663
+                                              FALSE);
 
664
+#else
 
665
        brasero_tray_icon_set_show_dialog (BRASERO_TRAYICON (priv->tray), FALSE);
 
666
+#endif /* HAVE_APP_INDICATOR */
 
667
        return TRUE;
 
668
 }
 
669
 
 
670
@@ -2480,6 +2535,40 @@
 
671
        brasero_burn_dialog_cancel (dialog, FALSE);
 
672
 }
 
673
 
 
674
+#ifdef HAVE_APP_INDICATOR
 
675
+static void
 
676
+brasero_burn_dialog_indicator_cancel_cb (BraseroAppIndicator *indicator,
 
677
+                                        BraseroBurnDialog *dialog)
 
678
+{
 
679
+       brasero_burn_dialog_cancel (dialog, FALSE);
 
680
+}
 
681
+
 
682
+static void
 
683
+brasero_burn_dialog_indicator_show_dialog_cb (BraseroAppIndicator *indicator,
 
684
+                                             gboolean show,
 
685
+                                             GtkWidget *dialog)
 
686
+{
 
687
+       BraseroBurnDialogPrivate *priv;
 
688
+
 
689
+       priv = BRASERO_BURN_DIALOG_PRIVATE (dialog);
 
690
+
 
691
+       /* we prevent to show the burn dialog once the success dialog has been
 
692
+        * shown to avoid the following strange behavior:
 
693
+        * Steps:
 
694
+        * - start burning
 
695
+        * - move to another workspace (ie, virtual desktop)
 
696
+        * - when the burning finishes, double-click the notification icon
 
697
+        * - you'll be unable to dismiss the dialogues normally and their behaviour will
 
698
+        *   be generally strange */
 
699
+       if (!priv->burn)
 
700
+               return;
 
701
+
 
702
+       if (show)
 
703
+               gtk_widget_show (dialog);
 
704
+       else
 
705
+               gtk_widget_hide (dialog);
 
706
+}
 
707
+#else
 
708
 static void
 
709
 brasero_burn_dialog_tray_cancel_cb (BraseroTrayIcon *tray,
 
710
                                    BraseroBurnDialog *dialog)
 
711
@@ -2512,6 +2601,7 @@
 
712
        else
 
713
                gtk_widget_hide (dialog);
 
714
 }
 
715
+#endif /* HAVE_APP_INDICATOR */
 
716
 
 
717
 static void
 
718
 brasero_burn_dialog_init (BraseroBurnDialog * obj)
 
719
@@ -2527,6 +2617,17 @@
 
720
 
 
721
        gtk_dialog_set_has_separator (GTK_DIALOG (obj), FALSE);
 
722
 
 
723
+#ifdef HAVE_APP_INDICATOR
 
724
+       priv->indicator = brasero_app_indicator_new ();
 
725
+       g_signal_connect (priv->indicator,
 
726
+                         "cancel",
 
727
+                         G_CALLBACK (brasero_burn_dialog_indicator_cancel_cb),
 
728
+                         obj);
 
729
+       g_signal_connect (priv->indicator,
 
730
+                         "show-dialog",
 
731
+                         G_CALLBACK (brasero_burn_dialog_indicator_show_dialog_cb),
 
732
+                         obj);
 
733
+#else
 
734
        priv->tray = brasero_tray_icon_new ();
 
735
        g_signal_connect (priv->tray,
 
736
                          "cancel",
 
737
@@ -2536,6 +2637,7 @@
 
738
                          "show-dialog",
 
739
                          G_CALLBACK (brasero_burn_dialog_tray_show_dialog_cb),
 
740
                          obj);
 
741
+#endif /* HAVE_APP_INDICATOR */
 
742
 
 
743
        alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
 
744
        gtk_widget_show (alignment);
 
745
@@ -2628,10 +2730,17 @@
 
746
                priv->burn = NULL;
 
747
        }
 
748
 
 
749
+#ifdef HAVE_APP_INDICATOR
 
750
+       if (priv->indicator) {
 
751
+               g_object_unref (priv->indicator);
 
752
+               priv->indicator = NULL;
 
753
+       }
 
754
+#else
 
755
        if (priv->tray) {
 
756
                g_object_unref (priv->tray);
 
757
                priv->tray = NULL;
 
758
        }
 
759
+#endif /* HAVE_APP_INDICATOR */
 
760
 
 
761
        if (priv->session) {
 
762
                g_object_unref (priv->session);