[glade/composite-templates-new: 1/3] Support editing of the widget name.



commit fcbfefd9c118bdbda5d2515c444918f44726fdb6
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sat Mar 30 19:54:08 2013 +0900

    Support editing of the widget name.
    
    Widget name's can be modified with this patch, some special case
    code in glade-editor-table.c ensures that the name property always
    comes first directly after the ID.

 gladeui/glade-editor-table.c |   20 +++++++++++++++-----
 plugins/gtk+/gtk+.xml.in     |    4 +++-
 2 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/gladeui/glade-editor-table.c b/gladeui/glade-editor-table.c
index 1e0fcb5..3a8448f 100644
--- a/gladeui/glade-editor-table.c
+++ b/gladeui/glade-editor-table.c
@@ -301,11 +301,21 @@ property_class_comp (gconstpointer a, gconstpointer b)
 {
   GladePropertyClass *ca = (GladePropertyClass *)a, *cb = (GladePropertyClass *)b;
   GParamSpec *pa, *pb;
+  const gchar *name_a, *name_b;
 
   pa = glade_property_class_get_pspec (ca);
   pb = glade_property_class_get_pspec (cb);
 
-  if (pa->owner_type == pb->owner_type)
+  name_a = glade_property_class_id (ca);
+  name_b = glade_property_class_id (cb);
+
+  /* Special case for the 'name' property, it *always* comes first. */
+  if (strcmp (name_a, "name") == 0)
+    return -1;
+  else if (strcmp (name_b, "name") == 0)
+    return 1;
+  /* Properties of the same class are sorted in the same level */
+  else if (pa->owner_type == pb->owner_type)
     {
       gdouble result = glade_property_class_weight (ca) - glade_property_class_weight (cb);
       /* Avoid cast to int */
@@ -316,6 +326,7 @@ property_class_comp (gconstpointer a, gconstpointer b)
       else
         return 0;
     }
+  /* Group properties by thier class hierarchy */
   else
     {
       if (g_type_is_a (pa->owner_type, pb->owner_type))
@@ -380,7 +391,6 @@ append_item (GladeEditorTable * table,
   return property;
 }
 
-
 static void
 append_items (GladeEditorTable * table,
               GladeWidgetAdaptor * adaptor, GladeEditorPageType type)
@@ -405,10 +415,10 @@ append_items (GladeEditorTable * table,
 static void
 append_name_field (GladeEditorTable * table)
 {
-  gchar *text = _("The Object's name");
+  gchar *text = _("The object's unique identifier");
 
-  /* Name */
-  table->priv->name_label = gtk_label_new (_("Name:"));
+  /* translators: The unique identifier of an object in the project */
+  table->priv->name_label = gtk_label_new (_("ID:"));
   gtk_misc_set_alignment (GTK_MISC (table->priv->name_label), 0.0, 0.5);
   gtk_widget_show (table->priv->name_label);
   gtk_widget_set_no_show_all (table->priv->name_label, TRUE);
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 75e865f..fc80dc2 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -126,8 +126,10 @@
          </displayable-values>
        </property>
 
+       <!-- Put the name in the main properties page glade-editor-table.c ensures it's always at the top -->
+       <property id="name" common="False"/>
+
        <property id="window" disabled="True" since="2.14"/>
-       <property id="name" disabled="True"/>
        <property id="parent" disabled="True"/>
        <property id="style" disabled="True"/>
        <property id="sensitive" ignore="True"/>


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