Re-added toolbar with menu item to show or hide it
authorPhilip Chimento <philip.chimento@gmail.com>
Fri, 4 Feb 2011 17:29:25 +0000 (18:29 +0100)
committerPhilip Chimento <philip.chimento@gmail.com>
Sat, 5 Feb 2011 01:57:31 +0000 (02:57 +0100)
player/callbacks.c
player/chimara.menus
player/chimara.ui
player/main.c

index 38629fe875da262df3d56369001eb85b2571103b..86e85b62a9e14c384134bee146c81f280d818276 100644 (file)
@@ -184,6 +184,17 @@ on_preferences_activate(GtkAction *action, ChimaraGlk *glk)
        gtk_window_present(GTK_WINDOW(prefswindow));
 }
 
+void
+on_toolbar_toggled(GtkToggleAction *action, ChimaraGlk *glk)
+{
+       extern GtkWidget *toolbar;
+       
+       if(gtk_toggle_action_get_active(action))
+               gtk_widget_show(toolbar);
+       else
+               gtk_widget_hide(toolbar);
+}
+
 void
 on_undo_activate(GtkAction *action, ChimaraGlk *glk)
 {
index 927bc825084633690d9fa150732c241216f71339..7f28fd51ff3d906d19c3fe605f0561d16bec49a2 100644 (file)
@@ -14,6 +14,9 @@
       <separator/>
       <menuitem action="preferences"/>
     </menu>
+    <menu action="view">
+      <menuitem action="toolbar"/>
+    </menu>
     <menu action="command">
       <menuitem action="undo"/>
       <menuitem action="save"/>
index 8bb7fc6941f6429d277e0b547556a8587cba5db0..d9d219c440463c9b15241ce4770a1a1369358b76 100644 (file)
@@ -3,6 +3,18 @@
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy toplevel-contextual -->
   <object class="GtkActionGroup" id="actiongroup">
+    <child>
+      <object class="GtkToggleAction" id="toolbar">
+        <property name="label" translatable="yes">_Toolbar</property>
+        <property name="tooltip" translatable="yes">Show a toolbar at the top of the window</property>
+        <signal name="toggled" handler="on_toolbar_toggled" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="view">
+        <property name="label" translatable="yes">_View</property>
+      </object>
+    </child>
     <child>
       <object class="GtkAction" id="about">
         <property name="label">_About...</property>
index 9722235c680309e32c785dffafeae4705c9d462d..85dba4e43e33d03e633abc5a918f8c961cff94c5 100644 (file)
@@ -55,6 +55,7 @@ static GtkWidget *glk = NULL;
 GtkBuilder *builder = NULL;
 GtkWidget *aboutwindow = NULL;
 GtkWidget *prefswindow = NULL;
+GtkWidget *toolbar = NULL;
 
 GObject *
 load_object(const gchar *name)
@@ -110,6 +111,7 @@ create_window(void)
        aboutwindow = GTK_WIDGET(load_object("aboutwindow"));
        prefswindow = GTK_WIDGET(load_object("prefswindow"));
        GtkActionGroup *actiongroup = GTK_ACTION_GROUP(load_object("actiongroup"));
+       GtkToggleAction *toolbar_action = GTK_TOGGLE_ACTION(load_object("toolbar"));
 
        const gchar **ptr;
        GtkRecentFilter *filter = gtk_recent_filter_new();
@@ -188,11 +190,16 @@ create_window(void)
 
        gtk_ui_manager_insert_action_group(uimanager, actiongroup, 0);
        GtkWidget *menubar = gtk_ui_manager_get_widget(uimanager, "/menubar");
-       //GtkWidget *toolbar = gtk_ui_manager_get_widget(uimanager, "/toolbar");
+       toolbar = gtk_ui_manager_get_widget(uimanager, "/toolbar");
+       gtk_widget_set_no_show_all(toolbar, TRUE);
+       if(gtk_toggle_action_get_active(toolbar_action))
+               gtk_widget_show(toolbar);
+       else
+               gtk_widget_hide(toolbar);
 
        gtk_box_pack_end(vbox, glk, TRUE, TRUE, 0);
        gtk_box_pack_start(vbox, menubar, FALSE, FALSE, 0);
-       //gtk_box_pack_start(vbox, toolbar, FALSE, FALSE, 0);
+       gtk_box_pack_start(vbox, toolbar, FALSE, FALSE, 0);
        
        gtk_builder_connect_signals(builder, glk);
        g_signal_connect(glk, "notify::program-name", G_CALLBACK(change_window_title), window);