desktop: open a file via xdg-open without additional output window
[pspp] / src / ui / gui / psppire-data-editor.c
index 6e7a0369671ea715eda8f30e8cc124fb6b150ef7..44dd119974cb937d96b98b4b04516c50e06f6bef 100644 (file)
@@ -1,6 +1,6 @@
 /* PSPPIRE - a graphical user interface for PSPP.
    Copyright (C) 2008, 2009, 2010, 2011, 2012, 2016,
-   2017 Free Software Foundation, Inc.
+   2017, 2019 Free Software Foundation, Inc.
 
    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
@@ -138,7 +138,7 @@ psppire_data_editor_set_property (GObject         *object,
       g_object_set (de->var_sheet, "split", de->split, NULL);
       break;
     case PROP_DATA_STORE:
-      if ( de->data_store)
+      if (de->data_store)
         {
           g_signal_handlers_disconnect_by_func (de->data_store,
                                                 G_CALLBACK (refresh_entry),
@@ -269,7 +269,7 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass)
     g_param_spec_pointer ("data-store",
                          "Data Store",
                          "A pointer to the data store associated with this editor",
-                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE );
+                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE);
 
   g_object_class_install_property (object_class,
                                    PROP_DATA_STORE,
@@ -279,7 +279,7 @@ psppire_data_editor_class_init (PsppireDataEditorClass *klass)
     g_param_spec_pointer ("dictionary",
                          "Dictionary",
                          "A pointer to the dictionary associated with this editor",
-                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE );
+                         G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_READABLE);
 
   g_object_class_install_property (object_class,
                                    PROP_DICTIONARY,
@@ -437,12 +437,7 @@ static void set_font_recursively (GtkWidget *w, gpointer data);
 void
 psppire_data_editor_data_delete_variables (PsppireDataEditor *de)
 {
-  SswRange *range = SSW_SHEET(de->data_sheet)->selection;
-
-  psppire_dict_delete_variables (de->dict, range->start_x,
-                                (range->end_x - range->start_x + 1));
-
-  gtk_widget_queue_draw (GTK_WIDGET (de->data_sheet));
+  psppire_data_sheet_delete_variables (PSPPIRE_DATA_SHEET (de->data_sheet));
 }
 
 void
@@ -450,6 +445,13 @@ psppire_data_editor_var_delete_variables (PsppireDataEditor *de)
 {
   SswRange *range = SSW_SHEET(de->var_sheet)->selection;
 
+  if (range->start_x > range->end_x)
+    {
+      gint temp = range->start_x;
+      range->start_x = range->end_x;
+      range->end_x = temp;
+    }
+
   psppire_dict_delete_variables (de->dict, range->start_y,
                                 (range->end_y - range->start_y + 1));
 
@@ -469,13 +471,7 @@ psppire_data_editor_insert_new_case_at_posn  (PsppireDataEditor *de, gint posn)
 void
 psppire_data_editor_insert_new_variable_at_posn (PsppireDataEditor *de, gint posn)
 {
-  g_return_if_fail (posn >= 0);
-  const struct variable *v = psppire_dict_insert_variable (de->dict, posn, NULL);
-  g_return_if_fail (v);
-  psppire_data_store_insert_value (de->data_store, var_get_width(v),
-                                  var_get_case_index (v));
-
-  gtk_widget_queue_draw (GTK_WIDGET (de));
+  psppire_data_sheet_insert_new_variable_at_posn (PSPPIRE_DATA_SHEET (de->data_sheet), posn);
 }
 
 static void
@@ -541,7 +537,7 @@ psppire_data_editor_init (PsppireDataEditor *de)
 
   if (psppire_conf_get_string (psppire_conf_new (),
                           "Data Editor", "font",
-                               &fontname) )
+                               &fontname))
     {
       de->font = pango_font_description_from_string (fontname);
       g_free (fontname);
@@ -604,7 +600,7 @@ set_font_recursively (GtkWidget *w, gpointer data)
   g_object_unref (cssp);
 
 
-  if ( GTK_IS_CONTAINER (w))
+  if (GTK_IS_CONTAINER (w))
     gtk_container_foreach (GTK_CONTAINER (w), set_font_recursively, font_desc);
 }