File nautilus-show-notification.patch of Package nautilus.27046

Index: nautilus-3.20.3/libnautilus-private/nautilus-file-operations.c
===================================================================
--- nautilus-3.20.3.orig/libnautilus-private/nautilus-file-operations.c
+++ nautilus-3.20.3/libnautilus-private/nautilus-file-operations.c
@@ -63,6 +63,7 @@
 #include "nautilus-file-conflict-dialog.h"
 #include "nautilus-file-undo-operations.h"
 #include "nautilus-file-undo-manager.h"
+#include "nautilus-ui-utilities.h"
 
 /* TODO: TESTING!!! */
 
@@ -2364,6 +2365,12 @@ do_unmount (UnmountData *data)
 	} else {
 		mount_op = gtk_mount_operation_new (data->parent_window);
 	}
+
+	g_signal_connect (mount_op, "show-unmount-progress",
+			  G_CALLBACK (file_show_unmount_progress_cb), NULL);
+	g_signal_connect (mount_op, "aborted",
+			  G_CALLBACK (file_show_unmount_progress_aborted_cb), NULL);
+
 	if (data->eject) {
 		g_mount_eject_with_operation (data->mount,
 					      0,
Index: nautilus-3.20.3/libnautilus-private/nautilus-ui-utilities.c
===================================================================
--- nautilus-3.20.3.orig/libnautilus-private/nautilus-ui-utilities.c
+++ nautilus-3.20.3/libnautilus-private/nautilus-ui-utilities.c
@@ -32,6 +32,7 @@
 #include <libgd/gd.h>
 #include <string.h>
 #include <glib/gi18n.h>
+#include "src/nautilus-application.h"
 
 static GMenuModel *
 find_gmenu_model (GMenuModel  *model,
@@ -434,3 +435,85 @@ get_text_for_date_range (GPtrArray *date
   return label;
 }
 
+static void
+notify_unmount_done (GMountOperation *op,
+                     const gchar     *message)
+{
+    NautilusApplication *application;
+    gchar *notification_id;
+
+    application = nautilus_application_get_default ();
+    notification_id = g_strdup_printf ("nautilus-mount-operation-%p", op);
+    nautilus_application_withdraw_notification (application, notification_id);
+
+    if (message != NULL)
+    {
+        GNotification *unplug;
+        GIcon *icon;
+        gchar **strings;
+
+        strings = g_strsplit (message, "\n", 0);
+        icon = g_themed_icon_new ("media-removable");
+        unplug = g_notification_new (strings[0]);
+        g_notification_set_body (unplug, strings[1]);
+        g_notification_set_icon (unplug, icon);
+
+        nautilus_application_send_notification (application, notification_id, unplug);
+        g_object_unref (unplug);
+        g_object_unref (icon);
+        g_strfreev (strings);
+    }
+
+    g_free (notification_id);
+}
+
+static void
+notify_unmount_show (GMountOperation *op,
+                     const gchar     *message)
+{
+    NautilusApplication *application;
+    GNotification *unmount;
+    gchar *notification_id;
+    GIcon *icon;
+    gchar **strings;
+
+    application = nautilus_application_get_default ();
+    strings = g_strsplit (message, "\n", 0);
+    icon = g_themed_icon_new ("media-removable");
+
+    unmount = g_notification_new (strings[0]);
+    g_notification_set_body (unmount, strings[1]);
+    g_notification_set_icon (unmount, icon);
+    g_notification_set_priority (unmount, G_NOTIFICATION_PRIORITY_URGENT);
+
+    notification_id = g_strdup_printf ("nautilus-mount-operation-%p", op);
+    nautilus_application_send_notification (application, notification_id, unmount);
+    g_object_unref (unmount);
+    g_object_unref (icon);
+    g_strfreev (strings);
+    g_free (notification_id);
+}
+
+void
+file_show_unmount_progress_cb (GMountOperation *op,
+                          const gchar     *message,
+                          gint64           time_left,
+                          gint64           bytes_left,
+                          gpointer         user_data)
+{
+    if (bytes_left == 0)
+    {
+        notify_unmount_done (op, message);
+    }
+    else
+    {
+        notify_unmount_show (op, message);
+    }
+}
+
+void
+file_show_unmount_progress_aborted_cb (GMountOperation *op,
+                                  gpointer         user_data)
+{
+    notify_unmount_done (op, NULL);
+}
Index: nautilus-3.20.3/libnautilus-private/nautilus-ui-utilities.h
===================================================================
--- nautilus-3.20.3.orig/libnautilus-private/nautilus-ui-utilities.h
+++ nautilus-3.20.3/libnautilus-private/nautilus-ui-utilities.h
@@ -52,4 +52,12 @@ gboolean   nautilus_file_date_in_between
                                                     GDateTime         *end_date);
 gchar*     get_text_for_date_range                 (GPtrArray         *date_range);
 
+
+void        file_show_unmount_progress_cb               (GMountOperation   *op,
+                                                    const gchar       *message,
+                                                    gint64             time_left,
+                                                    gint64             bytes_left,
+                                                    gpointer           user_data);
+void        file_show_unmount_progress_aborted_cb       (GMountOperation   *op,
+                                                    gpointer           user_data);
 #endif /* NAUTILUS_UI_UTILITIES_H */
Index: nautilus-3.20.3/src/Makefile.am
===================================================================
--- nautilus-3.20.3.orig/src/Makefile.am
+++ nautilus-3.20.3/src/Makefile.am
@@ -5,6 +5,99 @@ bin_PROGRAMS=					\
 	nautilus-autorun-software		\
 	$(NULL)
 
+noinst_LIBRARIES=libnautilus-test.a
+
+libnautilus_test_a_LDFLAGS =	\
+	-no-undefined			\
+	$(NULL)
+
+libnautilus_test_a_SOURCES = \
+	$(nautilus_built_sources) \
+	gtk/nautilusgtkplacesview.c			\
+	gtk/nautilusgtkplacesviewprivate.h		\
+	gtk/nautilusgtkplacesviewrow.c			\
+	gtk/nautilusgtkplacesviewrowprivate.h		\
+	nautilus-application.c			\
+	nautilus-application.h			\
+	nautilus-bookmark-list.c		\
+	nautilus-bookmark-list.h		\
+	nautilus-canvas-view.c			\
+	nautilus-canvas-view.h			\
+	nautilus-canvas-view-container.c	\
+	nautilus-canvas-view-container.h	\
+	nautilus-dbus-manager.c 		\
+	nautilus-dbus-manager.h 		\
+	nautilus-desktop-canvas-view.c		\
+	nautilus-desktop-canvas-view.h		\
+	nautilus-desktop-item-properties.c	\
+	nautilus-desktop-item-properties.h	\
+	nautilus-desktop-window.c		\
+	nautilus-desktop-window.h		\
+	nautilus-error-reporting.c		\
+	nautilus-error-reporting.h		\
+	nautilus-preferences-window.c	\
+	nautilus-preferences-window.h	\
+	nautilus-files-view.c			\
+	nautilus-files-view.h			\
+	nautilus-files-view-dnd.c		\
+	nautilus-files-view-dnd.h		\
+	nautilus-floating-bar.c			\
+	nautilus-floating-bar.h			\
+	nautilus-freedesktop-dbus.c		\
+	nautilus-freedesktop-dbus.h		\
+	nautilus-image-properties-page.c	\
+	nautilus-image-properties-page.h	\
+	nautilus-list-model.c			\
+	nautilus-list-model.h			\
+	nautilus-list-view.c			\
+	nautilus-list-view.h 			\
+	nautilus-list-view-private.h		\
+	nautilus-list-view-dnd.c		\
+	nautilus-list-view-dnd.h		\
+	nautilus-location-entry.c               \
+	nautilus-location-entry.h               \
+	nautilus-mime-actions.c 		\
+	nautilus-mime-actions.h 		\
+	nautilus-notebook.c			\
+	nautilus-notebook.h			\
+	nautilus-pathbar.c			\
+	nautilus-pathbar.h			\
+	nautilus-places-view.c			\
+	nautilus-places-view.h			\
+	nautilus-previewer.c			\
+	nautilus-previewer.h			\
+	nautilus-progress-info-widget.c		\
+	nautilus-progress-info-widget.h		\
+	nautilus-progress-persistence-handler.c	\
+	nautilus-progress-persistence-handler.h	\
+	nautilus-properties-window.c		\
+	nautilus-properties-window.h		\
+	nautilus-query-editor.c			\
+	nautilus-query-editor.h			\
+	nautilus-search-popover.c		\
+	nautilus-search-popover.h		\
+	nautilus-self-check-functions.c 	\
+	nautilus-self-check-functions.h 	\
+	nautilus-shell-search-provider.h	\
+	nautilus-shell-search-provider.c	\
+	nautilus-special-location-bar.c		\
+	nautilus-special-location-bar.h		\
+	nautilus-toolbar.c			\
+	nautilus-toolbar.h			\
+	nautilus-trash-bar.c			\
+	nautilus-trash-bar.h			\
+	nautilus-view.c				\
+	nautilus-view.h				\
+	nautilus-window-slot.c			\
+	nautilus-window-slot.h			\
+	nautilus-window-slot-dnd.c		\
+	nautilus-window-slot-dnd.h		\
+	nautilus-window.c			\
+	nautilus-window.h			\
+	nautilus-x-content-bar.c		\
+	nautilus-x-content-bar.h		\
+	$(NULL)
+
 AM_CPPFLAGS =							\
 	-I$(top_srcdir) 					\
 	-I$(top_srcdir)/libnautilus-private 			\
Index: nautilus-3.20.3/test/Makefile.am
===================================================================
--- nautilus-3.20.3.orig/test/Makefile.am
+++ nautilus-3.20.3/test/Makefile.am
@@ -12,12 +12,22 @@ AM_CPPFLAGS =\
 	$(NULL)
 
 LDADD =\
-	$(top_builddir)/libnautilus-private/libnautilus-private.la \
+	libmerge.a \
+	$(top_builddir)/libnautilus-extension/libnautilus-extension.la \
+	$(TRACKER_LIBS) \
+	$(SELINUX_LIBS) \
+	$(CORE_LIBS) \
+	$(EXIF_LIBS) \
+	$(EXEMPI_LIBS) \
+	$(POPT_LIBS) \
 	$(BASE_LIBS) \
 	$(COMMON_LIBS) \
 	$(NAUTILUS_LIBS) \
 	$(NULL)
 
+libmerge.a:
+	ar -rcT $@ $(top_builddir)/src/libnautilus-test.a $(top_builddir)/libnautilus-private/.libs/libnautilus-private.a
+
 noinst_PROGRAMS =\
 	test-nautilus-search-engine \
 	test-nautilus-directory-async \
openSUSE Build Service is sponsored by