[nautilus/wip/delete_notification: 12/12] delete notification
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/delete_notification: 12/12] delete notification
- Date: Mon, 26 Jan 2015 17:02:05 +0000 (UTC)
commit b042067af63a6665defcdb24e627240d162efedc
Author: Carlos Soriano <csoriano gnome org>
Date: Sat Jan 24 02:03:39 2015 +0100
delete notification
.gitmodules | 3 +
Makefile.am | 3 +-
autogen.sh | 2 +
configure.ac | 10 ++
libgd | 1 +
libnautilus-private/nautilus-file-operations.c | 7 +-
libnautilus-private/nautilus-file-operations.h | 1 +
nautilus-delete-notification.h | 39 +++++
src/Makefile.am | 6 +
src/nautilus-delete-notification.c | 97 +++++++++++++
src/nautilus-notification-delete.c | 184 ++++++++++++++++++++++++
src/nautilus-notification-delete.h | 57 ++++++++
src/nautilus-notification-manager.c | 89 ++++++++++++
src/nautilus-notification-manager.h | 58 ++++++++
src/nautilus-view.c | 4 +
src/nautilus-window-slot.c | 21 +++
src/nautilus-window-slot.h | 2 +
17 files changed, 580 insertions(+), 4 deletions(-)
---
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..bfd964e
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "libgd"]
+ path = libgd
+ url = git://git.gnome.org/libgd
diff --git a/Makefile.am b/Makefile.am
index bad8ee2..afeafc9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,6 +4,7 @@ DIRS = \
eel \
libnautilus-extension \
libnautilus-private \
+ libgd \
src \
test \
po \
@@ -56,6 +57,6 @@ MAINTAINERCLEANFILES = \
DISTCHECK_CONFIGURE_FLAGS = --disable-update-mimedb --enable-gtk-doc
-ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+ACLOCAL_AMFLAGS = -I m4 -I libgd ${ACLOCAL_FLAGS}
-include $(top_srcdir)/git.mk
diff --git a/autogen.sh b/autogen.sh
index de919b7..795422c 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -14,6 +14,8 @@ PKG_NAME="nautilus"
exit 1
}
+git submodule update --init --recursive
+
which gnome-autogen.sh || {
echo "gnome-autogen.sh not found, you need to install gnome-common"
exit 1
diff --git a/configure.ac b/configure.ac
index 4d29127..3ca7221 100644
--- a/configure.ac
+++ b/configure.ac
@@ -308,6 +308,15 @@ AC_ARG_ENABLE(update-mimedb,
enable_update_mimedb=yes)
AM_CONDITIONAL(ENABLE_UPDATE_MIMEDB, test x$enable_update_mimedb = xyes)
+LIBGD_INIT([
+ gtk-hacks
+ main-icon-view
+ main-view
+ notification
+ static
+ tagged-entry
+])
+
AC_CONFIG_FILES([
Makefile
data/Makefile
@@ -324,6 +333,7 @@ libnautilus-private/Makefile
libnautilus-extension/Makefile
libnautilus-extension/libnautilus-extension.pc
libnautilus-extension/libnautilus-extension-uninstalled.pc
+libgd/Makefile
po/Makefile.in
src/Makefile
nautilus-sendto-extension/Makefile
diff --git a/libgd b/libgd
new file mode 160000
index 0000000..04b2480
--- /dev/null
+++ b/libgd
@@ -0,0 +1 @@
+Subproject commit 04b2480259769709ec34d7ee48294878c94bbbb5
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index 0315a46..74601a0 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -104,6 +104,7 @@ typedef struct {
GList *files;
gboolean try_trash;
gboolean user_cancel;
+ guint n_items;
NautilusDeleteCallback done_callback;
gpointer done_callback_data;
} DeleteJob;
@@ -1905,12 +1906,11 @@ delete_job_done (gpointer user_data)
if (job->done_callback) {
debuting_uris = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref,
NULL);
- job->done_callback (debuting_uris, job->user_cancel, job->done_callback_data);
+ job->done_callback (debuting_uris, job->user_cancel, job->n_items, job->done_callback_data);
g_hash_table_unref (debuting_uris);
}
-
- finalize_common ((CommonJob *)job);
+ finalize_common ((CommonJob *)job);
nautilus_file_changes_consume_changes (TRUE);
return FALSE;
@@ -2015,6 +2015,7 @@ trash_or_delete_internal (GList *files,
job->files = g_list_copy_deep (files, (GCopyFunc) g_object_ref, NULL);
job->try_trash = try_trash;
job->user_cancel = FALSE;
+ job->n_items = g_list_length (files);
job->done_callback = done_callback;
job->done_callback_data = done_callback_data;
diff --git a/libnautilus-private/nautilus-file-operations.h b/libnautilus-private/nautilus-file-operations.h
index 87611b6..e61ce2d 100644
--- a/libnautilus-private/nautilus-file-operations.h
+++ b/libnautilus-private/nautilus-file-operations.h
@@ -38,6 +38,7 @@ typedef void (* NautilusOpCallback) (gboolean success,
gpointer callback_data);
typedef void (* NautilusDeleteCallback) (GHashTable *debuting_uris,
gboolean user_cancel,
+ guint n_items,
gpointer callback_data);
typedef void (* NautilusMountCallback) (GVolume *volume,
gboolean success,
diff --git a/nautilus-delete-notification.h b/nautilus-delete-notification.h
new file mode 100644
index 0000000..3794e88
--- /dev/null
+++ b/nautilus-delete-notification.h
@@ -0,0 +1,39 @@
+#ifndef NAUTILUS_DELETE_NOTIFICATION_H
+#define NAUTILUS_DELETE_NOTIFICATION_H
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_DELETE_NOTIFICATION (nautilus_delete_notification_get_type())
+#define NAUTILUS_DELETE_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
NAUTILUS_TYPE_DELETE_NOTIFICATION, NautilusDeleteNotification))
+#define NAUTILUS_DELETE_NOTIFICATION_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
NAUTILUS_TYPE_DELETE_NOTIFICATION, NautilusDeleteNotification const))
+#define NAUTILUS_DELETE_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
NAUTILUS_TYPE_DELETE_NOTIFICATION, NautilusDeleteNotificationClass))
+#define NAUTILUS_IS_DELETE_NOTIFICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
NAUTILUS_TYPE_DELETE_NOTIFICATION))
+#define NAUTILUS_IS_DELETE_NOTIFICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
NAUTILUS_TYPE_DELETE_NOTIFICATION))
+#define NAUTILUS_DELETE_NOTIFICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
NAUTILUS_TYPE_DELETE_NOTIFICATION, NautilusDeleteNotificationClass))
+
+typedef struct _NautilusDeleteNotification NautilusDeleteNotification;
+typedef struct _NautilusDeleteNotificationClass NautilusDeleteNotificationClass;
+typedef struct _NautilusDeleteNotificationPrivate NautilusDeleteNotificationPrivate;
+
+struct _NautilusDeleteNotification
+{
+ GtkGrid parent;
+
+ /*< private >*/
+ NautilusDeleteNotificationPrivate *priv;
+};
+
+struct _NautilusDeleteNotificationClass
+{
+ GtkGridClass parent;
+};
+
+GType nautilus_delete_notification_get_type (void);
+NautilusDeleteNotification *nautilus_delete_notification_new (void);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_DELETE_NOTIFICATION_H */
diff --git a/src/Makefile.am b/src/Makefile.am
index d3c88dd..82a7511 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,6 +13,7 @@ libexec_PROGRAMS= \
AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir)/libnautilus-private \
+ -I$(top_srcdir)/libgd \
$(BASE_CFLAGS) \
$(COMMON_CFLAGS) \
$(NAUTILUS_CFLAGS) \
@@ -30,6 +31,7 @@ AM_CPPFLAGS = \
LDADD =\
$(top_builddir)/libnautilus-private/libnautilus-private.la \
+ $(top_builddir)/libgd/libgd.la \
$(BASE_LIBS) \
$(COMMON_LIBS) \
$(NAUTILUS_LIBS) \
@@ -176,6 +178,10 @@ nautilus_SOURCES = \
nautilus-list-view.h \
nautilus-location-entry.c \
nautilus-location-entry.h \
+ nautilus-notification-delete.c \
+ nautilus-notification-delete.h \
+ nautilus-notification-manager.c \
+ nautilus-notification-manager.h \
nautilus-main.c \
nautilus-mime-actions.c \
nautilus-mime-actions.h \
diff --git a/src/nautilus-delete-notification.c b/src/nautilus-delete-notification.c
new file mode 100644
index 0000000..46da6a5
--- /dev/null
+++ b/src/nautilus-delete-notification.c
@@ -0,0 +1,97 @@
+#include "nautilus-delete-notification.h"
+
+struct _NautilusDeleteNotificationPrivate
+{
+ GList *items;
+ guint timeout_id;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (NautilusDeleteNotification, nautilus_delete_notification, GTK_TYPE_GRID)
+
+enum {
+ PROP_0,
+ PROP_ITEMS,
+ LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+NautilusDeleteNotification *
+nautilus_delete_notification_new (void)
+{
+ return g_object_new (NAUTILUS_TYPE_DELETE_NOTIFICATION, NULL);
+}
+
+static void
+nautilus_delete_notification_finalize (GObject *object)
+{
+ NautilusDeleteNotificationPrivate *priv = NAUTILUS_DELETE_NOTIFICATION (object)->priv;
+
+ G_OBJECT_CLASS (nautilus_delete_notification_parent_class)->finalize (object);
+}
+
+static void
+nautilus_delete_notification_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ NautilusDeleteNotification *self = NAUTILUS_DELETE_NOTIFICATION (object);
+
+ switch (prop_id)
+ {
+ case PROP_ITEMS:
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+nautilus_delete_notification_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ NautilusDeleteNotification *self = NAUTILUS_DELETE_NOTIFICATION (object);
+
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+nautilus_delete_notification_class_init (NautilusDeleteNotificationClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = nautilus_delete_notification_finalize;
+ object_class->get_property = nautilus_delete_notification_get_property;
+ object_class->set_property = nautilus_delete_notification_set_property;
+}
+
+static void
+nautilus_delete_notification_init (NautilusDeleteNotification *self)
+{
+ self->priv = nautilus_delete_notification_get_instance_private (self);
+}
+
+static void
+nautilus_delete_notification_remove_timeout (NAutilusDeleteNotification *self)
+{
+ if (self->priv->timeout_id != 0)
+ {
+ g_source_remove (self->priv->timeout_id);
+ self->priv->timeout_id = 0;
+ }
+}
+
+static void
+nautilus_delete_notification_destroy (PhotosDeleteNotification *self)
+{
+ nautilus_delete_notification_remove_timeout (self);
+ gtk_widget_destroy (GTK_WIDGET (self));
+}
+
diff --git a/src/nautilus-notification-delete.c b/src/nautilus-notification-delete.c
new file mode 100644
index 0000000..d54dffc
--- /dev/null
+++ b/src/nautilus-notification-delete.c
@@ -0,0 +1,184 @@
+/* nautilus-notification-delete.c
+ *
+ * Copyright (C) 2015 Carlos Soriano <csoriano gnome org>
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "nautilus-notification-delete.h"
+#include "nautilus-notification-manager.h"
+#include "nautilus-file-undo-manager.h"
+
+struct _NautilusNotificationDeletePrivate
+{
+ guint n_items;
+ guint timeout_id;
+ NautilusWindow *window;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (NautilusNotificationDelete, nautilus_notification_delete, GTK_TYPE_GRID)
+
+enum {
+ PROP_0,
+ PROP_N_ITEMS,
+ PROP_WINDOW,
+ LAST_PROP
+};
+
+enum
+{
+ NOTIFICATION_TIMEOUT = 10
+};
+
+static void
+nautilus_notification_delete_remove_timeout (NautilusNotificationDelete *self)
+{
+ if (self->priv->timeout_id != 0)
+ {
+ g_source_remove (self->priv->timeout_id);
+ self->priv->timeout_id = 0;
+ }
+}
+
+static void
+nautilus_notification_delete_destroy (NautilusNotificationDelete *self)
+{
+ nautilus_notification_delete_remove_timeout (self);
+ gtk_widget_destroy (GTK_WIDGET (self));
+}
+
+static gboolean
+nautilus_notification_delete_on_timeout (gpointer user_data)
+{
+ NautilusNotificationDelete *self = NAUTILUS_NOTIFICATION_DELETE (user_data);
+
+ self->priv->timeout_id = 0;
+ nautilus_notification_delete_destroy (self);
+
+ return G_SOURCE_REMOVE;
+}
+
+static void
+nautilus_notification_delete_undo_clicked (NautilusNotificationDelete *self)
+{
+ // nautilus_file_undo_manager_undo (GTK_WINDOW (self->priv->window));
+ nautilus_notification_delete_destroy (self);
+}
+
+static void
+nautilus_notification_delete_constructed (GObject *object)
+{
+ NautilusNotificationDelete *self = NAUTILUS_NOTIFICATION_DELETE (object);
+ GtkWidget *close;
+ gchar *label;
+ GtkWidget *label_widget;
+ GtkWidget *undo;
+
+ G_OBJECT_CLASS (nautilus_notification_delete_parent_class)->constructed (object);
+
+ if (self->priv->n_items == 1)
+ label = g_strdup (_("Selected item has been deleted"));
+ else
+ label = g_strdup_printf (_("%d items have been deleted"),
+ self->priv->n_items);
+ label_widget = gtk_label_new (label);
+ gtk_widget_set_halign (label_widget, GTK_ALIGN_START);
+ gtk_container_add (GTK_CONTAINER (self), label_widget);
+
+ undo = gtk_button_new_with_label (_("Undo"));
+ gtk_widget_set_valign (undo, GTK_ALIGN_CENTER);
+ gtk_container_add (GTK_CONTAINER (self), undo);
+ g_signal_connect_swapped (undo, "clicked", G_CALLBACK (nautilus_notification_delete_undo_clicked), self);
+
+ close = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_BUTTON);
+ gtk_widget_set_valign (close, GTK_ALIGN_CENTER);
+ gtk_button_set_focus_on_click (GTK_BUTTON (close), FALSE);
+ gtk_button_set_relief (GTK_BUTTON (close), GTK_RELIEF_NONE);
+ gtk_container_add (GTK_CONTAINER (self), close);
+ g_signal_connect_swapped (close, "clicked", G_CALLBACK (nautilus_notification_delete_destroy), self);
+
+ self->priv->timeout_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
+ NOTIFICATION_TIMEOUT,
+ nautilus_notification_delete_on_timeout,
+ g_object_ref (self),
+ g_object_unref);
+}
+
+NautilusNotificationDelete *
+nautilus_notification_delete_new (NautilusWindow *window,
+ guint n_items)
+{
+ g_assert (NAUTILUS_IS_WINDOW (window));
+
+ return g_object_new (NAUTILUS_TYPE_NOTIFICATION_DELETE,
+ "window", window,
+ "n-items", n_items,
+ NULL);
+}
+
+static void
+nautilus_notification_delete_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ NautilusNotificationDelete *self = NAUTILUS_NOTIFICATION_DELETE (object);
+
+ switch (prop_id)
+ {
+ case PROP_N_ITEMS:
+ self->priv->n_items = g_value_get_int (value);
+ break;
+
+ case PROP_WINDOW:
+ self->priv->window = NAUTILUS_WINDOW (g_value_get_pointer (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+nautilus_notification_delete_class_init (NautilusNotificationDeleteClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->set_property = nautilus_notification_delete_set_property;
+ object_class->constructed = nautilus_notification_delete_constructed;
+ g_object_class_install_property (object_class,
+ PROP_N_ITEMS,
+ g_param_spec_int ("n-items",
+ "Number of deleted items",
+ "Number of items that are being deleted",
+ 1,
+ G_MAXINT,
+ 1,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+ g_object_class_install_property (object_class,
+ PROP_WINDOW,
+ g_param_spec_pointer ("window",
+ "Window associated",
+ "The window that contains the notification",
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+}
+
+static void
+nautilus_notification_delete_init (NautilusNotificationDelete *self)
+{
+ self->priv = nautilus_notification_delete_get_instance_private (self);
+}
+
diff --git a/src/nautilus-notification-delete.h b/src/nautilus-notification-delete.h
new file mode 100644
index 0000000..d3c43c8
--- /dev/null
+++ b/src/nautilus-notification-delete.h
@@ -0,0 +1,57 @@
+/* nautilus-notification-delete.h
+ *
+ * Copyright (C) 2015 Carlos Soriano <csoriano gnome org>
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef NAUTILUS_NOTIFICATION_DELETE_H
+#define NAUTILUS_NOTIFICATION_DELETE_H
+
+#include <gtk/gtk.h>
+#include "nautilus-window.h"
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_NOTIFICATION_DELETE (nautilus_notification_delete_get_type())
+#define NAUTILUS_NOTIFICATION_DELETE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
NAUTILUS_TYPE_NOTIFICATION_DELETE, NautilusNotificationDelete))
+#define NAUTILUS_NOTIFICATION_DELETE_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
NAUTILUS_TYPE_NOTIFICATION_DELETE, NautilusNotificationDelete const))
+#define NAUTILUS_NOTIFICATION_DELETE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
NAUTILUS_TYPE_NOTIFICATION_DELETE, NautilusNotificationDeleteClass))
+#define NAUTILUS_IS_NOTIFICATION_DELETE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
NAUTILUS_TYPE_NOTIFICATION_DELETE))
+#define NAUTILUS_IS_NOTIFICATION_DELETE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
NAUTILUS_TYPE_NOTIFICATION_DELETE))
+#define NAUTILUS_NOTIFICATION_DELETE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
NAUTILUS_TYPE_NOTIFICATION_DELETE, NautilusNotificationDeleteClass))
+
+typedef struct _NautilusNotificationDelete NautilusNotificationDelete;
+typedef struct _NautilusNotificationDeleteClass NautilusNotificationDeleteClass;
+typedef struct _NautilusNotificationDeletePrivate NautilusNotificationDeletePrivate;
+
+struct _NautilusNotificationDelete
+{
+ GtkGrid parent;
+
+ /*< private >*/
+ NautilusNotificationDeletePrivate *priv;
+};
+
+struct _NautilusNotificationDeleteClass
+{
+ GtkGridClass parent;
+};
+
+GType nautilus_notification_delete_get_type (void);
+NautilusNotificationDelete *nautilus_notification_delete_new (NautilusWindow *window,
+ guint n_items);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_NOTIFICATION_DELETE_H */
diff --git a/src/nautilus-notification-manager.c b/src/nautilus-notification-manager.c
new file mode 100644
index 0000000..56e1e96
--- /dev/null
+++ b/src/nautilus-notification-manager.c
@@ -0,0 +1,89 @@
+#include "nautilus-notification-manager.h"
+#include "nautilus-file-undo-manager.h"
+
+struct _NautilusNotificationManagerPrivate
+{
+ GtkWidget *grid;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (NautilusNotificationManager, nautilus_notification_manager, GD_TYPE_NOTIFICATION)
+
+NautilusNotificationManager *
+nautilus_notification_manager_new (void)
+{
+ return g_object_new (NAUTILUS_TYPE_NOTIFICATION_MANAGER,
+ "show-close-button", FALSE,
+ "timeout", -1,
+ NULL);
+}
+
+void
+nautilus_notification_manager_add_notification (NautilusNotificationManager *self,
+ GtkWidget *notification)
+{
+ gtk_container_add (GTK_CONTAINER (self->priv->grid), notification);
+ gtk_widget_show_all (GTK_WIDGET (self));
+ g_print ("add notification\n");
+}
+
+static void
+nautilus_notification_manager_remove (NautilusNotificationManager *self)
+{
+ gtk_widget_hide (GTK_WIDGET (self));
+ gtk_container_foreach (GTK_CONTAINER (self->priv->grid),
+ (GtkCallback) gtk_widget_destroy,
+ NULL);
+ g_print ("remove\n");
+}
+
+static void
+nautilus_notification_manager_undo_manager_changed (NautilusFileUndoManager *undo_manager,
+ NautilusNotificationManager *self)
+{
+ g_print ("CHANGEEED \n");
+ nautilus_notification_manager_remove (self);
+}
+
+static void
+nautilus_notification_manager_dispose (GObject *object)
+{
+ NautilusNotificationManager *self = NAUTILUS_NOTIFICATION_MANAGER (object);
+
+ g_signal_handlers_disconnect_by_func (nautilus_file_undo_manager_get (),
+ G_CALLBACK (nautilus_notification_manager_undo_manager_changed),
+ self);
+
+ G_OBJECT_CLASS (nautilus_notification_manager_parent_class)->dispose (object);
+}
+
+static void
+nautilus_notification_manager_class_init (NautilusNotificationManagerClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ object_class->dispose = nautilus_notification_manager_dispose;
+}
+
+static void
+nautilus_notification_manager_init (NautilusNotificationManager *self)
+{
+ self->priv = nautilus_notification_manager_get_instance_private (self);
+
+ gtk_widget_set_halign (GTK_WIDGET (self), GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_START);
+
+ self->priv->grid = gtk_grid_new ();
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (self->priv->grid),
+ GTK_ORIENTATION_VERTICAL);
+ gtk_grid_set_row_spacing (GTK_GRID (self->priv->grid), 6);
+ gtk_container_add (GTK_CONTAINER (self), self->priv->grid);
+
+ g_signal_connect_swapped (self->priv->grid, "remove",
+ G_CALLBACK (nautilus_notification_manager_remove), self);
+ /* For now we only support one undo operation at once. So if undo changed,
+ * remove all notifications and the new one will be added to the appropiate
+ * notification manager
+ */
+ g_signal_connect_object (nautilus_file_undo_manager_get (), "undo-changed",
+ G_CALLBACK (nautilus_notification_manager_undo_manager_changed), self, 0);
+}
diff --git a/src/nautilus-notification-manager.h b/src/nautilus-notification-manager.h
new file mode 100644
index 0000000..598c45e
--- /dev/null
+++ b/src/nautilus-notification-manager.h
@@ -0,0 +1,58 @@
+/* nautilus-notification-manager.h
+ *
+ * Copyright (C) 2015 Carlos Soriano <csoriano gnome org>
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NAUTILUS_NOTIFICATION_MANAGER_H
+#define NAUTILUS_NOTIFICATION_MANAGER_H
+
+#include <libgd/gd.h>
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_NOTIFICATION_MANAGER (nautilus_notification_manager_get_type())
+#define NAUTILUS_NOTIFICATION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
NAUTILUS_TYPE_NOTIFICATION_MANAGER, NautilusNotificationManager))
+#define NAUTILUS_NOTIFICATION_MANAGER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
NAUTILUS_TYPE_NOTIFICATION_MANAGER, NautilusNotificationManager const))
+#define NAUTILUS_NOTIFICATION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
NAUTILUS_TYPE_NOTIFICATION_MANAGER, NautilusNotificationManagerClass))
+#define NAUTILUS_IS_NOTIFICATION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
NAUTILUS_TYPE_NOTIFICATION_MANAGER))
+#define NAUTILUS_IS_NOTIFICATION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
NAUTILUS_TYPE_NOTIFICATION_MANAGER))
+#define NAUTILUS_NOTIFICATION_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
NAUTILUS_TYPE_NOTIFICATION_MANAGER, NautilusNotificationManagerClass))
+
+typedef struct _NautilusNotificationManager NautilusNotificationManager;
+typedef struct _NautilusNotificationManagerClass NautilusNotificationManagerClass;
+typedef struct _NautilusNotificationManagerPrivate NautilusNotificationManagerPrivate;
+
+struct _NautilusNotificationManager
+{
+ GdNotification parent;
+
+ /*< private >*/
+ NautilusNotificationManagerPrivate *priv;
+};
+
+struct _NautilusNotificationManagerClass
+{
+ GdNotificationClass parent;
+};
+
+GType nautilus_notification_manager_get_type (void);
+NautilusNotificationManager *nautilus_notification_manager_new (void);
+void nautilus_notification_manager_add_notification (NautilusNotificationManager
*self,
+ GtkWidget
*notification);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_NOTIFICATION_MANAGER_H */
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index 02a9c38..5b295c7 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -3573,10 +3573,14 @@ desktop_or_home_dir_in_selection (GList *selection)
static void
trash_or_delete_done_cb (GHashTable *debuting_uris,
gboolean user_cancel,
+ guint n_items,
NautilusView *view)
{
if (user_cancel) {
view->details->selection_was_removed = FALSE;
+ } else {
+ nautilus_window_slot_add_notification_delete (view->details->slot,
+ n_items);
}
}
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 93ea872..16c8b1d 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -33,6 +33,8 @@
#include "nautilus-trash-bar.h"
#include "nautilus-window-private.h"
#include "nautilus-x-content-bar.h"
+#include "nautilus-notification-manager.h"
+#include "nautilus-notification-delete.h"
#include <glib/gi18n.h>
#include <eel/eel-stock-dialogs.h>
@@ -68,6 +70,9 @@ struct NautilusWindowSlotDetails {
GtkWidget *floating_bar;
GtkWidget *view_overlay;
+ /* Notifications */
+ NautilusNotificationManager *notification_manager;
+
/* slot contains
* 1) an vbox containing extra_location_widgets
* 2) the view
@@ -592,6 +597,9 @@ nautilus_window_slot_constructed (GObject *object)
gtk_box_pack_start (GTK_BOX (slot), slot->details->view_overlay, TRUE, TRUE, 0);
gtk_widget_show (slot->details->view_overlay);
+ slot->details->notification_manager = nautilus_notification_manager_new ();
+ gtk_overlay_add_overlay (GTK_OVERLAY (slot->details->view_overlay),
+ GTK_WIDGET (slot->details->notification_manager));
slot->details->floating_bar = nautilus_floating_bar_new (NULL, NULL, FALSE);
gtk_widget_set_halign (slot->details->floating_bar, GTK_ALIGN_END);
gtk_widget_set_valign (slot->details->floating_bar, GTK_ALIGN_END);
@@ -2401,6 +2409,19 @@ location_has_really_changed (NautilusWindowSlot *slot)
}
}
+void
+nautilus_window_slot_add_notification_delete (NautilusWindowSlot *slot,
+ guint n_items)
+{
+ NautilusNotificationDelete *notification;
+
+ notification = nautilus_notification_delete_new (nautilus_window_slot_get_window (slot),
+ n_items);
+ nautilus_notification_manager_add_notification (slot->details->notification_manager,
+ GTK_WIDGET (notification));
+ //g_object_unref (notification);
+}
+
static void
nautilus_window_slot_dispose (GObject *object)
{
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index ed4c873..4a62c23 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -124,5 +124,7 @@ void nautilus_window_slot_set_status (NautilusWindowSlot *slot,
const char *primary_status,
const char *detail_status);
void nautilus_window_slot_sync_view_mode (NautilusWindowSlot *slot);
+void nautilus_window_slot_add_notification_delete (NautilusWindowSlot *slot,
+ guint n_items);
#endif /* NAUTILUS_WINDOW_SLOT_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]