Hi Jamie,

I found several problems reload when changing preferences through t-p:
1. Check/uncheck evolution email(maybe more) does not make trackerd
restart
2. Trackerd restart will report another trackerd is running.
3. Key for BatteryIndex BatteryIndexInitial and FastMerges does not
initialized t-p GUI.

Attach the patch for review.

Thanks,
Halton.
Index: trunk/src/trackerd/tracker-dbus-methods.c
===================================================================
--- trunk/src/trackerd/tracker-dbus-methods.c	(revision 1038)
+++ trunk/src/trackerd/tracker-dbus-methods.c	(working copy)
@@ -478,18 +478,33 @@
 	} else if (strcasecmp (option, "EnableIndexing") == 0) {
 		tracker->enable_indexing = value;
 		tracker_log ("Enable indexing set to %d", value);
+	} else if (strcasecmp (option, "EnableWatching") == 0) {
+		tracker->enable_watching = value;
+		tracker_log ("Enable Watching set to %d", value);
 	} else if (strcasecmp (option, "LowMemoryMode") == 0) {
 		tracker->use_extra_memory = !value;
 		tracker_log ("Extra memory usage set to %d", !value);
 	} else if (strcasecmp (option, "IndexFileContents") == 0) {
 		tracker->enable_content_indexing = value;
 		tracker_log ("Index file contents set to %d", value);	
+	} else if (strcasecmp (option, "GenerateThumbs") == 0) {
+		tracker->enable_thumbnails = value;
+		tracker_log ("Generate thumbnails set to %d", value);	
+	} else if (strcasecmp (option, "SkipMountPoints") == 0) {
+		tracker->skip_mount_points = value;
+		tracker_log ("Skip mounted directories set to %d", value);
 	} else if (strcasecmp (option, "EnableEvolution") == 0) {
+		tracker->index_evolution_emails = value;
 		tracker_log ("evolution support set to %d", value);
-		tracker->index_evolution_emails = value;
 	} else if (strcasecmp (option, "FastMerges") == 0) {
+		tracker->fast_merges = value;
 		tracker_log ("Fast merges set to %d", value);
-		tracker->fast_merges = value;
+	} else if (strcasecmp (option, "BatteryIndex") == 0) {
+		tracker->index_on_battery = value;
+		tracker_log ("Disable index on battery set to %d", !value);
+	} else if (strcasecmp (option, "BatteryIndexInitial") == 0) {
+		tracker->index_on_battery = value;
+		tracker_log ("Disable initial index sweep on battery set to %d", !value);
 	}
 
 	tracker_notify_file_data_available ();
@@ -531,6 +546,12 @@
 	if (strcasecmp (option, "Throttle") == 0) {
 		tracker->throttle = value;
 		tracker_log ("throttle set to %d", value);
+	} else if (strcasecmp (option, "MaxText") == 0) {
+		tracker->max_index_text_length = value;
+		tracker_log ("Maxinum amount of text set to %d", value);
+	} else if (strcasecmp (option, "MaxWords") == 0) {
+		tracker->max_words_to_index = value;
+		tracker_log ("Maxinum number of unique words set to %d", value);
 	} 
 
 	reply = dbus_message_new_method_return (rec->message);
Index: trunk/src/tracker-preferences/Makefile.am
===================================================================
--- trunk/src/tracker-preferences/Makefile.am	(revision 1038)
+++ trunk/src/tracker-preferences/Makefile.am	(working copy)
@@ -19,6 +19,7 @@
 
 INCLUDES =	-DTRACKER_DATADIR=\""$(datadir)/tracker"\" \
 		-DTRACKER_LOCALEDIR=\""$(localedir)"\" \
+		-DTRACKER_BINDIR=\""$(bindir)"\" \
 		$(GLIB_CFLAGS) \
 		$(GTK2_CFLAGS) \
 		$(LIBGLADE_CFLAGS) \
Index: trunk/src/tracker-preferences/tracker-preferences.c
===================================================================
--- trunk/src/tracker-preferences/tracker-preferences.c	(revision 1038)
+++ trunk/src/tracker-preferences/tracker-preferences.c	(working copy)
@@ -237,6 +237,42 @@
 
 }
 
+void 
+spin_value_changed_cb (GtkSpinButton *spin_button, gpointer user_data)
+{
+	TrackerPreferencesPrivate *priv = user_data;
+	TrackerConfiguration *configuration = TRACKER_CONFIGURATION (priv->prefs);
+
+	const char *name = gtk_widget_get_name (GTK_WIDGET (spin_button));
+	int value = gtk_spin_button_get_value_as_int (spin_button);
+
+	if (name) {
+		g_print ("%s was clicked with value %d\n", name, value);
+	}  else {
+		g_print ("unknown widget was clicked with value %d\n", value);
+	}
+
+	if (g_str_equal (name, "spnMaxText")) {
+
+		set_int_option (priv, "MaxText", value*1024);
+
+		tracker_configuration_set_int (configuration,
+						"/Performance/MaxTextToIndex",
+						value);
+
+
+	} else 	if (g_str_equal (name, "spnMaxWords")) {
+
+		set_int_option (priv, "MaxWords", value);
+
+		tracker_configuration_set_int (configuration,
+					"/Performance/MaxWordsToIndex",
+					value);
+
+	}
+
+}
+
 void
 check_toggled_cb (GtkToggleButton *check_button, gpointer user_data)  
 {
@@ -257,9 +293,21 @@
 
 		set_bool_option (priv, "EnableIndexing", value);
 
-		tracker_configuration_set_bool (configuration, "/Indexing/EnableIndexing", value);
+		tracker_configuration_set_bool (configuration,
+						 "/Indexing/EnableIndexing",
+						 value);
+		flag_restart = TRUE;
 
+	} else 	if (g_str_equal (name, "chkEnableWatching")) {
 
+		set_bool_option (priv, "EnableWatching", value);
+
+		tracker_configuration_set_bool (configuration,
+					"/Watches/EnableWatching",
+					value);
+
+		flag_restart = TRUE;
+
 	} else 	if (g_str_equal (name, "chkEnableEvolutionIndexing")) {
 
 		set_bool_option (priv, "EnableEvolution", value);
@@ -268,6 +316,7 @@
 					"/Emails/IndexEvolutionEmails",
 					value);
 
+		flag_restart = TRUE;
 
 	} else 	if (g_str_equal (name, "chkIndexContents")) {
 
@@ -277,7 +326,26 @@
 					"/Indexing/EnableFileContentIndexing",
 					value);
 
+		flag_restart = TRUE;
 
+	} else 	if (g_str_equal (name, "chkGenerateThumbs")) {
+
+		set_bool_option (priv, "GenerateThumbs", value);
+
+		tracker_configuration_set_bool (configuration,
+					"/Indexing/EnableThumbnails",
+					value);
+
+
+	} else 	if (g_str_equal (name, "chkSkipMountPoints")) {
+
+		set_bool_option (priv, "SkipMountPoints", !value);
+
+		tracker_configuration_set_bool (configuration,
+					"/Indexing/SkipMountPoints",
+					!value);
+
+
 	} else 	if (g_str_equal (name, "chkFastMerges")) {
 
 		set_bool_option (priv, "FastMerges", value);
@@ -311,10 +379,6 @@
 					!value);
 	}
 
-
-
-
-
 }
 
 
@@ -353,6 +417,8 @@
 						NULL);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
 
+	g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled",
+			  G_CALLBACK (check_toggled_cb), priv);
 
 	widget = glade_xml_get_widget (priv->gxml, "comLanguage");
 	char *str_value = tracker_configuration_get_string (configuration,
@@ -368,6 +434,26 @@
 			break;
 		}
 	}
+
+	widget = glade_xml_get_widget (priv->gxml, "chkDisableBatteryIndex");
+	value = tracker_configuration_get_bool (configuration,
+						"/Indexing/BatteryIndex",
+						NULL);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), !value);
+
+	g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled",
+			  G_CALLBACK (check_toggled_cb), priv);
+
+	widget = glade_xml_get_widget (priv->gxml, "chkDisableBatteryInitialIndex");
+	value = tracker_configuration_get_bool (configuration,
+						"/Indexing/BatteryIndexInitial",
+						NULL);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), !value);
+
+	g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled",
+			  G_CALLBACK (check_toggled_cb), priv);
+
+
 }
 
 static void
@@ -405,7 +491,16 @@
 	g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled",
 			  G_CALLBACK (check_toggled_cb), priv);
 
+	widget = glade_xml_get_widget (priv->gxml, "chkFastMerges");
+	bvalue = tracker_configuration_get_bool (configuration,
+						 "/Indexing/FastMerges",
+						 NULL);
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bvalue);
 
+	g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled",
+			  G_CALLBACK (check_toggled_cb), priv);
+
+
 	widget = glade_xml_get_widget (priv->gxml, "spnMaxText");
 	value = tracker_configuration_get_int (configuration,
 					       "/Performance/MaxTextToIndex",
@@ -414,12 +509,18 @@
 	value = value / 1024;
 	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
 
+	g_signal_connect (GTK_SPIN_BUTTON (widget), "value-changed",
+			  G_CALLBACK (spin_value_changed_cb), priv);
+
 	widget = glade_xml_get_widget (priv->gxml, "spnMaxWords");
 	value = tracker_configuration_get_int (configuration,
 					       "/Performance/MaxWordsToIndex",
 					       NULL);
 
 	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
+
+	g_signal_connect (GTK_SPIN_BUTTON (widget), "value-changed",
+			  G_CALLBACK (spin_value_changed_cb), priv);
 }
 
 
@@ -451,12 +552,17 @@
 						"/Indexing/EnableThumbnails",
 						NULL);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
+	g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled",
+			  G_CALLBACK (check_toggled_cb), priv);
 
+
 	widget = glade_xml_get_widget (priv->gxml, "chkSkipMountPoints");
 	value = tracker_configuration_get_bool (configuration,
 						"/Indexing/SkipMountPoints",
 						NULL);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), !value);
+	g_signal_connect (GTK_TOGGLE_BUTTON (widget), "toggled",
+			  G_CALLBACK (check_toggled_cb), priv);
 
 
 	widget = glade_xml_get_widget (priv->gxml,
@@ -578,15 +684,21 @@
 		    const gchar * prev_owner, const gchar * new_owner,
 		    gpointer data)
 {
+        static gboolean first_time = TRUE;
+
 	if (!g_str_equal (name, TRACKER_SERVICE))
 		return;
 
+        if (!first_time)
+                return;
+
 	if (g_str_equal (new_owner, "")) {
 		/* tracker has exited */
-		const gchar *command = "trackerd";
+		const gchar *command = TRACKER_BINDIR "/trackerd";
 
 		if (!g_spawn_command_line_async (command, NULL))
 			g_warning ("Unable to execute command: %s", command);
+                first_time = FALSE;
 		gtk_main_quit ();
 	}
 }
@@ -671,17 +783,6 @@
 	tracker_configuration_set_int (configuration, "/General/InitialSleep",
 				       value);
 
-	widget = glade_xml_get_widget (priv->gxml, "chkEnableWatching");
-	value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	value_old = tracker_configuration_get_bool (configuration,
-						    "/Watches/EnableWatching",
-						    NULL);
-
-	if (value != value_old) flag_restart = TRUE;
-
-	tracker_configuration_set_bool (configuration,
-					"/Watches/EnableWatching", value);
-
 	widget = glade_xml_get_widget (priv->gxml, "comLanguage");
 	gint i = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
 	str_value = tracker_configuration_get_string (configuration,
@@ -698,73 +799,8 @@
 	}
 
 
-	/* save performance settings */
-	widget = glade_xml_get_widget (priv->gxml, "scaThrottle");
-
-	ivalue = gtk_range_get_value (GTK_RANGE (widget));
-	ivalue_old = tracker_configuration_get_int (configuration,
-						    "/Indexing/Throttle",
-						    NULL);
-
-	if (ivalue != ivalue_old) flag_restart = TRUE;
-
-	tracker_configuration_set_int (configuration,
-				       "/Indexing/Throttle", ivalue);
-
-	widget = glade_xml_get_widget (priv->gxml, "optReducedMemory");
-	value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	value_old = tracker_configuration_get_bool (configuration,
-						    "/General/LowMemoryMode",
-						    NULL);
-
-	widget = glade_xml_get_widget (priv->gxml, "spnMaxText");
-	ivalue = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
-	ivalue = ivalue * 1024;
-	ivalue_old = tracker_configuration_get_int (configuration,
-						    "/Performance/MaxTextToIndex",
-						    NULL);
-
-	if (ivalue != ivalue_old) flag_restart = TRUE;
-
-	tracker_configuration_set_int (configuration,
-				       "/Performance/MaxTextToIndex", ivalue);
-
-	widget = glade_xml_get_widget (priv->gxml, "spnMaxWords");
-	ivalue = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
-	ivalue_old = tracker_configuration_get_int (configuration,
-						    "/Performance/MaxWordsToIndex",
-						    NULL);
-
-	if (ivalue != ivalue_old) flag_restart = TRUE;
-
-	tracker_configuration_set_int (configuration,
-				       "/Performance/MaxWordsToIndex",
-				       ivalue);
-
-
 	/* files settings */
 
-	widget = glade_xml_get_widget (priv->gxml, "chkGenerateThumbs");
-	value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	value_old = tracker_configuration_get_bool (configuration,
-						    "/Indexing/EnableThumbnails",
-						    NULL);
-	if (value != value_old) {
-		flag_restart = TRUE;
-	}
-
-	tracker_configuration_set_bool (configuration,
-					"/Indexing/EnableThumbnails", value);
-
-	widget = glade_xml_get_widget (priv->gxml, "chkSkipMountPoints");
-	value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	value_old = tracker_configuration_get_bool (configuration,
-						    "/Indexing/SkipMountPoints",
-						    NULL);
-
-	tracker_configuration_set_bool (configuration,
-					"/Indexing/SkipMountPoints", !value);
-
 	widget = glade_xml_get_widget (priv->gxml,
 				       "lstAdditionalPathIndexes");
 	list = treeview_get_values (GTK_TREE_VIEW (widget));
@@ -806,32 +842,13 @@
 	list = NULL;
 
 
-	/* email settings */
-	widget = glade_xml_get_widget (priv->gxml,
-				       "chkEnableEvolutionIndexing");
-	value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	value_old = tracker_configuration_get_bool (configuration,
-						    "/Emails/IndexEvolutionEmails",
-						    NULL);
-	if (value != value_old)
-		flag_restart = TRUE;
-	tracker_configuration_set_bool (configuration,
-					"/Emails/IndexEvolutionEmails",
-					value);
-
-
 	tracker_configuration_write (configuration);
 
 	if (flag_restart && if_trackerd_start (priv)) {
 
-		
 		GtkWidget * dialog;
 		char *msg;
 
-
-		
-
-
 		if (flag_reindex) {
 			msg =  _("Your system must be re-indexed for your changes to take effect. Re-index now?");
 		} else {
Index: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	(revision 1038)
+++ trunk/ChangeLog	(working copy)
@@ -1,3 +1,21 @@
+2007-11-04 Halton Huo   <[EMAIL PROTECTED]>
+
+	Fix several problems for trackerd reload when changing preferences
+	through t-p:
+	1. Check/uncheck evolution email(maybe more) does not make
+	   trackerd restart
+	2. Trackerd restart will report another trackerd is running.
+	3. Key for BatteryIndex BatteryIndexInitial and FastMerges does
+	   not initialized t-p GUI.
+	* src/tracker-preferences/Makefile.am: Add TRACKER_BINDIR
+	* src/tracker-preferences/tracker-preferences.c:
+	(spin_value_changed_cb), (check_toggled_cb), (setup_page_general),
+	(setup_page_performance), (setup_page_files), (name_owner_changed),
+	(cmdClose_Clicked):
+	* src/trackerd/tracker-dbus-methods.c:
+	(tracker_dbus_method_set_bool_option): Add some bool option here.
+	(tracker_dbus_method_set_int_option): Add some int option here.
+
 2007-11-19 Marcus Fritzsch <m at fritschy dot de>
 
 	* python/deskbar-handler/tracker-{handler,module}.py
_______________________________________________
tracker-list mailing list
tracker-list@gnome.org
http://mail.gnome.org/mailman/listinfo/tracker-list

Reply via email to