/* 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
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
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
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2017 John Darrington
+ Copyright (C) 2017, 2019 John Darrington
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
gtk_menu_popup_at_pointer (GTK_MENU (sheet->data_sheet_cases_column_popup), NULL);
}
-static void
-insert_new_variable (PsppireDataSheet *sheet)
+void
+psppire_data_sheet_insert_new_variable_at_posn (PsppireDataSheet *sheet, gint posn)
{
PsppireDataStore *data_store = NULL;
g_object_get (sheet, "data-model", &data_store, NULL);
- gint posn = GPOINTER_TO_INT (g_object_get_data
- (G_OBJECT (sheet->data_sheet_cases_column_popup),
- "item"));
-
const struct variable *v = psppire_dict_insert_variable (data_store->dict,
posn, NULL);
psppire_data_store_insert_value (data_store, var_get_width(v),
var_get_case_index (v));
+ ssw_sheet_scroll_to (SSW_SHEET (sheet), posn, -1);
+
gtk_widget_queue_draw (GTK_WIDGET (sheet));
}
+static void
+insert_new_variable (PsppireDataSheet *sheet)
+{
+ PsppireDataStore *data_store = NULL;
+ g_object_get (sheet, "data-model", &data_store, NULL);
+
+ gint posn = GPOINTER_TO_INT (g_object_get_data
+ (G_OBJECT (sheet->data_sheet_cases_column_popup),
+ "item"));
+
+ psppire_data_sheet_insert_new_variable_at_posn (sheet, posn);
+}
+
+
static void
set_menu_items_sensitivity (PsppireDataSheet *sheet, gpointer selection, gpointer p)
{
whole_column_selected);
}
-static void
-delete_variables (PsppireDataSheet *sheet)
+void
+psppire_data_sheet_delete_variables (PsppireDataSheet *sheet)
{
SswRange *range = SSW_SHEET(sheet)->selection;
psppire_dict_delete_variables (data_store->dict, range->start_x,
(range->end_x - range->start_x + 1));
+ ssw_sheet_scroll_to (SSW_SHEET (sheet), range->start_x, -1);
+
gtk_widget_queue_draw (GTK_WIDGET (sheet));
}
sheet->data_clear_variables_menu_item =
gtk_menu_item_new_with_mnemonic (_("Cl_ear Variables"));
g_signal_connect_swapped (sheet->data_clear_variables_menu_item, "activate",
- G_CALLBACK (delete_variables),
+ G_CALLBACK (psppire_data_sheet_delete_variables),
sheet);
gtk_widget_set_sensitive (sheet->data_clear_variables_menu_item, FALSE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), sheet->data_clear_variables_menu_item);