From c2362c315ddb57dfeed99c240ef4f58ec2aeaa4d Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 26 Dec 2006 21:32:09 +0000 Subject: [PATCH] Enabled Edit->Clear in variable sheet --- src/ui/gui/ChangeLog | 5 +++ src/ui/gui/data-editor.c | 84 ++++++++++++++++++++++++++++++++++++ src/ui/gui/data-editor.glade | 8 ++-- 3 files changed, 93 insertions(+), 4 deletions(-) diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog index 7297a9a6..a27cd066 100644 --- a/src/ui/gui/ChangeLog +++ b/src/ui/gui/ChangeLog @@ -1,3 +1,8 @@ +Mon Dec 25 12:38:24 WST 2006 John Darrington + + * data-editor.c data-editor.glade: Enabled deleting of variables from + the variable sheet. + Mon Dec 25 11:28:29 WST 2006 John Darrington * psppire-dict.c psppire-dict.h: Removed explicit signal emit calls. diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c index d37e52eb..61b5aea0 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/data-editor.c @@ -40,6 +40,7 @@ #include "psppire-data-store.h" #include "psppire-var-store.h" + /* Switch between the VAR SHEET and the DATA SHEET */ enum {PAGE_DATA_SHEET = 0, PAGE_VAR_SHEET}; @@ -72,6 +73,31 @@ static void value_labels_toggled (GtkToggleToolButton *, gpointer); static void file_quit (GtkCheckMenuItem *, gpointer ); +static void on_clear_activate (GtkMenuItem *, gpointer); + +static void +enable_edit_clear (GtkWidget *w, gint row, gpointer data) +{ + struct data_editor *de = data; + + GtkWidget *menuitem = get_widget_assert (de->xml, "edit_clear"); + + gtk_widget_set_sensitive (menuitem, TRUE); +} + +static gboolean +disable_edit_clear (GtkWidget *w, gint x, gint y, gpointer data) +{ + struct data_editor *de = data; + + GtkWidget *menuitem = get_widget_assert (de->xml, "edit_clear"); + + gtk_widget_set_sensitive (menuitem, FALSE); + + return FALSE; +} + + /* Create a new data editor. @@ -110,6 +136,14 @@ new_data_editor (void) G_CALLBACK (open_syntax_window), e->window); + + g_signal_connect (get_widget_assert (de->xml,"edit_clear"), + "activate", + G_CALLBACK (on_clear_activate), + de); + + + g_signal_connect (get_widget_assert (de->xml,"help_about"), "activate", G_CALLBACK (about_new), @@ -128,6 +162,17 @@ new_data_editor (void) de); + g_signal_connect (get_widget_assert (de->xml, "variable_sheet"), + "select-row", + GTK_SIGNAL_FUNC (enable_edit_clear), + de); + + g_signal_connect (get_widget_assert (de->xml, "variable_sheet"), + "activate", + GTK_SIGNAL_FUNC (disable_edit_clear), + de); + + g_signal_connect (get_widget_assert (de->xml, "notebook"), "switch-page", G_CALLBACK (data_var_select), de); @@ -481,3 +526,42 @@ file_quit (GtkCheckMenuItem *menuitem, gpointer data) */ gtk_main_quit (); } + + + +/* Callback for when the Clear item in the edit menu is activated */ +static void +on_clear_activate (GtkMenuItem *menuitem, gpointer data) +{ + struct data_editor *de = data; + + GtkNotebook *notebook = GTK_NOTEBOOK (get_widget_assert (de->xml, + "notebook")); + + switch ( gtk_notebook_get_current_page (notebook) ) + { + case PAGE_VAR_SHEET: + { + GtkSheet *var_sheet = + GTK_SHEET (get_widget_assert (de->xml, "variable_sheet")); + + PsppireVarStore *vs = PSPPIRE_VAR_STORE + (gtk_sheet_get_model (var_sheet) ); + + /* This shouldn't be able to happen, because the menuitem + should be disabled */ + g_return_if_fail (var_sheet->state == GTK_SHEET_ROW_SELECTED ); + + psppire_dict_delete_variables (vs->dict, + var_sheet->range.row0, + 1 + + var_sheet->range.rowi - + var_sheet->range.row0 ); + } + break; + case PAGE_DATA_SHEET: + break; + default: + g_assert_not_reached (); + } +} diff --git a/src/ui/gui/data-editor.glade b/src/ui/gui/data-editor.glade index 6962555f..037cee9c 100644 --- a/src/ui/gui/data-editor.glade +++ b/src/ui/gui/data-editor.glade @@ -139,9 +139,9 @@ - + True - False + True _Edit True @@ -185,11 +185,11 @@ - + True + False Cl_ear True - -- 2.30.2