[nautilus] rename-file-popover-controller: close on file deletion
- From: Ernestas Kulik <ernestask src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] rename-file-popover-controller: close on file deletion
- Date: Sat, 4 Mar 2017 12:03:17 +0000 (UTC)
commit d9ac53c8b0d1068792c9277bfbd8fc64070f50de
Author: Ernestas Kulik <ernestask gnome org>
Date: Sat Mar 4 13:48:17 2017 +0200
rename-file-popover-controller: close on file deletion
Currently, the popover remains open if the file is deleted (can be
triggered by creating a file, opening the rename popover and undoing).
This commit makes the controller connect to the “changed” signal of the
target file and emits the “cancelled” signal if the file is gone.
https://bugzilla.gnome.org/show_bug.cgi?id=779568
src/nautilus-rename-file-popover-controller.c | 31 +++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/nautilus-rename-file-popover-controller.c b/src/nautilus-rename-file-popover-controller.c
index fe5e903..3a11c22 100644
--- a/src/nautilus-rename-file-popover-controller.c
+++ b/src/nautilus-rename-file-popover-controller.c
@@ -40,6 +40,7 @@ struct _NautilusRenameFilePopoverController
GtkWidget *rename_file_popover;
gint closed_handler_id;
+ gint file_changed_handler_id;
};
G_DEFINE_TYPE (NautilusRenameFilePopoverController, nautilus_rename_file_popover_controller,
NAUTILUS_TYPE_FILE_NAME_WIDGET_CONTROLLER)
@@ -181,6 +182,24 @@ name_entry_on_key_pressed (GtkWidget *widget,
return GDK_EVENT_PROPAGATE;
}
+static void
+target_file_on_changed (NautilusFile *file,
+ gpointer user_data)
+{
+ NautilusRenameFilePopoverController *controller;
+
+ controller = NAUTILUS_RENAME_FILE_POPOVER_CONTROLLER (user_data);
+
+ if (nautilus_file_is_gone (file))
+ {
+ g_signal_handler_disconnect (controller->target_file,
+ controller->file_changed_handler_id);
+ controller->file_changed_handler_id = 0;
+
+ g_signal_emit_by_name (controller, "cancelled");
+ }
+}
+
NautilusRenameFilePopoverController *
nautilus_rename_file_popover_controller_new (NautilusFile *target_file,
GdkRectangle *pointing_to,
@@ -236,6 +255,12 @@ nautilus_rename_file_popover_controller_new (NautilusFile *target_file,
"closed",
(GCallback) rename_file_popover_controller_on_closed,
self);
+
+ self->file_changed_handler_id = g_signal_connect (self->target_file,
+ "changed",
+ G_CALLBACK (target_file_on_changed),
+ self);
+
g_signal_connect (rename_file_popover,
"unmap",
(GCallback) gtk_widget_destroy,
@@ -314,6 +339,12 @@ nautilus_rename_file_popover_controller_finalize (GObject *object)
self->rename_file_popover = NULL;
}
+ if (self->file_changed_handler_id != 0)
+ {
+ g_signal_handler_disconnect (self->target_file,
+ self->file_changed_handler_id);
+ self->file_changed_handler_id = 0;
+ }
nautilus_file_unref (self->target_file);
G_OBJECT_CLASS (nautilus_rename_file_popover_controller_parent_class)->finalize (object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]