tracker r2645 - in trunk: . src/tracker-preferences



Author: ifrade
Date: Wed Dec  3 15:46:40 2008
New Revision: 2645
URL: http://svn.gnome.org/viewvc/tracker?rev=2645&view=rev

Log:
Fixed the language comparison in tracker-preferences. This was forcing a reindex everytime you closed the preferences dialog

Modified:
   trunk/ChangeLog
   trunk/src/tracker-preferences/tracker-preferences.c
   trunk/src/tracker-preferences/tracker-preferences.glade

Modified: trunk/src/tracker-preferences/tracker-preferences.c
==============================================================================
--- trunk/src/tracker-preferences/tracker-preferences.c	(original)
+++ trunk/src/tracker-preferences/tracker-preferences.c	Wed Dec  3 15:46:40 2008
@@ -405,17 +405,22 @@
 	TrackerPreferencesPrivate *priv;
 	GSList *list;
 	GSList *list_old;
-        gchar *language;
-        const gchar *language_old;
+        gchar *lang_code;
+        const gchar *lang_code_old;
 	gboolean bvalue, bvalue_old;
 	gint ivalue, ivalue_old;
+        GtkTreeIter   iter;
+        GtkTreeModel *model;
 
         priv = TRACKER_PREFERENCES_GET_PRIVATE (data);
 
 	/* Save general settings */
 	widget = glade_xml_get_widget (priv->gxml, "spnInitialSleep");
+        ivalue_old = tracker_config_get_initial_sleep (priv->config);
 	ivalue = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
-	tracker_config_set_initial_sleep (priv->config, ivalue);
+        if (ivalue_old != ivalue) {
+                tracker_config_set_initial_sleep (priv->config, ivalue);
+        }
 
 #ifdef ENABLE_DEPRECATED
 	widget = glade_xml_get_widget (priv->gxml, "chkEnableWatching");
@@ -440,20 +445,23 @@
 	}
 
 	widget = glade_xml_get_widget (priv->gxml, "comLanguage");
-        language = gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget));
-        language_old = tracker_config_get_language (priv->config);
 
-        if (language && language_old && strcmp (language, language_old) == 0) {
+        gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+        model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
+        
+        gtk_tree_model_get (model, &iter, 1, &lang_code, -1);
+        lang_code_old = tracker_config_get_language (priv->config);
+
+        if (lang_code 
+            && lang_code_old 
+            && strcmp (lang_code, lang_code_old) == 0) {
                 /* Same, do nothing */
         } else {
-                const gchar *code;
-
                 priv->should_restart = TRUE;
                 priv->should_reindex = TRUE;
 
-                /* Note, language can be NULL */
-                code = tracker_language_get_code_by_name (language);
-		tracker_config_set_language (priv->config, code);
+                /* Note, language can be NULL??? */
+		tracker_config_set_language (priv->config, lang_code);
         }
         
 	widget = glade_xml_get_widget (priv->gxml, "chkDisableBatteryIndex");
@@ -642,7 +650,7 @@
 		gchar *primary;
 		gchar *secondary;
 		gchar *button;
-
+                
 		if (priv->should_reindex) {
 			primary = g_strdup (_("Data must be reindexed"));
 			secondary = g_strdup (_("In order for your changes to "
@@ -677,7 +685,7 @@
 							  secondary);
 
 		gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-					GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
+					GTK_STOCK_NO, GTK_RESPONSE_NO,
 					button, GTK_RESPONSE_YES, NULL);
 
 		g_free (primary);
@@ -859,8 +867,8 @@
 	TrackerPreferencesPrivate *priv;
 	GtkWidget *widget;
         const gchar *language;
-	gchar *default_language = NULL;
         GSList *language_codes, *l;
+        GtkTreeStore *language_model;
 	gboolean value;
 	gint sleep;
 
@@ -884,27 +892,35 @@
 #endif
 
 	widget = glade_xml_get_widget (priv->gxml, "comLanguage");
+        language_model = gtk_tree_store_new (2, 
+                                             G_TYPE_STRING, 
+                                             G_TYPE_STRING);
+        gtk_combo_box_set_model (GTK_COMBO_BOX (widget), 
+                                 GTK_TREE_MODEL (language_model));
+
 	language = tracker_config_get_language (priv->config);
 	if (!language) {
 		/* No value for language? Default to "en" */
-		language = default_language = tracker_language_get_default_code ();
+		language = tracker_language_get_default_code ();
 	}
-
-        /* Default to English */
-	gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2);
         
         language_codes = tracker_language_get_all_by_code ();
         
 	for (l = language_codes; l; l = l->next) {
+
+                GtkTreeIter iter;
+                gtk_tree_store_append (language_model, &iter, NULL);
+                gtk_tree_store_set (language_model, &iter, 
+                                    0, tracker_language_get_name_by_code (l->data), 
+                                    1, l->data,
+                                    -1);
+
 		if (strcasecmp (language, l->data) == 0) {
                         gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 
                                                   g_slist_index (language_codes, l->data));
-                        break;
                 }
 	}
 
-        g_free (default_language);
-
 	widget = glade_xml_get_widget (priv->gxml, "chkDisableBatteryIndex");
 	value = tracker_config_get_disable_indexing_on_battery (priv->config);
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);

Modified: trunk/src/tracker-preferences/tracker-preferences.glade
==============================================================================
--- trunk/src/tracker-preferences/tracker-preferences.glade	(original)
+++ trunk/src/tracker-preferences/tracker-preferences.glade	Wed Dec  3 15:46:40 2008
@@ -65,8 +65,8 @@
                                         <property name="adjustment">0 0 1000 1 300 300</property>
                                         <property name="climb_rate">1</property>
                                         <accessibility>
-                                          <atkrelation target="lblInitialSleep" type="labelled-by"/>
                                           <atkrelation target="lblInitialSleepSeconds" type="labelled-by"/>
+                                          <atkrelation target="lblInitialSleep" type="labelled-by"/>
                                         </accessibility>
                                       </widget>
                                     </child>
@@ -207,19 +207,7 @@
                                 <child>
                                   <widget class="GtkComboBox" id="comLanguage">
                                     <property name="visible">True</property>
-                                    <property name="items" translatable="yes">Danish
-Dutch
-English
-Finnish
-French
-German
-Hungarian
-Italian
-Norwegian
-Portuguese
-Russian
-Spanish
-Swedish</property>
+                                    <property name="items" translatable="yes"></property>
                                   </widget>
                                   <packing>
                                     <property name="position">1</property>
@@ -889,34 +877,35 @@
                       </widget>
                       <packing>
                         <property name="expand">False</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkCheckButton" id="chkEnableThunderbirdIndexing">
+                      <widget class="GtkCheckButton" id="chkEnableKMailIndexing">
                         <property name="visible">True</property>
                         <property name="sensitive">False</property>
-                        <property name="label" translatable="yes">Enable _Thunderbird email indexing</property>
+                        <property name="label" translatable="yes">Enable _KMail email indexing</property>
                         <property name="use_underline">True</property>
                         <property name="response_id">0</property>
                         <property name="draw_indicator">True</property>
                       </widget>
                       <packing>
                         <property name="expand">False</property>
-                        <property name="position">1</property>
+                        <property name="position">2</property>
                       </packing>
                     </child>
                     <child>
-                      <widget class="GtkCheckButton" id="chkEnableKMailIndexing">
+                      <widget class="GtkCheckButton" id="chkEnableThunderbirdIndexing">
                         <property name="visible">True</property>
                         <property name="sensitive">False</property>
-                        <property name="label" translatable="yes">Enable _KMail email indexing</property>
+                        <property name="label" translatable="yes">Enable _Thunderbird email indexing</property>
                         <property name="use_underline">True</property>
                         <property name="response_id">0</property>
                         <property name="draw_indicator">True</property>
                       </widget>
                       <packing>
                         <property name="expand">False</property>
-                        <property name="position">2</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
                   </widget>
@@ -1041,28 +1030,32 @@
                                 <property name="column_spacing">12</property>
                                 <property name="row_spacing">6</property>
                                 <child>
-                                  <widget class="GtkLabel" id="lblThrottlingLevel">
+                                  <widget class="GtkHScale" id="scaThrottle">
                                     <property name="visible">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Indexing speed:</property>
+                                    <property name="adjustment">0 0 99 1 1 0</property>
+                                    <property name="digits">0</property>
                                     <accessibility>
-                                      <atkrelation target="scaThrottle" type="label-for"/>
+                                      <atkrelation target="lblThrottlingLevel" type="labelled-by"/>
                                     </accessibility>
                                   </widget>
                                   <packing>
-                                    <property name="right_attach">3</property>
-                                    <property name="x_options">GTK_FILL</property>
-                                    <property name="y_options"></property>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="y_options">GTK_FILL</property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkLabel" id="label24">
+                                  <widget class="GtkLabel" id="label23">
                                     <property name="visible">True</property>
                                     <property name="xalign">0</property>
                                     <property name="yalign">0</property>
-                                    <property name="label" translatable="yes">Faster</property>
+                                    <property name="label" translatable="yes">Slower</property>
                                   </widget>
                                   <packing>
+                                    <property name="left_attach">2</property>
+                                    <property name="right_attach">3</property>
                                     <property name="top_attach">1</property>
                                     <property name="bottom_attach">2</property>
                                     <property name="x_options">GTK_FILL</property>
@@ -1070,15 +1063,13 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkLabel" id="label23">
+                                  <widget class="GtkLabel" id="label24">
                                     <property name="visible">True</property>
                                     <property name="xalign">0</property>
                                     <property name="yalign">0</property>
-                                    <property name="label" translatable="yes">Slower</property>
+                                    <property name="label" translatable="yes">Faster</property>
                                   </widget>
                                   <packing>
-                                    <property name="left_attach">2</property>
-                                    <property name="right_attach">3</property>
                                     <property name="top_attach">1</property>
                                     <property name="bottom_attach">2</property>
                                     <property name="x_options">GTK_FILL</property>
@@ -1086,20 +1077,18 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkHScale" id="scaThrottle">
+                                  <widget class="GtkLabel" id="lblThrottlingLevel">
                                     <property name="visible">True</property>
-                                    <property name="adjustment">0 0 99 1 1 0</property>
-                                    <property name="digits">0</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Indexing speed:</property>
                                     <accessibility>
-                                      <atkrelation target="lblThrottlingLevel" type="labelled-by"/>
+                                      <atkrelation target="scaThrottle" type="label-for"/>
                                     </accessibility>
                                   </widget>
                                   <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>
-                                    <property name="y_options">GTK_FILL</property>
+                                    <property name="right_attach">3</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options"></property>
                                   </packing>
                                 </child>
                               </widget>
@@ -1256,28 +1245,28 @@
                                   <placeholder/>
                                 </child>
                                 <child>
-                                  <widget class="GtkLabel" id="label30">
+                                  <widget class="GtkLabel" id="label33">
                                     <property name="visible">True</property>
                                     <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Maximum _amount of text to index:</property>
-                                    <property name="use_underline">True</property>
-                                    <property name="mnemonic_widget">spnMaxText</property>
+                                    <property name="label" translatable="yes">kB</property>
                                   </widget>
                                   <packing>
+                                    <property name="left_attach">2</property>
+                                    <property name="right_attach">3</property>
                                     <property name="x_options">GTK_FILL</property>
                                     <property name="y_options"></property>
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkLabel" id="label31">
+                                  <widget class="GtkSpinButton" id="spnMaxWords">
                                     <property name="visible">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Maximum number of unique _words to index:</property>
-                                    <property name="use_markup">True</property>
-                                    <property name="use_underline">True</property>
-                                    <property name="mnemonic_widget">spnMaxWords</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="adjustment">10000 1000 1000000 100 500 500</property>
+                                    <property name="climb_rate">1</property>
                                   </widget>
                                   <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>
                                     <property name="x_options">GTK_FILL</property>
@@ -1299,15 +1288,15 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkSpinButton" id="spnMaxWords">
+                                  <widget class="GtkLabel" id="label31">
                                     <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="adjustment">10000 1000 1000000 100 500 500</property>
-                                    <property name="climb_rate">1</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Maximum number of unique _words to index:</property>
+                                    <property name="use_markup">True</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="mnemonic_widget">spnMaxWords</property>
                                   </widget>
                                   <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>
                                     <property name="x_options">GTK_FILL</property>
@@ -1315,14 +1304,14 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <widget class="GtkLabel" id="label33">
+                                  <widget class="GtkLabel" id="label30">
                                     <property name="visible">True</property>
                                     <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">kB</property>
+                                    <property name="label" translatable="yes">Maximum _amount of text to index:</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="mnemonic_widget">spnMaxText</property>
                                   </widget>
                                   <packing>
-                                    <property name="left_attach">2</property>
-                                    <property name="right_attach">3</property>
                                     <property name="x_options">GTK_FILL</property>
                                     <property name="y_options"></property>
                                   </packing>



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