From 82d3fc0e14c1465eb2d1de00796317d062151fe0 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 8 Jul 2007 02:39:10 +0000 Subject: [PATCH] Implemented the goto-case dialog --- src/ui/gui/ChangeLog | 8 + src/ui/gui/automake.mk | 2 + src/ui/gui/data-editor.c | 33 +++- src/ui/gui/data-editor.glade | 2 +- src/ui/gui/data-editor.h | 3 +- src/ui/gui/goto-case-dialog.c | 83 ++++++++++ src/ui/gui/goto-case-dialog.h | 27 ++++ src/ui/gui/psppire-case-file.c | 2 +- src/ui/gui/psppire-case-file.h | 2 +- src/ui/gui/psppire-data-store.c | 12 +- src/ui/gui/psppire-data-store.h | 3 + src/ui/gui/psppire.glade | 264 +++++++++++++++++++------------- 12 files changed, 328 insertions(+), 113 deletions(-) create mode 100644 src/ui/gui/goto-case-dialog.c create mode 100644 src/ui/gui/goto-case-dialog.h diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index 2ac8567c..a9d7c532 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,11 @@ +2007-07-08 John Darrington + + * 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 * 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 9e15fda6..9b5d4154 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 30e587ef..982b6983 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 ade5f222..a4dbe644 100644 --- a/src/ui/gui/data-editor.glade +++ b/src/ui/gui/data-editor.glade @@ -288,7 +288,7 @@ - + True False Go To Case diff --git a/src/ui/gui/data-editor.h b/src/ui/gui/data-editor.h index de3a0c9c..bc4a01ad 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 00000000..32e93dbd --- /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 . */ + + +#include "goto-case-dialog.h" +#include "helper.h" +#include "psppire-dialog.h" +#include "data-editor.h" +#include "psppire-data-store.h" +#include + + +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 00000000..536ccb08 --- /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 . */ + +#ifndef __GOTO_CASE_DIALOG_H +#define __GOTO_CASE_DIALOG_H + + +#include +#include + + +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 2401be4a..32b3cb40 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 7603b482..e11a4db4 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 976c533d..22bc10ee 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 b58562b4..9857a7b1 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 abe19f41..7949f52e 100644 --- a/src/ui/gui/psppire.glade +++ b/src/ui/gui/psppire.glade @@ -248,25 +248,36 @@ 5 5 - - True - 5 - - - - - - - - + True - 5 + + + True + 0 + Name Variable: + + + False + False + + + + + True + + + False + False + 1 + + + 1 + 2 1 2 - - GTK_FILL + @@ -319,35 +330,24 @@ - + True - - - True - 0 - Name Variable: - - - False - False - - - - - True - - - False - False - 1 - - + 5 - 1 - 2 1 2 + + GTK_FILL + + + + + True + 5 + + + @@ -1829,30 +1829,18 @@ 2 2 - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - True - - - - - - - + True - True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - True - radio-button-user-label + 0 + Use expression as label + 1 + 2 1 2 - + @@ -1889,18 +1877,30 @@ - + True + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Use expression as label + True + True + radio-button-user-label - 1 - 2 1 2 - + + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + + + @@ -1938,47 +1938,6 @@ 5 2 2 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - Numeric - - - 1 - 2 - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - True - radio-button-string - - - - - - - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - True - True - - - 1 - 2 - - - - True @@ -2027,6 +1986,47 @@ GTK_FILL + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + + + 1 + 2 + + + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + True + True + radio-button-string + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + Numeric + + + 1 + 2 + + @@ -2066,4 +2066,62 @@ + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Goto Case + True + PSPPIRE_VERTICAL + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 + Goto Case Number: + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 1 100 1 10 10 + + + 1 + + + + + False + 5 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + GTK_BUTTONBOX_SPREAD + PSPPIRE_BUTTON_GOTO_MASK | PSPPIRE_BUTTON_CANCEL_MASK + + + False + False + GTK_PACK_END + 1 + + + + + -- 2.30.2