gnome-disk-utility/no-statusicon.patch

203 lines
9.1 KiB
Diff
Raw Normal View History

2010-11-03 20:43:34 +00:00
diff -up gnome-disk-utility-2.32.0/src/notification/notification-main.c.no-statusicon gnome-disk-utility-2.32.0/src/notification/notification-main.c
--- gnome-disk-utility-2.32.0/src/notification/notification-main.c.no-statusicon 2010-08-05 13:03:58.000000000 -0400
+++ gnome-disk-utility-2.32.0/src/notification/notification-main.c 2010-11-03 16:29:01.159241997 -0400
@@ -39,16 +39,12 @@ typedef struct
{
GduPool *pool;
- GtkStatusIcon *status_icon;
-
/* List of GduDevice objects currently being unmounted */
GList *devices_being_unmounted;
/* List of GduDevice objects with ATA SMART failures */
GList *ata_smart_failures;
- gboolean show_icon_for_ata_smart_failures;
-
NotifyNotification *ata_smart_notification;
GFileMonitor *ata_smart_ignore_monitor;
@@ -69,9 +65,7 @@ static void update_unmount_dialogs (Noti
static void update_ata_smart_failures (NotificationData *data);
-static void update_status_icon (NotificationData *data);
-
-static void show_menu_for_status_icon (NotificationData *data);
+static void update_notification (NotificationData *data);
/* ---------------------------------------------------------------------------------------------------- */
@@ -119,24 +113,6 @@ on_device_job_changed (GduPool *pool,
}
static void
-on_status_icon_activate (GtkStatusIcon *status_icon,
- gpointer user_data)
-{
- NotificationData *data = user_data;
- show_menu_for_status_icon (data);
-}
-
-static void
-on_status_icon_popup_menu (GtkStatusIcon *status_icon,
- guint button,
- guint activate_time,
- gpointer user_data)
-{
- NotificationData *data = user_data;
- show_menu_for_status_icon (data);
-}
-
-static void
on_ata_smart_ignore_monitor_changed (GFileMonitor *monitor,
GFile *file,
GFile *other_file,
@@ -164,13 +140,6 @@ notification_data_new (void)
g_signal_connect (data->pool, "device-changed", G_CALLBACK (on_device_changed), data);
g_signal_connect (data->pool, "device-job-changed", G_CALLBACK (on_device_job_changed), data);
- data->status_icon = gtk_status_icon_new ();
- gtk_status_icon_set_visible (data->status_icon, FALSE);
- gtk_status_icon_set_from_icon_name (data->status_icon, "gdu-warning");
- gtk_status_icon_set_tooltip_markup (data->status_icon, _("One or more disks are failing"));
- g_signal_connect (data->status_icon, "activate", G_CALLBACK (on_status_icon_activate), data);
- g_signal_connect (data->status_icon, "popup-menu", G_CALLBACK (on_status_icon_popup_menu), data);
-
dir_path = g_build_filename (g_get_user_config_dir (),
"gnome-disk-utility",
"ata-smart-ignore",
@@ -208,10 +177,6 @@ notification_data_new (void)
static void
notification_data_free (NotificationData *data)
{
- g_signal_handlers_disconnect_by_func (data->status_icon, on_status_icon_activate, data);
- g_signal_handlers_disconnect_by_func (data->status_icon, on_status_icon_popup_menu, data);
- g_object_unref (data->status_icon);
-
g_signal_handlers_disconnect_by_func (data->pool, on_device_added, data);
g_signal_handlers_disconnect_by_func (data->pool, on_device_removed, data);
g_signal_handlers_disconnect_by_func (data->pool, on_device_changed, data);
@@ -478,72 +443,69 @@ update_ata_smart_failures (NotificationD
g_list_foreach (devices, (GFunc) g_object_unref, NULL);
g_list_free (devices);
- update_status_icon (data);
+ update_notification (data);
}
/* ---------------------------------------------------------------------------------------------------- */
-static gboolean
-show_notification (NotificationData *data)
+static void
+on_examine_action_clicked (NotifyNotification *notification,
+ char *action,
+ NotificationData *data)
{
- static int count = 0;
-
- /* wait for the panel to be settled before showing a bubble */
- if (gtk_status_icon_is_embedded (data->status_icon)) {
- notify_notification_show (data->ata_smart_notification, NULL);
- } else if (count < 20) {
- count++;
- g_timeout_add_seconds (1, (GSourceFunc) show_notification, data);
- } else {
- g_warning ("No notification area. Notification bubbles will not be displayed.");
- }
- return FALSE;
+ g_spawn_command_line_async ("palimpsest", NULL);
}
static void
-update_status_icon (NotificationData *data)
+update_notification (NotificationData *data)
{
- gboolean show_icon;
- gboolean old_show_icon_for_ata_smart_failures;
-
- old_show_icon_for_ata_smart_failures = data->show_icon_for_ata_smart_failures;
+ int num_drives;
- data->show_icon_for_ata_smart_failures = FALSE;
- if (g_list_length (data->ata_smart_failures) > 0)
- data->show_icon_for_ata_smart_failures = TRUE;
-
- show_icon = data->show_icon_for_ata_smart_failures;
-
- if (!show_icon) {
+ if (data->ata_smart_notification != NULL) {
if (data->ata_smart_notification != NULL) {
notify_notification_close (data->ata_smart_notification, NULL);
g_object_unref (data->ata_smart_notification);
data->ata_smart_notification = NULL;
}
- gtk_status_icon_set_visible (data->status_icon, FALSE);
goto out;
}
- gtk_status_icon_set_visible (data->status_icon, TRUE);
-
- /* we've started showing the icon for ATA RAID failures; pop up a libnotify notification */
- if (old_show_icon_for_ata_smart_failures != data->show_icon_for_ata_smart_failures) {
+ num_drives = g_list_length (data->ata_smart_failures);
+ if (data->ata_smart_notification == NULL) {
+ data->ata_smart_notification = notify_notification_new (
+ /* Translators: This is used as the title of the notification */
+ _("Hard Disk Problems Detected"),
+ /* Translators: This is used as the text of the notification*/
+ g_dngettext (GETTEXT_PACKAGE,
+ N_("A hard disk is reporting health problems."),
+ N_("Multiple system hard disks are reporting health problems."),
+ num_drives),
+ "gdu-warning");
- data->ata_smart_notification = notify_notification_new (
- /* Translators: This is used as the title of the notification */
- _("A hard disk may be failing"),
- /* Translators: This is used as the text of the notification*/
- _("One or more hard disks report health problems. Click the icon to get more information."),
- "gtk-dialog-warning",
- NULL);
- notify_notification_attach_to_status_icon (data->ata_smart_notification,
- data->status_icon);
notify_notification_set_urgency (data->ata_smart_notification, NOTIFY_URGENCY_CRITICAL);
notify_notification_set_timeout (data->ata_smart_notification, NOTIFY_EXPIRES_NEVER);
- show_notification (data);
+ notify_notification_add_action (data->ata_smart_notification,
+ "examine",
+ _("Examine"),
+ (NotifyActionCallback) on_examine_action_clicked,
+ data,
+ NULL);
+ } else {
+ notify_notification_update (data->ata_smart_notification,
+ /* Translators: This is used as the title of the notification */
+ _("Hard Disk Problems Detected"),
+ /* Translators: This is used as the text of the notification*/
+ g_dngettext (GETTEXT_PACKAGE,
+ N_("A hard disk is reporting health problems."),
+ N_("Multiple hard disks are reporting health problems."),
+ num_drives),
+ "gdu-warning");
+
}
+ notify_notification_show (data->ata_smart_notification, NULL);
+
out:
;
}
@@ -693,7 +655,7 @@ main (int argc, char **argv)
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- notify_init ("gdu-notification-daemon");
+ notify_init (_("Disk Utility"));
gtk_window_set_default_icon_name ("palimpsest");