[tracker/miner-web: 76/76] tracker-preferences: WIP on miner integration



commit 0ad9806f81bd1766c068f70878023bbd4e6446ba
Author: Adrien Bustany <abustany gnome org>
Date:   Mon Mar 1 09:00:11 2010 -0300

    tracker-preferences: WIP on miner integration

 src/tracker-preferences/Makefile.am              |    6 +-
 src/tracker-preferences/tracker-preferences.ui   |  293 +++++++++++++++++++++-
 src/tracker-preferences/tracker-preferences.vala |  121 +++++++++
 3 files changed, 411 insertions(+), 9 deletions(-)
---
diff --git a/src/tracker-preferences/Makefile.am b/src/tracker-preferences/Makefile.am
index c5b1e08..69dac4d 100644
--- a/src/tracker-preferences/Makefile.am
+++ b/src/tracker-preferences/Makefile.am
@@ -30,7 +30,9 @@ config_class_sources = \
 	$(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
+tracker_preferences_VALASOURCES = \
+	tracker-preferences.vala \
+	miner-manager.vala
 
 tracker_preferences_SOURCES = 						\
 	$(config_class_sources)						\
@@ -56,7 +58,7 @@ EXTRA_DIST = 								\
 	$(tracker_preferences_VALASOURCES)
 
 tracker-preferences.vala.stamp: $(tracker_preferences_VALASOURCES) tracker-config.vapi tracker-status-icon-config.vapi config.vapi
-	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) --pkg gtk+-2.0 --pkg gmodule-2.0 -C $(VALAFLAGS) $^
+	$(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) --pkg gtk+-2.0 --pkg gmodule-2.0 --pkg dbus-glib-1 --vapidir $(top_srcdir)/src/libtracker-miner --pkg tracker-miner-$(TRACKER_API_VERSION) -C $(VALAFLAGS) $^
 	$(AM_V_GEN)touch $@
 
 CLEANFILES = $(desktop_DATA)
diff --git a/src/tracker-preferences/tracker-preferences.ui b/src/tracker-preferences/tracker-preferences.ui
index 2eb5fd6..a1f2bf5 100644
--- a/src/tracker-preferences/tracker-preferences.ui
+++ b/src/tracker-preferences/tracker-preferences.ui
@@ -32,6 +32,16 @@
       <column type="gchararray"/>
     </columns>
   </object>
+  <object class="GtkListStore" id="liststore_miners">
+    <columns>
+      <!-- column-name icon -->
+      <column type="gchararray"/>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+      <!-- column-name object -->
+      <column type="gpointer"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="tracker-preferences">
     <property name="width_request">500</property>
     <property name="border_width">5</property>
@@ -253,7 +263,7 @@
                     <property name="label_xalign">0</property>
                     <property name="shadow_type">none</property>
                     <child>
-                      <object class="GtkAlignment" id="alignment3">
+                      <object class="GtkAlignment" id="alignment4">
                         <property name="visible">True</property>
                         <property name="top_padding">6</property>
                         <property name="left_padding">12</property>
@@ -296,7 +306,7 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkAlignment" id="alignment4">
+                              <object class="GtkAlignment" id="alignment7">
                                 <property name="visible">True</property>
                                 <property name="left_padding">12</property>
                                 <child>
@@ -376,7 +386,7 @@
                     <property name="label_xalign">0</property>
                     <property name="shadow_type">none</property>
                     <child>
-                      <object class="GtkAlignment" id="alignment7">
+                      <object class="GtkAlignment" id="alignment8">
                         <property name="visible">True</property>
                         <property name="top_padding">6</property>
                         <property name="left_padding">12</property>
@@ -1218,6 +1228,148 @@ Most commonly this is used to ignore directories like *~, *.o, *.la, etc</proper
                 <property name="tab_fill">False</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkFrame" id="frame2">
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment9">
+                    <property name="visible">True</property>
+                    <property name="top_padding">6</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkVBox" id="vbox12">
+                        <property name="visible">True</property>
+                        <property name="orientation">vertical</property>
+                        <child>
+                          <object class="GtkComboBox" id="combo_miners">
+                            <property name="visible">True</property>
+                            <property name="model">liststore_miners</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkHBox" id="hbox7">
+                            <property name="visible">True</property>
+                            <child>
+                              <object class="GtkImage" id="image_miner_status">
+                                <property name="visible">True</property>
+                                <property name="stock">gtk-dialog-question</property>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="padding">6</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label_miner_status">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">miner status text</property>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="padding">6</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkFrame" id="frame3">
+                            <property name="visible">True</property>
+                            <property name="label_xalign">0</property>
+                            <property name="shadow_type">none</property>
+                            <child>
+                              <object class="GtkAlignment" id="alignment10">
+                                <property name="visible">True</property>
+                                <property name="left_padding">12</property>
+                                <child>
+                                  <object class="GtkHBox" id="hbox8">
+                                    <property name="visible">True</property>
+                                    <child>
+                                      <object class="GtkLabel" id="label16">
+                                        <property name="visible">True</property>
+                                        <property name="xalign">0</property>
+                                        <property name="label">miner association text</property>
+                                      </object>
+                                      <packing>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkHButtonBox" id="hbuttonbox1">
+                                        <property name="visible">True</property>
+                                        <child>
+                                          <object class="GtkButton" id="button_miner_associate">
+                                            <property name="label">Associate</property>
+                                            <property name="visible">True</property>
+                                            <property name="sensitive">False</property>
+                                            <property name="can_focus">True</property>
+                                            <property name="receives_default">True</property>
+                                          </object>
+                                          <packing>
+                                            <property name="expand">False</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
+                            </child>
+                            <child type="label">
+                              <object class="GtkLabel" id="label15">
+                                <property name="visible">True</property>
+                                <property name="label" translatable="yes">&lt;b&gt;Association&lt;/b&gt;</property>
+                                <property name="use_markup">True</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label14">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Miner&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="position">4</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label13">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Miners</property>
+              </object>
+              <packing>
+                <property name="position">4</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="position">1</property>
@@ -1276,10 +1428,6 @@ Most commonly this is used to ignore directories like *~, *.o, *.la, etc</proper
     <property name="step_increment">1</property>
     <property name="page_increment">2</property>
   </object>
-  <object class="GtkImage" id="image1">
-    <property name="visible">True</property>
-    <property name="stock">gtk-missing-image</property>
-  </object>
   <object class="GtkAdjustment" id="adjustment_disk_space_limit">
     <property name="lower">-1</property>
     <property name="upper">100</property>
@@ -1291,6 +1439,137 @@ Most commonly this is used to ignore directories like *~, *.o, *.la, etc</proper
     <property name="upper">1000</property>
     <property name="step_increment">1</property>
   </object>
+  <object class="GtkDialog" id="dialog_miner_userpass">
+    <property name="border_width">5</property>
+    <property name="type_hint">normal</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox2">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkTable" id="table1">
+            <property name="visible">True</property>
+            <property name="n_rows">3</property>
+            <property name="n_columns">2</property>
+            <property name="column_spacing">6</property>
+            <property name="row_spacing">6</property>
+            <child>
+              <object class="GtkLabel" id="label_miner_userpass_info">
+                <property name="visible">True</property>
+                <property name="ypad">6</property>
+                <property name="label" translatable="yes">Please input the username and password of the service your are connecting to</property>
+              </object>
+              <packing>
+                <property name="right_attach">2</property>
+                <property name="y_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label_miner_userpass_username">
+                <property name="visible">True</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">Username </property>
+                <property name="justify">right</property>
+              </object>
+              <packing>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+                <property name="x_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="label_miner_userpass_password">
+                <property name="visible">True</property>
+                <property name="xalign">1</property>
+                <property name="label" translatable="yes">Password</property>
+                <property name="justify">right</property>
+              </object>
+              <packing>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+                <property name="x_options">GTK_FILL</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="entry_miner_username">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="invisible_char">&#x25CF;</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkEntry" id="entry_miner_password">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="visibility">False</property>
+                <property name="invisible_char">&#x25CF;</property>
+              </object>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+                <property name="top_attach">2</property>
+                <property name="bottom_attach">3</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area2">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="button_miner_userpass_discard">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="button_miner_userpass_save">
+                <property name="label">gtk-save</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">button_miner_userpass_discard</action-widget>
+      <action-widget response="0">button_miner_userpass_save</action-widget>
+    </action-widgets>
+  </object>
   <object class="GtkSizeGroup" id="sizegroup_indexing">
     <widgets>
       <widget name="label_disk_space_limit"/>
diff --git a/src/tracker-preferences/tracker-preferences.vala b/src/tracker-preferences/tracker-preferences.vala
index 5f9dfb0..b8d3a35 100644
--- a/src/tracker-preferences/tracker-preferences.vala
+++ b/src/tracker-preferences/tracker-preferences.vala
@@ -28,6 +28,9 @@ public static Config config = null;
 public static IconConfig icon_config = null;
 
 public const string HOME_STRING = "$HOME";
+public const string DESKTOP_GROUP = "Desktop Entry";
+public const string MINER_ON_ICON = "gtk-yes";
+public const string MINER_OFF_ICON = "gtk-no";
 
 public static Window window;
 public static CheckButton checkbutton_enable_index_on_battery_first_time;
@@ -52,6 +55,13 @@ 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 ListStore liststore_miners;
+public static ComboBox combo_miners;
+public static Image image_miner_status;
+public static Label label_miner_status;
+public static Button button_miner_associate;
+
+private MinerManager miner_manager;
 
 public static void radiobutton_visibility_toggled_cb (RadioButton source) {
 	if (radiobutton_display_never.active) {
@@ -322,6 +332,103 @@ setup_standard_treeview (TreeView view, string title)
 	view.append_column (column);
 }
 
+static void
+setup_combo_miners ()
+{
+	var icon_renderer = new CellRendererPixbuf ();
+	var name_renderer = new CellRendererText ();
+	combo_miners.pack_start (icon_renderer, false);
+	combo_miners.pack_start (name_renderer, true);
+	combo_miners.add_attribute (icon_renderer,
+	                            "icon-name", 0);
+	combo_miners.add_attribute (name_renderer,
+	                            "text", 1);
+}
+
+static void
+fill_in_miners_model ()
+{
+	TreeIter iter;
+	foreach (var m in miner_manager.get_miners ()) {
+		liststore_miners.append (out iter);
+		liststore_miners.set (iter,
+		                      0, m.icon,
+                              1, m.name,
+                              2, m);
+	}
+}
+
+static void
+update_miner_status_panel (string name, string association_type)
+{
+//	string dbus_name = "org.freedesktop.Tracker1.Miner.%s".printf (name);
+//	string dbus_path = "/org/freedesktop/Tracker1/Miner/Web/%s".printf (name);
+//
+//	dynamic DBus.Object miner = dbus_conn.get_object (dbus_name, dbus_path, MINER_WEB_DBUS_INTERFACE);
+//
+//	try {
+//		MinerWebAssociationStatus miner_status = miner.GetAssociationStatus ();
+//
+//		switch (miner_status) {
+//			case MinerWebAssociationStatus.ASSOCIATED:
+//				image_miner_status.set_from_stock (STOCK_YES, IconSize.MENU);
+//				label_miner_status.set_text (_("Running"));
+//				button_miner_associate.set_label (_("Associate as another user"));
+//				break;
+//			case MinerWebAssociationStatus.UNASSOCIATED:
+//				image_miner_status.set_from_stock (STOCK_NO, IconSize.MENU);
+//				label_miner_status.set_text (_("Needs association"));
+//				button_miner_associate.set_label (_("Associate"));
+//				break;
+//		}
+//		frame_miner_association.show ();
+//
+//		switch (association_type) {
+//			case "Token":
+//				vbox_miner_tokenassociation.show ();
+//				table_miner_userassociation.hide ();
+//				break;
+//			case "UserPass":
+//				vbox_miner_tokenassociation.hide ();
+//				table_miner_userassociation.show ();
+//				break;
+//			default:
+//				break;
+//		}
+//	} catch (Error e) {
+//		warning ("Error while contacting miner : %s", e.message);
+//		image_miner_status.set_from_stock (STOCK_DIALOG_ERROR, IconSize.MENU);
+//		label_miner_status.set_text (_("Error while contacting the miner"));
+//		frame_miner_association.hide ();
+//	}
+//
+//	vbox_miners.show ();
+}
+
+static void
+combo_miners_changed ()
+{
+	TreeIter active_iter;
+	unowned Miner m;
+
+	combo_miners.get_active_iter (out active_iter);
+	liststore_miners.get (active_iter,
+	                      2, out m);
+
+	string? status = m.status;
+	if (status == null) {
+		label_miner_status.set_text (_("Error while retrieving miner status"));
+	} else {
+		message ("%s", status);
+		label_miner_status.set_text (status);
+	}
+}
+
+static void
+button_miner_associate_clicked (Button source)
+{
+}
+
 static int main (string[] args) {
 	Gtk.init (ref args);
 
@@ -364,11 +471,20 @@ static int main (string[] args) {
 		treeview_ignored_directories_with_content = builder.get_object ("treeview_ignored_directories_with_content") as TreeView;
 		treeview_ignored_files = builder.get_object ("treeview_ignored_files") as TreeView;
 
+		miner_manager = new MinerManager ();
+
+		combo_miners = builder.get_object ("combo_miners") as ComboBox;
+		image_miner_status = builder.get_object ("image_miner_status") as Image;
+		label_miner_status = builder.get_object ("label_miner_status") as Label;
+		button_miner_associate = builder.get_object ("button_miner_associate") as Button;
+
 		setup_standard_treeview (treeview_index_recursively, _("Directory"));
 		setup_standard_treeview (treeview_index_single, _("Directory"));
 		setup_standard_treeview (treeview_ignored_directories, _("Directory"));
 		setup_standard_treeview (treeview_ignored_directories_with_content, _("Directory"));
 		setup_standard_treeview (treeview_ignored_files, _("File"));
+		setup_combo_miners ();
+		combo_miners.changed.connect (combo_miners_changed);
 
 		liststore_index_recursively = builder.get_object ("liststore_index_recursively") as ListStore;
 		fill_in_model (liststore_index_recursively, config.index_recursive_directories);
@@ -387,9 +503,14 @@ static int main (string[] args) {
 		liststore_gnored_directories_with_content = builder.get_object ("liststore_gnored_directories_with_content") as ListStore;
 		fill_in_model (liststore_gnored_directories_with_content, config.ignored_directories_with_content);
 
+		liststore_miners = builder.get_object ("liststore_miners") as ListStore;
+		fill_in_miners_model ();
+		combo_miners.set_active (0);
+
 		builder.connect_signals (null);
 
 		window.show_all ();
+
 		Gtk.main ();
 	} catch (Error e) {
 		stderr.printf ("Could not load UI: %s\n", e.message);



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