Enabled Edit->Clear in variable sheet
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 26 Dec 2006 21:32:09 +0000 (21:32 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 26 Dec 2006 21:32:09 +0000 (21:32 +0000)
src/ui/gui/ChangeLog
src/ui/gui/data-editor.c
src/ui/gui/data-editor.glade

index 7297a9a6f1af76ada17226fda1eb14a08380a166..a27cd0660b55f065fea74868d9d43e4248d42495 100644 (file)
@@ -1,3 +1,8 @@
+Mon Dec 25 12:38:24 WST 2006 John Darrington <john@darrington.wattle.id.au>
+
+       * data-editor.c data-editor.glade: Enabled deleting of variables from
+       the variable sheet.
+
 Mon Dec 25 11:28:29 WST 2006 John Darrington <john@darrington.wattle.id.au>
 
        * psppire-dict.c psppire-dict.h: Removed explicit signal emit calls.
index d37e52ebf8b5cf2e0a27a9da73a711e6e055b97b..61b5aea0228975867f5ba32fab7d20bb51cf9caf 100644 (file)
@@ -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 ();
+    }
+}
index 6962555f87c85b88d32baa520cc4fa24da86f104..037cee9c0f84588cd57e774df2567bce66fe4016 100644 (file)
          </child>
 
          <child>
-           <widget class="GtkMenuItem" id="menuitem2">
+           <widget class="GtkMenuItem" id="edit">
              <property name="visible">True</property>
-             <property name="sensitive">False</property>
+             <property name="sensitive">True</property>
              <property name="label" translatable="yes">_Edit</property>
              <property name="use_underline">True</property>
 
                  </child>
 
                  <child>
-                   <widget class="GtkMenuItem" id="clear1">
+                   <widget class="GtkMenuItem" id="edit_clear">
                      <property name="visible">True</property>
+                     <property name="sensitive">False</property>
                      <property name="label" translatable="yes">Cl_ear</property>
                      <property name="use_underline">True</property>
-                     <signal name="activate" handler="on_clear_activate" last_modification_time="Sun, 02 Jul 2006 07:00:12 GMT"/>
                      <accelerator key="Delete" modifiers="0" signal="activate"/>
                    </widget>
                  </child>