X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-dialog-action-aggregate.c;h=33f6d78f5318c194d8f879e6ead506a509a560b8;hb=00d5ccd2b3072493b84dbf85b40467ef0a2c1df8;hp=66dda9edcd47bef4df1a3cad0c064f3d11757c4b;hpb=258cbd9cdf386687122b0854274923acafc786d4;p=pspp diff --git a/src/ui/gui/psppire-dialog-action-aggregate.c b/src/ui/gui/psppire-dialog-action-aggregate.c index 66dda9edcd..33f6d78f53 100644 --- a/src/ui/gui/psppire-dialog-action-aggregate.c +++ b/src/ui/gui/psppire-dialog-action-aggregate.c @@ -62,7 +62,7 @@ append_summary_variable_syntax (const PsppireDialogActionAggregate *agg, GStrin for (ok = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (acr_model), &iter); ok ; ok = gtk_tree_model_iter_next (GTK_TREE_MODEL (acr_model), &iter) - ) +) { g_string_append (string, "\n\t/"); @@ -73,7 +73,7 @@ append_summary_variable_syntax (const PsppireDialogActionAggregate *agg, GStrin static void append_destination_filename (const PsppireDialogActionAggregate *agg, GString *gs) { - if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (agg->filename_radiobutton))) + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (agg->filename_radiobutton))) { struct string ss; const gchar *s = gtk_label_get_text (GTK_LABEL (agg->filename_label)); @@ -86,7 +86,7 @@ append_destination_filename (const PsppireDialogActionAggregate *agg, GString *g { g_string_append (gs, "* "); - if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (agg->replace_radiobutton))) + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (agg->replace_radiobutton))) g_string_append (gs, "MODE=REPLACE"); else g_string_append (gs, "MODE=ADDVARIABLES"); @@ -105,7 +105,7 @@ generate_syntax (const PsppireDialogAction *act) append_destination_filename (agg, string); - if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (agg->sorted_button))) + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (agg->sorted_button))) g_string_append (string, "\n\t/PRESORTED"); g_string_append (string, "\n\t/BREAK="); @@ -132,12 +132,12 @@ dialog_state_valid (gpointer user_data) GtkTreeModel *liststore = gtk_tree_view_get_model (GTK_TREE_VIEW (agg->break_variables)); - if ( ! gtk_tree_model_get_iter_first (liststore, &iter)) + if (! gtk_tree_model_get_iter_first (liststore, &iter)) return FALSE; liststore = GTK_TREE_MODEL (PSPPIRE_ACR (agg->summary_acr)->list_store); - - if ( ! gtk_tree_model_get_iter_first (liststore, &iter)) + + if (! gtk_tree_model_get_iter_first (liststore, &iter)) return FALSE; return TRUE; @@ -168,7 +168,7 @@ refresh (PsppireDialogAction *fd_) gtk_entry_set_text (GTK_ENTRY (agg->summary_var_name_entry), "N_BREAK"); gtk_editable_select_region (GTK_EDITABLE (agg->summary_var_name_entry), 0, -1); - gtk_combo_box_set_active (GTK_COMBO_BOX (agg->function_combo), N); + gtk_combo_box_set_active (GTK_COMBO_BOX (agg->function_combo), AGRF_N); gtk_list_store_clear (PSPPIRE_ACR (agg->summary_acr)->list_store); @@ -194,12 +194,12 @@ render_summary (GtkTreeViewColumn *tree_column, gpointer data) { PsppireDialogActionAggregate *agg = data; - + GString *string = g_string_new (""); append_summary_spec (agg, iter, string); - + g_object_set (cell, "text", string->str, NULL); g_string_free (string, TRUE); @@ -216,7 +216,7 @@ choose_filename (PsppireDialogActionAggregate *fd) _("Cancel"), GTK_RESPONSE_CANCEL, _("Save"), GTK_RESPONSE_ACCEPT, NULL); - + g_object_set (dialog, "local-only", FALSE, NULL); gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE); @@ -287,7 +287,7 @@ populate_combo_model (GtkComboBox *cb) } -enum +enum { SUMMARY_COL_VARNAME = 0, SUMMARY_COL_VARLABEL, @@ -354,7 +354,7 @@ summary_complete (const PsppireDialogActionAggregate *agg) gboolean ok; GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (agg->function_combo)); - if ( 0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_var_name_entry)))) + if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_var_name_entry)))) return FALSE; ok = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (agg->function_combo), &iter); @@ -370,19 +370,19 @@ summary_complete (const PsppireDialogActionAggregate *agg) COMBO_MODEL_COL_SRC_VARS, &src_vars, -1); - if ( src_vars == AGR_SV_YES ) + if (src_vars == AGR_SV_YES) { if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_sv_entry)))) return FALSE; } - if ( n_args >= 2) + if (n_args >= 2) { if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_arg2_entry)))) return FALSE; } - if ( n_args >= 1) + if (n_args >= 1) { if (0 == strcmp ("", gtk_entry_get_text (GTK_ENTRY (agg->summary_arg1_entry)))) return FALSE; @@ -416,7 +416,7 @@ on_acr_change (const PsppireDialogActionAggregate *agg, GtkTreeView *tv) double arg1, arg2; gchar *text1 = g_strdup (""); gchar *text2 = g_strdup (""); - + GtkTreeIter iter; GtkTreeModel *model = gtk_tree_view_get_model (tv); GtkTreeSelection *sel = gtk_tree_view_get_selection (tv); @@ -434,7 +434,7 @@ on_acr_change (const PsppireDialogActionAggregate *agg, GtkTreeView *tv) gtk_entry_set_text (GTK_ENTRY (agg->summary_var_name_entry), varname); gtk_entry_set_text (GTK_ENTRY (agg->summary_var_label_entry), label); gtk_entry_set_text (GTK_ENTRY (agg->summary_sv_entry), srcvar); - + text1 = c_xasprintf ("%.*g", DBL_DIG + 1, arg1); text2 = c_xasprintf ("%.*g", DBL_DIG + 1, arg2); } @@ -457,7 +457,7 @@ update_arguments (PsppireDialogActionAggregate *agg) gboolean ok = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (agg->function_combo), &iter); - if ( ok) + if (ok) { GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (agg->function_combo)); int n_args; @@ -482,124 +482,116 @@ update_arguments (PsppireDialogActionAggregate *agg) -static void -psppire_dialog_action_aggregate_activate (PsppireDialogAction *a) +static GtkBuilder * +psppire_dialog_action_aggregate_activate (PsppireDialogAction *a, GVariant *param) { PsppireDialogActionAggregate *act = PSPPIRE_DIALOG_ACTION_AGGREGATE (a); PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); - GHashTable *thing = psppire_dialog_action_get_hash_table (pda); - GtkBuilder *xml = g_hash_table_lookup (thing, a); - if (!xml) - { - xml = builder_new ("aggregate.ui"); - g_hash_table_insert (thing, a, xml); - + GtkBuilder *xml = builder_new ("aggregate.ui"); - pda->dialog = get_widget_assert (xml, "aggregate-dialog"); - pda->source = get_widget_assert (xml, "dict-view"); + pda->dialog = get_widget_assert (xml, "aggregate-dialog"); + pda->source = get_widget_assert (xml, "dict-view"); + GtkWidget *break_selector = get_widget_assert (xml, "break-selector"); + act->pane = get_widget_assert (xml, "hbox1"); - GtkWidget *break_selector = get_widget_assert (xml, "break-selector"); + act->break_variables = get_widget_assert (xml, "psppire-var-view1"); + act->filename_radiobutton = get_widget_assert (xml, "filename-radiobutton"); + act->filename_button = get_widget_assert (xml, "filename-button"); + act->filename_box = get_widget_assert (xml, "filename-box"); + act->filename_label = get_widget_assert (xml, "filename-label"); + act->replace_radiobutton = get_widget_assert (xml, "replace-radiobutton"); + act->add_radiobutton = get_widget_assert (xml, "add-radiobutton"); + act->function_combo = get_widget_assert (xml, "function-combo"); - act->pane = get_widget_assert (xml, "hbox1"); - - act->break_variables = get_widget_assert (xml, "psppire-var-view1"); - act->filename_radiobutton = get_widget_assert (xml, "filename-radiobutton"); - act->filename_button = get_widget_assert (xml, "filename-button"); - act->filename_box = get_widget_assert (xml, "filename-box"); - act->filename_label = get_widget_assert (xml, "filename-label"); - act->replace_radiobutton = get_widget_assert (xml, "replace-radiobutton"); - act->add_radiobutton = get_widget_assert (xml, "add-radiobutton"); - act->function_combo = get_widget_assert (xml, "function-combo"); + act->summary_acr = get_widget_assert (xml, "psppire-acr1"); + act->summary_var_name_entry = get_widget_assert (xml, "summary-var-name-entry"); - act->summary_acr = get_widget_assert (xml, "psppire-acr1"); - act->summary_var_name_entry = get_widget_assert (xml, "summary-var-name-entry"); + act->summary_arg1 = get_widget_assert (xml, "summary-arg1"); + act->summary_arg2 = get_widget_assert (xml, "summary-arg2"); - act->summary_arg1 = get_widget_assert (xml, "summary-arg1"); - act->summary_arg2 = get_widget_assert (xml, "summary-arg2"); + act->summary_arg1_entry = get_widget_assert (xml, "summary-arg-entry1"); + act->summary_arg2_entry = get_widget_assert (xml, "summary-arg-entry2"); - act->summary_arg1_entry = get_widget_assert (xml, "summary-arg-entry1"); - act->summary_arg2_entry = get_widget_assert (xml, "summary-arg-entry2"); + act->summary_var_label_entry = get_widget_assert (xml, "summary-var-label-entry"); - act->summary_var_label_entry = get_widget_assert (xml, "summary-var-label-entry"); + act->summary_sv = get_widget_assert (xml, "source-var"); + act->summary_sv_entry = get_widget_assert (xml, "source-var-entry"); - act->summary_sv = get_widget_assert (xml, "source-var"); - act->summary_sv_entry = get_widget_assert (xml, "source-var-entry"); + act->sorted_button = get_widget_assert (xml, "sorted-radiobutton"); + act->needs_sort_button = get_widget_assert (xml, "needs-sort-radiobutton"); - act->sorted_button = get_widget_assert (xml, "sorted-radiobutton"); - act->needs_sort_button = get_widget_assert (xml, "needs-sort-radiobutton"); + { + GtkTreeViewColumn *column ; - { - GtkTreeViewColumn *column ; + GList *l ; - GList *l ; + GtkCellRenderer *cell_renderer ; - GtkCellRenderer *cell_renderer ; + GtkListStore *list = gtk_list_store_new (6, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_INT, + G_TYPE_STRING, + G_TYPE_DOUBLE, + G_TYPE_DOUBLE); - GtkListStore *list = gtk_list_store_new (6, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_INT, - G_TYPE_STRING, - G_TYPE_DOUBLE, - G_TYPE_DOUBLE); + psppire_acr_set_model (PSPPIRE_ACR (act->summary_acr), list); + g_object_unref (list); - psppire_acr_set_model (PSPPIRE_ACR (act->summary_acr), list); - g_object_unref (list); + psppire_acr_set_get_value_func (PSPPIRE_ACR (act->summary_acr), + get_summary_spec, act); - psppire_acr_set_get_value_func (PSPPIRE_ACR (act->summary_acr), - get_summary_spec, act); + column = gtk_tree_view_get_column (PSPPIRE_ACR (act->summary_acr)->tv, 0); - column = gtk_tree_view_get_column (PSPPIRE_ACR (act->summary_acr)->tv, 0); + l = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); - l = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); + cell_renderer = l->data; - cell_renderer = l->data; + gtk_tree_view_column_set_cell_data_func (column, + cell_renderer, + render_summary, + act, + NULL); - gtk_tree_view_column_set_cell_data_func (column, - cell_renderer, - render_summary, - act, - NULL); + g_signal_connect_swapped (PSPPIRE_ACR (act->summary_acr)->tv, + "cursor-changed", G_CALLBACK (on_acr_change), act); + } - g_signal_connect_swapped (PSPPIRE_ACR (act->summary_acr)->tv, - "cursor-changed", G_CALLBACK (on_acr_change), act); - } - - g_signal_connect_swapped (act->summary_var_name_entry, "changed", G_CALLBACK (update_acr), act); - g_signal_connect_swapped (act->function_combo, "changed", G_CALLBACK (update_acr), act); - g_signal_connect_swapped (act->summary_sv_entry, "changed", G_CALLBACK (update_acr), act); - g_signal_connect_swapped (act->summary_arg1_entry, "changed", G_CALLBACK (update_acr), act); - g_signal_connect_swapped (act->summary_arg2_entry, "changed", G_CALLBACK (update_acr), act); + g_signal_connect_swapped (act->summary_var_name_entry, "changed", G_CALLBACK (update_acr), act); + g_signal_connect_swapped (act->function_combo, "changed", G_CALLBACK (update_acr), act); + g_signal_connect_swapped (act->summary_sv_entry, "changed", G_CALLBACK (update_acr), act); + g_signal_connect_swapped (act->summary_arg1_entry, "changed", G_CALLBACK (update_acr), act); + g_signal_connect_swapped (act->summary_arg2_entry, "changed", G_CALLBACK (update_acr), act); - g_signal_connect_swapped (act->function_combo, "changed", - G_CALLBACK (update_arguments), act); + g_signal_connect_swapped (act->function_combo, "changed", + G_CALLBACK (update_arguments), act); - populate_combo_model (GTK_COMBO_BOX (act->function_combo)); + populate_combo_model (GTK_COMBO_BOX (act->function_combo)); - psppire_selector_set_filter_func (PSPPIRE_SELECTOR (break_selector), NULL); + psppire_selector_set_filter_func (PSPPIRE_SELECTOR (break_selector), NULL); - g_signal_connect (act->filename_radiobutton, "toggled", - G_CALLBACK (set_sensitivity_from_toggle), act->filename_box ); + g_signal_connect (act->filename_radiobutton, "toggled", + G_CALLBACK (set_sensitivity_from_toggle), act->filename_box); - g_signal_connect_swapped (act->filename_button, "clicked", - G_CALLBACK (choose_filename), act); + g_signal_connect_swapped (act->filename_button, "clicked", + G_CALLBACK (choose_filename), act); - psppire_dialog_action_set_refresh (pda, refresh); - psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); - } + psppire_dialog_action_set_refresh (pda, refresh); + psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); + return xml; } static void psppire_dialog_action_aggregate_class_init (PsppireDialogActionAggregateClass *class) { - psppire_dialog_action_set_activation (class, psppire_dialog_action_aggregate_activate); + PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_aggregate_activate; PSPPIRE_DIALOG_ACTION_CLASS (class)->generate_syntax = generate_syntax; } @@ -658,20 +650,20 @@ append_summary_spec (const PsppireDialogActionAggregate *agg, GtkTreeIter *iter, g_string_append (string, ds_cstr (&ss)); ds_destroy (&ss); } - + g_string_append_printf (string, " = %s", funcname); - if ( has_src_vars != AGR_SV_NO) + if (has_src_vars != AGR_SV_NO) { struct string dss; ds_init_cstr (&dss, " ("); - + ds_put_cstr (&dss, srcvar); - if ( arity > 0) + if (arity > 0) ds_put_c_format (&dss, ", %.*g", DBL_DIG + 1, arg1); - if ( arity > 1) + if (arity > 1) ds_put_c_format (&dss, ", %.*g", DBL_DIG + 1, arg2); ds_put_cstr (&dss, ")");