X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-dict.c;h=7a8245f2bd21ae09d20b1e1329bc711875285274;hb=4790395fad95f64a4cffa76faf4478ffe3bfb5a2;hp=ff30d64c69a0d74211ab1ba5853d5f1ba85a604f;hpb=6a2471b3e5f3e443ae1a2022040ebbbf0c1189d3;p=pspp diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c index ff30d64c69..7a8245f2bd 100644 --- a/src/ui/gui/psppire-dict.c +++ b/src/ui/gui/psppire-dict.c @@ -34,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 @@ -81,34 +79,52 @@ 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)); + + { + PangoContext *context = gtk_widget_create_pango_context (button); + PangoLayout *layout = pango_layout_new (context); + PangoRectangle rect; + + pango_layout_set_text (layout, "M", 1); + + pango_layout_get_extents (layout, NULL, &rect); + + g_object_unref (G_OBJECT (layout)); + g_object_unref (G_OBJECT (context)); + + gtk_widget_set_size_request (button, + (0.25 + var_get_display_width (v)) + * rect.width / PANGO_SCALE, + -1); + } } - 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; @@ -152,7 +168,7 @@ psppire_dict_get_type (void) }; static const GInterfaceInfo list_model_info = { - (GInterfaceInitFunc) jmd_init_iface, + (GInterfaceInitFunc) ssw_init_iface, NULL, NULL }; @@ -160,7 +176,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); @@ -180,7 +196,7 @@ psppire_dict_class_init (PsppireDictClass *class) parent_class = g_type_class_peek_parent (class); object_class->dispose = psppire_dict_dispose; - + signals [VARIABLE_CHANGED] = g_signal_new ("variable-changed", G_TYPE_FROM_CLASS (class), @@ -192,10 +208,7 @@ psppire_dict_class_init (PsppireDictClass *class) 3, G_TYPE_INT, G_TYPE_UINT, - G_TYPE_POINTER - ); - - + G_TYPE_POINTER); signals [VARIABLE_INSERTED] = g_signal_new ("variable-inserted", @@ -208,7 +221,6 @@ psppire_dict_class_init (PsppireDictClass *class) 1, G_TYPE_INT); - signals [VARIABLE_DELETED] = g_signal_new ("variable-deleted", G_TYPE_FROM_CLASS (class), @@ -222,7 +234,6 @@ psppire_dict_class_init (PsppireDictClass *class) G_TYPE_INT, G_TYPE_INT); - signals [WEIGHT_CHANGED] = g_signal_new ("weight-changed", G_TYPE_FROM_CLASS (class), @@ -234,7 +245,6 @@ psppire_dict_class_init (PsppireDictClass *class) 1, G_TYPE_INT); - signals [FILTER_CHANGED] = g_signal_new ("filter-changed", G_TYPE_FROM_CLASS (class), @@ -246,7 +256,6 @@ psppire_dict_class_init (PsppireDictClass *class) 1, G_TYPE_INT); - signals [SPLIT_CHANGED] = g_signal_new ("split-changed", G_TYPE_FROM_CLASS (class), @@ -344,7 +353,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; @@ -358,7 +367,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); @@ -390,7 +399,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) @@ -435,7 +444,7 @@ psppire_dict_insert_variable (PsppireDict *d, gint idx, const gchar *name) g_signal_emit (d, signals[VARIABLE_INSERTED], 0, idx); g_signal_emit_by_name (d, "items-changed", idx, 0, 1); - + return var; } @@ -682,7 +691,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: @@ -810,7 +819,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: @@ -948,8 +957,6 @@ psppire_dict_dump (const PsppireDict *dict) #endif - - const gchar * psppire_dict_encoding (const PsppireDict *dict) {