From: John Darrington <john@darrington.wattle.id.au> Date: Sun, 8 Jul 2007 02:39:10 +0000 (+0000) Subject: Implemented the goto-case dialog X-Git-Tag: sav-api~1412 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=82d3fc0e14c1465eb2d1de00796317d062151fe0;p=pspp Implemented the goto-case dialog --- diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index 2ac8567c36..a9d7c532f4 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,11 @@ +2007-07-08 John Darrington <john@darrington.wattle.id.au> + + * goto-case-dialog.c goto-case-dialog.h (new files) + * automake.mk data-editor.c data-editor.glade data-editor.h + psppire-case-file.c psppire-case-file.h psppire-data-store.c + psppire-data-store.h psppire.glade : Implemented the goto-case dialog + + 2007-07-07 John Darrington <john@darrington.wattle.id.au> * psppire-data-store.c psppire-data-store.h: Made cases number from diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 9e15fda651..9b5d4154cd 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -77,6 +77,8 @@ src_ui_gui_psppire_SOURCES = \ src/ui/gui/comments-dialog.h \ src/ui/gui/customentry.c \ src/ui/gui/customentry.h \ + src/ui/gui/goto-case-dialog.c \ + src/ui/gui/goto-case-dialog.h \ src/ui/gui/data-sheet.c \ src/ui/gui/data-sheet.h \ src/ui/gui/data-editor.c \ diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c index 30e587ef5c..982b6983a8 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/data-editor.c @@ -33,6 +33,7 @@ #include "transpose-dialog.h" #include "sort-cases-dialog.h" #include "compute-dialog.h" +#include "goto-case-dialog.h" #include "comments-dialog.h" #include "variable-info-dialog.h" #include "dict-display.h" @@ -248,6 +249,13 @@ new_data_editor (void) G_CALLBACK (insert_variable), de); + + g_signal_connect (de->insert_variable, "activate", + G_CALLBACK (insert_variable), de); + + + + gtk_action_connect_proxy (de->insert_variable, get_widget_assert (de->xml, "button-insert-variable") ); @@ -256,6 +264,26 @@ new_data_editor (void) get_widget_assert (de->xml, "data_insert-variable") ); + de->invoke_goto_dialog = + gtk_action_new ("goto-case-dialog", + _("Goto Case"), + _("Jump to a Case in the Data Sheet"), + "gtk-jump-to"); + + + gtk_action_connect_proxy (de->invoke_goto_dialog, + get_widget_assert (de->xml, "button-goto-case") + ); + + gtk_action_connect_proxy (de->invoke_goto_dialog, + get_widget_assert (de->xml, "data_goto-case") + ); + + + g_signal_connect (de->invoke_goto_dialog, "activate", + G_CALLBACK (goto_case_dialog), de); + + de->invoke_weight_cases_dialog = gtk_action_new ("weight-cases-dialog", _("Weights"), @@ -619,13 +647,12 @@ select_sheet (struct data_editor *de, guint page_num) gtk_widget_show (view_data); gtk_widget_set_sensitive (insert_variable, TRUE); gtk_widget_set_sensitive (insert_cases, FALSE); + gtk_action_set_sensitive (de->invoke_goto_dialog, FALSE); break; case PAGE_DATA_SHEET: gtk_widget_show (view_variables); gtk_widget_hide (view_data); -#if 0 - gtk_widget_set_sensitive (insert_cases, TRUE); -#endif + gtk_action_set_sensitive (de->invoke_goto_dialog, TRUE); break; default: g_assert_not_reached (); diff --git a/src/ui/gui/data-editor.glade b/src/ui/gui/data-editor.glade index ade5f222bf..a4dbe64411 100644 --- a/src/ui/gui/data-editor.glade +++ b/src/ui/gui/data-editor.glade @@ -288,7 +288,7 @@ </widget> </child> <child> - <widget class="GtkImageMenuItem" id="go_to_case"> + <widget class="GtkImageMenuItem" id="data_goto-case"> <property name="visible">True</property> <property name="sensitive">False</property> <property name="label" translatable="yes">Go To Case</property> diff --git a/src/ui/gui/data-editor.h b/src/ui/gui/data-editor.h index de3a0c9c93..bc4a01ad4c 100644 --- a/src/ui/gui/data-editor.h +++ b/src/ui/gui/data-editor.h @@ -37,10 +37,9 @@ struct data_editor GtkAction *invoke_sort_cases_dialog; GtkAction *invoke_compute_dialog; GtkAction *invoke_comments_dialog; - + GtkAction *invoke_goto_dialog; GtkAction *invoke_variable_info_dialog; - GtkAction *insert_variable; GladeXML *xml; diff --git a/src/ui/gui/goto-case-dialog.c b/src/ui/gui/goto-case-dialog.c new file mode 100644 index 0000000000..32e93dbd4c --- /dev/null +++ b/src/ui/gui/goto-case-dialog.c @@ -0,0 +1,83 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2007 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + + +#include "goto-case-dialog.h" +#include "helper.h" +#include "psppire-dialog.h" +#include "data-editor.h" +#include "psppire-data-store.h" +#include <gtksheet/gtksheet.h> + + +static void +refresh (const struct data_editor *de, GladeXML *xml) +{ + GtkSheet *data_sheet = + GTK_SHEET (get_widget_assert (de->xml, "data_sheet")); + + PsppireDataStore *ds = + PSPPIRE_DATA_STORE (gtk_sheet_get_model (data_sheet)); + + GtkWidget *case_num_entry = + get_widget_assert (xml, "goto-case-case-num-entry"); + + casenumber case_count = + psppire_data_store_get_case_count (ds); + + gtk_spin_button_set_range (GTK_SPIN_BUTTON (case_num_entry), + 1, case_count); +} + +void +goto_case_dialog (GObject *o, gpointer data) +{ + gint response; + GladeXML *xml = XML_NEW ("psppire.glade"); + struct data_editor *de = data; + + GtkWidget *dialog = get_widget_assert (xml, "goto-case-dialog"); + + + gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + + refresh (de, xml); + + response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); + + if ( response == PSPPIRE_RESPONSE_GOTO ) + { + gint row, column; + GtkSheet *data_sheet = + GTK_SHEET (get_widget_assert (de->xml, "data_sheet")); + + + GtkWidget *case_num_entry = + get_widget_assert (xml, "goto-case-case-num-entry"); + + gtk_sheet_get_active_cell (data_sheet, &row, &column); + + row = + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (case_num_entry)) + - FIRST_CASE_NUMBER ; + + gtk_sheet_moveto (data_sheet, + row, column, + 0.5, 0.5); + + gtk_sheet_set_active_cell (data_sheet, row, column); + } +} diff --git a/src/ui/gui/goto-case-dialog.h b/src/ui/gui/goto-case-dialog.h new file mode 100644 index 0000000000..536ccb08e8 --- /dev/null +++ b/src/ui/gui/goto-case-dialog.h @@ -0,0 +1,27 @@ +/* PSPPIRE - a graphical user interface for PSPP. + Copyright (C) 2007 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef __GOTO_CASE_DIALOG_H +#define __GOTO_CASE_DIALOG_H + + +#include <gtk/gtk.h> +#include <glade/glade.h> + + +void goto_case_dialog (GObject *o, gpointer data); + +#endif diff --git a/src/ui/gui/psppire-case-file.c b/src/ui/gui/psppire-case-file.c index 2401be4a27..32b3cb401f 100644 --- a/src/ui/gui/psppire-case-file.c +++ b/src/ui/gui/psppire-case-file.c @@ -223,7 +223,7 @@ psppire_case_file_append_case (PsppireCaseFile *cf, } -inline gint +inline casenumber psppire_case_file_get_case_count (const PsppireCaseFile *cf) { g_return_val_if_fail (cf, FALSE); diff --git a/src/ui/gui/psppire-case-file.h b/src/ui/gui/psppire-case-file.h index 7603b482ff..e11a4db482 100644 --- a/src/ui/gui/psppire-case-file.h +++ b/src/ui/gui/psppire-case-file.h @@ -71,7 +71,7 @@ PsppireCaseFile *psppire_case_file_new (const struct casereader *); gboolean psppire_case_file_insert_case (PsppireCaseFile *cf, struct ccase *c, gint row); -gint psppire_case_file_get_case_count (const PsppireCaseFile *cf); +casenumber psppire_case_file_get_case_count (const PsppireCaseFile *cf); union value * psppire_case_file_get_value (const PsppireCaseFile *cf, diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index 976c533da5..22bc10ee8d 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -159,8 +159,14 @@ psppire_data_store_get_var_count (const GSheetModel *model) return psppire_dict_get_var_cnt (store->dict); } +casenumber +psppire_data_store_get_case_count (PsppireDataStore *store) +{ + return psppire_case_file_get_case_count (store->case_file); +} + static gint -psppire_data_store_get_case_count (const GSheetModel *model) +psppire_data_store_get_case_count_from_model (const GSheetModel *model) { const PsppireDataStore *store = PSPPIRE_DATA_STORE (model); @@ -168,6 +174,8 @@ psppire_data_store_get_case_count (const GSheetModel *model) } + + static void psppire_data_store_init (PsppireDataStore *data_store) { @@ -219,7 +227,7 @@ psppire_data_store_sheet_model_init (GSheetModelIface *iface) iface->get_font_desc = psppire_data_store_get_font_desc; iface->get_cell_border = NULL; iface->get_column_count = psppire_data_store_get_var_count; - iface->get_row_count = psppire_data_store_get_case_count; + iface->get_row_count = psppire_data_store_get_case_count_from_model; } static diff --git a/src/ui/gui/psppire-data-store.h b/src/ui/gui/psppire-data-store.h index b58562b484..9857a7b1cf 100644 --- a/src/ui/gui/psppire-data-store.h +++ b/src/ui/gui/psppire-data-store.h @@ -108,6 +108,9 @@ gboolean psppire_data_store_set_string (PsppireDataStore *ds, const gchar *text, gint row, gint column); +casenumber psppire_data_store_get_case_count (PsppireDataStore *store); + + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/ui/gui/psppire.glade b/src/ui/gui/psppire.glade index abe19f4175..7949f52e9f 100644 --- a/src/ui/gui/psppire.glade +++ b/src/ui/gui/psppire.glade @@ -248,25 +248,36 @@ <property name="column_spacing">5</property> <property name="row_spacing">5</property> <child> - <widget class="PsppireSelector" id="psppire-selector2"> - <property name="visible">True</property> - <property name="border_width">5</property> - </widget> - <packing> - <property name="x_options"></property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="PsppireSelector" id="psppire-selector3"> + <widget class="GtkVBox" id="vbox5"> <property name="visible">True</property> - <property name="border_width">5</property> + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Name Variable:</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> + <widget class="GtkEntry" id="new-name-entry"> + <property name="visible">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> </widget> <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> <property name="top_attach">1</property> <property name="bottom_attach">2</property> - <property name="x_options"></property> - <property name="y_options">GTK_FILL</property> + <property name="y_options"></property> </packing> </child> <child> @@ -319,35 +330,24 @@ </packing> </child> <child> - <widget class="GtkVBox" id="vbox5"> + <widget class="PsppireSelector" id="psppire-selector3"> <property name="visible">True</property> - <child> - <widget class="GtkLabel" id="label4"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Name Variable:</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - <child> - <widget class="GtkEntry" id="new-name-entry"> - <property name="visible">True</property> - </widget> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> + <property name="border_width">5</property> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> <property name="top_attach">1</property> <property name="bottom_attach">2</property> + <property name="x_options"></property> + <property name="y_options">GTK_FILL</property> + </packing> + </child> + <child> + <widget class="PsppireSelector" id="psppire-selector2"> + <property name="visible">True</property> + <property name="border_width">5</property> + </widget> + <packing> + <property name="x_options"></property> <property name="y_options"></property> </packing> </child> @@ -1829,30 +1829,18 @@ <property name="n_rows">2</property> <property name="n_columns">2</property> <child> - <widget class="GtkRadioButton" id="radio-button-user-label"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="x_options"></property> - </packing> - </child> - <child> - <widget class="GtkRadioButton" id="radio-button-expression-label"> + <widget class="GtkLabel" id="label27"> <property name="visible">True</property> - <property name="can_focus">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - <property name="group">radio-button-user-label</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Use expression as label</property> </widget> <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> <property name="top_attach">1</property> <property name="bottom_attach">2</property> - <property name="x_options"></property> + <property name="y_options"></property> </packing> </child> <child> @@ -1889,18 +1877,30 @@ </packing> </child> <child> - <widget class="GtkLabel" id="label27"> + <widget class="GtkRadioButton" id="radio-button-expression-label"> <property name="visible">True</property> + <property name="can_focus">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Use expression as label</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">radio-button-user-label</property> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> <property name="top_attach">1</property> <property name="bottom_attach">2</property> - <property name="y_options"></property> + <property name="x_options"></property> + </packing> + </child> + <child> + <widget class="GtkRadioButton" id="radio-button-user-label"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="x_options"></property> </packing> </child> </widget> @@ -1938,47 +1938,6 @@ <property name="border_width">5</property> <property name="n_rows">2</property> <property name="n_columns">2</property> - <child> - <widget class="GtkLabel" id="label28"> - <property name="visible">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Numeric</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - </packing> - </child> - <child> - <widget class="GtkRadioButton" id="radio-button-numeric"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - <property name="group">radio-button-string</property> - </widget> - <packing> - <property name="x_options"></property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkRadioButton" id="radio-button-string"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options"></property> - <property name="y_options"></property> - </packing> - </child> <child> <widget class="GtkHBox" id="hbox20"> <property name="visible">True</property> @@ -2027,6 +1986,47 @@ <property name="x_options">GTK_FILL</property> </packing> </child> + <child> + <widget class="GtkRadioButton" id="radio-button-string"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkRadioButton" id="radio-button-numeric"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">radio-button-string</property> + </widget> + <packing> + <property name="x_options"></property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="label28"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Numeric</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + </packing> + </child> </widget> </child> </widget> @@ -2066,4 +2066,62 @@ </widget> </child> </widget> + <widget class="PsppireDialog" id="goto-case-dialog"> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="title">Goto Case</property> + <property name="modal">True</property> + <property name="orientation">PSPPIRE_VERTICAL</property> + <child internal-child="hbox"> + <widget class="GtkVBox" id="dialog-hbox10"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="spacing">5</property> + <child> + <widget class="GtkHBox" id="hbox22"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="spacing">5</property> + <child> + <widget class="GtkLabel" id="label31"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Goto Case Number:</property> + </widget> + </child> + <child> + <widget class="GtkSpinButton" id="goto-case-case-num-entry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="adjustment">1 1 100 1 10 10</property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> + </widget> + <packing> + <property name="fill">False</property> + <property name="padding">5</property> + </packing> + </child> + <child> + <widget class="PsppireHButtonBox" id="psppire-hbuttonbox4"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="border_width">5</property> + <property name="layout_style">GTK_BUTTONBOX_SPREAD</property> + <property name="buttons">PSPPIRE_BUTTON_GOTO_MASK | PSPPIRE_BUTTON_CANCEL_MASK</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="pack_type">GTK_PACK_END</property> + <property name="position">1</property> + </packing> + </child> + </widget> + </child> + </widget> </glade-interface>