Add browser actions and toolbar
authorP. F. Chimento <philip.chimento@gmail.com>
Wed, 22 Jun 2011 21:13:06 +0000 (23:13 +0200)
committerP. F. Chimento <philip.chimento@gmail.com>
Wed, 22 Jun 2011 21:13:06 +0000 (23:13 +0200)
player/browser.c
player/browser.menus
player/chimara.ui

index 0a09630884026c782f4f1e02baedd9a740e70604..f63404d2afc99503e2f9a6b8d2cc9d1d453bd6ac 100644 (file)
@@ -37,7 +37,7 @@
 #include "util.h"
 
 typedef struct _ChimaraBrowserPrivate {
 #include "util.h"
 
 typedef struct _ChimaraBrowserPrivate {
-       int dummy;
+       GtkActionGroup *action_group;
 } ChimaraBrowserPrivate;
 
 #define CHIMARA_BROWSER_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), CHIMARA_TYPE_BROWSER, ChimaraBrowserPrivate))
 } ChimaraBrowserPrivate;
 
 #define CHIMARA_BROWSER_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), CHIMARA_TYPE_BROWSER, ChimaraBrowserPrivate))
@@ -59,6 +59,9 @@ on_browser_delete_event(GtkWidget *browser, GdkEvent *event)
 static void
 chimara_browser_finalize(GObject *self)
 {
 static void
 chimara_browser_finalize(GObject *self)
 {
+       CHIMARA_BROWSER_USE_PRIVATE;
+       g_object_unref(priv->action_group);
+
        /* Chain up */
        G_OBJECT_CLASS(chimara_browser_parent_class)->finalize(self);
 }
        /* Chain up */
        G_OBJECT_CLASS(chimara_browser_parent_class)->finalize(self);
 }
@@ -77,6 +80,7 @@ chimara_browser_class_init(ChimaraBrowserClass *klass)
 static void
 chimara_browser_init(ChimaraBrowser *self)
 {
 static void
 chimara_browser_init(ChimaraBrowser *self)
 {
+       CHIMARA_BROWSER_USE_PRIVATE;
        ChimaraApp *theapp = chimara_app_get();
 
        /* Set own properties */
        ChimaraApp *theapp = chimara_app_get();
 
        /* Set own properties */
@@ -84,16 +88,35 @@ chimara_browser_init(ChimaraBrowser *self)
                "title", _("Chimara"),
                NULL);
 
                "title", _("Chimara"),
                NULL);
 
+       /* Build user interface */
+       char *object_ids[] = {
+               "browser_group",
+               NULL
+       };
+       GtkBuilder *builder = new_builder_with_objects(object_ids);
+
+       priv->action_group = GTK_ACTION_GROUP(load_object(builder, "browser_group"));
+       g_object_ref(priv->action_group);
+
        GtkUIManager *uimanager = new_ui_manager("browser.menus");
 
        GtkUIManager *uimanager = new_ui_manager("browser.menus");
 
-       gtk_ui_manager_insert_action_group(uimanager, chimara_app_get_action_group(theapp), 0);
+       gtk_ui_manager_insert_action_group(uimanager, priv->action_group, 0);
+       gtk_ui_manager_insert_action_group(uimanager, chimara_app_get_action_group(theapp), 1);
        GtkWidget *menubar = gtk_ui_manager_get_widget(uimanager, "/browser_menu");
        GtkWidget *menubar = gtk_ui_manager_get_widget(uimanager, "/browser_menu");
-       gtk_container_add(GTK_CONTAINER(self), menubar);
+       GtkWidget *toolbar = gtk_ui_manager_get_widget(uimanager, "/browser_toolbar");
+       GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
+       gtk_container_add(GTK_CONTAINER(self), vbox);
+       gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
 
        g_signal_connect(self, "delete-event", G_CALLBACK(on_browser_delete_event), NULL);
 
        g_signal_connect(self, "delete-event", G_CALLBACK(on_browser_delete_event), NULL);
+
+       g_object_unref(uimanager);
+       g_object_unref(builder);
 }
 
 /* PUBLIC FUNCTIONS */
 }
 
 /* PUBLIC FUNCTIONS */
+
 GtkWidget *
 chimara_browser_new(void)
 {
 GtkWidget *
 chimara_browser_new(void)
 {
@@ -102,3 +125,29 @@ chimara_browser_new(void)
                NULL));
 }
 
                NULL));
 }
 
+/* GLADE CALLBACKS */
+
+void
+action_add_file(GtkAction *action, ChimaraBrowser *browser)
+{
+}
+
+void
+action_add_watched_folder(GtkAction *action, ChimaraBrowser *browser)
+{
+}
+
+void
+action_remove_file(GtkAction *action, ChimaraBrowser *browser)
+{
+}
+
+void
+action_play(GtkAction *action, ChimaraBrowser *browser)
+{
+}
+
+void
+action_more_info(GtkAction *action, ChimaraBrowser *browser)
+{
+}
index a1151c9f309daf77f57e40809f9aded3796fa20e..fc2ccda867cabcf3f27986bf4012b43816ff036c 100644 (file)
@@ -2,6 +2,9 @@
 <ui>
   <menubar name="browser_menu">
     <menu action="game">
 <ui>
   <menubar name="browser_menu">
     <menu action="game">
+      <menuitem action="play"/>
+      <menuitem action="more_info"/>
+      <separator/>
       <menuitem action="open"/>
          <menuitem action="recent"/>
       <separator/>
       <menuitem action="open"/>
          <menuitem action="recent"/>
       <separator/>
     <menu action="edit">
       <menuitem action="preferences"/>
     </menu>
     <menu action="edit">
       <menuitem action="preferences"/>
     </menu>
+    <menu action="library">
+      <menuitem action="add_file"/>
+      <menuitem action="add_watched_folder"/>
+      <menuitem action="remove_file"/>
+    </menu>
     <menu action="help">
       <menuitem action="about"/>
     </menu>
   </menubar>
     <menu action="help">
       <menuitem action="about"/>
     </menu>
   </menubar>
+  <toolbar name="browser_toolbar">
+    <toolitem action="add_file"/>
+    <toolitem action="remove_file"/>
+    <separator/>
+    <toolitem action="play"/>
+    <toolitem action="more_info"/>
+  </toolbar>
 </ui>
 </ui>
index bb60f49ffb1337abdc4ff20408cb1db032bbef73..36669fd8eefff536f886e019731476eedfc44713 100644 (file)
         <property name="label">_Open...</property>
         <property name="short_label">_Open</property>
         <property name="tooltip">Quit the current game and load a new one</property>
         <property name="label">_Open...</property>
         <property name="short_label">_Open</property>
         <property name="tooltip">Quit the current game and load a new one</property>
-        <property name="stock_id">gtk-media-play</property>
+        <property name="stock_id">gtk-open</property>
         <signal name="activate" handler="on_open_activate" swapped="no"/>
       </object>
       <accelerator key="o" modifiers="GDK_CONTROL_MASK"/>
         <signal name="activate" handler="on_open_activate" swapped="no"/>
       </object>
       <accelerator key="o" modifiers="GDK_CONTROL_MASK"/>
       </object>
     </child>
   </object>
       </object>
     </child>
   </object>
+  <object class="GtkActionGroup" id="browser_group">
+    <child>
+      <object class="GtkAction" id="add_file">
+        <property name="label" translatable="yes">_Add file to library...</property>
+        <property name="short_label" translatable="yes">Add</property>
+        <property name="tooltip" translatable="yes">Add a single game file to your library</property>
+        <property name="stock_id">gtk-add</property>
+        <signal name="activate" handler="action_add_file" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="add_watched_folder">
+        <property name="label" translatable="yes">Add watched _folder to library...</property>
+        <property name="short_label" translatable="yes">Add folder</property>
+        <property name="tooltip" translatable="yes">Add all the game files in a folder to your library, and keep monitoring the folder to see if any game files are added to it in the future</property>
+        <property name="stock_id">gtk-directory</property>
+        <signal name="activate" handler="action_add_watched_folder" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="play">
+        <property name="label" translatable="yes">_Play</property>
+        <property name="short_label" translatable="yes">Play</property>
+        <property name="tooltip" translatable="yes">Play the game</property>
+        <property name="stock_id">gtk-media-play</property>
+        <signal name="activate" handler="action_play" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="more_info">
+        <property name="label" translatable="yes">More _information...</property>
+        <property name="short_label" translatable="yes">Info</property>
+        <property name="tooltip" translatable="yes">View information about this game</property>
+        <property name="stock_id">gtk-info</property>
+        <signal name="activate" handler="action_more_info" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="remove_file">
+        <property name="label" translatable="yes">_Remove file</property>
+        <property name="short_label" translatable="yes">Remove</property>
+        <property name="tooltip" translatable="yes">Remove this game file from your library</property>
+        <property name="stock_id">gtk-remove</property>
+        <signal name="activate" handler="action_remove_file" swapped="no"/>
+      </object>
+    </child>
+    <child>
+      <object class="GtkAction" id="library">
+        <property name="label" translatable="yes">_Library</property>
+      </object>
+    </child>
+  </object>
   <object class="GtkAboutDialog" id="aboutwindow">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
   <object class="GtkAboutDialog" id="aboutwindow">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>