[glade/glade-3-16] Improved pango text integer attributes editors. Make the spin button numeric and clear the attr if t



commit b4b825108cd7ff0aae01360f541a61919ee815bd
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Fri Sep 13 23:55:32 2013 -0300

    Improved pango text integer attributes editors.
    Make the spin button numeric and clear the attr if the new text is an empty string!
    
    This should be enough to close Bug 679006
    "The "size" attribute for labels only accepts integer values (not strings like "larger")"

 plugins/gtk+/glade-attributes.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/plugins/gtk+/glade-attributes.c b/plugins/gtk+/glade-attributes.c
index 41cc75f..33e7e2b 100644
--- a/plugins/gtk+/glade-attributes.c
+++ b/plugins/gtk+/glade-attributes.c
@@ -820,7 +820,7 @@ value_combo_spin_edited (GtkCellRendererText *cell,
   gtk_tree_model_get (eprop_attrs->model, &iter, COLUMN_TYPE, &type, -1);
 
   /* Reset the column */
-  if (new_text && strcmp (new_text, _("None")) == 0)
+  if (new_text && (*new_text == '\0' || strcmp (new_text, _("None")) == 0))
     {
       gtk_list_store_set (GTK_LIST_STORE (eprop_attrs->model), &iter,
                           COLUMN_TEXT, _("<Enter Value>"),
@@ -839,6 +839,15 @@ value_combo_spin_edited (GtkCellRendererText *cell,
 
 }
 
+static void
+value_combo_spin_editing_started (GtkCellRenderer *cell,
+                                  GtkCellEditable *editable,
+                                  const gchar     *path)
+{
+  if (GTK_IS_SPIN_BUTTON (editable))
+    gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (editable), TRUE);
+}
+
 static GtkWidget *
 glade_eprop_attrs_view (GladeEditorProperty *eprop)
 {
@@ -953,6 +962,8 @@ glade_eprop_attrs_view (GladeEditorProperty *eprop)
                                        "digits", COLUMN_SPIN_DIGITS, NULL);
   g_signal_connect (G_OBJECT (renderer), "edited",
                     G_CALLBACK (value_combo_spin_edited), eprop);
+  g_signal_connect (G_OBJECT (renderer), "editing-started",
+                    G_CALLBACK (value_combo_spin_editing_started), NULL);
 
   gtk_tree_view_column_set_expand (GTK_TREE_VIEW_COLUMN (column), TRUE);
   gtk_tree_view_append_column (GTK_TREE_VIEW (view_widget), column);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]