X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-dict.c;h=3bc39e40959c61a6f9db9d1d895d84d9a2d479d7;hb=656e46ed80e20bf34312f01607a7bebdd2d8d622;hp=0a0c3ae0b4f1884b32803e905fd4781207607833;hpb=1131cd88a0beb1311d9ae064b9dc14d556e52c07;p=pspp diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c index 0a0c3ae0b4..3bc39e4095 100644 --- a/src/ui/gui/psppire-dict.c +++ b/src/ui/gui/psppire-dict.c @@ -1,5 +1,6 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2004, 2006, 2007, 2009, 2010, 2011, 2012, 2016 Free Software Foundation + Copyright (C) 2004, 2006, 2007, 2009, 2010, 2011, 2012, + 2016, 2017 Free Software Foundation 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 @@ -33,8 +34,6 @@ #include "ui/gui/psppire-marshal.h" #include "ui/gui/psppire-var-ptr.h" -#include "ui/gui/efficient-sheet/jmd-datum.h" - #include #include @@ -49,8 +48,6 @@ GType role_enum_type; enum { - ITEMS_CHANGED, - VARIABLE_CHANGED, VARIABLE_INSERTED, VARIABLE_DELETED, @@ -82,34 +79,34 @@ gni (GListModel *list) static GType git (GListModel *list) { - return JMD_TYPE_DATUM; + return GTK_TYPE_BUTTON; } static gpointer gi (GListModel *list, guint id) { - JmdDatum *gd = JMD_DATUM (g_object_new (JMD_TYPE_DATUM, NULL)); + GtkWidget *button = gtk_button_new (); PsppireDict *dict = PSPPIRE_DICT (list); - + if (id >= psppire_dict_get_var_cnt (dict)) { - gd->text = g_strdup (_("Var")); + gtk_button_set_label (GTK_BUTTON (button), _("Var")); } else { const struct variable *v = psppire_dict_get_variable (dict, id); - gd->text = g_strdup (var_get_name (v)); - gd->label = g_strdup (var_get_label (v)); + gtk_button_set_label (GTK_BUTTON (button), var_get_name (v)); + gtk_widget_set_tooltip_text (button, var_get_label (v)); } - return gd; + return button; } static void -jmd_init_iface (GListModelInterface *iface) +ssw_init_iface (GListModelInterface *iface) { iface->get_n_items = gni; iface->get_item = gi; @@ -153,7 +150,7 @@ psppire_dict_get_type (void) }; static const GInterfaceInfo list_model_info = { - (GInterfaceInitFunc) jmd_init_iface, + (GInterfaceInitFunc) ssw_init_iface, NULL, NULL }; @@ -161,7 +158,7 @@ psppire_dict_get_type (void) object_type = g_type_register_static (G_TYPE_OBJECT, "PsppireDict", &object_info, 0); - + g_type_add_interface_static (object_type, GTK_TYPE_TREE_MODEL, &tree_model_info); @@ -181,20 +178,6 @@ psppire_dict_class_init (PsppireDictClass *class) parent_class = g_type_class_peek_parent (class); object_class->dispose = psppire_dict_dispose; - - signals [ITEMS_CHANGED] = - g_signal_new ("changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_FIRST, - 0, - NULL, NULL, - psppire_marshal_VOID__UINT_UINT_UINT, - G_TYPE_NONE, - 3, - G_TYPE_UINT, - G_TYPE_UINT, - G_TYPE_UINT); - signals [VARIABLE_CHANGED] = g_signal_new ("variable-changed", @@ -293,7 +276,7 @@ addcb (struct dictionary *d, int idx, void *pd) if ( ! dict->disable_insert_signal) { g_signal_emit (dict, signals [VARIABLE_INSERTED], 0, idx); - g_signal_emit (dict, signals [ITEMS_CHANGED], 0, idx, 1, 1); + g_signal_emit_by_name (dict, "items-changed", idx, 1, 1); } } @@ -303,14 +286,14 @@ delcb (struct dictionary *d, const struct variable *var, { g_signal_emit (pd, signals [VARIABLE_DELETED], 0, var, dict_idx, case_idx); - g_signal_emit (pd, signals [ITEMS_CHANGED], 0, dict_idx, 1, 0); + g_signal_emit_by_name (pd, "items-changed", dict_idx, 1, 0); } static void mutcb (struct dictionary *d, int idx, unsigned int what, const struct variable *oldvar, void *pd) { g_signal_emit (pd, signals [VARIABLE_CHANGED], 0, idx, what, oldvar); - g_signal_emit (pd, signals [ITEMS_CHANGED], 0, idx, 1, 1); + g_signal_emit_by_name (pd, "items-changed", idx, 1, 1); } static void @@ -359,7 +342,7 @@ psppire_dict_new_from_dict (struct dictionary *d) { PsppireDict *new_dict = g_object_new (PSPPIRE_TYPE_DICT, NULL); new_dict->dict = d; - + dict_set_callbacks (new_dict->dict, &gui_callbacks, new_dict); return new_dict; @@ -373,7 +356,7 @@ psppire_dict_replace_dictionary (PsppireDict *dict, struct dictionary *d) guint old_n = dict_get_var_cnt (dict->dict); guint new_n = dict_get_var_cnt (d); - + dict->dict = d; weight_changed_callback (d, var ? var_get_dict_index (var) : -1, dict); @@ -385,7 +368,7 @@ psppire_dict_replace_dictionary (PsppireDict *dict, struct dictionary *d) dict_set_callbacks (dict->dict, &gui_callbacks, dict); - g_signal_emit (dict, signals [ITEMS_CHANGED], 0, 0, old_n, new_n); + g_signal_emit_by_name (dict, "items-changed", 0, old_n, new_n); } @@ -405,7 +388,7 @@ psppire_dict_generate_name (const PsppireDict *dict, char *name, size_t size) - The string may not contain whitespace. - The first character may not be '$' - The first character may not be a digit - - The final charactor may not be '.' or '_' + - The final character may not be '.' or '_' */ len = snprintf (name, size, _("Var%04d"), d); if (len + 1 >= size) @@ -449,8 +432,8 @@ psppire_dict_insert_variable (PsppireDict *d, gint idx, const gchar *name) d->disable_insert_signal = FALSE; g_signal_emit (d, signals[VARIABLE_INSERTED], 0, idx); - g_signal_emit (d, signals [ITEMS_CHANGED], 0, idx, 0, 1); - + g_signal_emit_by_name (d, "items-changed", idx, 0, 1); + return var; } @@ -578,7 +561,7 @@ psppire_dict_clear (PsppireDict *d) } -/* Return true is NAME would be a valid name of a variable to add to the +/* Return true if NAME would be a valid name of a variable to add to the dictionary. False otherwise. If REPORT is true, then invalid names will be reported as such as errors */ @@ -697,7 +680,7 @@ tree_model_column_type (GtkTreeModel *model, gint index) g_return_val_if_fail (PSPPIRE_IS_DICT (model), (GType) 0); GType t = 0; - + switch (index) { case DICT_TVM_COL_NAME: @@ -825,7 +808,7 @@ tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter, var = iter->user_data; const struct fmt_spec *fs = var_get_write_format (var); - + switch (column) { case DICT_TVM_COL_NAME: