[gnome-software/gbsneto/hide-on-close] shell: Override GtkWindow.close_request
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gbsneto/hide-on-close] shell: Override GtkWindow.close_request
- Date: Fri, 17 Dec 2021 15:20:29 +0000 (UTC)
commit 014d353c2d215c5f2f8d8dcd1c4bab3a55231b48
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Dec 17 11:43:08 2021 -0300
shell: Override GtkWindow.close_request
We want the main Software window not to be destroyed when it's
closed. So far, we've been connecting GsShell's close-request
signal, which doesn't seem to prevent the default handler from
running.
Override the vfunc directly instead.
src/gs-shell.c | 10 ++++++----
src/gs-shell.ui | 1 -
2 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 11abeee04..2814f1694 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1020,9 +1020,9 @@ window_button_pressed_cb (GtkGestureClick *click_gesture,
}
static gboolean
-main_window_closed_cb (GtkWidget *dialog, gpointer user_data)
+gs_shell_close_request (GtkWindow *window)
{
- GsShell *shell = user_data;
+ GsShell *shell = GS_SHELL (window);
/* hide any notifications */
g_application_withdraw_notification (g_application_get_default (),
@@ -1052,7 +1052,7 @@ main_window_closed_cb (GtkWidget *dialog, gpointer user_data)
#endif /* HAVE_MOGWAI */
gs_shell_clean_back_entry_stack (shell);
- gtk_widget_hide (dialog);
+ gtk_widget_hide (GTK_WIDGET (window));
return TRUE;
}
@@ -2563,6 +2563,7 @@ gs_shell_class_init (GsShellClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkWindowClass *window_class = GTK_WINDOW_CLASS (klass);
object_class->get_property = gs_shell_get_property;
object_class->set_property = gs_shell_set_property;
@@ -2570,6 +2571,8 @@ gs_shell_class_init (GsShellClass *klass)
widget_class->size_allocate = gs_shell_size_allocate;
+ window_class->close_request = gs_shell_close_request;
+
/**
* GsShell:is-narrow:
*
@@ -2630,7 +2633,6 @@ gs_shell_class_init (GsShellClass *klass)
gtk_widget_class_bind_template_callback (widget_class, gs_shell_main_window_mapped_cb);
gtk_widget_class_bind_template_callback (widget_class, gs_shell_main_window_realized_cb);
- gtk_widget_class_bind_template_callback (widget_class, main_window_closed_cb);
gtk_widget_class_bind_template_callback (widget_class, window_key_pressed_cb);
gtk_widget_class_bind_template_callback (widget_class, window_keypress_handler);
gtk_widget_class_bind_template_callback (widget_class, window_button_pressed_cb);
diff --git a/src/gs-shell.ui b/src/gs-shell.ui
index d696238d7..7c6b9e3f9 100644
--- a/src/gs-shell.ui
+++ b/src/gs-shell.ui
@@ -22,7 +22,6 @@
<property name="icon_name">org.gnome.Software</property>
<signal name="map" handler="gs_shell_main_window_mapped_cb"/>
<signal name="realize" handler="gs_shell_main_window_realized_cb"/>
- <signal name="close-request" handler="main_window_closed_cb"/>
<child>
<object class="GtkEventControllerKey">
<property name="propagation-phase">capture</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]