[gnome-builder/wip/gtk4-port] plugins/project-tree: close pages on rename request
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] plugins/project-tree: close pages on rename request
- Date: Fri, 29 Apr 2022 04:07:14 +0000 (UTC)
commit 2a24290c5b6a15ecb7851198dd7e8d3589d01dfc
Author: Christian Hergert <chergert redhat com>
Date: Thu Apr 28 21:01:28 2022 -0700
plugins/project-tree: close pages on rename request
.../project-tree/gbp-project-tree-pane-actions.c | 30 +++++++++++++++++-----
1 file changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/project-tree/gbp-project-tree-pane-actions.c
b/src/plugins/project-tree/gbp-project-tree-pane-actions.c
index 6c3827f53..efbe7de60 100644
--- a/src/plugins/project-tree/gbp-project-tree-pane-actions.c
+++ b/src/plugins/project-tree/gbp-project-tree-pane-actions.c
@@ -242,11 +242,29 @@ gbp_project_tree_pane_actions_new (GbpProjectTreePane *self,
g_steal_pointer (&task));
}
+static void
+rename_save_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ IdeBuffer *buffer = (IdeBuffer *)object;
+ g_autoptr(IdePage) page = user_data;
+ g_autoptr(GError) error = NULL;
+
+ g_assert (IDE_IS_BUFFER (buffer));
+ g_assert (G_IS_ASYNC_RESULT (result));
+ g_assert (IDE_IS_PAGE (page));
+
+ if (!ide_buffer_save_file_finish (buffer, result, &error))
+ g_warning ("Failed to save file before rename: %s", error->message);
+
+ panel_widget_close (PANEL_WIDGET (page));
+}
+
static void
close_matching_pages (IdePage *page,
gpointer user_data)
{
-#if 0
GFile *file = user_data;
GFile *this_file;
@@ -256,17 +274,17 @@ close_matching_pages (IdePage *page,
if (!IDE_IS_EDITOR_PAGE (page))
return;
- this_file = ide_editor_page_get_file (IDE_EDITOR_PAGE (page));
- if (this_file == NULL)
+ if (!(this_file = ide_editor_page_get_file (IDE_EDITOR_PAGE (page))))
return;
if (g_file_equal (this_file, file))
{
IdeBuffer *buffer = ide_editor_page_get_buffer (IDE_EDITOR_PAGE (page));
- ide_buffer_save_file_async (buffer, NULL, NULL, NULL, NULL, NULL);
- gtk_widget_destroy (widget);
+ ide_buffer_save_file_async (buffer, NULL, NULL,
+ NULL,
+ rename_save_cb,
+ g_object_ref (page));
}
-#endif
}
#define DEFINE_ACTION_HANDLER(short_name, BODY) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]