[tracker] tracker-preferences: Allow configuring status icon visibility.



commit a2d0d64cdb80f3141dc549f5f2b4e5af8f7c3663
Author: Carlos Garnacho <carlos lanedo com>
Date:   Thu Oct 15 17:04:15 2009 +0200

    tracker-preferences: Allow configuring status icon visibility.

 src/tracker-preferences/Makefile.am                |   13 +++-
 src/tracker-preferences/tracker-preferences.ui     |   75 +++++++++++++++++++-
 src/tracker-preferences/tracker-preferences.vala   |   32 ++++++++
 .../tracker-status-icon-config.vapi                |   29 ++++++++
 4 files changed, 145 insertions(+), 4 deletions(-)
---
diff --git a/src/tracker-preferences/Makefile.am b/src/tracker-preferences/Makefile.am
index 558aba3..ac727ea 100644
--- a/src/tracker-preferences/Makefile.am
+++ b/src/tracker-preferences/Makefile.am
@@ -25,7 +25,9 @@ BUILT_SOURCES = tracker-preferences.vala.stamp
 
 config_class_sources = \
 	$(top_srcdir)/src/tracker-miner-fs/tracker-config.h		\
-	$(top_srcdir)/src/tracker-miner-fs/tracker-config.c
+	$(top_srcdir)/src/tracker-miner-fs/tracker-config.c		\
+	$(top_srcdir)/src/tracker-status-icon/tracker-icon-config.h	\
+	$(top_srcdir)/src/tracker-status-icon/tracker-icon-config.c
 
 tracker_preferences_VALASOURCES = tracker-preferences.vala
 
@@ -44,11 +46,16 @@ MAINTAINERCLEANFILES =							\
 	$(tracker_preferences_VALASOURCES:.vala=.c)			\
 	$(NULL)
 
-EXTRA_DIST = $(pkgdata_DATA) config.vapi tracker-config.vapi tracker-preferences.vala.stamp \
+EXTRA_DIST = \
+	$(pkgdata_DATA) 						\
+	config.vapi							\
+	tracker-config.vapi						\
+	tracker-status-icon-config.vala					\
+	tracker-preferences.vala.stamp 					\
 	$(tracker_preferences_VALASOURCES)
 
 tracker-preferences.vala.stamp: $(tracker_preferences_VALASOURCES)
-	$(AM_V_GEN)$(VALAC) --pkg gtk+-2.0 --pkg gmodule-2.0 -C $(VALAFLAGS) tracker-config.vapi config.vapi $^
+	$(AM_V_GEN)$(VALAC) --pkg gtk+-2.0 --pkg gmodule-2.0 -C $(VALAFLAGS) tracker-config.vapi tracker-status-icon-config.vapi config.vapi $^
 	$(AM_V_GEN)touch $@
 
 CLEANFILES = $(desktop_DATA)
diff --git a/src/tracker-preferences/tracker-preferences.ui b/src/tracker-preferences/tracker-preferences.ui
index d5bde80..3af1d3a 100644
--- a/src/tracker-preferences/tracker-preferences.ui
+++ b/src/tracker-preferences/tracker-preferences.ui
@@ -405,6 +405,79 @@ Checking this means that when Tracker is run for the first time, it will not pau
                     <property name="position">1</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkFrame" id="frame1">
+                    <property name="visible">True</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment2">
+                        <property name="visible">True</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkVBox" id="vbox9">
+                            <property name="visible">True</property>
+                            <property name="orientation">vertical</property>
+                            <child>
+                              <object class="GtkRadioButton" id="radiobutton_display_never">
+                                <property name="label" translatable="yes">Never display icon</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                                <signal name="toggled" handler="radiobutton_visibility_toggled_cb"/>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="radiobutton_display_active">
+                                <property name="label" translatable="yes">Only display when indexing content</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">radiobutton_display_never</property>
+                                <signal name="toggled" handler="radiobutton_visibility_toggled_cb"/>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkRadioButton" id="radiobutton_display_always">
+                                <property name="label" translatable="yes">Always display icon</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="active">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="group">radiobutton_display_never</property>
+                                <signal name="toggled" handler="radiobutton_visibility_toggled_cb"/>
+                              </object>
+                              <packing>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label8">
+                        <property name="visible">True</property>
+                        <property name="xpad">3</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Notification area&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
               </object>
             </child>
             <child type="tab">
@@ -1171,8 +1244,8 @@ Most commonly this is used to ignore directories like *~, *.o, *.la, etc</proper
   </object>
   <object class="GtkSizeGroup" id="sizegroup_indexing">
     <widgets>
-      <widget name="label_throttle"/>
       <widget name="label_disk_space_limit"/>
+      <widget name="label_throttle"/>
     </widgets>
   </object>
 </interface>
diff --git a/src/tracker-preferences/tracker-preferences.vala b/src/tracker-preferences/tracker-preferences.vala
index 487f4e2..0a96af4 100644
--- a/src/tracker-preferences/tracker-preferences.vala
+++ b/src/tracker-preferences/tracker-preferences.vala
@@ -25,6 +25,7 @@ using GLib;
 using Tracker;
 
 public static Config config = null;
+public static IconConfig icon_config = null;
 
 public const string HOME_STRING = "$HOME";
 
@@ -49,6 +50,29 @@ public static TreeView treeview_ignored_directories;
 public static TreeView treeview_ignored_directories_with_content;
 public static TreeView treeview_ignored_files;
 public static ToggleButton togglebutton_home;
+public static RadioButton radiobutton_display_never;
+public static RadioButton radiobutton_display_active;
+public static RadioButton radiobutton_display_always;
+
+public static void radiobutton_visibility_toggled_cb (RadioButton source) {
+	if (radiobutton_display_never.active) {
+		icon_config.visibility = 0;
+	} else if (radiobutton_display_active.active) {
+		icon_config.visibility = 1;
+	} else {
+		icon_config.visibility = 2;
+	}
+}
+
+public static void initialize_visibility_radiobutton () {
+	if (icon_config.visibility == 0) {
+		radiobutton_display_never.active = true;
+	} else if (icon_config.visibility == 1) {
+		radiobutton_display_active.active = true;
+	} else {
+		radiobutton_display_always.active = true;
+	}
+}
 
 public static void spinbutton_delay_value_changed_cb (SpinButton source) {
 	config.initial_sleep = source.get_value_as_int ();
@@ -249,6 +273,7 @@ public static void button_apply_clicked_cb (Button source) {
 	config.index_recursive_directories = model_to_slist (liststore_index_recursively);
 
 	config.save ();
+	icon_config.save ();
 
 	/* TODO: restart the Application and Files miner (no idea how to cleanly do this atm) */
 }
@@ -307,6 +332,8 @@ static int main (string[] args) {
 
 	try {
 		config = new Config.with_domain ("tracker-miner-fs");
+		icon_config = new IconConfig.with_domain ("tracker-status-icon");
+
 		var builder = new Builder ();
 		builder.add_from_file (TRACKER_DATADIR + Path.DIR_SEPARATOR_S + "tracker-preferences.ui");
 
@@ -333,6 +360,11 @@ static int main (string[] args) {
 		hscale_throttle.set_value ((double) config.throttle);
 		togglebutton_home = builder.get_object ("togglebutton_home") as ToggleButton;
 
+		radiobutton_display_never = builder.get_object ("radiobutton_display_never") as RadioButton;
+		radiobutton_display_active = builder.get_object ("radiobutton_display_active") as RadioButton;
+		radiobutton_display_always = builder.get_object ("radiobutton_display_always") as RadioButton;
+		initialize_visibility_radiobutton ();
+
 		treeview_index_recursively = builder.get_object ("treeview_index_recursively") as TreeView;
 		treeview_index_single = builder.get_object ("treeview_index_single") as TreeView;
 		treeview_ignored_directories = builder.get_object ("treeview_ignored_directories") as TreeView;
diff --git a/src/tracker-preferences/tracker-status-icon-config.vapi b/src/tracker-preferences/tracker-status-icon-config.vapi
new file mode 100644
index 0000000..d2a0ae7
--- /dev/null
+++ b/src/tracker-preferences/tracker-status-icon-config.vapi
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2008-2009, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+namespace Tracker {
+	[CCode (cheader_filename = "tracker-status-icon/tracker-icon-config.h")]
+	public class IconConfig : GLib.Object {
+		public IconConfig.with_domain (string domain);
+
+		public int visibility { get; set; }
+		public bool save ();
+	}
+}
+



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