[amtk] shortcuts: improve amtk_shortcuts_window_new()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [amtk] shortcuts: improve amtk_shortcuts_window_new()
- Date: Sat, 14 Apr 2018 13:35:31 +0000 (UTC)
commit 3d356b639d7bd204463a2e02c83bfc84e32bfa2c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Apr 14 15:32:35 2018 +0200
shortcuts: improve amtk_shortcuts_window_new()
amtk/amtk-shortcuts.c | 24 ++++++++++++++++++------
amtk/amtk-shortcuts.h | 2 +-
tests/test-headerbar.c | 11 ++++++-----
3 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/amtk/amtk-shortcuts.c b/amtk/amtk-shortcuts.c
index c6f6b67..931ad95 100644
--- a/amtk/amtk-shortcuts.c
+++ b/amtk/amtk-shortcuts.c
@@ -33,19 +33,31 @@
/**
* amtk_shortcuts_window_new:
+ * @parent: the #GtkWindow:transient-for.
*
- * Creates a new #GtkShortcutsWindow. It is on purpose that the return type is
- * #GtkShortcutsWindow, not #GtkWidget or something else, so in C when you
- * declare the variable as #GtkShortcutsWindow it's easier to find it later
- * (searching "GtkShortcuts" will return something in your codebase).
+ * Creates a new #GtkShortcutsWindow. The #GtkWindow:modal property is set to
+ * %TRUE.
+ *
+ * It is on purpose that the return type is #GtkShortcutsWindow, not #GtkWidget
+ * or something else, so in C when you declare the variable as
+ * #GtkShortcutsWindow it's easier to find it later (searching "GtkShortcuts"
+ * will return something in your codebase).
*
* Returns: (transfer floating): a new #GtkShortcutsWindow.
* Since: 5.0
*/
GtkShortcutsWindow *
-amtk_shortcuts_window_new (void)
+amtk_shortcuts_window_new (GtkWindow *parent)
{
- return g_object_new (GTK_TYPE_SHORTCUTS_WINDOW, NULL);
+ GtkShortcutsWindow *shortcuts_window;
+
+ g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
+
+ shortcuts_window = g_object_new (GTK_TYPE_SHORTCUTS_WINDOW, NULL);
+ gtk_window_set_modal (GTK_WINDOW (shortcuts_window), TRUE);
+ gtk_window_set_transient_for (GTK_WINDOW (shortcuts_window), parent);
+
+ return shortcuts_window;
}
/**
diff --git a/amtk/amtk-shortcuts.h b/amtk/amtk-shortcuts.h
index 2956928..cf9ebb5 100644
--- a/amtk/amtk-shortcuts.h
+++ b/amtk/amtk-shortcuts.h
@@ -28,7 +28,7 @@
G_BEGIN_DECLS
-GtkShortcutsWindow * amtk_shortcuts_window_new (void);
+GtkShortcutsWindow * amtk_shortcuts_window_new (GtkWindow *parent);
GtkContainer * amtk_shortcuts_section_new (const gchar *title);
diff --git a/tests/test-headerbar.c b/tests/test-headerbar.c
index bb28e81..506a055 100644
--- a/tests/test-headerbar.c
+++ b/tests/test-headerbar.c
@@ -66,7 +66,8 @@ shortcuts_window_activate_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
- GtkShortcutsWindow *window;
+ GtkApplicationWindow *app_window = GTK_APPLICATION_WINDOW (user_data);
+ GtkShortcutsWindow *shortcuts_window;
GtkContainer *section;
GtkContainer *group;
AmtkFactory *factory;
@@ -84,10 +85,10 @@ shortcuts_window_activate_cb (GSimpleAction *action,
section = amtk_shortcuts_section_new (NULL);
gtk_container_add (section, GTK_WIDGET (group));
- window = amtk_shortcuts_window_new ();
- gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (section));
+ shortcuts_window = amtk_shortcuts_window_new (GTK_WINDOW (app_window));
+ gtk_container_add (GTK_CONTAINER (shortcuts_window), GTK_WIDGET (section));
- gtk_widget_show_all (GTK_WIDGET (window));
+ gtk_widget_show_all (GTK_WIDGET (shortcuts_window));
}
static void
@@ -105,7 +106,7 @@ add_win_actions (GtkApplicationWindow *window,
amtk_action_map_add_action_entries_check_dups (G_ACTION_MAP (window),
entries, -1,
- NULL);
+ window);
side_panel_action = g_property_action_new ("show-side-panel", side_panel, "visible");
g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (side_panel_action));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]