[libpanel/wip/chergert/fix-14] widget: add panel_widget_force_close()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpanel/wip/chergert/fix-14] widget: add panel_widget_force_close()
- Date: Tue, 13 Sep 2022 17:43:33 +0000 (UTC)
commit 8df55206ae03d8f64e6c803e5de38ef4c1767aca
Author: Christian Hergert <chergert redhat com>
Date: Tue Sep 13 10:43:21 2022 -0700
widget: add panel_widget_force_close()
This allows bypassing the save checks as part of the close process.
src/panel-widget.c | 21 ++++++++++++++++++++-
src/panel-widget.h | 2 ++
2 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/panel-widget.c b/src/panel-widget.c
index 3b78412..5e089da 100644
--- a/src/panel-widget.c
+++ b/src/panel-widget.c
@@ -73,6 +73,7 @@ typedef struct
guint modified : 1;
guint needs_attention : 1;
guint saving : 1;
+ guint force_close : 1;
} PanelWidgetPrivate;
typedef struct
@@ -1307,7 +1308,7 @@ _panel_widget_can_save (PanelWidget *self)
g_return_val_if_fail (PANEL_IS_WIDGET (self), FALSE);
- return !priv->saving && priv->modified && priv->save_delegate != NULL;
+ return !priv->saving && priv->modified && priv->save_delegate && !priv->force_close;
}
void
@@ -1321,6 +1322,24 @@ panel_widget_close (PanelWidget *self)
_panel_frame_request_close (PANEL_FRAME (frame), self);
}
+/**
+ * panel_widget_force_close:
+ * @self: a #PanelWidget
+ *
+ * Closes the widget without any save dialogs.
+ */
+void
+panel_widget_force_close (PanelWidget *self)
+{
+ PanelWidgetPrivate *priv = panel_widget_get_instance_private (self);
+
+ g_return_if_fail (PANEL_IS_WIDGET (self));
+
+ priv->force_close = TRUE;
+
+ panel_widget_close (self);
+}
+
void
_panel_widget_emit_presented (PanelWidget *self)
{
diff --git a/src/panel-widget.h b/src/panel-widget.h
index b7d56bc..de94200 100644
--- a/src/panel-widget.h
+++ b/src/panel-widget.h
@@ -123,6 +123,8 @@ void panel_widget_set_save_delegate (PanelWidget
PANEL_AVAILABLE_IN_ALL
void panel_widget_close (PanelWidget *self);
PANEL_AVAILABLE_IN_ALL
+void panel_widget_force_close (PanelWidget *self);
+PANEL_AVAILABLE_IN_ALL
void panel_widget_insert_action_group (PanelWidget *self,
const char *prefix,
GActionGroup *group);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]