]> Pileus Git - ~andy/gtk/blob - gtk/gtkapplicationwindow.c
Update GtkApplicationWindow docs
[~andy/gtk] / gtk / gtkapplicationwindow.c
1 /*
2  * Copyright © 2011 Canonical Limited
3  *
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.
8  *
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.
13  *
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.
18  *
19  * Author: Ryan Lortie <desrt@desrt.ca>
20  */
21
22 #include "config.h"
23
24 #include "gtkapplicationwindow.h"
25
26 #include "gtkmodelmenu.h"
27 #include "gactionmuxer.h"
28 #include "gtkintl.h"
29
30 /**
31  * SECTION:gtkapplicationwindow
32  * @title: GtkApplicationWindow
33  * @short_description: GtkWindow subclass with GtkApplication support
34  *
35  * GtkApplicationWindow is a #GtkWindow subclass that offers some
36  * extra functionality for better integration with #GtkApplication
37  * features.  Notably, it can handle both the application menu as well
38  * as the menubar.  See g_application_set_app_menu() and
39  * g_application_set_menubar().
40  *
41  * This class implements the #GActionGroup and #GActionMap interfaces,
42  * to let you add window-specific actions that will be exported by the
43  * associated #GtkApplication, together with its application-wide
44  * actions.  Window-specific actions are prefixed with the "win."
45  * prefix and application-wide actions are prefixed with the "app."
46  * prefix.  Actions must be addressed with the prefixed name when
47  * referring to them from a #GMenuModel.
48  *
49  * If the desktop environment does not display the application menu
50  * as part of the desktop shell, then #GApplicationWindow will
51  * automatically show the menu as part of a menubar. This behaviour
52  * can be overridden with the #GtkApplicationWindow:show-menubar
53  * property.
54  */
55 struct _GtkApplicationWindowPrivate
56 {
57   GSimpleActionGroup *actions;
58   GtkWidget *menubar;
59
60   GMenu *app_menu_section;
61   GMenu *menubar_section;
62   gboolean show_menubar;
63 };
64
65 static void
66 gtk_application_window_update_menubar (GtkApplicationWindow *window)
67 {
68   gboolean should_have_menubar;
69   gboolean have_menubar;
70
71   have_menubar = window->priv->menubar != NULL;
72
73   should_have_menubar = window->priv->show_menubar &&
74                         (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->app_menu_section)) ||
75                          g_menu_model_get_n_items (G_MENU_MODEL (window->priv->menubar_section)));
76
77   if (have_menubar && !should_have_menubar)
78     {
79       gtk_widget_unparent (window->priv->menubar);
80       window->priv->menubar = NULL;
81
82       gtk_widget_queue_resize (GTK_WIDGET (window));
83     }
84
85   if (!have_menubar && should_have_menubar)
86     {
87       GActionMuxer *muxer;
88       GMenu *combined;
89
90       muxer = g_action_muxer_new ();
91       g_action_muxer_insert (muxer, "app", G_ACTION_GROUP (gtk_window_get_application (GTK_WINDOW (window))));
92       g_action_muxer_insert (muxer, "win", G_ACTION_GROUP (window));
93
94       combined = g_menu_new ();
95       g_menu_append_section (combined, NULL, G_MENU_MODEL (window->priv->app_menu_section));
96       g_menu_append_section (combined, NULL, G_MENU_MODEL (window->priv->menubar_section));
97
98       window->priv->menubar = gtk_model_menu_create_menu_bar (G_MENU_MODEL (combined), G_ACTION_OBSERVABLE (muxer));
99       gtk_widget_set_parent (window->priv->menubar, GTK_WIDGET (window));
100       gtk_widget_show_all (window->priv->menubar);
101       g_object_unref (combined);
102       g_object_unref (muxer);
103
104       gtk_widget_queue_resize (GTK_WIDGET (window));
105     }
106 }
107
108 static void
109 gtk_application_window_update_shell_shows_app_menu (GtkApplicationWindow *window,
110                                                     GtkSettings          *settings)
111 {
112   gboolean shown_by_shell;
113
114   g_object_get (settings, "gtk-shell-shows-app-menu", &shown_by_shell, NULL);
115
116   if (shown_by_shell)
117     {
118       /* the shell shows it, so don't show it locally */
119       if (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->app_menu_section)) != 0)
120         g_menu_remove (window->priv->app_menu_section, 0);
121     }
122   else
123     {
124       /* the shell does not show it, so make sure we show it */
125       if (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->app_menu_section)) == 0)
126         {
127           GMenuModel *app_menu;
128
129           app_menu = g_application_get_app_menu (G_APPLICATION (gtk_window_get_application (GTK_WINDOW (window))));
130
131           if (app_menu != NULL)
132             g_menu_append_submenu (window->priv->app_menu_section, _("Application"), app_menu);
133         }
134     }
135 }
136
137 static void
138 gtk_application_window_update_shell_shows_menubar (GtkApplicationWindow *window,
139                                                    GtkSettings          *settings)
140 {
141   gboolean shown_by_shell;
142
143   g_object_get (settings, "gtk-shell-shows-menubar", &shown_by_shell, NULL);
144
145   if (shown_by_shell)
146     {
147       /* the shell shows it, so don't show it locally */
148       if (g_menu_model_get_n_items (G_MENU_MODEL (window->priv->menubar_section)) != 0)
149         g_menu_remove (window->priv->menubar_section, 0);
150     }
151   else
152     {
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->menubar_section)) == 0)
155         {
156           GMenuModel *menubar;
157
158           menubar = g_application_get_menubar (G_APPLICATION (gtk_window_get_application (GTK_WINDOW (window))));
159
160           if (menubar != NULL)
161             g_menu_append_section (window->priv->menubar_section, NULL, menubar);
162         }
163     }
164 }
165
166 static void
167 gtk_application_window_shell_shows_app_menu_changed (GObject    *object,
168                                                      GParamSpec *pspec,
169                                                      gpointer    user_data)
170 {
171   GtkApplicationWindow *window = user_data;
172
173   gtk_application_window_update_shell_shows_app_menu (window, GTK_SETTINGS (object));
174   gtk_application_window_update_menubar (window);
175 }
176
177 static void
178 gtk_application_window_shell_shows_menubar_changed (GObject    *object,
179                                                     GParamSpec *pspec,
180                                                     gpointer    user_data)
181 {
182   GtkApplicationWindow *window = user_data;
183
184   gtk_application_window_update_shell_shows_menubar (window, GTK_SETTINGS (object));
185   gtk_application_window_update_menubar (window);
186 }
187
188 static gchar **
189 gtk_application_window_list_actions (GActionGroup *group)
190 {
191   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (group);
192
193   return g_action_group_list_actions (G_ACTION_GROUP (window->priv->actions));
194 }
195
196 static gboolean
197 gtk_application_window_query_action (GActionGroup        *group,
198                                      const gchar         *action_name,
199                                      gboolean            *enabled,
200                                      const GVariantType **parameter_type,
201                                      const GVariantType **state_type,
202                                      GVariant           **state_hint,
203                                      GVariant           **state)
204 {
205   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (group);
206
207   return g_action_group_query_action (G_ACTION_GROUP (window->priv->actions),
208                                       action_name, enabled, parameter_type, state_type, state_hint, state);
209 }
210
211 static void
212 gtk_application_window_activate_action (GActionGroup *group,
213                                         const gchar  *action_name,
214                                         GVariant     *parameter)
215 {
216   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (group);
217
218   return g_action_group_activate_action (G_ACTION_GROUP (window->priv->actions), action_name, parameter);
219 }
220
221 static void
222 gtk_application_window_change_action_state (GActionGroup *group,
223                                             const gchar  *action_name,
224                                             GVariant     *state)
225 {
226   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (group);
227
228   return g_action_group_change_action_state (G_ACTION_GROUP (window->priv->actions), action_name, state);
229 }
230
231 static GAction *
232 gtk_application_window_lookup_action (GActionMap  *action_map,
233                                       const gchar *action_name)
234 {
235   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (action_map);
236
237   return g_action_map_lookup_action (G_ACTION_MAP (window->priv->actions), action_name);
238 }
239
240 static void
241 gtk_application_window_add_action (GActionMap *action_map,
242                                    GAction    *action)
243 {
244   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (action_map);
245
246   g_action_map_add_action (G_ACTION_MAP (window->priv->actions), action);
247 }
248
249 static void
250 gtk_application_window_remove_action (GActionMap  *action_map,
251                                       const gchar *action_name)
252 {
253   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (action_map);
254
255   g_action_map_remove_action (G_ACTION_MAP (window->priv->actions), action_name);
256 }
257
258 static void
259 gtk_application_window_group_iface_init (GActionGroupInterface *iface)
260 {
261   iface->list_actions = gtk_application_window_list_actions;
262   iface->query_action = gtk_application_window_query_action;
263   iface->activate_action = gtk_application_window_activate_action;
264   iface->change_action_state = gtk_application_window_change_action_state;
265 }
266
267 static void
268 gtk_application_window_map_iface_init (GActionMapInterface *iface)
269 {
270   iface->lookup_action = gtk_application_window_lookup_action;
271   iface->add_action = gtk_application_window_add_action;
272   iface->remove_action = gtk_application_window_remove_action;
273 }
274
275 G_DEFINE_TYPE_WITH_CODE (GtkApplicationWindow, gtk_application_window, GTK_TYPE_WINDOW,
276                          G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, gtk_application_window_group_iface_init)
277                          G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_MAP, gtk_application_window_map_iface_init))
278
279 enum {
280   PROP_0,
281   PROP_SHOW_MENUBAR,
282   N_PROPS
283 };
284 static GParamSpec *gtk_application_window_properties[N_PROPS];
285
286 static void
287 gtk_application_window_real_get_preferred_height (GtkWidget *widget,
288                                                   gint      *minimum_height,
289                                                   gint      *natural_height)
290 {
291   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
292
293   GTK_WIDGET_CLASS (gtk_application_window_parent_class)
294     ->get_preferred_height (widget, minimum_height, natural_height);
295
296   if (window->priv->menubar != NULL)
297     {
298       gint menubar_min_height, menubar_nat_height;
299
300       gtk_widget_get_preferred_height (window->priv->menubar, &menubar_min_height, &menubar_nat_height);
301       *minimum_height += menubar_min_height;
302       *natural_height += menubar_nat_height;
303     }
304 }
305
306 static void
307 gtk_application_window_real_get_preferred_height_for_width (GtkWidget *widget,
308                                                             gint       width,
309                                                             gint      *minimum_height,
310                                                             gint      *natural_height)
311 {
312   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
313
314   GTK_WIDGET_CLASS (gtk_application_window_parent_class)
315     ->get_preferred_height_for_width (widget, width, minimum_height, natural_height);
316
317   if (window->priv->menubar != NULL)
318     {
319       gint menubar_min_height, menubar_nat_height;
320
321       gtk_widget_get_preferred_height_for_width (window->priv->menubar, width, &menubar_min_height, &menubar_nat_height);
322       *minimum_height += menubar_min_height;
323       *natural_height += menubar_nat_height;
324     }
325 }
326
327 static void
328 gtk_application_window_real_get_preferred_width (GtkWidget *widget,
329                                                  gint      *minimum_width,
330                                                  gint      *natural_width)
331 {
332   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
333
334   GTK_WIDGET_CLASS (gtk_application_window_parent_class)
335     ->get_preferred_width (widget, minimum_width, natural_width);
336
337   if (window->priv->menubar != NULL)
338     {
339       gint menubar_min_width, menubar_nat_width;
340
341       gtk_widget_get_preferred_width (window->priv->menubar, &menubar_min_width, &menubar_nat_width);
342       *minimum_width = MAX (*minimum_width, menubar_min_width);
343       *natural_width = MAX (*natural_width, menubar_nat_width);
344     }
345 }
346
347 static void
348 gtk_application_window_real_get_preferred_width_for_height (GtkWidget *widget,
349                                                             gint       height,
350                                                             gint      *minimum_width,
351                                                             gint      *natural_width)
352 {
353   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
354
355   GTK_WIDGET_CLASS (gtk_application_window_parent_class)
356     ->get_preferred_width_for_height (widget, height, minimum_width, natural_width);
357
358   if (window->priv->menubar != NULL)
359     {
360       gint menubar_min_width, menubar_nat_width;
361
362       gtk_widget_get_preferred_width_for_height (window->priv->menubar, height, &menubar_min_width, &menubar_nat_width);
363       *minimum_width = MAX (*minimum_width, menubar_min_width);
364       *natural_width = MAX (*natural_width, menubar_nat_width);
365     }
366 }
367
368 static void
369 gtk_application_window_real_size_allocate (GtkWidget     *widget,
370                                            GtkAllocation *allocation)
371 {
372   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
373
374   if (window->priv->menubar != NULL)
375     {
376       GtkAllocation menubar_allocation = *allocation;
377       gint menubar_min_height, menubar_nat_height;
378       GtkWidget *child;
379
380       gtk_widget_get_preferred_height_for_width (window->priv->menubar, allocation->width, &menubar_min_height, &menubar_nat_height);
381
382       menubar_allocation.height = menubar_min_height;
383       gtk_widget_size_allocate (window->priv->menubar, &menubar_allocation);
384
385       child = gtk_bin_get_child (GTK_BIN (window));
386       if (child != NULL && gtk_widget_get_visible (child))
387         {
388           GtkAllocation child_allocation = *allocation;
389           gint border_width;
390
391           child_allocation.height = MAX (1, child_allocation.height - menubar_min_height);
392
393           border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
394           child_allocation.x += border_width;
395           child_allocation.y += border_width + menubar_min_height;
396           child_allocation.width -= border_width * 2;
397           child_allocation.height -= border_width * 2 - menubar_min_height;
398           gtk_widget_size_allocate (child, &child_allocation);
399         }
400
401       gtk_widget_set_allocation (widget, allocation);
402     }
403   else
404     GTK_WIDGET_CLASS (gtk_application_window_parent_class)
405       ->size_allocate (widget, allocation);
406 }
407
408 static void
409 gtk_application_window_real_realize (GtkWidget *widget)
410 {
411   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
412   GtkSettings *settings;
413
414   settings = gtk_widget_get_settings (widget);
415
416   g_signal_connect (settings, "notify::gtk-shell-shows-app-menu",
417                     G_CALLBACK (gtk_application_window_shell_shows_app_menu_changed), window);
418   g_signal_connect (settings, "notify::gtk-shell-shows-menubar",
419                     G_CALLBACK (gtk_application_window_shell_shows_menubar_changed), window);
420
421   gtk_application_window_update_shell_shows_app_menu (window, settings);
422   gtk_application_window_update_shell_shows_menubar (window, settings);
423   gtk_application_window_update_menubar (window);
424
425   GTK_WIDGET_CLASS (gtk_application_window_parent_class)
426     ->realize (widget);
427 }
428
429 static void
430 gtk_application_window_real_unrealize (GtkWidget *widget)
431 {
432   GtkSettings *settings;
433
434   settings = gtk_widget_get_settings (widget);
435
436   g_signal_handlers_disconnect_by_func (settings, gtk_application_window_shell_shows_app_menu_changed, widget);
437   g_signal_handlers_disconnect_by_func (settings, gtk_application_window_shell_shows_menubar_changed, widget);
438
439   GTK_WIDGET_CLASS (gtk_application_window_parent_class)
440     ->unrealize (widget);
441 }
442
443 static void
444 gtk_application_window_real_map (GtkWidget *widget)
445 {
446   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (widget);
447
448   /* XXX could eliminate this by tweaking gtk_window_map */
449   if (window->priv->menubar)
450     gtk_widget_map (window->priv->menubar);
451
452   GTK_WIDGET_CLASS (gtk_application_window_parent_class)
453     ->map (widget);
454 }
455
456 static void
457 gtk_application_window_real_forall_internal (GtkContainer *container,
458                                              gboolean      include_internal,
459                                              GtkCallback   callback,
460                                              gpointer      user_data)
461 {
462   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (container);
463
464   if (window->priv->menubar)
465     callback (window->priv->menubar, user_data);
466
467   GTK_CONTAINER_CLASS (gtk_application_window_parent_class)
468     ->forall (container, include_internal, callback, user_data);
469 }
470
471
472 static void
473 gtk_application_window_get_property (GObject    *object,
474                                      guint       prop_id,
475                                      GValue     *value,
476                                      GParamSpec *pspec)
477 {
478   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (object);
479
480   switch (prop_id)
481     {
482     case PROP_SHOW_MENUBAR:
483       g_value_set_boolean (value, window->priv->show_menubar);
484       break;
485
486     default:
487       g_assert_not_reached ();
488     }
489 }
490
491 static void
492 gtk_application_window_set_property (GObject      *object,
493                                      guint         prop_id,
494                                      const GValue *value,
495                                      GParamSpec   *pspec)
496 {
497   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (object);
498
499   switch (prop_id)
500     {
501     case PROP_SHOW_MENUBAR:
502       gtk_application_window_set_show_menubar (window, g_value_get_boolean (value));
503       break;
504
505     default:
506       g_assert_not_reached ();
507     }
508 }
509
510 static void
511 gtk_application_window_dispose (GObject *object)
512 {
513   GtkApplicationWindow *window = GTK_APPLICATION_WINDOW (object);
514
515   if (window->priv->menubar)
516     {
517       gtk_widget_unparent (window->priv->menubar);
518       window->priv->menubar = NULL;
519     }
520
521   g_clear_object (&window->priv->app_menu_section);
522   g_clear_object (&window->priv->menubar_section);
523   g_clear_object (&window->priv->actions);
524
525   G_OBJECT_CLASS (gtk_application_window_parent_class)
526     ->dispose (object);
527 }
528
529 static void
530 gtk_application_window_init (GtkApplicationWindow *window)
531 {
532   window->priv = G_TYPE_INSTANCE_GET_PRIVATE (window, GTK_TYPE_APPLICATION_WINDOW, GtkApplicationWindowPrivate);
533
534   window->priv->actions = g_simple_action_group_new ();
535   window->priv->app_menu_section = g_menu_new ();
536   window->priv->menubar_section = g_menu_new ();
537
538   /* window->priv->actions is the one and only ref on the group, so when
539    * we dispose, the action group will die, disconnecting all signals.
540    */
541   g_signal_connect_swapped (window->priv->actions, "action-added",
542                             G_CALLBACK (g_action_group_action_added), window);
543   g_signal_connect_swapped (window->priv->actions, "action-enabled-changed",
544                             G_CALLBACK (g_action_group_action_enabled_changed), window);
545   g_signal_connect_swapped (window->priv->actions, "action-state-changed",
546                             G_CALLBACK (g_action_group_action_state_changed), window);
547   g_signal_connect_swapped (window->priv->actions, "action-removed",
548                             G_CALLBACK (g_action_group_action_removed), window);
549 }
550
551 static void
552 gtk_application_window_class_init (GtkApplicationWindowClass *class)
553 {
554   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
555   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
556   GObjectClass *object_class = G_OBJECT_CLASS (class);
557
558   container_class->forall = gtk_application_window_real_forall_internal;
559   widget_class->get_preferred_height = gtk_application_window_real_get_preferred_height;
560   widget_class->get_preferred_height_for_width = gtk_application_window_real_get_preferred_height_for_width;
561   widget_class->get_preferred_width = gtk_application_window_real_get_preferred_width;
562   widget_class->get_preferred_width_for_height = gtk_application_window_real_get_preferred_width_for_height;
563   widget_class->size_allocate = gtk_application_window_real_size_allocate;
564   widget_class->realize = gtk_application_window_real_realize;
565   widget_class->unrealize = gtk_application_window_real_unrealize;
566   widget_class->map = gtk_application_window_real_map;
567   object_class->get_property = gtk_application_window_get_property;
568   object_class->set_property = gtk_application_window_set_property;
569   object_class->dispose = gtk_application_window_dispose;
570
571   /**
572    * GtkApplicationWindow:show-menubar:
573    *
574    * If this property is %TRUE, the window will display a menubar
575    * that includes the app menu and menubar, unless these are
576    * shown by the desktop shell. See g_application_set_app_menu()
577    * and g_application_set_menubar().
578    *
579    * If %FALSE, the window will not display a menubar, regardless
580    * of whether the desktop shell is showing the menus or not.
581    */
582   gtk_application_window_properties[PROP_SHOW_MENUBAR] =
583     g_param_spec_boolean ("show-menubar",
584                           P_("Show a menubar"),
585                           P_("TRUE if the window should show a "
586                              "menubar at the top of the window"),
587                           TRUE, G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
588   g_object_class_install_properties (object_class, N_PROPS, gtk_application_window_properties);
589   g_type_class_add_private (class, sizeof (GtkApplicationWindowPrivate));
590 }
591
592 /**
593  * gtk_application_window_new:
594  * @application: a #GtkApplication
595  *
596  * Creates a new #GtkApplicationWindow.
597  *
598  * Returns: a newly created #GtkApplicationWindow
599  *
600  * Since: 3.4
601  */
602 GtkWidget *
603 gtk_application_window_new (GtkApplication *application)
604 {
605   g_return_val_if_fail (GTK_IS_APPLICATION (application), NULL);
606
607   return g_object_new (GTK_TYPE_APPLICATION_WINDOW,
608                        "application", application,
609                        NULL);
610 }
611
612 /**
613  * gtk_application_window_get_show_menubar:
614  * @window: a #GtkApplicationWindow
615  *
616  * Returns whether the window will display a menubar for the app menu
617  * and menubar as needed.
618  *
619  * Returns: %TRUE if @window will display a menubar when needed
620  *
621  * Since: 3.4
622  */
623 gboolean
624 gtk_application_window_get_show_menubar (GtkApplicationWindow *window)
625 {
626   return window->priv->show_menubar;
627 }
628
629 /**
630  * gtk_application_window_set_show_menubar:
631  * @window: a #GtkApplicationWindow
632  * @show_menubar: whether to show a menubar when needed
633  *
634  * Sets whether the window will display a menubar for the app menu
635  * and menubar as needed.
636  *
637  * Since: 3.4
638  */
639 void
640 gtk_application_window_set_show_menubar (GtkApplicationWindow *window,
641                                          gboolean              show_menubar)
642 {
643   g_return_if_fail (GTK_IS_APPLICATION_WINDOW (window));
644
645   show_menubar = !!show_menubar;
646
647   if (window->priv->show_menubar != show_menubar)
648     {
649       window->priv->show_menubar = show_menubar;
650
651       gtk_application_window_update_menubar (window);
652
653       g_object_notify_by_pspec (G_OBJECT (window), gtk_application_window_properties[PROP_SHOW_MENUBAR]);
654     }
655 }