[baobab/wip/vala: 21/45] wire up the toolbar buttons



commit d1cdfde8315ac69c4004a9e34a543d3ce8f6e6e9
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Jan 6 00:50:27 2012 -0500

    wire up the toolbar buttons
    
    This requires the latest git version of vala to build.
    
    In order to actually work, it also requires a patched gtk+ (with
    the patch in bug #667394).

 data/baobab-main-window.ui |   20 ++++++++++++--------
 src/baobab-window.vala     |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 8 deletions(-)
---
diff --git a/data/baobab-main-window.ui b/data/baobab-main-window.ui
index fd467e6..e9a9d24 100644
--- a/data/baobab-main-window.ui
+++ b/data/baobab-main-window.ui
@@ -13,7 +13,7 @@
           <class name="primary-toolbar"/>
         </style>
         <child>
-          <object class="GtkToolButton" id="tbscanhome1">
+          <object class="GtkToolButton" id="scan-home-button">
             <property name="use_action_appearance">False</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -25,6 +25,7 @@
             <property name="label" translatable="yes">Scan Home</property>
             <property name="use_underline">True</property>
             <property name="stock_id">gtk-home</property>
+            <property name="action_name">win.scan-home</property>
             <child internal-child="accessible">
               <object class="AtkObject" id="tbscanhome1-atkobject">
                 <property name="AtkObject::accessible-name" translatable="yes">Scan home folder</property>
@@ -37,7 +38,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkToolButton" id="tbscanall1">
+          <object class="GtkToolButton" id="scan-filesystem-button">
             <property name="use_action_appearance">False</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -48,6 +49,7 @@
             <property name="label" translatable="yes">Scan Filesystem</property>
             <property name="use_underline">True</property>
             <property name="stock_id">gtk-harddisk</property>
+            <property name="action_name">win.scan-filesystem</property>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -55,7 +57,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkToolButton" id="tbscandir1">
+          <object class="GtkToolButton" id="scan-folder-button">
             <property name="use_action_appearance">False</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -66,6 +68,7 @@
             <property name="label" translatable="yes">Scan Folder</property>
             <property name="use_underline">True</property>
             <property name="stock_id">gtk-directory</property>
+            <property name="action_name">win.scan-folder</property>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -73,7 +76,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkToolButton" id="tb_scan_remote1">
+          <object class="GtkToolButton" id="scan-remote-button">
             <property name="use_action_appearance">False</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -84,6 +87,7 @@
             <property name="label" translatable="yes">Scan Remote Folder</property>
             <property name="use_underline">True</property>
             <property name="stock_id">gtk-network</property>
+            <property name="action_name">win.scan-remote</property>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -100,16 +104,16 @@
           </packing>
         </child>
         <child>
-          <object class="GtkToolButton" id="tbstop1">
+          <object class="GtkToolButton" id="stop-button">
             <property name="use_action_appearance">False</property>
             <property name="visible">True</property>
-            <property name="sensitive">False</property>
             <property name="can_focus">False</property>
             <property name="has_tooltip">True</property>
             <property name="tooltip_markup" translatable="yes">Stop scanning</property>
             <property name="tooltip_text" translatable="yes">Stop scanning</property>
             <property name="use_action_appearance">False</property>
             <property name="stock_id">gtk-stop</property>
+            <property name="action_name">win.stop</property>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -117,16 +121,16 @@
           </packing>
         </child>
         <child>
-          <object class="GtkToolButton" id="tbrescan1">
+          <object class="GtkToolButton" id="rescan-button">
             <property name="use_action_appearance">False</property>
             <property name="visible">True</property>
-            <property name="sensitive">False</property>
             <property name="can_focus">False</property>
             <property name="has_tooltip">True</property>
             <property name="tooltip_markup" translatable="yes">Refresh</property>
             <property name="tooltip_text" translatable="yes">Refresh</property>
             <property name="use_action_appearance">False</property>
             <property name="stock_id">gtk-refresh</property>
+            <property name="action_name">win.refresh</property>
           </object>
           <packing>
             <property name="expand">False</property>
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 215dc04..0404279 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -7,6 +7,8 @@ namespace Baobab {
 		public Window (Application app) {
 			Object (application: app);
 
+			add_action_entries (action_entries, this);
+
 			// Build ourselves.
 			var builder = new Gtk.Builder ();
 			try {
@@ -39,6 +41,39 @@ namespace Baobab {
 			show ();
 		}
 
+		void scan_home_activated () {
+			print ("sh\n");
+		}
+
+		void scan_filesystem_activated () {
+			print ("sfs\n");
+		}
+
+		void scan_folder_activated () {
+			print ("sf\n");
+		}
+
+		void scan_remote_activated () {
+			print ("sr\n");
+		}
+
+		void stop_activated () {
+			print ("s\n");
+		}
+
+		void refresh_activated () {
+			print ("r\n");
+		}
+
+		private const GLib.ActionEntry[] action_entries = {
+			{ "scan-home",       scan_home_activated       },
+			{ "scan-filesystem", scan_filesystem_activated },
+			{ "scan-folder",     scan_folder_activated     },
+			{ "scan-remote",     scan_remote_activated     },
+			{ "stop",            stop_activated            },
+			{ "refresh",         refresh_activated         }
+		};
+
 		void message (string primary_msg, string secondary_msg, Gtk.MessageType type) {
 			var dialog = new Gtk.MessageDialog (this, Gtk.DialogFlags.DESTROY_WITH_PARENT, type,
 			                                    Gtk.ButtonsType.OK, "%s", primary_msg);



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