[Xfce4-commits] [apps/mousepad] 07/09: Refactor window initialization code for new stuff

noreply at xfce.org noreply at xfce.org
Sun Jul 13 05:10:25 CEST 2014


This is an automated email from the git hooks/post-receive script.

mbrush pushed a commit to branch master
in repository apps/mousepad.

commit 9054bf405debd2432d3c3c49748b2c632635c944
Author: Matthew Brush <mbrush at codebrainz.ca>
Date:   Sat Jul 12 18:59:23 2014 -0700

    Refactor window initialization code for new stuff
    
    Add separate functions to create each the menubar, toolbar, statusbar,
    root warning bar, notebook, etc. Improve updating of fullscreen mode
    settings when changing setting/action.
---
 mousepad/mousepad-window.c |  399 +++++++++++++++++++++++++++++---------------
 1 file changed, 262 insertions(+), 137 deletions(-)

diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index 6296928..d5d19b4 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -103,6 +103,8 @@ static void              mousepad_window_populate_statusbar_popup     (MousepadW
 static void              mousepad_window_create_statusbar             (MousepadWindow         *window);
 static void              mousepad_window_statusbar_filetype_toggled   (GtkCheckMenuItem       *item,
                                                                        MousepadWindow         *window);
+static gboolean          mousepad_window_get_in_fullscreen            (MousepadWindow         *window);
+static void              mousepad_window_update_main_widgets          (MousepadWindow         *window);
 
 /* notebook signals */
 static void              mousepad_window_notebook_switch_page         (GtkNotebook            *notebook,
@@ -680,88 +682,45 @@ mousepad_window_restore (MousepadWindow *window)
 
 
 static void
-mousepad_window_init (MousepadWindow *window)
+mousepad_window_create_menubar (MousepadWindow *window)
 {
-  GtkAccelGroup *accel_group;
-  GtkWidget     *label;
-  GtkWidget     *separator;
-  GtkWidget     *ebox;
-  GtkWidget     *item;
-  GtkAction     *action;
-  gboolean       active;
-
-  /* initialize stuff */
-  window->save_geometry_timer_id = 0;
-  window->update_recent_menu_id = 0;
-  window->update_go_menu_id = 0;
-  window->gomenu_merge_id = 0;
-  window->recent_merge_id = 0;
-  window->search_bar = NULL;
-  window->statusbar = NULL;
-  window->replace_dialog = NULL;
-  window->active = NULL;
-  window->recent_manager = NULL;
-
-  /* increase clipboard history ref count */
-  clipboard_history_ref_count++;
-
-  /* signal for handling the window delete event */
-  g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (mousepad_window_delete_event), NULL);
-
-  /* allocate a closure for the menu_item_selected() callback */
-  window->menu_item_selected_closure = g_cclosure_new_object (G_CALLBACK (mousepad_window_menu_item_selected), G_OBJECT (window));
-  g_closure_ref (window->menu_item_selected_closure);
-  g_closure_sink (window->menu_item_selected_closure);
-
-  /* allocate a closure for the menu_item_deselected() callback */
-  window->menu_item_deselected_closure = g_cclosure_new_object (G_CALLBACK (mousepad_window_menu_item_deselected), G_OBJECT (window));
-  g_closure_ref (window->menu_item_deselected_closure);
-  g_closure_sink (window->menu_item_deselected_closure);
-
-  /* restore window settings */
-  mousepad_window_restore (window);
-
-  /* the action group for this window */
-  window->action_group = gtk_action_group_new ("MousepadWindow");
-  gtk_action_group_set_translation_domain (window->action_group, GETTEXT_PACKAGE);
-  gtk_action_group_add_actions (window->action_group, action_entries, G_N_ELEMENTS (action_entries), GTK_WIDGET (window));
-  gtk_action_group_add_toggle_actions (window->action_group, toggle_action_entries, G_N_ELEMENTS (toggle_action_entries), GTK_WIDGET (window));
-  gtk_action_group_add_radio_actions (window->action_group, radio_action_entries, G_N_ELEMENTS (radio_action_entries), -1, G_CALLBACK (mousepad_window_action_line_ending), GTK_WIDGET (window));
+  GtkAction *action;
+  gboolean   active;
 
-  /* create the ui manager and connect proxy signals for the statusbar */
-  window->ui_manager = gtk_ui_manager_new ();
-  g_signal_connect (G_OBJECT (window->ui_manager), "connect-proxy", G_CALLBACK (mousepad_window_connect_proxy), window);
-  g_signal_connect (G_OBJECT (window->ui_manager), "disconnect-proxy", G_CALLBACK (mousepad_window_disconnect_proxy), window);
-  gtk_ui_manager_insert_action_group (window->ui_manager, window->action_group, 0);
-  gtk_ui_manager_add_ui_from_string (window->ui_manager, mousepad_window_ui, mousepad_window_ui_length, NULL);
+  window->menubar = gtk_ui_manager_get_widget (window->ui_manager, "/main-menu");
+  gtk_box_pack_start (GTK_BOX (window->box), window->menubar, FALSE, FALSE, 0);
 
-  /* build the templates menu when the item is shown for the first time */
-  /* from here we also trigger the idle build of the recent menu */
-  item = gtk_ui_manager_get_widget (window->ui_manager, "/main-menu/file-menu/template-menu");
-  g_signal_connect (G_OBJECT (item), "map", G_CALLBACK (mousepad_window_menu_templates), window);
+  /* sync the menubar visibility and action state to the setting */
+  action = gtk_action_group_get_action (window->action_group, "menubar");
+  if (MOUSEPAD_SETTING_GET_BOOLEAN (WINDOW_FULLSCREEN))
+    {
+      gint value = MOUSEPAD_SETTING_GET_BOOLEAN (MENUBAR_VISIBLE_FULLSCREEN);
+      active = (value == 0) ? MOUSEPAD_SETTING_GET_BOOLEAN (MENUBAR_VISIBLE) : (value == 2);
+    }
+  else
+    active = MOUSEPAD_SETTING_GET_BOOLEAN (MENUBAR_VISIBLE);
+  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
+  gtk_widget_set_visible (window->menubar, active);
 
-  /* add tab size menu */
-  mousepad_window_menu_tab_sizes (window);
+  MOUSEPAD_SETTING_CONNECT (MENUBAR_VISIBLE,
+                            G_CALLBACK (mousepad_window_update_main_widgets),
+                            window,
+                            G_CONNECT_SWAPPED);
 
-  /* add color schemes menu */
-  mousepad_window_menu_color_schemes (window);
+  MOUSEPAD_SETTING_CONNECT (MENUBAR_VISIBLE_FULLSCREEN,
+                            G_CALLBACK (mousepad_window_update_main_widgets),
+                            window,
+                            G_CONNECT_SWAPPED);
+}
 
-  /* add languages/filetypes menu */
-  mousepad_window_menu_languages (window);
 
-  /* set accel group for the window */
-  accel_group = gtk_ui_manager_get_accel_group (window->ui_manager);
-  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
 
-  /* create the main table */
-  window->box = gtk_vbox_new (FALSE, 0);
-  gtk_container_add (GTK_CONTAINER (window), window->box);
-  gtk_widget_show (window->box);
-
-  window->menubar = gtk_ui_manager_get_widget (window->ui_manager, "/main-menu");
-  gtk_box_pack_start (GTK_BOX (window->box), window->menubar, FALSE, FALSE, 0);
-  gtk_widget_show (window->menubar);
-  MOUSEPAD_SETTING_BIND (MENUBAR_VISIBLE, window->menubar, "visible", G_SETTINGS_BIND_DEFAULT);
+static void
+mousepad_window_create_toolbar (MousepadWindow *window)
+{
+  GtkWidget *item;
+  GtkAction *action;
+  gboolean   active;
 
   window->toolbar = gtk_ui_manager_get_widget (window->ui_manager, "/main-toolbar");
   gtk_box_pack_start (GTK_BOX (window->box), window->toolbar, FALSE, FALSE, 0);
@@ -773,27 +732,51 @@ mousepad_window_init (MousepadWindow *window)
 
   /* sync the toolbar visibility and action state to the setting */
   action = gtk_action_group_get_action (window->action_group, "toolbar");
-  active = MOUSEPAD_SETTING_GET_BOOLEAN (TOOLBAR_VISIBLE);
+  if (MOUSEPAD_SETTING_GET_BOOLEAN (WINDOW_FULLSCREEN))
+    {
+      gint value = MOUSEPAD_SETTING_GET_BOOLEAN (TOOLBAR_VISIBLE_FULLSCREEN);
+      active = (value == 0) ? MOUSEPAD_SETTING_GET_BOOLEAN (TOOLBAR_VISIBLE) : (value == 2);
+    }
+  else
+    active = MOUSEPAD_SETTING_GET_BOOLEAN (TOOLBAR_VISIBLE);
   gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
+  gtk_widget_set_visible (window->toolbar, active);
 
   /* update the toolbar with the settings */
   mousepad_window_update_toolbar (window, NULL, NULL);
+
+  /* connect to some signals to keep in sync */
   MOUSEPAD_SETTING_CONNECT (TOOLBAR_VISIBLE,
                             G_CALLBACK (mousepad_window_update_toolbar),
                             window,
                             G_CONNECT_SWAPPED);
+
+  MOUSEPAD_SETTING_CONNECT (TOOLBAR_VISIBLE_FULLSCREEN,
+                            G_CALLBACK (mousepad_window_update_main_widgets),
+                            window,
+                            G_CONNECT_SWAPPED);
+
   MOUSEPAD_SETTING_CONNECT (TOOLBAR_STYLE,
                             G_CALLBACK (mousepad_window_update_toolbar),
                             window,
                             G_CONNECT_SWAPPED);
+
   MOUSEPAD_SETTING_CONNECT (TOOLBAR_ICON_SIZE,
                             G_CALLBACK (mousepad_window_update_toolbar),
                             window,
                             G_CONNECT_SWAPPED);
+}
+
 
+
+static void
+mousepad_window_create_root_warning (MousepadWindow *window)
+{
   /* check if we need to add the root warning */
   if (G_UNLIKELY (geteuid () == 0))
     {
+      GtkWidget *ebox, *label, *separator;
+
       /* install default settings for the root warning text box */
       gtk_rc_parse_string ("style\"mousepad-window-root-style\"\n"
                              "{\n"
@@ -819,8 +802,13 @@ mousepad_window_init (MousepadWindow *window)
       gtk_box_pack_start (GTK_BOX (window->box), separator, FALSE, FALSE, 0);
       gtk_widget_show (separator);
     }
+}
 
-  /* create the notebook */
+
+
+static void
+mousepad_window_create_notebook (MousepadWindow *window)
+{
   window->notebook = g_object_new (GTK_TYPE_NOTEBOOK,
                                    "homogeneous", FALSE,
                                    "scrollable", TRUE,
@@ -851,13 +839,45 @@ mousepad_window_init (MousepadWindow *window)
   /* append and show the notebook */
   gtk_box_pack_start (GTK_BOX (window->box), window->notebook, TRUE, TRUE, PADDING);
   gtk_widget_show (window->notebook);
+}
 
-  /* create the statusbar */
-  mousepad_window_create_statusbar (window);
 
-  /* allow drops in the window */
-  gtk_drag_dest_set (GTK_WIDGET (window), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, drop_targets, G_N_ELEMENTS (drop_targets), GDK_ACTION_COPY | GDK_ACTION_MOVE);
-  g_signal_connect (G_OBJECT (window), "drag-data-received", G_CALLBACK (mousepad_window_drag_data_received), window);
+
+static void
+mousepad_window_create_statusbar (MousepadWindow *window)
+{
+  GtkAction *action;
+  gboolean   active;
+
+  /* setup a new statusbar */
+  window->statusbar = mousepad_statusbar_new ();
+
+  /* sync the statusbar visibility and action state to the setting */
+  action = gtk_action_group_get_action (window->action_group, "statusbar");
+  if (MOUSEPAD_SETTING_GET_BOOLEAN (WINDOW_FULLSCREEN))
+    {
+      gint value = MOUSEPAD_SETTING_GET_BOOLEAN (STATUSBAR_VISIBLE_FULLSCREEN);
+      active = (value == 0) ? MOUSEPAD_SETTING_GET_BOOLEAN (STATUSBAR_VISIBLE) : (value == 2);
+    }
+  else
+    active = MOUSEPAD_SETTING_GET_BOOLEAN (STATUSBAR_VISIBLE);
+  gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
+  gtk_widget_set_visible (window->statusbar, active);
+
+  /* pack the statusbar into the window UI */
+  gtk_box_pack_end (GTK_BOX (window->box), window->statusbar, FALSE, FALSE, 0);
+
+  /* overwrite toggle signal */
+  g_signal_connect_swapped (G_OBJECT (window->statusbar), "enable-overwrite",
+                            G_CALLBACK (mousepad_window_action_statusbar_overwrite), window);
+
+  /* populate filetype popup menu signal */
+  g_signal_connect_swapped (G_OBJECT (window->statusbar), "populate-filetype-popup",
+                            G_CALLBACK (mousepad_window_populate_statusbar_popup), window);
+
+  /* update the statusbar items */
+  if (MOUSEPAD_IS_DOCUMENT (window->active))
+    mousepad_document_send_signals (window->active);
 
   /* update the statusbar with certain settings */
   MOUSEPAD_SETTING_CONNECT (TAB_WIDTH,
@@ -870,6 +890,112 @@ mousepad_window_init (MousepadWindow *window)
                             window,
                             G_CONNECT_SWAPPED);
 
+  MOUSEPAD_SETTING_CONNECT (STATUSBAR_VISIBLE,
+                            G_CALLBACK (mousepad_window_update_main_widgets),
+                            window,
+                            G_CONNECT_SWAPPED);
+
+  MOUSEPAD_SETTING_CONNECT (STATUSBAR_VISIBLE_FULLSCREEN,
+                            G_CALLBACK (mousepad_window_update_main_widgets),
+                            window,
+                            G_CONNECT_SWAPPED);
+}
+
+
+
+static void
+mousepad_window_init (MousepadWindow *window)
+{
+  GtkAccelGroup *accel_group;
+  GtkWidget     *item;
+
+  /* initialize stuff */
+  window->save_geometry_timer_id = 0;
+  window->update_recent_menu_id = 0;
+  window->update_go_menu_id = 0;
+  window->gomenu_merge_id = 0;
+  window->recent_merge_id = 0;
+  window->search_bar = NULL;
+  window->statusbar = NULL;
+  window->replace_dialog = NULL;
+  window->active = NULL;
+  window->recent_manager = NULL;
+
+  /* increase clipboard history ref count */
+  clipboard_history_ref_count++;
+
+  /* signal for handling the window delete event */
+  g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (mousepad_window_delete_event), NULL);
+
+  /* allocate a closure for the menu_item_selected() callback */
+  window->menu_item_selected_closure = g_cclosure_new_object (G_CALLBACK (mousepad_window_menu_item_selected), G_OBJECT (window));
+  g_closure_ref (window->menu_item_selected_closure);
+  g_closure_sink (window->menu_item_selected_closure);
+
+  /* allocate a closure for the menu_item_deselected() callback */
+  window->menu_item_deselected_closure = g_cclosure_new_object (G_CALLBACK (mousepad_window_menu_item_deselected), G_OBJECT (window));
+  g_closure_ref (window->menu_item_deselected_closure);
+  g_closure_sink (window->menu_item_deselected_closure);
+
+  /* restore window settings */
+  mousepad_window_restore (window);
+
+  /* the action group for this window */
+  window->action_group = gtk_action_group_new ("MousepadWindow");
+  gtk_action_group_set_translation_domain (window->action_group, GETTEXT_PACKAGE);
+  gtk_action_group_add_actions (window->action_group, action_entries, G_N_ELEMENTS (action_entries), GTK_WIDGET (window));
+  gtk_action_group_add_toggle_actions (window->action_group, toggle_action_entries, G_N_ELEMENTS (toggle_action_entries), GTK_WIDGET (window));
+  gtk_action_group_add_radio_actions (window->action_group, radio_action_entries, G_N_ELEMENTS (radio_action_entries), -1, G_CALLBACK (mousepad_window_action_line_ending), GTK_WIDGET (window));
+
+  /* create the ui manager and connect proxy signals for the statusbar */
+  window->ui_manager = gtk_ui_manager_new ();
+  g_signal_connect (G_OBJECT (window->ui_manager), "connect-proxy", G_CALLBACK (mousepad_window_connect_proxy), window);
+  g_signal_connect (G_OBJECT (window->ui_manager), "disconnect-proxy", G_CALLBACK (mousepad_window_disconnect_proxy), window);
+  gtk_ui_manager_insert_action_group (window->ui_manager, window->action_group, 0);
+  gtk_ui_manager_add_ui_from_string (window->ui_manager, mousepad_window_ui, mousepad_window_ui_length, NULL);
+
+  /* build the templates menu when the item is shown for the first time */
+  /* from here we also trigger the idle build of the recent menu */
+  item = gtk_ui_manager_get_widget (window->ui_manager, "/main-menu/file-menu/template-menu");
+  g_signal_connect (G_OBJECT (item), "map", G_CALLBACK (mousepad_window_menu_templates), window);
+
+  /* add tab size menu */
+  mousepad_window_menu_tab_sizes (window);
+
+  /* add color schemes menu */
+  mousepad_window_menu_color_schemes (window);
+
+  /* add languages/filetypes menu */
+  mousepad_window_menu_languages (window);
+
+  /* set accel group for the window */
+  accel_group = gtk_ui_manager_get_accel_group (window->ui_manager);
+  gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
+
+  /* create the main table */
+  window->box = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (window), window->box);
+  gtk_widget_show (window->box);
+
+  /* create the main menu from the ui manager */
+  mousepad_window_create_menubar (window);
+
+  /* create the toolbar from the ui manager */
+  mousepad_window_create_toolbar (window);
+
+  /* create the root-warning bar (if needed) */
+  mousepad_window_create_root_warning (window);
+
+  /* create the notebook */
+  mousepad_window_create_notebook (window);
+
+  /* create the statusbar */
+  mousepad_window_create_statusbar (window);
+
+  /* allow drops in the window */
+  gtk_drag_dest_set (GTK_WIDGET (window), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, drop_targets, G_N_ELEMENTS (drop_targets), GDK_ACTION_COPY | GDK_ACTION_MOVE);
+  g_signal_connect (G_OBJECT (window), "drag-data-received", G_CALLBACK (mousepad_window_drag_data_received), window);
+
   /* update the window title when 'path-in-title' setting changes */
   MOUSEPAD_SETTING_CONNECT (PATH_IN_TITLE,
                             G_CALLBACK (mousepad_window_update_window_title),
@@ -1605,6 +1731,21 @@ mousepad_window_populate_statusbar_popup (MousepadWindow    *window,
 
 
 
+static gboolean
+mousepad_window_get_in_fullscreen (MousepadWindow *window)
+{
+  if (GTK_IS_WIDGET (window) && gtk_widget_get_visible (GTK_WIDGET (window)))
+    {
+      GdkWindow     *win = gtk_widget_get_window (GTK_WIDGET (window));
+      GdkWindowState state = gdk_window_get_state (win);
+      return (state & GDK_WINDOW_STATE_FULLSCREEN);
+    }
+
+  return FALSE;
+}
+
+
+
 /**
  * Notebook Signal Functions
  **/
@@ -3617,36 +3758,6 @@ mousepad_window_menu_languages (MousepadWindow *window)
 
 
 
-static void
-mousepad_window_create_statusbar (MousepadWindow *window)
-{
-  GtkAction *action;
-
-  /* setup a new statusbar */
-  window->statusbar = mousepad_statusbar_new ();
-
-  /* bind the GSetting to the GtkAction that controls the statusbar */
-  action = gtk_action_group_get_action (window->action_group, "statusbar");
-  MOUSEPAD_SETTING_BIND (STATUSBAR_VISIBLE, action, "active", G_SETTINGS_BIND_DEFAULT);
-
-  /* pack the statusbar into the window UI */
-  gtk_box_pack_end (GTK_BOX (window->box), window->statusbar, FALSE, FALSE, 0);
-
-  /* overwrite toggle signal */
-  g_signal_connect_swapped (G_OBJECT (window->statusbar), "enable-overwrite",
-                            G_CALLBACK (mousepad_window_action_statusbar_overwrite), window);
-
-  /* populate filetype popup menu signal */
-  g_signal_connect_swapped (G_OBJECT (window->statusbar), "populate-filetype-popup",
-                            G_CALLBACK (mousepad_window_populate_statusbar_popup), window);
-
-  /* update the statusbar items */
-  if (MOUSEPAD_IS_DOCUMENT (window->active))
-    mousepad_document_send_signals (window->active);
-}
-
-
-
 /**
  * Menu Actions
  *
@@ -4982,7 +5093,10 @@ mousepad_window_action_menubar (GtkToggleAction *action,
 
   active = gtk_toggle_action_get_active (action);
 
-  MOUSEPAD_SETTING_SET_BOOLEAN (MENUBAR_VISIBLE, active);
+  if (mousepad_window_get_in_fullscreen (window))
+    MOUSEPAD_SETTING_SET_ENUM (MENUBAR_VISIBLE_FULLSCREEN, (active ? 2 : 1));
+  else
+    MOUSEPAD_SETTING_SET_BOOLEAN (MENUBAR_VISIBLE, active);
 }
 
 
@@ -4997,7 +5111,10 @@ mousepad_window_action_toolbar (GtkToggleAction *action,
 
   active = gtk_toggle_action_get_active (action);
 
-  MOUSEPAD_SETTING_SET_BOOLEAN (TOOLBAR_VISIBLE, active);
+  if (mousepad_window_get_in_fullscreen (window))
+    MOUSEPAD_SETTING_SET_ENUM (TOOLBAR_VISIBLE_FULLSCREEN, (active ? 2 : 1));
+  else
+    MOUSEPAD_SETTING_SET_BOOLEAN (TOOLBAR_VISIBLE, active);
 }
 
 
@@ -5019,34 +5136,30 @@ static void
 mousepad_window_action_statusbar (GtkToggleAction *action,
                                   MousepadWindow  *window)
 {
-  gboolean show_statusbar;
+  gboolean active;
 
   mousepad_return_if_fail (MOUSEPAD_IS_WINDOW (window));
 
-  /* whether we show the statusbar */
-  show_statusbar = gtk_toggle_action_get_active (action);
+  active = gtk_toggle_action_get_active (action);
 
-  /* show/hide the statusbar accordingly */
-  gtk_widget_set_visible (window->statusbar, show_statusbar);
+  if (mousepad_window_get_in_fullscreen (window))
+    MOUSEPAD_SETTING_SET_ENUM (STATUSBAR_VISIBLE_FULLSCREEN, (active ? 2 : 1));
+  else
+    MOUSEPAD_SETTING_SET_BOOLEAN (STATUSBAR_VISIBLE, active);
 }
 
 
 
 static void
-mousepad_window_action_fullscreen (GtkToggleAction *action,
-                                   MousepadWindow  *window)
+mousepad_window_update_main_widgets (MousepadWindow *window)
 {
   gboolean       fullscreen, mb_visible, tb_visible, sb_visible;
   gint           mb_visible_fs, tb_visible_fs, sb_visible_fs;
-  GdkWindow     *gdk_window;
-  GdkWindowState state;
 
   if (! gtk_widget_get_visible (GTK_WIDGET (window)))
     return;
 
-  fullscreen = gtk_toggle_action_get_active (action);
-  gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
-  state = gdk_window_get_state (gdk_window);
+  fullscreen = mousepad_window_get_in_fullscreen (window);
 
   /* get the non-fullscreen settings */
   mb_visible = MOUSEPAD_SETTING_GET_BOOLEAN (MENUBAR_VISIBLE);
@@ -5063,30 +5176,42 @@ mousepad_window_action_fullscreen (GtkToggleAction *action,
   tb_visible_fs = (tb_visible_fs == 0) ? tb_visible : (tb_visible_fs == 2);
   sb_visible_fs = (sb_visible_fs == 0) ? sb_visible : (sb_visible_fs == 2);
 
+  /* update the widgets' visibility */
+  gtk_widget_set_visible (window->menubar, fullscreen ? mb_visible_fs : mb_visible);
+  gtk_widget_set_visible (window->toolbar, fullscreen ? tb_visible_fs : tb_visible);
+  gtk_widget_set_visible (window->statusbar, fullscreen ? sb_visible_fs : sb_visible);
+}
+
+
+
+static void
+mousepad_window_action_fullscreen (GtkToggleAction *action,
+                                   MousepadWindow  *window)
+{
+  gboolean fullscreen;
+
+  if (! gtk_widget_get_visible (GTK_WIDGET (window)))
+    return;
+
+  fullscreen = gtk_toggle_action_get_active (action);
+
   /* entering fullscreen mode */
-  if (fullscreen && !(state & GDK_WINDOW_STATE_FULLSCREEN))
+  if (fullscreen && ! mousepad_window_get_in_fullscreen (window))
     {
       gtk_window_fullscreen (GTK_WINDOW (window));
       gtk_action_set_stock_id (GTK_ACTION (action), GTK_STOCK_LEAVE_FULLSCREEN);
       gtk_action_set_tooltip (GTK_ACTION (action), _("Leave fullscreen mode"));
-
-      /* update main widgets visibility for fullscreen mode */
-      gtk_widget_set_visible (window->menubar, mb_visible_fs);
-      gtk_widget_set_visible (window->toolbar, tb_visible_fs);
-      gtk_widget_set_visible (window->statusbar, sb_visible_fs);
     }
   /* leaving fullscreen mode */
-  else if (state & GDK_WINDOW_STATE_FULLSCREEN)
+  else if (mousepad_window_get_in_fullscreen (window))
     {
       gtk_window_unfullscreen (GTK_WINDOW (window));
       gtk_action_set_stock_id (GTK_ACTION (action), GTK_STOCK_FULLSCREEN);
       gtk_action_set_tooltip (GTK_ACTION (action), _("Make the window fullscreen"));
-
-      /* update main widgets visibility for normal mode */
-      gtk_widget_set_visible (window->menubar, mb_visible);
-      gtk_widget_set_visible (window->toolbar, tb_visible);
-      gtk_widget_set_visible (window->statusbar, sb_visible);
     }
+
+  /* update the widgets based on whether in fullscreen mode or not */
+  mousepad_window_update_main_widgets (window);
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list