/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2007, 2009, 2010, 2011, 2012, 2014, 2016 Free Software Foundation
+ Copyright (C) 2007, 2009, 2010, 2011, 2012, 2014, 2016,
+ 2020 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
{
struct new_value *copy = g_memdup (nv, sizeof (*copy));
- if ( nv->type == NV_STRING )
+ if (nv->type == NV_STRING)
copy->v.s = xstrdup (nv->v.s);
return copy;
static void
new_value_free (struct new_value *nv)
{
- if ( nv->type == NV_STRING )
+ if (nv->type == NV_STRING)
g_free (nv->v.s);
g_free (nv);
{
static GType t = 0;
- if (t == 0 )
+ if (t == 0)
{
t = g_boxed_type_register_static ("psppire-recode-new-values",
(GBoxedCopyFunc) new_value_copy,
on_string_toggled (GtkToggleButton *b, PsppireDialogActionRecode *rd)
{
gboolean active;
- if (! rd->input_var_is_string )
+ if (! rd->input_var_is_string)
return ;
active = gtk_toggle_button_get_active (b);
static void
focus_value_entry (GtkWidget *w, PsppireDialogActionRecode *rd)
{
- if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
gtk_widget_grab_focus (rd->new_value_entry);
}
{
const gchar *text;
- if ( !gtk_toggle_button_get_active
+ if (!gtk_toggle_button_get_active
(GTK_TOGGLE_BUTTON (rd->toggle[BUTTON_NEW_VALUE])))
{
psppire_acr_set_enabled (PSPPIRE_ACR (rd->acr), TRUE);
struct old_value *ov = NULL;
struct new_value *nv = NULL;
- if ( ! gtk_tree_selection_get_selected (selection, &model, &iter) )
+ if (! gtk_tree_selection_get_selected (selection, &model, &iter))
return;
if (PSPPIRE_DIALOG_ACTION_RECODE_CLASS (G_OBJECT_GET_CLASS (rd))->target_is_string (rd))
nv.type = NV_STRING;
- if ( nv.type == NV_STRING )
+ if (nv.type == NV_STRING)
nv.v.s = g_strdup (text);
else
nv.v.v = g_strtod (text, 0);
{
PsppireDialogActionRecode *rd = data;
- switch ( col )
+ switch (col)
{
case COL_VALUE_OLD:
set_old_value (val, rd);
return TRUE;
}
+static void
+set_old_and_new_button_sensitivity (GtkTreeSelection *sel, PsppireDialogActionRecode *rd)
+{
+ GtkTreeModel *model = NULL;
+
+ GList *rows = gtk_tree_selection_get_selected_rows (sel, &model);
+
+ gtk_widget_set_sensitive (rd->old_and_new, rows != NULL);
+}
+
static void
run_old_and_new_dialog (PsppireDialogActionRecode *rd)
{
psppire_acr_set_model (PSPPIRE_ACR (rd->acr), NULL);
- if ( response == PSPPIRE_RESPONSE_CONTINUE )
+ if (response == PSPPIRE_RESPONSE_CONTINUE)
{
g_object_unref (rd->value_map);
rd->value_map = clone_list_store (local_store);
gtk_widget_set_sensitive (rd->change_button, FALSE);
gtk_widget_set_sensitive (rd->new_name_entry, FALSE);
gtk_widget_set_sensitive (rd->new_label_entry, FALSE);
+ gtk_widget_set_sensitive (rd->old_and_new, FALSE);
gtk_list_store_clear (GTK_LIST_STORE (rd->value_map));
}
GtkWidget *selector = get_widget_assert (xml, "psppire-selector1");
- GtkWidget *oldandnew = get_widget_assert (xml, "button1");
-
+ act->old_and_new = get_widget_assert (xml, "button1");
act->output_variable_box = get_widget_assert (xml,"frame4");
}
- g_signal_connect_swapped (oldandnew, "clicked",
+ g_signal_connect_swapped (act->old_and_new, "clicked",
G_CALLBACK (run_old_and_new_dialog), act);
+ GtkTreeSelection *sel =
+ gtk_tree_view_get_selection (GTK_TREE_VIEW (act->variable_treeview));
+ g_signal_connect (sel, "changed",
+ G_CALLBACK (set_old_and_new_button_sensitivity), act);
+
g_signal_connect (act->toggle[BUTTON_NEW_VALUE], "toggled",
G_CALLBACK (toggle_sensitivity), act->new_value_entry);
ds_put_cstr (&dds, "\n\t");
- if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->convert_button)))
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->convert_button)))
{
ds_put_cstr (&dds, "(CONVERT) ");
}