[recipes] Add a modal dialog stack
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes] Add a modal dialog stack
- Date: Fri, 10 Feb 2017 01:35:49 +0000 (UTC)
commit f0f0ab9641b8d4df52b05ccdac28084bced14de9
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Feb 9 19:24:04 2017 -0500
Add a modal dialog stack
Add a new api that lets us properly stack modal dialogs
on top of each other. This is more or less a direct copy
of the corresponding api in gnome-software.
src/gr-window.c | 38 +++++++++++++++++++++++++++++++++++---
src/gr-window.h | 3 +++
2 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/src/gr-window.c b/src/gr-window.c
index d9e2436..10fda78 100644
--- a/src/gr-window.c
+++ b/src/gr-window.c
@@ -76,6 +76,8 @@ struct _GrWindow
GtkWidget *chef_dialog;
+ GList *dialogs;
+
GQueue *back_entry_stack;
gboolean is_fullscreen;
};
@@ -408,6 +410,8 @@ gr_window_finalize (GObject *object)
self->shopping_timeout_id = 0;
}
+ g_list_free (self->dialogs);
+
G_OBJECT_CLASS (gr_window_parent_class)->finalize (object);
}
@@ -693,11 +697,11 @@ gr_window_show_my_chef_information (GrWindow *window)
else
chef = gr_chef_new ();
- window->chef_dialog = (GtkWidget *)gr_chef_dialog_new (GTK_WINDOW (window), chef);
- gr_chef_dialog_can_create (GR_CHEF_DIALOG (window->chef_dialog), FALSE);
+ window->chef_dialog = (GtkWidget *)gr_chef_dialog_new (chef, FALSE);
gtk_window_set_title (GTK_WINDOW (window->chef_dialog), _("My Chef Information"));
g_signal_connect (window->chef_dialog, "done", G_CALLBACK (chef_done), window);
- gtk_window_present (GTK_WINDOW (window->chef_dialog));
+
+ gr_window_present_dialog (window, GTK_WINDOW (window->chef_dialog));
}
void
@@ -903,3 +907,31 @@ gr_window_show_image (GrWindow *window,
gtk_stack_set_visible_child_name (GTK_STACK (window->main_stack), "details");
}
}
+
+static void
+dialog_unmapped_cb (GtkWidget *dialog,
+ GrWindow *window)
+{
+ window->dialogs = g_list_remove (window->dialogs, dialog);
+}
+
+void
+gr_window_present_dialog (GrWindow *window,
+ GtkWindow *dialog)
+{
+ GtkWindow *parent;
+
+ if (window->dialogs)
+ parent = window->dialogs->data;
+ else
+ parent = GTK_WINDOW (window);
+
+ gtk_window_set_transient_for (dialog, parent);
+ gtk_window_set_modal (dialog, TRUE);
+
+ window->dialogs = g_list_prepend (window->dialogs, dialog);
+ g_signal_connect (dialog, "unmap",
+ G_CALLBACK (dialog_unmapped_cb), window);
+
+ gtk_window_present (dialog);
+}
diff --git a/src/gr-window.h b/src/gr-window.h
index fe753a2..631852d 100644
--- a/src/gr-window.h
+++ b/src/gr-window.h
@@ -32,6 +32,9 @@ G_DECLARE_FINAL_TYPE (GrWindow, gr_window, GR, WINDOW, GtkApplicationWindow)
GrWindow *gr_window_new (GrApp *app);
+void gr_window_present_dialog (GrWindow *window,
+ GtkWindow *dialog);
+
void gr_window_show_recipe (GrWindow *window,
GrRecipe *recipe);
void gr_window_edit_recipe (GrWindow *window,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]