diff --git configure.in configure.in index a59e055..24e8904 100644 --- configure.in +++ configure.in @@ -368,6 +368,22 @@ dnl AC_DEFINE(HAVE_LIBNOTIFY, 1, [define if you want to use with libnotify supp dnl fi dnl AM_CONDITIONAL(HAVE_LIBNOTIFY, test x"$build_libnotify" = "xyes") +dnl ****************check for appindicators (optional) ************** +APPINDICATOR_REQS=0.0.7 + +PKG_CHECK_EXISTS(appindicator-0.1 >= $APPINDICATOR_REQS, [ + have_app_indicator=yes + AC_DEFINE(HAVE_APP_INDICATOR, 1, [Have AppIndicator]) +], [have_app_indicator=no]) +AM_CONDITIONAL(HAVE_APP_INDICATOR, test x"$have_app_indicator" = xyes) + +if test x$have_app_indicator = xyes ; then + PKG_CHECK_MODULES(APP_INDICATOR, + appindicator-0.1 >= $APPINDICATOR_REQS) + AC_SUBST(APP_INDICATOR_CFLAGS) + AC_SUBST(APP_INDICATOR_LIBS) +fi + dnl ****************check for search (optional)************** BEAGLE_REQUIRED=0.3.0 TRACKER_REQUIRED=0.7.0 @@ -637,6 +653,7 @@ echo "Version: $BRASERO_VERSION Build growisofs plugins : ${build_growisofs} Build libburnia plugins : ${build_libburnia} Build GObject-Introspection : ${found_introspection} + Build App Indicators : ${have_app_indicator} " echo echo diff --git libbrasero-burn/Makefile.am libbrasero-burn/Makefile.am index 4c9e7a6..ba5210b 100644 --- libbrasero-burn/Makefile.am +++ libbrasero-burn/Makefile.am @@ -201,6 +201,12 @@ if BUILD_INOTIFY libbrasero_burn_la_SOURCES += brasero-file-monitor.c brasero-file-monitor.h endif +if HAVE_APP_INDICATOR +libbrasero_burn_la_SOURCES += brasero-app-indicator.h brasero-app-indicator.c +libbrasero_burn_la_LIBADD += @APP_INDICATOR_LIBS@ +INCLUDES += -DHAVE_APP_INDICATOR @APP_INDICATOR_CFLAGS@ +endif + EXTRA_DIST = \ libbrasero-marshal.list # libbrasero-burn.symbols diff --git libbrasero-burn/brasero-app-indicator.c libbrasero-burn/brasero-app-indicator.c new file mode 100644 index 0000000..27f089d --- /dev/null +++ libbrasero-burn/brasero-app-indicator.c @@ -0,0 +1,354 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Libbrasero-burn + * Copyright (C) Canonical 2010 + * + * Libbrasero-burn is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The Libbrasero-burn authors hereby grant permission for non-GPL compatible + * GStreamer plugins to be used and distributed together with GStreamer + * and Libbrasero-burn. This permission is above and beyond the permissions granted + * by the GPL license by which Libbrasero-burn is covered. If you modify this code + * you may extend this exception to your version of the code, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * + * Libbrasero-burn is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include + +#include + +#include + +#include "burn-basics.h" +#include "brasero-app-indicator.h" + +static void brasero_app_indicator_class_init (BraseroAppIndicatorClass *klass); +static void brasero_app_indicator_init (BraseroAppIndicator *sp); +static void brasero_app_indicator_finalize (GObject *object); + +static void +brasero_app_indicator_cancel_cb (GtkAction *action, BraseroAppIndicator *indicator); + +static void +brasero_app_indicator_show_cb (GtkAction *action, BraseroAppIndicator *indicator); + +struct BraseroAppIndicatorPrivate { + AppIndicator *indicator; + BraseroBurnAction action; + gchar *action_string; + + GtkUIManager *manager; + + int rounded_percent; + int percent; +}; + +typedef enum { + CANCEL_SIGNAL, + CLOSE_AFTER_SIGNAL, + SHOW_DIALOG_SIGNAL, + LAST_SIGNAL +} BraseroAppIndicatorSignalType; + +static guint brasero_app_indicator_signals[LAST_SIGNAL] = { 0 }; +static GObjectClass *parent_class = NULL; + +static GtkActionEntry entries[] = { + {"ContextualMenu", NULL, N_("Menu")}, + {"Progress", NULL, "Progress"}, + {"Cancel", GTK_STOCK_CANCEL, NULL, NULL, N_("Cancel ongoing burning"), + G_CALLBACK (brasero_app_indicator_cancel_cb)}, +}; + +static GtkToggleActionEntry toggle_entries[] = { + {"Show", NULL, N_("Show _Dialog"), NULL, N_("Show dialog"), + G_CALLBACK (brasero_app_indicator_show_cb), TRUE,}, +}; + +static const char *description = { + "" + "" + "" + "" + "" + "" + "" + "" + "" +}; + +G_DEFINE_TYPE (BraseroAppIndicator, brasero_app_indicator, G_TYPE_OBJECT); + +static void +brasero_app_indicator_class_init (BraseroAppIndicatorClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS(klass); + + parent_class = g_type_class_peek_parent(klass); + object_class->finalize = brasero_app_indicator_finalize; + + brasero_app_indicator_signals[SHOW_DIALOG_SIGNAL] = + g_signal_new ("show_dialog", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (BraseroAppIndicatorClass, + show_dialog), NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, + 1, + G_TYPE_BOOLEAN); + brasero_app_indicator_signals[CANCEL_SIGNAL] = + g_signal_new ("cancel", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (BraseroAppIndicatorClass, + cancel), NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + brasero_app_indicator_signals[CLOSE_AFTER_SIGNAL] = + g_signal_new ("close_after", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (BraseroAppIndicatorClass, + close_after), NULL, NULL, + g_cclosure_marshal_VOID__BOOLEAN, + G_TYPE_NONE, + 1, + G_TYPE_BOOLEAN); +} + +static GtkWidget * +brasero_app_indicator_build_menu (BraseroAppIndicator *indicator) +{ + GtkActionGroup *action_group; + GtkWidget *menu = NULL, + *progress = NULL; + GError *error = NULL; + + action_group = gtk_action_group_new ("MenuAction"); + gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); + gtk_action_group_add_actions (action_group, + entries, + G_N_ELEMENTS (entries), + indicator); + gtk_action_group_add_toggle_actions (action_group, + toggle_entries, + G_N_ELEMENTS (toggle_entries), + indicator); + + indicator->priv->manager = gtk_ui_manager_new (); + gtk_ui_manager_insert_action_group (indicator->priv->manager, + action_group, + 0); + + if (!gtk_ui_manager_add_ui_from_string (indicator->priv->manager, + description, + -1, + &error)) { + g_message ("building menus failed: %s", error->message); + g_error_free (error); + } else { + menu = gtk_ui_manager_get_widget (indicator->priv->manager, "/ContextMenu"); + progress = gtk_ui_manager_get_widget (indicator->priv->manager, "/ContextMenu/Progress"); + gtk_widget_set_sensitive(progress, FALSE); + } + + return menu; +} + +static void +brasero_app_indicator_init (BraseroAppIndicator *obj) +{ + GtkWidget *indicator_menu; + + obj->priv = g_new0 (BraseroAppIndicatorPrivate, 1); + indicator_menu = brasero_app_indicator_build_menu (obj); + + if (indicator_menu != NULL) { + obj->priv->indicator = app_indicator_new_with_path ("brasero", + "brasero-disc-00", + APP_INDICATOR_CATEGORY_APPLICATION_STATUS, + BRASERO_DATADIR "/icons"); + + app_indicator_set_status (obj->priv->indicator, + APP_INDICATOR_STATUS_ACTIVE); + + app_indicator_set_menu (obj->priv->indicator, GTK_MENU (indicator_menu)); + } +} + +static void +brasero_app_indicator_finalize (GObject *object) +{ + BraseroAppIndicator *cobj; + + cobj = BRASERO_APPINDICATOR (object); + + if (cobj->priv->action_string) { + g_free (cobj->priv->action_string); + cobj->priv->action_string = NULL; + } + + g_free (cobj->priv); + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +BraseroAppIndicator * +brasero_app_indicator_new () +{ + BraseroAppIndicator *obj; + + obj = BRASERO_APPINDICATOR (g_object_new (BRASERO_TYPE_APPINDICATOR, NULL)); + + return obj; +} + +static void +brasero_app_indicator_set_progress_menu_text (BraseroAppIndicator *indicator, + glong remaining) +{ + gchar *text; + GtkWidget *progress; + const gchar *action_string; + + if (!indicator->priv->action_string) + action_string = brasero_burn_action_to_string (indicator->priv->action); + else + action_string = indicator->priv->action_string; + + if (remaining > 0) { + gchar *remaining_string; + + remaining_string = brasero_units_get_time_string ((double) remaining * 1000000000, TRUE, FALSE); + text = g_strdup_printf (_("%s, %d%% done, %s remaining"), + action_string, + indicator->priv->percent, + remaining_string); + g_free (remaining_string); + } + else if (indicator->priv->percent > 0) + text = g_strdup_printf (_("%s, %d%% done"), + action_string, + indicator->priv->percent); + else + text = g_strdup (action_string); + + /* Set the text on the menu */ + progress = gtk_ui_manager_get_widget (indicator->priv->manager, + "/ContextMenu/Progress"); + gtk_menu_item_set_label (GTK_MENU_ITEM (progress), text); + g_free (text); +} + +void +brasero_app_indicator_set_action (BraseroAppIndicator *indicator, + BraseroBurnAction action, + const gchar *string) +{ + indicator->priv->action = action; + if (indicator->priv->action_string) + g_free (indicator->priv->action_string); + + if (string) + indicator->priv->action_string = g_strdup (string); + else + indicator->priv->action_string = NULL; + + brasero_app_indicator_set_progress_menu_text (indicator, -1); +} + +void +brasero_app_indicator_set_progress (BraseroAppIndicator *indicator, + gdouble fraction, + glong remaining) +{ + gint percent; + gint remains; + gchar *icon_name; + + percent = fraction * 100; + indicator->priv->percent = percent; + + /* set the tooltip */ + brasero_app_indicator_set_progress_menu_text (indicator, remaining); + + /* change image if need be */ + remains = percent % 5; + if (remains > 3) + percent += 5 - remains; + else + percent -= remains; + + if (indicator->priv->rounded_percent == percent + || percent < 0 || percent > 100) + return; + + indicator->priv->rounded_percent = percent; + + icon_name = g_strdup_printf ("brasero-disc-%02i", percent); + app_indicator_set_icon(indicator->priv->indicator, + icon_name); + g_free (icon_name); +} + +static void +brasero_app_indicator_change_show_dialog_state (BraseroAppIndicator *indicator) +{ + GtkAction *action; + gboolean active; + + /* update menu */ + action = gtk_ui_manager_get_action (indicator->priv->manager, "/ContextMenu/Show"); + active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); + + /* signal show dialog was requested the dialog again */ + g_signal_emit (indicator, + brasero_app_indicator_signals [SHOW_DIALOG_SIGNAL], + 0, + active); +} + +static void +brasero_app_indicator_cancel_cb (GtkAction *action, BraseroAppIndicator *indicator) +{ + g_signal_emit (indicator, + brasero_app_indicator_signals [CANCEL_SIGNAL], + 0); +} + +static void +brasero_app_indicator_show_cb (GtkAction *action, BraseroAppIndicator *indicator) +{ + brasero_app_indicator_change_show_dialog_state (indicator); +} + +void +brasero_app_indicator_set_show_dialog (BraseroAppIndicator *indicator, gboolean show) +{ + GtkAction *action; + + /* update menu */ + action = gtk_ui_manager_get_action (indicator->priv->manager, "/ContextMenu/Show"); + gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), show); +} diff --git libbrasero-burn/brasero-app-indicator.h libbrasero-burn/brasero-app-indicator.h new file mode 100644 index 0000000..5343ac7 --- /dev/null +++ libbrasero-burn/brasero-app-indicator.h @@ -0,0 +1,85 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Libbrasero-burn + * Copyright (C) Canonical 2010 + * + * Libbrasero-burn is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * The Libbrasero-burn authors hereby grant permission for non-GPL compatible + * GStreamer plugins to be used and distributed together with GStreamer + * and Libbrasero-burn. This permission is above and beyond the permissions granted + * by the GPL license by which Libbrasero-burn is covered. If you modify this code + * you may extend this exception to your version of the code, but you are not + * obligated to do so. If you do not wish to do so, delete this exception + * statement from your version. + * + * Libbrasero-burn is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to: + * The Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301, USA. + */ + +#ifndef APP_INDICATOR_H +#define APP_INDICATOR_H + +#include +#include + +#include + +#include "burn-basics.h" + +G_BEGIN_DECLS + +#define BRASERO_TYPE_APPINDICATOR (brasero_app_indicator_get_type ()) +#define BRASERO_APPINDICATOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), BRASERO_TYPE_APPINDICATOR, BraseroAppIndicator)) +#define BRASERO_APPINDICATOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), BRASERO_TYPE_APPINDICATOR, BraseroAppIndicatorClass)) +#define BRASERO_IS_APPINDICATOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), BRASERO_TYPE_APPINDICATOR)) +#define BRASERO_IS_APPINDICATOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), BRASERO_TYPE_APPINDICATOR)) +#define BRASERO_APPINDICATOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), BRASERO_TYPE_APPINDICATOR, BraseroAppIndicatorClass)) + +typedef struct BraseroAppIndicatorPrivate BraseroAppIndicatorPrivate; + +typedef struct { + GObject parent; + BraseroAppIndicatorPrivate *priv; +} BraseroAppIndicator; + +typedef struct { + GObjectClass parent_class; + + void (*show_dialog) (BraseroAppIndicator *indicator, gboolean show); + void (*close_after) (BraseroAppIndicator *indicator, gboolean close); + void (*cancel) (BraseroAppIndicator *indicator); + +} BraseroAppIndicatorClass; + +GType brasero_app_indicator_get_type (void); +BraseroAppIndicator *brasero_app_indicator_new (void); + +void +brasero_app_indicator_set_progress (BraseroAppIndicator *indicator, + gdouble fraction, + long remaining); + +void +brasero_app_indicator_set_action (BraseroAppIndicator *indicator, + BraseroBurnAction action, + const gchar *string); + +void +brasero_app_indicator_set_show_dialog (BraseroAppIndicator *indicator, + gboolean show); + +G_END_DECLS + +#endif /* APP_INDICATOR_H */ diff --git libbrasero-burn/brasero-burn-dialog.c libbrasero-burn/brasero-burn-dialog.c index f5f908b..e2b5e3b 100644 --- libbrasero-burn/brasero-burn-dialog.c +++ libbrasero-burn/brasero-burn-dialog.c @@ -2,6 +2,7 @@ /* * Libbrasero-burn * Copyright (C) Philippe Rouquier 2005-2009 + * Copyright (C) Canonical 2010 * * Libbrasero-burn is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,12 +16,12 @@ * you may extend this exception to your version of the code, but you are not * obligated to do so. If you do not wish to do so, delete this exception * statement from your version. - * + * * Libbrasero-burn is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to: * The Free Software Foundation, Inc., @@ -49,7 +50,12 @@ #include "brasero-burn-dialog.h" +#ifdef HAVE_APP_INDICATOR +#include "brasero-app-indicator.h" +#else #include "brasero-tray.h" +#endif + #include "brasero-session-cfg.h" #include "brasero-session-helper.h" @@ -75,6 +81,16 @@ static void brasero_burn_dialog_cancel_clicked_cb (GtkWidget *button, BraseroBurnDialog *dialog); +#ifdef HAVE_APP_INDICATOR +static void +brasero_burn_dialog_indicator_cancel_cb (BraseroAppIndicator *indicator, + BraseroBurnDialog *dialog); + +static void +brasero_burn_dialog_indicator_show_dialog_cb (BraseroAppIndicator *indicator, + gboolean show, + GtkWidget *dialog); +#else static void brasero_burn_dialog_tray_cancel_cb (BraseroTrayIcon *tray, BraseroBurnDialog *dialog); @@ -83,6 +99,7 @@ static void brasero_burn_dialog_tray_show_dialog_cb (BraseroTrayIcon *tray, gboolean show, GtkWidget *dialog); +#endif typedef struct BraseroBurnDialogPrivate BraseroBurnDialogPrivate; struct BraseroBurnDialogPrivate { @@ -97,7 +114,12 @@ struct BraseroBurnDialogPrivate { GtkWidget *header; GtkWidget *cancel; GtkWidget *image; + +#ifdef HAVE_APP_INDICATOR + BraseroAppIndicator *indicator; +#else BraseroTrayIcon *tray; +#endif /* for our final statistics */ GTimer *total_time; @@ -185,7 +207,7 @@ brasero_burn_dialog_create_dialog_title_for_action (BraseroBurnDialog *dialog, action, percent); } - else + else /* Translators: This string is used in the title bar %s is the action currently performed */ tmp = g_strdup (action); @@ -354,7 +376,7 @@ brasero_burn_dialog_update_info (BraseroBurnDialog *dialog, header = g_strdup_printf ("%s", _("Simulation of image to CD burning")); else header = g_strdup_printf ("%s", _("Burning image to CD")); - + gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), "media-optical", GTK_ICON_SIZE_DIALOG); @@ -424,7 +446,7 @@ brasero_burn_dialog_wait_for_insertion_cb (BraseroDrive *drive, BraseroMedium *medium, GtkDialog *message) { - /* we might have a dialog waiting for the + /* we might have a dialog waiting for the * insertion of a disc if so close it */ gtk_dialog_response (GTK_DIALOG (message), GTK_RESPONSE_OK); } @@ -524,7 +546,7 @@ brasero_burn_dialog_get_media_type_string (BraseroBurn *burn, } else if (type & BRASERO_MEDIUM_WRITABLE) { gint64 isosize = 0; - + brasero_burn_status (burn, NULL, &isosize, @@ -534,14 +556,14 @@ brasero_burn_dialog_get_media_type_string (BraseroBurn *burn, if ((type & BRASERO_MEDIUM_CD) && !(type & BRASERO_MEDIUM_DVD)) { if (!insert) { if (isosize) - message = g_strdup_printf (_("Please replace the disc with a writable CD with at least %i MiB of free space."), + message = g_strdup_printf (_("Please replace the disc with a writable CD with at least %i MiB of free space."), (int) (isosize / 1048576)); else message = g_strdup (_("Please replace the disc with a writable CD.")); } else { if (isosize) - message = g_strdup_printf (_("Please insert a writable CD with at least %i MiB of free space."), + message = g_strdup_printf (_("Please insert a writable CD with at least %i MiB of free space."), (int) (isosize / 1048576)); else message = g_strdup (_("Please insert a writable CD.")); @@ -550,14 +572,14 @@ brasero_burn_dialog_get_media_type_string (BraseroBurn *burn, else if (!(type & BRASERO_MEDIUM_CD) && (type & BRASERO_MEDIUM_DVD)) { if (!insert) { if (isosize) - message = g_strdup_printf (_("Please replace the disc with a writable DVD with at least %i MiB of free space."), + message = g_strdup_printf (_("Please replace the disc with a writable DVD with at least %i MiB of free space."), (int) (isosize / 1048576)); else message = g_strdup (_("Please replace the disc with a writable DVD.")); } else { if (isosize) - message = g_strdup_printf (_("Please insert a writable DVD with at least %i MiB of free space."), + message = g_strdup_printf (_("Please insert a writable DVD with at least %i MiB of free space."), (int) (isosize / 1048576)); else message = g_strdup (_("Please insert a writable DVD.")); @@ -565,14 +587,14 @@ brasero_burn_dialog_get_media_type_string (BraseroBurn *burn, } else if (!insert) { if (isosize) - message = g_strdup_printf (_("Please replace the disc with a writable CD or DVD with at least %i MiB of free space."), + message = g_strdup_printf (_("Please replace the disc with a writable CD or DVD with at least %i MiB of free space."), (int) (isosize / 1048576)); else message = g_strdup (_("Please replace the disc with a writable CD or DVD.")); } else { if (isosize) - message = g_strdup_printf (_("Please insert a writable CD or DVD with at least %i MiB of free space."), + message = g_strdup_printf (_("Please insert a writable CD or DVD with at least %i MiB of free space."), (int) (isosize / 1048576)); else message = g_strdup (_("Please insert a writable CD or DVD.")); @@ -614,7 +636,7 @@ brasero_burn_dialog_insert_disc_cb (BraseroBurn *burn, /* Translators: %s is the name of a drive */ main_message = g_strdup_printf (_("\"%s\" is busy."), drive_name); secondary_message = g_strdup_printf ("%s.", _("Make sure another application is not using it")); - } + } else if (error == BRASERO_BURN_ERROR_MEDIUM_NONE) { secondary_message = g_strdup_printf (_("There is no disc in \"%s\"."), drive_name); main_message = brasero_burn_dialog_get_media_type_string (burn, type, TRUE); @@ -808,7 +830,7 @@ brasero_burn_dialog_image_error (BraseroBurn *burn, } static BraseroBurnResult -brasero_burn_dialog_loss_warnings_cb (BraseroBurnDialog *dialog, +brasero_burn_dialog_loss_warnings_cb (BraseroBurnDialog *dialog, const gchar *main_message, const gchar *secondary_message, const gchar *button_text, @@ -911,7 +933,7 @@ brasero_burn_dialog_previous_session_loss_cb (BraseroBurn *burn, secondary = g_strdup_printf ("%s\n%s", _("If you import them you will be able to see and use them once the current selection of files is burned."), _("If you don't, they will be invisible (though still readable).")); - + result = brasero_burn_dialog_loss_warnings_cb (dialog, _("There are files already burned on this disc. Would you like to import them?"), secondary, @@ -970,7 +992,7 @@ brasero_burn_dialog_wait_for_ejection_cb (BraseroDrive *drive, BraseroMedium *medium, GtkDialog *message) { - /* we might have a dialog waiting for the + /* we might have a dialog waiting for the * insertion of a disc if so close it */ gtk_dialog_response (GTK_DIALOG (message), GTK_RESPONSE_OK); } @@ -1074,7 +1096,7 @@ brasero_burn_dialog_disable_joliet_cb (BraseroBurn *burn, gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); - + result = gtk_dialog_run (GTK_DIALOG (message)); gtk_widget_destroy (message); @@ -1177,7 +1199,7 @@ brasero_burn_dialog_progress_changed_real (BraseroBurnDialog *dialog, if (written >= 0) mb_written = (gint) (written / 1048576); - + if (isosize > 0) mb_isosize = (gint) (isosize / 1048576); @@ -1196,16 +1218,22 @@ brasero_burn_dialog_progress_changed_real (BraseroBurnDialog *dialog, mb_written, rate); +#ifdef HAVE_APP_INDICATOR + brasero_app_indicator_set_progress (BRASERO_APPINDICATOR (priv->indicator), + task_progress, + remaining); +#else brasero_tray_icon_set_progress (BRASERO_TRAYICON (priv->tray), task_progress, remaining); +#endif if (rate > 0 && priv->is_writing) priv->rates = g_slist_prepend (priv->rates, GINT_TO_POINTER ((gint) rate)); } static void -brasero_burn_dialog_progress_changed_cb (BraseroBurn *burn, +brasero_burn_dialog_progress_changed_cb (BraseroBurn *burn, gdouble overall_progress, gdouble task_progress, glong remaining, @@ -1249,13 +1277,19 @@ brasero_burn_dialog_action_changed_real (BraseroBurnDialog *dialog, brasero_burn_progress_set_action (BRASERO_BURN_PROGRESS (priv->progress), action, string); +#ifdef HAVE_APP_INDICATOR + brasero_app_indicator_set_action (BRASERO_APPINDICATOR (priv->indicator), + action, + string); +#else brasero_tray_icon_set_action (BRASERO_TRAYICON (priv->tray), action, string); +#endif } static void -brasero_burn_dialog_action_changed_cb (BraseroBurn *burn, +brasero_burn_dialog_action_changed_cb (BraseroBurn *burn, BraseroBurnAction action, BraseroBurnDialog *dialog) { @@ -1589,17 +1623,29 @@ brasero_burn_dialog_setup_session (BraseroBurnDialog *dialog, -1, -1); +#ifdef HAVE_APP_INDICATOR + brasero_app_indicator_set_progress (BRASERO_APPINDICATOR (priv->indicator), + 0.0, + -1); +#else brasero_tray_icon_set_progress (BRASERO_TRAYICON (priv->tray), 0.0, -1); +#endif brasero_burn_progress_set_action (BRASERO_BURN_PROGRESS (priv->progress), BRASERO_BURN_ACTION_NONE, NULL); +#ifdef HAVE_APP_INDICATOR + brasero_app_indicator_set_action (BRASERO_APPINDICATOR (priv->indicator), + BRASERO_BURN_ACTION_NONE, + NULL); +#else brasero_tray_icon_set_action (BRASERO_TRAYICON (priv->tray), BRASERO_BURN_ACTION_NONE, NULL); +#endif g_timer_continue (priv->total_time); @@ -2119,7 +2165,7 @@ brasero_burn_dialog_record_spanned_session (BraseroBurnDialog *dialog, res = brasero_burn_dialog_wait_for_insertion (dialog, burner, _("Please insert a writable CD or DVD."), - secondary_message, + secondary_message, TRUE); if (res != GTK_RESPONSE_OK) { @@ -2417,7 +2463,7 @@ brasero_burn_dialog_cancel_dialog (BraseroBurnDialog *toplevel) gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); - + result = gtk_dialog_run (GTK_DIALOG (message)); gtk_widget_destroy (message); @@ -2461,14 +2507,19 @@ brasero_burn_dialog_cancel (BraseroBurnDialog *dialog, } static gboolean -brasero_burn_dialog_delete (GtkWidget *widget, +brasero_burn_dialog_delete (GtkWidget *widget, GdkEventAny *event) { BraseroBurnDialogPrivate *priv; priv = BRASERO_BURN_DIALOG_PRIVATE (widget); +#ifdef HAVE_APP_INDICATOR + brasero_app_indicator_set_show_dialog (BRASERO_APPINDICATOR (priv->indicator), + FALSE); +#else brasero_tray_icon_set_show_dialog (BRASERO_TRAYICON (priv->tray), FALSE); +#endif return TRUE; } @@ -2480,6 +2531,40 @@ brasero_burn_dialog_cancel_clicked_cb (GtkWidget *button, brasero_burn_dialog_cancel (dialog, FALSE); } +#ifdef HAVE_APP_INDICATOR +static void +brasero_burn_dialog_indicator_cancel_cb (BraseroAppIndicator *indicator, + BraseroBurnDialog *dialog) +{ + brasero_burn_dialog_cancel (dialog, FALSE); +} + +static void +brasero_burn_dialog_indicator_show_dialog_cb (BraseroAppIndicator *indicator, + gboolean show, + GtkWidget *dialog) +{ + BraseroBurnDialogPrivate *priv; + + priv = BRASERO_BURN_DIALOG_PRIVATE (dialog); + + /* we prevent to show the burn dialog once the success dialog has been + * shown to avoid the following strange behavior: + * Steps: + * - start burning + * - move to another workspace (ie, virtual desktop) + * - when the burning finishes, double-click the notification icon + * - you'll be unable to dismiss the dialogues normally and their behaviour will + * be generally strange */ + if (!priv->burn) + return; + + if (show) + gtk_widget_show (dialog); + else + gtk_widget_hide (dialog); +} +#else static void brasero_burn_dialog_tray_cancel_cb (BraseroTrayIcon *tray, BraseroBurnDialog *dialog) @@ -2496,7 +2581,7 @@ brasero_burn_dialog_tray_show_dialog_cb (BraseroTrayIcon *tray, priv = BRASERO_BURN_DIALOG_PRIVATE (dialog); - /* we prevent to show the burn dialog once the success dialog has been + /* we prevent to show the burn dialog once the success dialog has been * shown to avoid the following strange behavior: * Steps: * - start burning @@ -2512,6 +2597,8 @@ brasero_burn_dialog_tray_show_dialog_cb (BraseroTrayIcon *tray, else gtk_widget_hide (dialog); } +#endif + static void brasero_burn_dialog_init (BraseroBurnDialog * obj) @@ -2527,6 +2614,17 @@ brasero_burn_dialog_init (BraseroBurnDialog * obj) gtk_dialog_set_has_separator (GTK_DIALOG (obj), FALSE); +#ifdef HAVE_APP_INDICATOR + priv->indicator = brasero_app_indicator_new (); + g_signal_connect (priv->indicator, + "cancel", + G_CALLBACK (brasero_burn_dialog_indicator_cancel_cb), + obj); + g_signal_connect (priv->indicator, + "show-dialog", + G_CALLBACK (brasero_burn_dialog_indicator_show_dialog_cb), + obj); +#else priv->tray = brasero_tray_icon_new (); g_signal_connect (priv->tray, "cancel", @@ -2536,6 +2634,7 @@ brasero_burn_dialog_init (BraseroBurnDialog * obj) "show-dialog", G_CALLBACK (brasero_burn_dialog_tray_show_dialog_cb), obj); +#endif alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); gtk_widget_show (alignment); @@ -2628,10 +2727,17 @@ brasero_burn_dialog_finalize (GObject * object) priv->burn = NULL; } +#ifdef HAVE_APP_INDICATOR + if (priv->indicator) { + g_object_unref (priv->indicator); + priv->indicator = NULL; + } +#else if (priv->tray) { g_object_unref (priv->tray); priv->tray = NULL; } +#endif if (priv->session) { g_object_unref (priv->session);