if (var_has_value_labels (var) && GTK_IS_COMBO_BOX (editable))
{
const struct val_labs *labels = var_get_value_labels (var);
- const struct val_lab *vl;
+ const struct val_lab **vls = val_labs_sorted (labels);
+ size_t n_vls = val_labs_count (labels);
GtkListStore *list_store;
+ int i;
list_store = gtk_list_store_new (1, G_TYPE_STRING);
- for (vl = val_labs_first (labels); vl != NULL;
- vl = val_labs_next (labels, vl))
+ for (i = 0; i < n_vls; ++i)
{
+ const struct val_lab *vl = vls[i];
GtkTreeIter iter;
gtk_list_store_append (list_store, &iter);
0, val_lab_get_label (vl),
-1);
}
+ free (vls);
gtk_combo_box_set_model (GTK_COMBO_BOX (editable),
GTK_TREE_MODEL (list_store));
{
PsppireDataSheet *data_sheet = PSPPIRE_DATA_SHEET (object);
+ if (data_sheet->clip != NULL && data_sheet->on_owner_change_signal != 0)
+ {
+ g_signal_handler_disconnect (data_sheet->clip,
+ data_sheet->on_owner_change_signal);
+ data_sheet->on_owner_change_signal = 0;
+ }
+
if (data_sheet->dispose_has_run)
return;
static void
psppire_data_sheet_map (GtkWidget *widget)
{
- GtkClipboard *clip;
+ PsppireDataSheet *data_sheet = PSPPIRE_DATA_SHEET (widget);
GTK_WIDGET_CLASS (psppire_data_sheet_parent_class)->map (widget);
- clip = gtk_widget_get_clipboard (widget, GDK_SELECTION_CLIPBOARD);
- g_signal_connect (clip, "owner-change", G_CALLBACK (on_owner_change),
- widget);
- on_owner_change (clip, NULL, widget);
+ data_sheet->clip = gtk_widget_get_clipboard (widget,
+ GDK_SELECTION_CLIPBOARD);
+ if (data_sheet->on_owner_change_signal)
+ g_signal_handler_disconnect (data_sheet->clip,
+ data_sheet->on_owner_change_signal);
+ data_sheet->on_owner_change_signal
+ = g_signal_connect (data_sheet->clip, "owner-change",
+ G_CALLBACK (on_owner_change), widget);
+ on_owner_change (data_sheet->clip, NULL, widget);
}
static void
obj->scroll_to_bottom_signal = 0;
obj->scroll_to_right_signal = 0;
+ obj->on_owner_change_signal = 0;
obj->new_variable_column = NULL;
obj->container = NULL;
static void
on_variable_changed (PsppireDict *dict, int dict_index,
+ guint what, const struct variable *oldvar,
PsppireDataSheet *data_sheet)
{
PsppireDataStore *data_store = psppire_data_sheet_get_data_store (data_sheet);
g_return_if_fail (data_sheet->data_store != NULL);
g_return_if_fail (dict == data_sheet->data_store->dict);
+
+ if (what & VAR_TRAIT_DISPLAY_WIDTH)
+ on_variable_display_width_changed (dict, dict_index, data_sheet);
+
column = psppire_data_sheet_find_column_for_variable (data_sheet,
dict_index);
if (column == NULL)
return;
+
var = psppire_dict_get_variable (data_store->dict, dict_index);
g_return_if_fail (var != NULL);
g_signal_connect (data_store->dict, "variable-changed",
G_CALLBACK (on_variable_changed),
data_sheet);
- g_signal_connect (data_store->dict, "variable-display-width-changed",
- G_CALLBACK (on_variable_display_width_changed),
- data_sheet);
g_signal_connect (data_store->dict, "variable-inserted",
G_CALLBACK (on_variable_inserted), data_sheet);
g_signal_connect (data_store->dict, "variable-deleted",
}
static void
-on_owner_change (GtkClipboard *clip, GdkEventOwnerChange *event, gpointer data)
+psppire_data_sheet_targets_received_cb (GtkClipboard *clipboard,
+ GdkAtom *atoms,
+ gint n_atoms,
+ gpointer data)
{
- PsppireDataSheet *data_sheet = PSPPIRE_DATA_SHEET (data);
- gboolean compatible_target = FALSE;
- GtkAction *action;
+ GtkAction *action = GTK_ACTION (data);
+ gboolean compatible_target;
gint i;
+ compatible_target = FALSE;
for (i = 0; i < G_N_ELEMENTS (targets); i++)
{
- GdkAtom atom = gdk_atom_intern (targets[i].target, TRUE);
- if (gtk_clipboard_wait_is_target_available (clip, atom))
- {
- compatible_target = TRUE;
- break;
- }
+ GdkAtom target = gdk_atom_intern (targets[i].target, TRUE);
+ gint j;
+
+ for (j = 0; j < n_atoms; j++)
+ if (target == atoms[j])
+ {
+ compatible_target = TRUE;
+ break;
+ }
}
- action = get_action_assert (data_sheet->builder, "edit_paste");
gtk_action_set_sensitive (action, compatible_target);
+ g_object_unref (action);
+}
+
+static void
+on_owner_change (GtkClipboard *clip, GdkEventOwnerChange *event, gpointer data)
+{
+ PsppireDataSheet *data_sheet = PSPPIRE_DATA_SHEET (data);
+ GtkAction *action = get_action_assert (data_sheet->builder, "edit_paste");
+
+ g_object_ref (action);
+ gtk_clipboard_request_targets (clip, psppire_data_sheet_targets_received_cb,
+ action);
}