treewide: Replace <name>_cnt by n_<name>s and <name>_cap by allocated_<name>.
[pspp] / src / ui / gui / psppire-data-window.c
index 2f31923af286c0517ab5b796beaaa8321198a77e..ad7e9250f7d404389aefaa0e79bf55e23d2f32d3 100644 (file)
 struct session *the_session;
 struct ll_list all_data_windows = LL_INITIALIZER (all_data_windows);
 
-static void psppire_data_window_class_init    (PsppireDataWindowClass *class);
-static void psppire_data_window_init          (PsppireDataWindow      *data_editor);
-
-
 static void psppire_data_window_iface_init (PsppireWindowIface *iface);
 
 static void psppire_data_window_dispose (GObject *object);
@@ -118,45 +114,10 @@ static void psppire_data_window_get_property (GObject         *object,
                                               GValue          *value,
                                               GParamSpec      *pspec);
 
-GType
-psppire_data_window_get_type (void)
-{
-  static GType psppire_data_window_type = 0;
-
-  if (!psppire_data_window_type)
-    {
-      static const GTypeInfo psppire_data_window_info =
-       {
-         sizeof (PsppireDataWindowClass),
-         NULL,
-         NULL,
-         (GClassInitFunc)psppire_data_window_class_init,
-         (GClassFinalizeFunc) NULL,
-         NULL,
-         sizeof (PsppireDataWindow),
-         0,
-         (GInstanceInitFunc) psppire_data_window_init,
-       };
-
-      static const GInterfaceInfo window_interface_info =
-       {
-         (GInterfaceInitFunc) psppire_data_window_iface_init,
-         NULL,
-         NULL
-       };
-
-      psppire_data_window_type =
-       g_type_register_static (PSPPIRE_TYPE_WINDOW, "PsppireDataWindow",
-                               &psppire_data_window_info, 0);
 
-
-      g_type_add_interface_static (psppire_data_window_type,
-                                  PSPPIRE_TYPE_WINDOW_MODEL,
-                                  &window_interface_info);
-    }
-
-  return psppire_data_window_type;
-}
+G_DEFINE_TYPE_WITH_CODE (PsppireDataWindow, psppire_data_window, PSPPIRE_TYPE_WINDOW,
+                        G_IMPLEMENT_INTERFACE (PSPPIRE_TYPE_WINDOW_MODEL,
+                                               psppire_data_window_iface_init))
 
 static GObjectClass *parent_class ;
 
@@ -253,7 +214,7 @@ on_split_change (PsppireDict *dict, gpointer data)
 {
   PsppireDataWindow  *de = PSPPIRE_DATA_WINDOW (data);
 
-  size_t n_split_vars = dict_get_split_cnt (dict->dict);
+  size_t n_split_vars = dict_get_n_splits (dict->dict);
 
   GtkWidget *split_status_area =
     get_widget_assert (de->builder, "split-file-status-area");
@@ -938,7 +899,7 @@ set_unsaved (gpointer w)
 static void
 enable_save (PsppireDataWindow *dw)
 {
-  gboolean enable = psppire_dict_get_var_cnt (dw->dict) > 0;
+  gboolean enable = psppire_dict_get_n_vars (dw->dict) > 0;
 
   GAction *save_as = g_action_map_lookup_action (G_ACTION_MAP (dw), "save-as");
   GAction *save = g_action_map_lookup_action (G_ACTION_MAP (dw), "save");
@@ -1076,6 +1037,19 @@ on_cut (PsppireDataWindow *dw)
       if (ssw_sheet_try_cut (sheet))
        return;
 
+      if (sel.start_x > sel.end_x)
+       {
+         gint tmp = sel.start_x;
+         sel.start_x = sel.end_x;
+         sel.end_x = tmp;
+       }
+      if (sel.start_y > sel.end_y)
+       {
+         gint tmp = sel.start_y;
+         sel.start_y = sel.end_y;
+         sel.end_y = tmp;
+       }
+         
       GtkClipboard *clip =
        gtk_clipboard_get_for_display (gtk_widget_get_display (GTK_WIDGET (dw)),
                                       GDK_SELECTION_CLIPBOARD);
@@ -1946,7 +1920,7 @@ psppire_data_window_new (struct dataset *ds)
 bool
 psppire_data_window_is_empty (PsppireDataWindow *dw)
 {
-  return psppire_dict_get_var_cnt (dw->dict) == 0;
+  return psppire_dict_get_n_vars (dw->dict) == 0;
 }