[Xfce4-commits] [apps/xfce4-terminal] 01/01: Hide menubar and toolbar members

noreply at xfce.org noreply at xfce.org
Sat Nov 19 12:21:06 CET 2016


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

f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.

commit 7e7d585af1d55fc03479302029cf1039d9ed974c
Author: Igor <f2404 at yandex.ru>
Date:   Sat Nov 19 13:21:00 2016 +0200

    Hide menubar and toolbar members
---
 terminal/terminal-window-dropdown.c | 14 ++------
 terminal/terminal-window.c          | 71 +++++++++++++++++++++++++++++--------
 terminal/terminal-window.h          |  6 ++--
 3 files changed, 63 insertions(+), 28 deletions(-)

diff --git a/terminal/terminal-window-dropdown.c b/terminal/terminal-window-dropdown.c
index 6fefbc2..056f3b0 100644
--- a/terminal/terminal-window-dropdown.c
+++ b/terminal/terminal-window-dropdown.c
@@ -643,18 +643,8 @@ terminal_window_dropdown_animate_up (gpointer data)
   /* sizes of the widgets that cannot be shrunk */
   gtk_widget_get_preferred_size (window->notebook, &req1, NULL);
   min_size = req1.height;
-  if (window->menubar != NULL
-      && gtk_widget_get_visible (window->menubar))
-    {
-      gtk_widget_get_preferred_size (window->menubar, &req1, NULL);
-      min_size += req1.height;
-    }
-  if (window->toolbar != NULL
-      && gtk_widget_get_visible (window->toolbar))
-    {
-      gtk_widget_get_preferred_size (window->toolbar, &req1, NULL);
-      min_size += req1.height;
-    }
+  min_size += terminal_window_get_menubar_height (window);
+  min_size += terminal_window_get_toolbar_height (window);
 
   if (vbox_h < min_size)
     {
diff --git a/terminal/terminal-window.c b/terminal/terminal-window.c
index bb1d10a..56f2a47 100644
--- a/terminal/terminal-window.c
+++ b/terminal/terminal-window.c
@@ -223,6 +223,9 @@ struct _TerminalWindowPrivate
 {
   GtkUIManager        *ui_manager;
 
+  GtkWidget           *menubar;
+  GtkWidget           *toolbar;
+
   /* for the drop-down to keep open with dialogs */
   guint                n_child_windows;
 
@@ -1591,18 +1594,18 @@ terminal_window_action_show_menubar (GtkToggleAction *action,
 
   if (gtk_toggle_action_get_active (action))
     {
-      if (G_LIKELY (window->menubar == NULL))
+      if (G_LIKELY (window->priv->menubar == NULL))
         {
-          window->menubar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu");
-          gtk_box_pack_start (GTK_BOX (window->vbox), window->menubar, FALSE, FALSE, 0);
-          gtk_box_reorder_child (GTK_BOX (window->vbox), window->menubar, 0);
+          window->priv->menubar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu");
+          gtk_box_pack_start (GTK_BOX (window->vbox), window->priv->menubar, FALSE, FALSE, 0);
+          gtk_box_reorder_child (GTK_BOX (window->vbox), window->priv->menubar, 0);
         }
 
-      gtk_widget_show (window->menubar);
+      gtk_widget_show (window->priv->menubar);
     }
-  else if (window->menubar != NULL)
+  else if (window->priv->menubar != NULL)
     {
-      gtk_widget_hide (window->menubar);
+      gtk_widget_hide (window->priv->menubar);
     }
 
   terminal_window_size_pop (window);
@@ -1621,18 +1624,20 @@ terminal_window_action_show_toolbar (GtkToggleAction *action,
 
   if (gtk_toggle_action_get_active (action))
     {
-      if (window->toolbar == NULL)
+      if (window->priv->toolbar == NULL)
         {
-          window->toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar");
-          gtk_box_pack_start (GTK_BOX (window->vbox), window->toolbar, FALSE, FALSE, 0);
-          gtk_box_reorder_child (GTK_BOX (window->vbox), window->toolbar, window->menubar != NULL ? 1 : 0);
+          window->priv->toolbar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-toolbar");
+          gtk_box_pack_start (GTK_BOX (window->vbox), window->priv->toolbar, FALSE, FALSE, 0);
+          gtk_box_reorder_child (GTK_BOX (window->vbox),
+                                 window->priv->toolbar,
+                                 window->priv->menubar != NULL ? 1 : 0);
         }
 
-      gtk_widget_show (window->toolbar);
+      gtk_widget_show (window->priv->toolbar);
     }
-  else if (window->toolbar != NULL)
+  else if (window->priv->toolbar != NULL)
     {
-      gtk_widget_hide (window->toolbar);
+      gtk_widget_hide (window->priv->toolbar);
     }
 
   terminal_window_size_pop (window);
@@ -2504,6 +2509,44 @@ terminal_window_set_scrollbar_visibility (TerminalWindow     *window,
 
 
 /**
+ * terminal_window_get_menubar_height:
+ * @window  : A #TerminalWindow.
+ **/
+gint
+terminal_window_get_menubar_height (TerminalWindow *window)
+{
+  GtkRequisition req;
+
+  req.height = 0;
+
+  if (window->priv->menubar != NULL && gtk_widget_get_visible (window->priv->menubar))
+    gtk_widget_get_preferred_size (window->priv->menubar, &req, NULL);
+
+  return req.height;
+}
+
+
+
+/**
+ * terminal_window_get_toolbar_height:
+ * @window  : A #TerminalWindow.
+ **/
+gint
+terminal_window_get_toolbar_height (TerminalWindow *window)
+{
+  GtkRequisition req;
+
+  req.height = 0;
+
+  if (window->priv->toolbar != NULL && gtk_widget_get_visible (window->priv->toolbar))
+    gtk_widget_get_preferred_size (window->priv->toolbar, &req, NULL);
+
+  return req.height;
+}
+
+
+
+/**
  * terminal_window_rebuild_tabs_menu:
  * @window  : A #TerminalWindow.
  **/
diff --git a/terminal/terminal-window.h b/terminal/terminal-window.h
index e1416cb..c1d14c6 100644
--- a/terminal/terminal-window.h
+++ b/terminal/terminal-window.h
@@ -50,8 +50,6 @@ typedef struct
   guint                  drop_down : 1;
 
   GtkWidget             *vbox;
-  GtkWidget             *menubar;
-  GtkWidget             *toolbar;
   GtkWidget             *notebook;
 
   gchar                 *font;
@@ -93,6 +91,10 @@ TerminalVisibility terminal_window_get_scrollbar_visibility (TerminalWindow
 void               terminal_window_set_scrollbar_visibility (TerminalWindow     *window,
                                                              TerminalVisibility  scrollbar);
 
+gint               terminal_window_get_menubar_height       (TerminalWindow     *window);
+
+gint               terminal_window_get_toolbar_height       (TerminalWindow     *window);
+
 void               terminal_window_rebuild_tabs_menu        (TerminalWindow     *window);
 
 G_END_DECLS

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


More information about the Xfce4-commits mailing list