[libpanel/wip/chergert/fix-14] example: only use one save delegate
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpanel/wip/chergert/fix-14] example: only use one save delegate
- Date: Tue, 13 Sep 2022 18:58:28 +0000 (UTC)
commit cbb37a578b8e1a1678d80c0c11f872696643cda7
Author: Christian Hergert <chergert redhat com>
Date: Tue Sep 13 11:58:06 2022 -0700
example: only use one save delegate
example/example-page.c | 8 ++++++--
example/example-window.c | 33 ---------------------------------
2 files changed, 6 insertions(+), 35 deletions(-)
---
diff --git a/example/example-page.c b/example/example-page.c
index 20b3c4b..b9087f6 100644
--- a/example/example-page.c
+++ b/example/example-page.c
@@ -49,7 +49,7 @@ example_page_new (void)
return g_object_new (EXAMPLE_TYPE_PAGE, NULL);
}
-static void
+static gboolean
example_page_save (ExamplePage *self,
GTask *task,
PanelSaveDelegate *delegate)
@@ -59,6 +59,8 @@ example_page_save (ExamplePage *self,
g_assert (PANEL_IS_SAVE_DELEGATE (delegate));
g_task_return_boolean (task, TRUE);
+
+ return TRUE;
}
static void
@@ -203,8 +205,10 @@ example_page_init (ExamplePage *self)
G_CALLBACK (example_page_save),
self,
G_CONNECT_SWAPPED);
+ g_signal_connect_swapped (delegate, "discard", G_CALLBACK (panel_widget_force_close), self);
+ g_signal_connect_swapped (delegate, "close", G_CALLBACK (panel_widget_force_close), self);
g_object_bind_property (self, "title", delegate, "title", G_BINDING_SYNC_CREATE);
g_object_bind_property (self, "icon", delegate, "icon", G_BINDING_SYNC_CREATE);
- panel_save_delegate_set_subtitle (delegate, "Something about the document");
+ panel_save_delegate_set_subtitle (delegate, "~/Documents");
panel_widget_set_save_delegate (PANEL_WIDGET (self), delegate);
}
diff --git a/example/example-window.c b/example/example-window.c
index 8caffaf..c7b8100 100644
--- a/example/example-window.c
+++ b/example/example-window.c
@@ -52,26 +52,6 @@ example_window_new (GtkApplication *application)
NULL);
}
-static gboolean
-on_save_cb (PanelSaveDelegate *delegate,
- GTask *task,
- PanelWidget *widget)
-{
- g_assert (PANEL_IS_SAVE_DELEGATE (delegate));
- g_assert (G_IS_TASK (task));
- g_assert (PANEL_IS_WIDGET (widget));
-
- // actually do the save here, ideally asynchronously
-
- g_print ("Actually save the file\n");
-
- panel_widget_set_modified (widget, FALSE);
- panel_save_delegate_set_progress (delegate, 1.0);
- g_task_return_boolean (task, TRUE);
-
- return TRUE;
-}
-
static gboolean
text_to_visible (GBinding *binding,
const GValue *from_value,
@@ -88,32 +68,20 @@ example_window_add_document (ExampleWindow *self)
{
static guint count;
PanelWidget *widget;
- PanelSaveDelegate *save_delegate;
char *title;
g_return_if_fail (EXAMPLE_IS_WINDOW (self));
title = g_strdup_printf ("Untitled Document %u", ++count);
-
- save_delegate = panel_save_delegate_new ();
- panel_save_delegate_set_title (save_delegate, title);
- panel_save_delegate_set_subtitle (save_delegate, "~/Documents");
-
widget = g_object_new (EXAMPLE_TYPE_PAGE,
"title", title,
"kind", PANEL_WIDGET_KIND_DOCUMENT,
"icon-name", "text-x-generic-symbolic",
"menu-model", self->page_menu,
"can-maximize", TRUE,
- "save-delegate", save_delegate,
"modified", TRUE,
NULL);
- g_signal_connect (save_delegate,
- "save",
- G_CALLBACK (on_save_cb),
- widget);
-
panel_grid_add (self->grid, widget);
panel_widget_raise (widget);
panel_widget_focus_default (widget);
@@ -125,7 +93,6 @@ example_window_add_document (ExampleWindow *self)
g_object_bind_property_full (widget, "command-text", self->command, "visible", 0, text_to_visible, NULL,
NULL, NULL);
g_object_bind_property (widget, "command-text", self->command, "label", 0);
- g_object_unref (save_delegate);
g_free (title);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]