X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-dialog-action-var-info.c;h=998f7bb45c73c6e02f92c216dc35664d2051a43e;hb=dd0534adaf2831e6857185aa6580fa44aff19545;hp=a638be441fb6e17df561179122b92e3a59d1a795;hpb=3e98eec9f2c774a7c695944c15de651ecd120430;p=pspp diff --git a/src/ui/gui/psppire-dialog-action-var-info.c b/src/ui/gui/psppire-dialog-action-var-info.c index a638be441f..998f7bb45c 100644 --- a/src/ui/gui/psppire-dialog-action-var-info.c +++ b/src/ui/gui/psppire-dialog-action-var-info.c @@ -52,11 +52,11 @@ treeview_item_selected (gpointer data) GtkTreeView *tv = GTK_TREE_VIEW (pda->source); GtkTreeSelection *selection = gtk_tree_view_get_selection (tv); - return gtk_tree_selection_count_selected_rows (selection) > 0; + return gtk_tree_selection_count_selected_rows (selection) == 1; } static gchar * -generate_syntax__ (PsppireDialogAction *act, const char *prefix) +generate_syntax__ (const PsppireDialogAction *act, const char *prefix) { struct variable **vars; size_t n_vars; @@ -101,7 +101,7 @@ generate_syntax__ (PsppireDialogAction *act, const char *prefix) } static gchar * -generate_syntax (PsppireDialogAction *act) +generate_syntax (const PsppireDialogAction *act) { return generate_syntax__ (act, ""); } @@ -164,35 +164,40 @@ jump_to (PsppireDialog *d, gint response, gpointer data) } static void -psppire_dialog_action_var_info_activate (GtkAction *a) +psppire_dialog_action_var_info_activate (PsppireDialogAction *a) { PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionVarInfo *act = PSPPIRE_DIALOG_ACTION_VAR_INFO (pda); - GtkBuilder *xml = builder_new ("variable-info.ui"); - act->output = psppire_output_view_new ( - GTK_LAYOUT (get_widget_assert (xml, "layout1")), NULL, NULL, NULL); - - pda->dialog = get_widget_assert (xml, "variable-info-dialog"); - pda->source = get_widget_assert (xml, "treeview2"); - - g_object_set (pda->source, - "selection-mode", GTK_SELECTION_MULTIPLE, - NULL); - - g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (pda->source)), - "changed", G_CALLBACK (populate_output), - act); + GHashTable *thing = psppire_dialog_action_get_hash_table (pda); + GtkBuilder *xml = g_hash_table_lookup (thing, a); + if (!xml) + { + xml = builder_new ("variable-info.ui"); + g_hash_table_insert (thing, a, xml); + act->output = + psppire_output_view_new (GTK_LAYOUT (get_widget_assert (xml, "layout1")), + NULL, NULL, NULL); + + pda->dialog = get_widget_assert (xml, "variable-info-dialog"); + pda->source = get_widget_assert (xml, "treeview2"); - g_signal_connect (pda->dialog, "response", G_CALLBACK (jump_to), - pda); + g_object_set (pda->source, + "selection-mode", GTK_SELECTION_MULTIPLE, + NULL); - psppire_dialog_action_set_valid_predicate (pda, - treeview_item_selected); + g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (pda->source)), + "changed", G_CALLBACK (populate_output), + act); - g_object_unref (xml); + g_signal_connect (pda->dialog, "response", G_CALLBACK (jump_to), + pda); + psppire_dialog_action_set_valid_predicate (pda, + treeview_item_selected); + } + if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_var_info_parent_class)->activate) PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_var_info_parent_class)->activate (pda); } @@ -200,9 +205,7 @@ psppire_dialog_action_var_info_activate (GtkAction *a) static void psppire_dialog_action_var_info_class_init (PsppireDialogActionVarInfoClass *class) { - GtkActionClass *action_class = GTK_ACTION_CLASS (class); - - action_class->activate = psppire_dialog_action_var_info_activate; + psppire_dialog_action_set_activation (class, psppire_dialog_action_var_info_activate); PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax; }