X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-dialog-action-sort.c;h=7dfb0b278ce895ba3f50ef7fb667e9fb7132d5c1;hb=95008dd8d8a668c4e7163486835e32d1755b8269;hp=2a80a6e7dc5471ba5830135e6b614de43979cdaf;hpb=24ab436df2f3f115c1cb949dbf0a932cda7667b2;p=pspp diff --git a/src/ui/gui/psppire-dialog-action-sort.c b/src/ui/gui/psppire-dialog-action-sort.c index 2a80a6e7dc..7dfb0b278c 100644 --- a/src/ui/gui/psppire-dialog-action-sort.c +++ b/src/ui/gui/psppire-dialog-action-sort.c @@ -30,22 +30,24 @@ static void psppire_dialog_action_sort_class_init (PsppireDialogActionSortC G_DEFINE_TYPE (PsppireDialogActionSort, psppire_dialog_action_sort, PSPPIRE_TYPE_DIALOG_ACTION); static char * -generate_syntax (PsppireDialogAction *act) +generate_syntax (const PsppireDialogAction *act) { PsppireDialogActionSort *scd = PSPPIRE_DIALOG_ACTION_SORT (act); gchar *text; GString *string = g_string_new ("SORT CASES BY "); - gint n_vars = psppire_var_view_append_names (scd->variables, 0, string); + PsppireVarView *var_view = PSPPIRE_VAR_VIEW (scd->variables); + gint n_vars = psppire_var_view_append_names (var_view, 0, string); - if ( n_vars == 0 ) + if (n_vars == 0) { g_string_assign (string, ""); } else { const char up_down = - gtk_toggle_button_get_active (scd->ascending) ? 'A' : 'D'; + (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (scd->ascending)) + ? 'A' : 'D'); g_string_append_printf (string, "(%c)", up_down); g_string_append (string, "."); } @@ -66,58 +68,55 @@ reset (PsppireDialogAction *act) gtk_list_store_clear (GTK_LIST_STORE (liststore)); - gtk_toggle_button_set_active (scd->ascending, TRUE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scd->ascending), TRUE); } static gboolean -dialog_state_valid (PsppireDialogAction *act) +dialog_state_valid (gpointer act) { PsppireDialogActionSort *scd = PSPPIRE_DIALOG_ACTION_SORT (act); GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (scd->variables)); gint n_rows = gtk_tree_model_iter_n_children (model, NULL); - if ( n_rows == 0 ) + if (n_rows == 0) return FALSE; return TRUE; } -static void -psppire_dialog_action_sort_activate (GtkAction *a) +static GtkBuilder * +psppire_dialog_action_sort_activate (PsppireDialogAction *a, GVariant *param) { PsppireDialogAction *pda = PSPPIRE_DIALOG_ACTION (a); PsppireDialogActionSort *act = PSPPIRE_DIALOG_ACTION_SORT (a); GtkBuilder *xml = builder_new ("sort.ui"); - pda->dialog = get_widget_assert (xml, "sort-cases-dialog"); - pda->source = get_widget_assert (xml, "sort-cases-treeview1"); - - act->variables = get_widget_assert (xml, "sort-cases-treeview2"); + + pda->dialog = get_widget_assert (xml, "sort-cases-dialog"); + pda->source = get_widget_assert (xml, "sort-cases-treeview1"); + + act->variables = get_widget_assert (xml, "sort-cases-treeview2"); act->ascending = get_widget_assert (xml, "sort-cases-radiobutton0"); psppire_dialog_action_set_refresh (pda, reset); psppire_dialog_action_set_valid_predicate (pda, dialog_state_valid); - - if (PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_sort_parent_class)->activate) - PSPPIRE_DIALOG_ACTION_CLASS (psppire_dialog_action_sort_parent_class)->activate (pda); + return xml; } static void psppire_dialog_action_sort_class_init (PsppireDialogActionSortClass *class) { - GtkActionClass *action_class = GTK_ACTION_CLASS (class); - PsppireDialogActionClass *pdac = PSPPIRE_DIALOG_ACTION_CLASS (class); - - action_class->activate = psppire_dialog_action_sort_activate; + PsppireDialogActionClass *pdac = PSPPIRE_DIALOG_ACTION_CLASS (class); + PSPPIRE_DIALOG_ACTION_CLASS (class)->initial_activate = psppire_dialog_action_sort_activate; - pdac->generate_syntax = generate_syntax; + pdac->generate_syntax = generate_syntax; }