2 * Copyright © 2011 Canonical Limited
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the licence, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 * Author: Ryan Lortie <desrt@desrt.ca>
24 #include "gtkapplicationwindow.h"
26 #include "gtkmodelmenu.h"
27 #include "gactionmuxer.h"
28 #include "gtkaccelgroup.h"
29 #include "gtkaccelmap.h"
33 * SECTION:gtkapplicationwindow
34 * @title: GtkApplicationWindow
35 * @short_description: GtkWindow subclass with GtkApplication support
37 * GtkApplicationWindow is a #GtkWindow subclass that offers some
38 * extra functionality for better integration with #GtkApplication
39 * features. Notably, it can handle both the application menu as well
40 * as the menubar. See g_application_set_app_menu() and
41 * g_application_set_menubar().
43 * This class implements the #GActionGroup and #GActionMap interfaces,
44 * to let you add window-specific actions that will be exported by the
45 * associated #GtkApplication, together with its application-wide
46 * actions. Window-specific actions are prefixed with the "win."
47 * prefix and application-wide actions are prefixed with the "app."
48 * prefix. Actions must be addressed with the prefixed name when
49 * referring to them from a #GMenuModel.
51 * If the desktop environment does not display the application menu
52 * as part of the desktop shell, then #GApplicationWindow will
53 * automatically show the menu as part of a menubar. This behaviour
54 * can be overridden with the #GtkApplicationWindow:show-menubar
57 * <example><title>A GtkApplicationWindow with a menubar</title>
58 * <programlisting><![CDATA[
59 * app = gtk_application_new ();
61 * builder = gtk_builder_new ();
62 * gtk_builder_add_from_string (builder,
64 * " <menu id='menubar'>"
65 * " <submenu label='_Edit'>"
66 * " <item label='_Copy' action='win.copy'/>"
67 * " <item label='_Paste' action='win.paste'/>"
71 * g_application_set_menubar (G_APPLICATION (app),
72 * G_MENU_MODEL (gtk_builder_get_object (builder, "menubar")));
73 * g_object_unref (builder);
77 * window = gtk_application_window_new (app);
82 struct _GtkApplicationWindowPrivate
84 GSimpleActionGroup *actions;
86 GtkAccelGroup *accels;
87 GSList *accel_closures;
89 GMenu *app_menu_section;
90 GMenu *menubar_section;
91 gboolean show_menubar;
95 gtk_application_window_update_menubar (GtkApplicationWindow *window)
97 gboolean should_have_menubar;
98 gboolean have_menubar;
100 have_menubar = window->priv->menubar != NULL;
102 should_have_menubar = window->priv->show_menubar &&
103 (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->app_menu_section)) ||
104 g_menu_model_get_n_items (G_MENU_MODEL (window->priv->menubar_section)));
106 if (have_menubar && !should_have_menubar)
108 gtk_widget_unparent (window->priv->menubar);
109 window->priv->menubar = NULL;
111 gtk_widget_queue_resize (GTK_WIDGET (window));
114 if (!have_menubar && should_have_menubar)
119 muxer = g_action_muxer_new ();
120 g_action_muxer_insert (muxer, "app", G_ACTION_GROUP (gtk_window_get_application (GTK_WINDOW (window))));
121 g_action_muxer_insert (muxer, "win", G_ACTION_GROUP (window));
123 combined = g_menu_new ();
124 g_menu_append_section (combined, NULL, G_MENU_MODEL (window->priv->app_menu_section));
125 g_menu_append_section (combined, NULL, G_MENU_MODEL (window->priv->menubar_section));
127 window->priv->menubar = gtk_model_menu_create_menu_bar (G_MENU_MODEL (combined), G_ACTION_OBSERVABLE (muxer), window->priv->accels);
128 gtk_widget_set_parent (window->priv->menubar, GTK_WIDGET (window));
129 gtk_widget_show_all (window->priv->menubar);
130 g_object_unref (combined);
131 g_object_unref (muxer);
133 gtk_widget_queue_resize (GTK_WIDGET (window));
138 gtk_application_window_update_shell_shows_app_menu (GtkApplicationWindow *window,
139 GtkSettings *settings)
141 gboolean shown_by_shell;
143 g_object_get (settings, "gtk-shell-shows-app-menu", &shown_by_shell, NULL);
147 /* the shell shows it, so don't show it locally */
148 if (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->app_menu_section)) != 0)
149 g_menu_remove (window->priv->app_menu_section, 0);
153 /* the shell does not show it, so make sure we show it */
154 if (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->app_menu_section)) == 0)
156 GMenuModel *app_menu;
158 app_menu = g_application_get_app_menu (G_APPLICATION (gtk_window_get_application (GTK_WINDOW (window))));
160 if (app_menu != NULL)
161 g_menu_append_submenu (window->priv->app_menu_section, _("Application"), app_menu);
167 gtk_application_window_update_shell_shows_menubar (GtkApplicationWindow *window,
168 GtkSettings *settings)
170 gboolean shown_by_shell;
172 g_object_get (settings, "gtk-shell-shows-menubar", &shown_by_shell, NULL);
176 /* the shell shows it, so don't show it locally */
177 if (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->menubar_section)) != 0)
178 g_menu_remove (window->priv->menubar_section, 0);
182 /* the shell does not show it, so make sure we show it */
183 if (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->menubar_section)) == 0)
187 menubar = g_application_get_menubar (G_APPLICATION (gtk_window_get_application (GTK_WINDOW (window))));
190 g_menu_append_section (window->priv->menubar_section, NULL, menubar);
202 accel_activate (GClosure *closure,
203 GValue *return_value,
204 guint n_param_values,
205 const GValue *param_values,
206 gpointer invocation_hint,
207 gpointer marshal_data)
209 AccelClosure *aclosure = (AccelClosure*)closure;
210 GActionGroup *actions;
212 actions = G_ACTION_GROUP (closure->data);
213 if (g_action_group_get_action_enabled (actions, aclosure->action_name))
215 g_action_group_activate_action (actions, aclosure->action_name, aclosure->parameter);
217 /* we handled the accelerator */
218 g_value_set_boolean (return_value, TRUE);
223 free_accel_closures (GtkApplicationWindow *window)
227 for (l = window->priv->accel_closures; l; l = l->next)
229 AccelClosure *closure = l->data;
231 gtk_accel_group_disconnect (window->priv->accels, &closure->closure);
233 g_object_unref (closure->closure.data);
234 if (closure->parameter)
235 g_variant_unref (closure->parameter);
236 g_free (closure->action_name);
237 g_closure_invalidate (&closure->closure);
238 g_closure_unref (&closure->closure);
240 g_slist_free (window->priv->accel_closures);
241 window->priv->accel_closures = NULL;
245 GtkApplicationWindow *window;
246 GActionGroup *actions;
249 /* Hack. We iterate over the accel map instead of the actions,
250 * in order to pull the parameters out of accel map entries
253 add_accel_closure (gpointer data,
254 const gchar *accel_path,
256 GdkModifierType accel_mods,
260 GtkApplicationWindow *window = d->window;
261 GActionGroup *actions = d->actions;
266 AccelClosure *closure;
271 if (!g_str_has_prefix (accel_path, "<Actions>/"))
274 path = accel_path + strlen ("<Actions>/");
275 p = strchr (path, '/');
278 action_name = g_strndup (path, p - path);
279 parameter = g_variant_parse (NULL, p + 1, NULL, NULL, NULL);
281 g_warning ("Failed to parse parameter from '%s'\n", accel_path);
285 action_name = g_strdup (path);
289 if (g_action_group_has_action (actions, action_name))
291 closure = (AccelClosure*) g_closure_new_object (sizeof (AccelClosure), g_object_ref (actions));
292 g_closure_set_marshal (&closure->closure, accel_activate);
294 closure->action_name = g_strdup (action_name);
295 closure->parameter = parameter ? g_variant_ref_sink (parameter) : NULL;
297 window->priv->accel_closures = g_slist_prepend (window->priv->accel_closures, g_closure_ref (&closure->closure));
298 g_closure_sink (&closure->closure);
300 gtk_accel_group_connect_by_path (window->priv->accels, accel_path, &closure->closure);
303 g_free (action_name);
307 gtk_application_window_update_accels (GtkApplicationWindow *window)
309 GtkApplication *application;
313 /* FIXME: we should keep the muxer around, and listen for changes.
314 * Also, we should listen for accel map changes
316 application = gtk_window_get_application (GTK_WINDOW (window));
318 free_accel_closures (window);
320 muxer = g_action_muxer_new ();
321 g_action_muxer_insert (muxer, "app", G_ACTION_GROUP (application));
322 g_action_muxer_insert (muxer, "win", G_ACTION_GROUP (window));
324 data.window = window;
325 data.actions = G_ACTION_GROUP (muxer);
327 gtk_accel_map_foreach (&data, add_accel_closure);
329 g_object_unref (muxer);
333 gtk_application_window_shell_shows_app_menu_changed (GObject *object,
337 GtkApplicationWindow *window = user_data;
339 gtk_application_window_update_shell_shows_app_menu (window, GTK_SETTINGS (object));
340 gtk_application_window_update_menubar (window);
344 gtk_application_window_shell_shows_menubar_changed (GObject *object,
348 GtkApplicationWindow *window = user_data;
350 gtk_application_window_update_shell_shows_menubar (window, GTK_SETTINGS (object));
351 gtk_application_window_update_menubar (window);
355 gtk_application_window_list_actions (GActionGroup *group)
357 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (group);
359 return g_action_group_list_actions (G_ACTION_GROUP (window->priv->actions));
363 gtk_application_window_query_action (GActionGroup *group,
364 const gchar *action_name,
366 const GVariantType **parameter_type,
367 const GVariantType **state_type,
368 GVariant **state_hint,
371 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (group);
373 return g_action_group_query_action (G_ACTION_GROUP (window->priv->actions),
374 action_name, enabled, parameter_type, state_type, state_hint, state);
378 gtk_application_window_activate_action (GActionGroup *group,
379 const gchar *action_name,
382 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (group);
384 return g_action_group_activate_action (G_ACTION_GROUP (window->priv->actions), action_name, parameter);
388 gtk_application_window_change_action_state (GActionGroup *group,
389 const gchar *action_name,
392 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (group);
394 return g_action_group_change_action_state (G_ACTION_GROUP (window->priv->actions), action_name, state);
398 gtk_application_window_lookup_action (GActionMap *action_map,
399 const gchar *action_name)
401 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (action_map);
403 return g_action_map_lookup_action (G_ACTION_MAP (window->priv->actions), action_name);
407 gtk_application_window_add_action (GActionMap *action_map,
410 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (action_map);
412 g_action_map_add_action (G_ACTION_MAP (window->priv->actions), action);
416 gtk_application_window_remove_action (GActionMap *action_map,
417 const gchar *action_name)
419 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (action_map);
421 g_action_map_remove_action (G_ACTION_MAP (window->priv->actions), action_name);
425 gtk_application_window_group_iface_init (GActionGroupInterface *iface)
427 iface->list_actions = gtk_application_window_list_actions;
428 iface->query_action = gtk_application_window_query_action;
429 iface->activate_action = gtk_application_window_activate_action;
430 iface->change_action_state = gtk_application_window_change_action_state;
434 gtk_application_window_map_iface_init (GActionMapInterface *iface)
436 iface->lookup_action = gtk_application_window_lookup_action;
437 iface->add_action = gtk_application_window_add_action;
438 iface->remove_action = gtk_application_window_remove_action;
441 G_DEFINE_TYPE_WITH_CODE (GtkApplicationWindow, gtk_application_window, GTK_TYPE_WINDOW,
442 G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, gtk_application_window_group_iface_init)
443 G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_MAP, gtk_application_window_map_iface_init))
450 static GParamSpec *gtk_application_window_properties[N_PROPS];
453 gtk_application_window_real_get_preferred_height (GtkWidget *widget,
454 gint *minimum_height,
455 gint *natural_height)
457 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
459 GTK_WIDGET_CLASS (gtk_application_window_parent_class)
460 ->get_preferred_height (widget, minimum_height, natural_height);
462 if (window->priv->menubar != NULL)
464 gint menubar_min_height, menubar_nat_height;
466 gtk_widget_get_preferred_height (window->priv->menubar, &menubar_min_height, &menubar_nat_height);
467 *minimum_height += menubar_min_height;
468 *natural_height += menubar_nat_height;
473 gtk_application_window_real_get_preferred_height_for_width (GtkWidget *widget,
475 gint *minimum_height,
476 gint *natural_height)
478 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
480 GTK_WIDGET_CLASS (gtk_application_window_parent_class)
481 ->get_preferred_height_for_width (widget, width, minimum_height, natural_height);
483 if (window->priv->menubar != NULL)
485 gint menubar_min_height, menubar_nat_height;
487 gtk_widget_get_preferred_height_for_width (window->priv->menubar, width, &menubar_min_height, &menubar_nat_height);
488 *minimum_height += menubar_min_height;
489 *natural_height += menubar_nat_height;
494 gtk_application_window_real_get_preferred_width (GtkWidget *widget,
498 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
500 GTK_WIDGET_CLASS (gtk_application_window_parent_class)
501 ->get_preferred_width (widget, minimum_width, natural_width);
503 if (window->priv->menubar != NULL)
505 gint menubar_min_width, menubar_nat_width;
507 gtk_widget_get_preferred_width (window->priv->menubar, &menubar_min_width, &menubar_nat_width);
508 *minimum_width = MAX (*minimum_width, menubar_min_width);
509 *natural_width = MAX (*natural_width, menubar_nat_width);
514 gtk_application_window_real_get_preferred_width_for_height (GtkWidget *widget,
519 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
521 GTK_WIDGET_CLASS (gtk_application_window_parent_class)
522 ->get_preferred_width_for_height (widget, height, minimum_width, natural_width);
524 if (window->priv->menubar != NULL)
526 gint menubar_min_width, menubar_nat_width;
528 gtk_widget_get_preferred_width_for_height (window->priv->menubar, height, &menubar_min_width, &menubar_nat_width);
529 *minimum_width = MAX (*minimum_width, menubar_min_width);
530 *natural_width = MAX (*natural_width, menubar_nat_width);
535 gtk_application_window_real_size_allocate (GtkWidget *widget,
536 GtkAllocation *allocation)
538 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
540 if (window->priv->menubar != NULL)
542 GtkAllocation menubar_allocation = *allocation;
543 gint menubar_min_height, menubar_nat_height;
546 gtk_widget_get_preferred_height_for_width (window->priv->menubar, allocation->width, &menubar_min_height, &menubar_nat_height);
548 menubar_allocation.height = menubar_min_height;
549 gtk_widget_size_allocate (window->priv->menubar, &menubar_allocation);
551 child = gtk_bin_get_child (GTK_BIN (window));
552 if (child != NULL && gtk_widget_get_visible (child))
554 GtkAllocation child_allocation = *allocation;
557 child_allocation.height = MAX (1, child_allocation.height - menubar_min_height);
559 border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
560 child_allocation.x += border_width;
561 child_allocation.y += border_width + menubar_min_height;
562 child_allocation.width -= border_width * 2;
563 child_allocation.height -= border_width * 2 - menubar_min_height;
564 gtk_widget_size_allocate (child, &child_allocation);
567 gtk_widget_set_allocation (widget, allocation);
570 GTK_WIDGET_CLASS (gtk_application_window_parent_class)
571 ->size_allocate (widget, allocation);
575 gtk_application_window_real_realize (GtkWidget *widget)
577 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
578 GtkSettings *settings;
580 settings = gtk_widget_get_settings (widget);
582 g_signal_connect (settings, "notify::gtk-shell-shows-app-menu",
583 G_CALLBACK (gtk_application_window_shell_shows_app_menu_changed), window);
584 g_signal_connect (settings, "notify::gtk-shell-shows-menubar",
585 G_CALLBACK (gtk_application_window_shell_shows_menubar_changed), window);
587 gtk_application_window_update_shell_shows_app_menu (window, settings);
588 gtk_application_window_update_shell_shows_menubar (window, settings);
589 gtk_application_window_update_menubar (window);
590 gtk_application_window_update_accels (window);
592 GTK_WIDGET_CLASS (gtk_application_window_parent_class)
597 gtk_application_window_real_unrealize (GtkWidget *widget)
599 GtkSettings *settings;
601 settings = gtk_widget_get_settings (widget);
603 g_signal_handlers_disconnect_by_func (settings, gtk_application_window_shell_shows_app_menu_changed, widget);
604 g_signal_handlers_disconnect_by_func (settings, gtk_application_window_shell_shows_menubar_changed, widget);
606 GTK_WIDGET_CLASS (gtk_application_window_parent_class)
607 ->unrealize (widget);
611 gtk_application_window_real_map (GtkWidget *widget)
613 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
615 /* XXX could eliminate this by tweaking gtk_window_map */
616 if (window->priv->menubar)
617 gtk_widget_map (window->priv->menubar);
619 GTK_WIDGET_CLASS (gtk_application_window_parent_class)
624 gtk_application_window_real_forall_internal (GtkContainer *container,
625 gboolean include_internal,
626 GtkCallback callback,
629 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (container);
631 if (window->priv->menubar)
632 callback (window->priv->menubar, user_data);
634 GTK_CONTAINER_CLASS (gtk_application_window_parent_class)
635 ->forall (container, include_internal, callback, user_data);
640 gtk_application_window_get_property (GObject *object,
645 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (object);
649 case PROP_SHOW_MENUBAR:
650 g_value_set_boolean (value, window->priv->show_menubar);
654 g_assert_not_reached ();
659 gtk_application_window_set_property (GObject *object,
664 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (object);
668 case PROP_SHOW_MENUBAR:
669 gtk_application_window_set_show_menubar (window, g_value_get_boolean (value));
673 g_assert_not_reached ();
678 gtk_application_window_dispose (GObject *object)
680 GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (object);
682 if (window->priv->menubar)
684 gtk_widget_unparent (window->priv->menubar);
685 window->priv->menubar = NULL;
688 free_accel_closures (window);
690 g_clear_object (&window->priv->app_menu_section);
691 g_clear_object (&window->priv->menubar_section);
692 g_clear_object (&window->priv->actions);
693 g_clear_object (&window->priv->accels);
695 G_OBJECT_CLASS (gtk_application_window_parent_class)
700 gtk_application_window_init (GtkApplicationWindow *window)
702 window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, GTK_TYPE_APPLICATION_WINDOW, GtkApplicationWindowPrivate);
704 window->priv->actions = g_simple_action_group_new ();
705 window->priv->app_menu_section = g_menu_new ();
706 window->priv->menubar_section = g_menu_new ();
707 window->priv->accels = gtk_accel_group_new ();
708 gtk_window_add_accel_group (GTK_WINDOW (window), window->priv->accels);
710 /* window->priv->actions is the one and only ref on the group, so when
711 * we dispose, the action group will die, disconnecting all signals.
713 g_signal_connect_swapped (window->priv->actions, "action-added",
714 G_CALLBACK (g_action_group_action_added), window);
715 g_signal_connect_swapped (window->priv->actions, "action-enabled-changed",
716 G_CALLBACK (g_action_group_action_enabled_changed), window);
717 g_signal_connect_swapped (window->priv->actions, "action-state-changed",
718 G_CALLBACK (g_action_group_action_state_changed), window);
719 g_signal_connect_swapped (window->priv->actions, "action-removed",
720 G_CALLBACK (g_action_group_action_removed), window);
724 gtk_application_window_class_init (GtkApplicationWindowClass *class)
726 GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
727 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
728 GObjectClass *object_class = G_OBJECT_CLASS (class);
730 container_class->forall = gtk_application_window_real_forall_internal;
731 widget_class->get_preferred_height = gtk_application_window_real_get_preferred_height;
732 widget_class->get_preferred_height_for_width = gtk_application_window_real_get_preferred_height_for_width;
733 widget_class->get_preferred_width = gtk_application_window_real_get_preferred_width;
734 widget_class->get_preferred_width_for_height = gtk_application_window_real_get_preferred_width_for_height;
735 widget_class->size_allocate = gtk_application_window_real_size_allocate;
736 widget_class->realize = gtk_application_window_real_realize;
737 widget_class->unrealize = gtk_application_window_real_unrealize;
738 widget_class->map = gtk_application_window_real_map;
739 object_class->get_property = gtk_application_window_get_property;
740 object_class->set_property = gtk_application_window_set_property;
741 object_class->dispose = gtk_application_window_dispose;
744 * GtkApplicationWindow:show-menubar:
746 * If this property is %TRUE, the window will display a menubar
747 * that includes the app menu and menubar, unless these are
748 * shown by the desktop shell. See g_application_set_app_menu()
749 * and g_application_set_menubar().
751 * If %FALSE, the window will not display a menubar, regardless
752 * of whether the desktop shell is showing the menus or not.
754 gtk_application_window_properties[PROP_SHOW_MENUBAR] =
755 g_param_spec_boolean ("show-menubar",
756 P_("Show a menubar"),
757 P_("TRUE if the window should show a "
758 "menubar at the top of the window"),
759 TRUE, G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
760 g_object_class_install_properties (object_class, N_PROPS, gtk_application_window_properties);
761 g_type_class_add_private (class, sizeof (GtkApplicationWindowPrivate));
765 * gtk_application_window_new:
766 * @application: a #GtkApplication
768 * Creates a new #GtkApplicationWindow.
770 * Returns: a newly created #GtkApplicationWindow
775 gtk_application_window_new (GtkApplication *application)
777 g_return_val_if_fail (GTK_IS_APPLICATION (application), NULL);
779 return g_object_new (GTK_TYPE_APPLICATION_WINDOW,
780 "application", application,
785 * gtk_application_window_get_show_menubar:
786 * @window: a #GtkApplicationWindow
788 * Returns whether the window will display a menubar for the app menu
789 * and menubar as needed.
791 * Returns: %TRUE if @window will display a menubar when needed
796 gtk_application_window_get_show_menubar (GtkApplicationWindow *window)
798 return window->priv->show_menubar;
802 * gtk_application_window_set_show_menubar:
803 * @window: a #GtkApplicationWindow
804 * @show_menubar: whether to show a menubar when needed
806 * Sets whether the window will display a menubar for the app menu
807 * and menubar as needed.
812 gtk_application_window_set_show_menubar (GtkApplicationWindow *window,
813 gboolean show_menubar)
815 g_return_if_fail (GTK_IS_APPLICATION_WINDOW (window));
817 show_menubar = !!show_menubar;
819 if (window->priv->show_menubar != show_menubar)
821 window->priv->show_menubar = show_menubar;
823 gtk_application_window_update_menubar (window);
825 g_object_notify_by_pspec (G_OBJECT (window), gtk_application_window_properties[PROP_SHOW_MENUBAR]);