From: John Darrington Date: Sat, 21 Aug 2010 09:48:05 +0000 (+0200) Subject: Text input dialog: Use widget-io X-Git-Tag: sav-api~98 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=01e18746832583769419e3f59824b80229321275 Text input dialog: Use widget-io Use the widget_scanf function instead of manually juxtaposing widgets. This makes life a lot easier for translators. --- diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index 5560fba11e..5add061365 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -19,7 +19,7 @@ #include - +#include "widget-io.h" #include "checkbox-treeview.h" #include "descriptives-dialog.h" @@ -720,8 +720,7 @@ close_assistant (struct import_assistant *ia, int response) /* The "intro" page of the assistant. */ -static void on_intro_amount_changed (GtkToggleButton *button, - struct import_assistant *); +static void on_intro_amount_changed (struct import_assistant *); /* Initializes IA's intro substructure. */ static void @@ -730,21 +729,47 @@ init_intro_page (struct import_assistant *ia) GtkBuilder *builder = ia->asst.builder; struct intro_page *p = &ia->intro; struct string s; + GtkWidget *hbox_n_cases ; + GtkWidget *hbox_percent ; + GtkWidget *table ; + + + p->n_cases_spin = gtk_spin_button_new_with_range (0, INT_MAX, 100); + + hbox_n_cases = widget_scanf (_("Only the first %4d cases"), &p->n_cases_spin); + + table = get_widget_assert (builder, "button-table"); + + gtk_table_attach_defaults (GTK_TABLE (table), hbox_n_cases, + 1, 2, + 1, 2); + + p->percent_spin = gtk_spin_button_new_with_range (0, 100, 10); + + hbox_percent = widget_scanf (_("Only the first %3d %% of file (approximately)"), &p->percent_spin); + + gtk_table_attach_defaults (GTK_TABLE (table), hbox_percent, + 1, 2, + 2, 3); p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Intro"), GTK_ASSISTANT_PAGE_INTRO); + p->all_cases_button = get_widget_assert (builder, "import-all-cases"); + p->n_cases_button = get_widget_assert (builder, "import-n-cases"); - p->n_cases_spin = get_widget_assert (builder, "n-cases-spin"); + p->percent_button = get_widget_assert (builder, "import-percent"); - p->percent_spin = get_widget_assert (builder, "percent-spin"); - g_signal_connect (p->all_cases_button, "toggled", + + g_signal_connect_swapped (p->all_cases_button, "toggled", G_CALLBACK (on_intro_amount_changed), ia); - g_signal_connect (p->n_cases_button, "toggled", + g_signal_connect_swapped (p->n_cases_button, "toggled", G_CALLBACK (on_intro_amount_changed), ia); - g_signal_connect (p->percent_button, "toggled", + g_signal_connect_swapped (p->percent_button, "toggled", G_CALLBACK (on_intro_amount_changed), ia); + on_intro_amount_changed (ia); + ds_init_empty (&s); ds_put_cstr (&s, _("This assistant will guide you through the process of " "importing data into PSPP from a text file with one line " @@ -790,8 +815,7 @@ reset_intro_page (struct import_assistant *ia) /* Called when one of the radio buttons is clicked. */ static void -on_intro_amount_changed (GtkToggleButton *button UNUSED, - struct import_assistant *ia) +on_intro_amount_changed (struct import_assistant *ia) { struct intro_page *p = &ia->intro; @@ -799,7 +823,7 @@ on_intro_amount_changed (GtkToggleButton *button UNUSED, gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (p->n_cases_button))); - gtk_widget_set_sensitive (ia->intro.percent_spin, + gtk_widget_set_sensitive (p->percent_spin, gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (p->percent_button))); } diff --git a/src/ui/gui/text-data-import.ui b/src/ui/gui/text-data-import.ui index d3125921fb..d8a33d118a 100644 --- a/src/ui/gui/text-data-import.ui +++ b/src/ui/gui/text-data-import.ui @@ -42,136 +42,69 @@ The selected file contains N lines of text. Only the first M of these will be s GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 12 - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - vertical - 6 + 3 + 2 - All cases True True False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK True True - 0 + - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 6 - - - Only first - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - True - import-all-cases - - - False - False - 0 - - - - - True - False - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - adjustment2 - 10 - True - - - False - False - 1 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - cases - - - False - False - 2 - - + True + False + True + True + import-all-cases - False - False - 1 + 1 + 2 + - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 6 - - - Only first - True - True - False - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - True - import-all-cases - - - False - False - 0 - - - - - True - False - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - adjustment1 - True - - - False - False - 1 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - % of file (approximately) - - - False - False - 2 - - + True + False + True + True + import-all-cases - 2 + 2 + 3 + + + + + + True + 0 + All cases + + + 1 + 2 + + + + + + @@ -726,13 +659,11 @@ The selected file contains N lines of text. Only the first M of these will be s 100 1 10 - 0 1000 100000000 1 10 - 0