[gnome-software/wip/temp/ubuntu-xenial-rebased: 137/329] Revert "Quit when main window is closed"



commit c66f26fa8d429ada04e195be0e6a5d57e520ecd5
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Mar 4 09:37:33 2016 +1300

    Revert "Quit when main window is closed"
    
    This reverts commit f1e766864a2a0c49fd7f67267da264d731c2f4d1.

 src/gs-shell.c |   36 ++++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 14 deletions(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index ba1b848..73319a8 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -604,6 +604,25 @@ window_button_press_event (GtkWidget *win, GdkEventButton *event, GsShell *shell
        return GDK_EVENT_STOP;
 }
 
+static gboolean
+main_window_closed_cb (GtkWidget *dialog, GdkEvent *event, gpointer user_data)
+{
+       GsShell *shell = user_data;
+       GsShellPrivate *priv = gs_shell_get_instance_private (shell);
+       BackEntry *entry;
+
+       /* When the window is closed, reset the initial mode to overview */
+       priv->mode = GS_SHELL_MODE_OVERVIEW;
+
+       /* ... and clear any remaining entries in the back button stack */
+       while ((entry = g_queue_pop_head (priv->back_entry_stack)) != NULL) {
+               free_back_entry (entry);
+       }
+
+       gtk_widget_hide (dialog);
+       return TRUE;
+}
+
 /**
  * gs_shell_updates_changed_cb:
  */
@@ -621,18 +640,6 @@ gs_shell_updates_changed_cb (GsPluginLoader *plugin_loader, GsShell *shell)
 }
 
 /**
- * gs_shell_main_window_destroyed_cb:
- */
-static void
-gs_shell_main_window_destroyed_cb (GtkWidget *widget,
-                                  GsShell   *shell)
-{
-       GActionGroup *action_group = G_ACTION_GROUP (g_application_get_default ());
-
-       g_action_group_activate_action (action_group, "quit", NULL);
-}
-
-/**
  * gs_shell_main_window_mapped_cb:
  */
 static void
@@ -688,8 +695,6 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
        /* get UI */
        priv->builder = gtk_builder_new_from_resource ("/org/gnome/Software/gnome-software.ui");
        priv->main_window = GTK_WINDOW (gtk_builder_get_object (priv->builder, "window_software"));
-       g_signal_connect (priv->main_window, "destroy",
-                         G_CALLBACK (gs_shell_main_window_destroyed_cb), shell);
        g_signal_connect (priv->main_window, "map",
                          G_CALLBACK (gs_shell_main_window_mapped_cb), shell);
 
@@ -697,6 +702,9 @@ gs_shell_setup (GsShell *shell, GsPluginLoader *plugin_loader, GCancellable *can
        gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
                                           GS_DATA G_DIR_SEPARATOR_S "icons");
 
+       g_signal_connect (priv->main_window, "delete-event",
+                         G_CALLBACK (main_window_closed_cb), shell);
+
        /* fix up the header bar */
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "header"));
        if (gs_utils_is_current_desktop ("Unity")) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]