/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2005, 2009, 2010, 2011, 2012 Free Software Foundation
+ Copyright (C) 2005, 2009, 2010, 2011, 2012, 2015, 2016 Free Software Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
PROP_VALUE_LABELS
};
+static void do_change (PsppireValLabsDialog *);
+
static void
psppire_val_labs_dialog_set_property (GObject *object,
guint prop_id,
{
return PSPPIRE_VAL_LABS_DIALOG (
g_object_new (PSPPIRE_TYPE_VAL_LABS_DIALOG,
- "orientation", PSPPIRE_HORIZONTAL,
"variable", var,
NULL));
}
value_destroy (&v, val_labs_get_width (dialog->labs));
}
+/* This callback occurs when Enter is pressed in the label entry box. */
+static void
+on_label_entry_activate (GtkEntry *entry, gpointer data)
+{
+ PsppireValLabsDialog *dialog = data;
+ do_change (dialog);
+}
+
+/* Return the value-label pair currently selected in the dialog box */
/* Set the TREEVIEW list cursor to the item which has the value VAL */
static void
value_destroy (&v, val_labs_get_width (dialog->labs));
}
+/* This callback occurs when Enter is pressed in the value entry box. */
+static void
+on_value_entry_activate (GtkEntry *entry, gpointer data)
+{
+ PsppireValLabsDialog *dialog = data;
+
+ gtk_widget_grab_focus (dialog->label_entry);
+}
-/* Return the value-label pair currently selected in the dialog box */
static gboolean
get_selected_tuple (PsppireValLabsDialog *dialog,
union value *valuep, const char **label)
if (vl != NULL)
*label = val_lab_get_escaped_label (vl);
}
-
+
return TRUE;
}
on_change (GtkWidget *w, gpointer data)
{
PsppireValLabsDialog *dialog = data;
+ do_change (dialog);
+}
+static void
+do_change (PsppireValLabsDialog *dialog)
+{
const gchar *val_text = gtk_entry_get_text (GTK_ENTRY (dialog->value_entry));
union value v;
- text_to_value__ (val_text, &dialog->format, dialog->encoding, &v);
-
- val_labs_replace (dialog->labs, &v,
- gtk_entry_get_text (GTK_ENTRY (dialog->label_entry)));
+ if (text_to_value__ (val_text, &dialog->format, dialog->encoding, &v))
+ {
+ val_labs_replace (dialog->labs, &v,
+ gtk_entry_get_text (GTK_ENTRY (dialog->label_entry)));
- gtk_widget_set_sensitive (dialog->change_button, FALSE);
+ gtk_widget_set_sensitive (dialog->change_button, FALSE);
- repopulate_dialog (dialog);
- gtk_widget_grab_focus (dialog->value_entry);
+ repopulate_dialog (dialog);
+ gtk_widget_grab_focus (dialog->value_entry);
- value_destroy (&v, val_labs_get_width (dialog->labs));
+ value_destroy (&v, val_labs_get_width (dialog->labs));
+ }
}
/* Callback which occurs when the "Add" button is clicked */
const gchar *text = gtk_entry_get_text (GTK_ENTRY (dialog->value_entry));
- text_to_value__ (text, &dialog->format, dialog->encoding, &v);
-
- if (val_labs_add (dialog->labs, &v,
- gtk_entry_get_text
- ( GTK_ENTRY (dialog->label_entry)) ) )
+ if (text_to_value__ (text, &dialog->format, dialog->encoding, &v))
{
- gtk_widget_set_sensitive (dialog->add_button, FALSE);
+ if (val_labs_add (dialog->labs, &v,
+ gtk_entry_get_text
+ ( GTK_ENTRY (dialog->label_entry)) ) )
+ {
+ gtk_widget_set_sensitive (dialog->add_button, FALSE);
- repopulate_dialog (dialog);
- gtk_widget_grab_focus (dialog->value_entry);
- }
+ repopulate_dialog (dialog);
+ gtk_widget_grab_focus (dialog->value_entry);
+ }
- value_destroy (&v, val_labs_get_width (dialog->labs));
+ value_destroy (&v, val_labs_get_width (dialog->labs));
+ }
}
/* Callback which occurs when the "Remove" button is clicked */
if (! get_selected_tuple (dialog, &value, NULL))
return;
-
+
vl = val_labs_lookup (dialog->labs, &value);
if (vl != NULL)
val_labs_remove (dialog->labs, vl);
if (! get_selected_tuple (dialog, &value, &label))
return;
-
+
text = value_to_text__ (value, &dialog->format, dialog->encoding);
g_signal_handler_block (GTK_ENTRY (dialog->value_entry),
type, n_properties, properties);
dialog = PSPPIRE_VAL_LABS_DIALOG (obj);
- content_area = GTK_CONTAINER (PSPPIRE_DIALOG (dialog)->box);
+ content_area = GTK_CONTAINER (PSPPIRE_DIALOG (dialog));
gtk_container_add (GTK_CONTAINER (content_area),
get_widget_assert (xml, "val-labs-dialog"));
g_signal_connect (dialog->label_entry,
"changed",
G_CALLBACK (on_label_entry_change), dialog);
+ g_signal_connect (dialog->label_entry, "activate",
+ G_CALLBACK (on_label_entry_activate), dialog);
dialog->value_handler_id =
g_signal_connect (dialog->value_entry,
"changed",
G_CALLBACK (on_value_entry_change), dialog);
+ g_signal_connect (dialog->value_entry, "activate",
+ G_CALLBACK (on_value_entry_activate), dialog);
g_signal_connect (dialog->change_button,
"clicked",