[gnome-commander] GnomeCmdNotebook: an option for controlling tabbar visibility



commit 0e3c04159a9d4f6a110051296a9d1894d94d5d29
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sun Feb 6 00:47:53 2011 +0100

    GnomeCmdNotebook: an option for controlling tabbar visibility

 src/gnome-cmd-notebook.cc |   19 +++++++++++++++++++
 src/gnome-cmd-notebook.h  |   18 ++++++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)
---
diff --git a/src/gnome-cmd-notebook.cc b/src/gnome-cmd-notebook.cc
index 01d5364..2a0fe9c 100644
--- a/src/gnome-cmd-notebook.cc
+++ b/src/gnome-cmd-notebook.cc
@@ -81,6 +81,25 @@ static void gnome_cmd_notebook_class_init (GnomeCmdNotebookClass *klass)
 }
 
 
+GnomeCmdNotebook::GnomeCmdNotebook(TabBarVisibility visibility)
+{
+    tabs_visibility = visibility;
+
+    if (visibility==SHOW_TABS)
+        g_object_set (this, "show-tabs", TRUE, NULL);
+}
+
+
+void GnomeCmdNotebook::show_tabs(TabBarVisibility _show_tabs)
+{
+    if (_show_tabs!=tabs_visibility)
+    {
+        tabs_visibility = _show_tabs;
+        gtk_notebook_set_show_tabs (*this, _show_tabs==SHOW_TABS || _show_tabs!=HIDE_TABS && size()>1);
+    }
+}
+
+
 int GnomeCmdNotebook::find_tab_num_at_pos(gint screen_x, gint screen_y) const
 {
     if (!GTK_NOTEBOOK (this)->first_tab)
diff --git a/src/gnome-cmd-notebook.h b/src/gnome-cmd-notebook.h
index 296fad1..1f805a7 100644
--- a/src/gnome-cmd-notebook.h
+++ b/src/gnome-cmd-notebook.h
@@ -49,6 +49,17 @@ struct GnomeCmdNotebook
     operator GtkContainer * () const    {  return GTK_CONTAINER (this);  }
     operator GtkNotebook * () const     {  return GTK_NOTEBOOK (this);   }
 
+    enum TabBarVisibility
+    {
+        HIDE_TABS,
+        HIDE_TABS_IF_ONE,
+        SHOW_TABS
+    };
+
+    TabBarVisibility tabs_visibility;
+
+    GnomeCmdNotebook(TabBarVisibility visibility=HIDE_TABS_IF_ONE);
+
     int size() const                    {  return gtk_notebook_get_n_pages (*this);       }
     bool empty() const                  {  return size()==0;                              }
 
@@ -78,12 +89,15 @@ struct GnomeCmdNotebook
     void prev_page();
     void next_page();
 
+    void show_tabs(TabBarVisibility show);
+    void show_tabs(gboolean show)                                           {  show_tabs(show ? SHOW_TABS : HIDE_TABS);             }
+
     int find_tab_num_at_pos(gint screen_x, gint screen_y) const;
 };
 
 inline gint GnomeCmdNotebook::insert_page(GtkWidget *page, gint n, GtkWidget *label)
 {
-    if (size()==1)
+    if (tabs_visibility==HIDE_TABS_IF_ONE && size()==1)
         gtk_notebook_set_show_tabs (*this, TRUE);
     return gtk_notebook_insert_page (*this, page, label, n);
 }
@@ -91,7 +105,7 @@ inline gint GnomeCmdNotebook::insert_page(GtkWidget *page, gint n, GtkWidget *la
 inline void GnomeCmdNotebook::remove_page(gint n)
 {
     gtk_notebook_remove_page (*this, n);
-    if (size()<2)
+    if (tabs_visibility==HIDE_TABS_IF_ONE && size()<2)
         gtk_notebook_set_show_tabs (*this, FALSE);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]