psppire-import-assistant: Implement quotation checkbox and combo box.
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 30 Dec 2019 06:35:16 +0000 (06:35 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 30 Dec 2019 06:35:16 +0000 (06:35 +0000)
This seems to have been overlooked.

Bug #57457.

src/ui/gui/psppire-import-assistant.c
src/ui/gui/psppire-import-assistant.h
src/ui/gui/text-data-import.ui

index 8270938373f6ae9e5be4954d5921b87f9d35075d..edab2288f266a7a6ac50ca903f278cbd968a37ef 100644 (file)
@@ -1024,32 +1024,6 @@ psppire_import_assistant_new (GtkWindow *toplevel)
 
 \f
 
-static void
-set_quote_list (GtkComboBox *cb)
-{
-  GtkListStore *list =  gtk_list_store_new (1, G_TYPE_STRING);
-  GtkTreeIter iter;
-  gint i;
-  const gchar *separator[3] = {"'\"", "\'", "\""};
-
-  for (i = 0; i < 3; i++)
-    {
-      const gchar *s = separator[i];
-
-      /* Add a new row to the model */
-      gtk_list_store_append (list, &iter);
-      gtk_list_store_set (list, &iter,
-                          0, s,
-                          -1);
-
-    }
-
-  gtk_combo_box_set_model (GTK_COMBO_BOX (cb), GTK_TREE_MODEL (list));
-  g_object_unref (list);
-
-  gtk_combo_box_set_entry_text_column (cb, 0);
-}
-
 /* Chooses a name for each column on the separators page */
 static void
 choose_column_names (PsppireImportAssistant *ia)
@@ -1159,10 +1133,9 @@ separators_page_create (PsppireImportAssistant *ia)
   ia->custom_cb = get_widget_assert (builder, "custom-cb");
   ia->custom_entry = get_widget_assert (builder, "custom-entry");
   ia->quote_combo = get_widget_assert (builder, "quote-combo");
-  ia->quote_entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (ia->quote_combo)));
   ia->quote_cb = get_widget_assert (builder, "quote-cb");
 
-  set_quote_list (GTK_COMBO_BOX (ia->quote_combo));
+  gtk_combo_box_set_active (GTK_COMBO_BOX (ia->quote_combo), 0);
 
   if (ia->fields_tree_view == NULL)
     {
@@ -1423,8 +1396,15 @@ separators_append_syntax (const PsppireImportAssistant *ia, struct string *s)
        }
     }
   ds_put_cstr (s, "\"\n");
-  if (!ds_is_empty (&ia->quotes))
-    syntax_gen_pspp (s, "  /QUALIFIER=%sq\n", ds_cstr (&ia->quotes));
+
+  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ia->quote_cb)))
+    {
+      GtkComboBoxText *cbt = GTK_COMBO_BOX_TEXT (ia->quote_combo);
+      gchar *quotes = gtk_combo_box_text_get_active_text (cbt);
+      if (quotes && *quotes)
+        syntax_gen_pspp (s, "  /QUALIFIER=%sq\n", quotes);
+      free (quotes);
+    }
 }
 
 static void
index cdcf8fb73ee48f274745eccffd547da248a28a01..3e1d7e843300807411768540de5a739ba4df37ff 100644 (file)
@@ -96,7 +96,6 @@ struct _PsppireImportAssistant
   GtkWidget *quote_cb;
   GtkWidget *quote_combo;
 
-  GtkEntry *quote_entry;
   GtkWidget *fields_tree_view;
 
 /* END Page where the user chooses field separators. */
index 86e6f39906e27603569e501cb0f33edca4e6ccda..3cc118610fd4a780a521e23aec3afd5e97444aab 100644 (file)
                 <property name="row_spacing">6</property>
                 <property name="column_spacing">6</property>
                 <child>
-                  <object class="GtkComboBox" id="quote-combo">
+                  <object class="GtkComboBoxText" id="quote-combo">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                         <property name="can_focus">False</property>
                       </object>
                     </child>
+                    <items>
+                      <item translatable="no">'"</item>
+                      <item translatable="no">'</item>
+                      <item translatable="no">"</item>
+                    </items>
                   </object>
                   <packing>
                     <property name="left_attach">1</property>