[tracker/needle-info-bar: 2/7] tracker-needle: Add GtkInfoBar and API to control its content



commit 4a942618461dd7b5dcd1fb33ebe718da19d3306d
Author: Carlos Garnacho <carlos lanedo com>
Date:   Thu Oct 6 13:25:16 2011 +0200

    tracker-needle: Add GtkInfoBar and API to control its content

 src/tracker-needle/tracker-needle.ui   |   35 +++++++++++++++++++++++++++++++-
 src/tracker-needle/tracker-needle.vala |   19 +++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletions(-)
---
diff --git a/src/tracker-needle/tracker-needle.ui b/src/tracker-needle/tracker-needle.ui
index bfce7d5..cd10afd 100644
--- a/src/tracker-needle/tracker-needle.ui
+++ b/src/tracker-needle/tracker-needle.ui
@@ -367,6 +367,39 @@
           </packing>
         </child>
         <child>
+          <object class="GtkInfoBar" id="info_bar">
+            <property name="visible">False</property>
+	    <child internal-child="content_area">
+	      <object class="GtkBox" id="info_bar_content_area">
+		<child>
+		  <object class="GtkLabel" id="info_bar_label">
+		    <property name="visible">True</property>
+		    <property name="label" translatable="yes"></property>
+		    <property name="wrap">True</property>
+		  </object>
+		</child>
+	      </object>
+	    </child>
+	    <child internal-child="action_area">
+	      <object class="GtkBox" id="info_bar_action_area">
+		<child>
+		  <object class="GtkButton" id="info_bar_button">
+		    <property name="label">gtk-close</property>
+		    <property name="visible">True</property>
+		    <property name="use_underline">True</property>
+		    <property name="use_stock">True</property>
+		  </object>
+		</child>
+	      </object>
+	    </child>
+	  </object>
+	  <packing>
+	    <property name="expand">False</property>
+	    <property name="fill">True</property>
+	    <property name="position">1</property>
+	  </packing>
+        </child>
+        <child>
           <object class="GtkHBox" id="hbox_view">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -378,7 +411,7 @@
           <packing>
             <property name="expand">True</property>
             <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="position">2</property>
           </packing>
         </child>
       </object>
diff --git a/src/tracker-needle/tracker-needle.vala b/src/tracker-needle/tracker-needle.vala
index 9045b59..8cfbd22 100644
--- a/src/tracker-needle/tracker-needle.vala
+++ b/src/tracker-needle/tracker-needle.vala
@@ -48,6 +48,8 @@ public class Tracker.Needle {
 	private Tracker.View sw_categories;
 	private Tracker.View sw_filelist;
 	private Tracker.View sw_icons;
+	private InfoBar info_bar;
+	private Label info_bar_label;
 	private TrackerTagsFilter tags_filter;
 	private uint last_search_id = 0;
 	private int size_small = 0;
@@ -221,6 +223,7 @@ public class Tracker.Needle {
 
 	private void setup_ui () {
 		var builder = new Gtk.Builder ();
+		Button info_bar_button;
 		Toolbar toolbar;
 
 		try {
@@ -253,6 +256,11 @@ public class Tracker.Needle {
 		toolbar = builder.get_object ("toolbar_main") as Toolbar;
 		toolbar.get_style_context().add_class (STYLE_CLASS_PRIMARY_TOOLBAR);
 
+		info_bar = builder.get_object("info_bar") as InfoBar;
+		info_bar_label = builder.get_object ("info_bar_label") as Label;
+		info_bar_button = builder.get_object("info_bar_button") as Button;
+		info_bar_button.clicked.connect (info_bar_closed);
+
 		view_filelist = builder.get_object ("toolbutton_view_filelist") as ToggleToolButton;
 		view_filelist.toggled.connect (view_toggled);
 
@@ -594,6 +602,17 @@ public class Tracker.Needle {
 		Tracker.Stats s = new Tracker.Stats ();
 		s.show ();
 	}
+
+	public void show_info_message (string          message,
+	                               Gtk.MessageType type) {
+		info_bar.set_message_type (type);
+		info_bar_label.set_label (message);
+		info_bar.show ();
+	}
+
+	private void info_bar_closed () {
+		info_bar.hide ();
+	}
 }
 
 static bool print_version = false;



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