diff options
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/caja-application.c | 36 | ||||
-rw-r--r-- | src/caja-places-sidebar.c | 33 |
4 files changed, 67 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac index 908483b3..a9817a7b 100644 --- a/configure.ac +++ b/configure.ac @@ -11,6 +11,7 @@ m4_define(xml_minver, 2.4.7) m4_define(exif_minver, 0.6.14) m4_define(exempi_minver, 1.99.5) m4_define(gail_minver, 0.16) +m4_define(notify_minver, 0.7.0) dnl 1. If the library code has changed at all since last release, then increment revision. diff --git a/src/Makefile.am b/src/Makefile.am index e13f5bc2..5ad77ed4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -41,6 +41,7 @@ LDADD = \ $(EXIF_LIBS) \ $(EXEMPI_LIBS) \ $(POPT_LIBS) \ + -lnotify $(NULL) dbus_freedesktop_built_sources = \ diff --git a/src/caja-application.c b/src/caja-application.c index 23a4ec56..e1d8a892 100644 --- a/src/caja-application.c +++ b/src/caja-application.c @@ -90,6 +90,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> +#include <libnotify/notify.h> #else enum { COMMAND_0, /* unused: 0 is an invalid command */ @@ -158,8 +159,36 @@ struct _CajaApplicationPriv { gboolean force_desktop; gboolean autostart; gchar *geometry; + NotifyNotification *unmount_notify; }; +void +caja_application_notify_unmount_show (CajaApplication *application, + const gchar *message) +{ + gchar **strings; + + strings = g_strsplit (message, "\n", 0); + + if (application->priv->unmount_notify == NULL) { + application->priv->unmount_notify = + notify_notification_new (strings[0], strings[1], + "media-removable"); + + notify_notification_set_hint (application->priv->unmount_notify, + "transient", g_variant_new_boolean (TRUE)); + notify_notification_set_urgency (application->priv->unmount_notify, + NOTIFY_URGENCY_CRITICAL); + } else { + notify_notification_update (application->priv->unmount_notify, + strings[0], strings[1], + "media-removable"); + } + + notify_notification_show (application->priv->unmount_notify, NULL); + g_strfreev (strings); +} + #else G_DEFINE_TYPE (CajaApplication, caja_application, G_TYPE_OBJECT); @@ -597,6 +626,7 @@ caja_application_finalize (GObject *object) } g_free (application->priv->geometry); + #else if (application->volume_monitor) { @@ -634,7 +664,9 @@ caja_application_finalize (GObject *object) g_object_unref (application->ss_proxy); application->ss_proxy = NULL; } - +#if ENABLE_LIBUNIQUE == (FALSE) + notify_uninit (); +#endif G_OBJECT_CLASS (caja_application_parent_class)->finalize (object); } @@ -3204,7 +3236,7 @@ caja_application_startup (GApplication *app) menu_provider_init_callback (); /* Initialize the UI handler singleton for file operations */ - /*notify_init (GETTEXT_PACKAGE); */ + notify_init (GETTEXT_PACKAGE); /* Watch for unmounts so we can close open windows */ /* TODO-gio: This should be using the UNMOUNTED feature of GFileMonitor instead */ diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index a66bbc5c..ae0434e2 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -38,6 +38,9 @@ #include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> #include <glib/gi18n.h> +#if ENABLE_LIBUNIQUE == (FALSE) +#include <caja-application.h> +#endif #include <libcaja-private/caja-debug-log.h> #include <libcaja-private/caja-dnd.h> #include <libcaja-private/caja-bookmark.h> @@ -57,7 +60,9 @@ #include "caja-bookmark-list.h" #include "caja-places-sidebar.h" #include "caja-window.h" - +#if ENABLE_LIBUNIQUE == (FALSE) +#include <libnotify/notify.h> +#endif #define EJECT_BUTTON_XPAD 6 #define ICON_CELL_XPAD 6 @@ -2241,6 +2246,12 @@ drive_eject_cb (GObject *source_object, } g_error_free (error); } +#if ENABLE_LIBUNIQUE == (FALSE) + else { + CajaApplication *app = CAJA_APPLICATION (g_application_get_default ()); + caja_application_notify_unmount_show (app, "It is now safe to remove the drive"); + } +#endif } static void @@ -2270,8 +2281,14 @@ volume_eject_cb (GObject *source_object, NULL); g_free (primary); } - g_error_free (error); + g_error_free (error); + } +#if ENABLE_LIBUNIQUE == (FALSE) + else { + CajaApplication *app = CAJA_APPLICATION (g_application_get_default ()); + caja_application_notify_unmount_show (app, "It is now safe to remove the drive"); } +#endif } static void @@ -2303,6 +2320,12 @@ mount_eject_cb (GObject *source_object, } g_error_free (error); } +#if ENABLE_LIBUNIQUE == (FALSE) + else { + CajaApplication *app = CAJA_APPLICATION (g_application_get_default ()); + caja_application_notify_unmount_show (app, "It is now safe to remove the drive"); + } +#endif } static void @@ -2311,9 +2334,11 @@ do_eject (GMount *mount, GDrive *drive, CajaPlacesSidebar *sidebar) { + GMountOperation *mount_op; mount_op = gtk_mount_operation_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (sidebar)))); + if (mount != NULL) { caja_window_info_set_initiated_unmount (sidebar->window, TRUE); @@ -2332,6 +2357,10 @@ do_eject (GMount *mount, g_drive_eject_with_operation (drive, 0, mount_op, NULL, drive_eject_cb, g_object_ref (sidebar->window)); } +#if ENABLE_LIBUNIQUE == (FALSE) + CajaApplication *app = CAJA_APPLICATION (g_application_get_default ()); + caja_application_notify_unmount_show (app, "writing data to the drive-do not unplug"); +#endif g_object_unref (mount_op); } |