[dia] [meta info] Use the meta info editor in an extra tab



commit d0c487be511230700f5653462cd6836898333622
Author: Hans Breuer <hans breuer org>
Date:   Thu Aug 5 19:49:38 2010 +0200

    [meta info] Use the meta info editor in an extra tab
    
    lib/object.h : explain why it is a bad idea to use PROP_FLAG_VISIBLE on "meta":PROP_TYPE_DICT (and other object properties)
    
    The meta info editor is put on an extra tab in the property dialog. If necessary other properties are wrapped into their own tab. For 'UML - Class' and 'Database - Table' there is no meta info editor shown yet.

 lib/object.h      |    3 +++
 lib/propdialogs.c |   41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/lib/object.h b/lib/object.h
index 2e0b3be..077d5ba 100644
--- a/lib/object.h
+++ b/lib/object.h
@@ -545,6 +545,9 @@ struct _DiaObjectType {
 };
 
 /* base property stuff ... */
+/* Needs to stay ~PROP_FLAG_VISIBLE or the dialogs get seriously messed up.
+ * The meta info has special code in property dialog creation.
+ */
 #define OBJECT_COMMON_PROPERTIES \
   { "obj_pos", PROP_TYPE_POINT, PROP_FLAG_OPTIONAL, \
     "Object position", "Where the object is located"}, \
diff --git a/lib/propdialogs.c b/lib/propdialogs.c
index d935c33..9a7a0e3 100644
--- a/lib/propdialogs.c
+++ b/lib/propdialogs.c
@@ -310,6 +310,43 @@ pdtpp_is_visible_default (const PropDescription *pdesc)
   return pdtpp_defaults (pdesc) && pdtpp_is_visible_no_standard(pdesc);
 }
 
+static void
+_prop_list_extend_for_meta (GPtrArray *props)
+{
+  static PropDescription extras[] = {
+    PROP_STD_NOTEBOOK_BEGIN,
+    PROP_NOTEBOOK_PAGE("general_page",PROP_FLAG_DONT_MERGE,N_("General")),
+    PROP_NOTEBOOK_PAGE("meta_page",0,N_("Meta")),
+    { "meta", PROP_TYPE_DICT, PROP_FLAG_VISIBLE, "", ""},
+    PROP_STD_NOTEBOOK_END,
+    {NULL}
+  };
+
+  Property *p = g_ptr_array_index(props,0);
+  GPtrArray *pex = prop_list_from_descs(extras,pdtpp_is_visible);
+
+  if (strcmp (p->type, PROP_TYPE_NOTEBOOK_BEGIN) != 0) {
+    int i, olen = props->len;
+    /* wrap everything into a first notebook page */
+    g_ptr_array_set_size (props, olen + 2);
+    /* make room for 2 at the beginning */
+    for (i = olen - 1; i >=  0; --i)
+      g_ptr_array_index (props, i + 2) = g_ptr_array_index (props, i);
+    g_ptr_array_index (props, 0) = g_ptr_array_index (pex, 0);
+    g_ptr_array_index (props, 1) = g_ptr_array_index (pex, 1);
+  } else {
+    p = g_ptr_array_index (props, props->len - 1);
+    g_assert (strcmp (p->type, PROP_TYPE_NOTEBOOK_END) == 0);
+    /* drop the end, we'll add it again below */
+    g_ptr_array_set_size (props, props->len - 1);
+  }
+  g_ptr_array_add (props, g_ptr_array_index (pex, 2));
+  g_ptr_array_add (props, g_ptr_array_index (pex, 3));
+  g_ptr_array_add (props, g_ptr_array_index (pex, 4));
+  /* free the array, but not the reused segments */
+  g_ptr_array_free (pex, FALSE);
+}
+
 static void 
 prop_dialog_fill(PropDialog *dialog, GList *objects, gboolean is_default)
 {
@@ -330,7 +367,9 @@ prop_dialog_fill(PropDialog *dialog, GList *objects, gboolean is_default)
       props = prop_list_from_descs(pdesc,pdtpp_is_visible);
 
   if (!props) return;
-    
+
+  _prop_list_extend_for_meta (props);
+
   dialog->props = props;
   object_list_get_props(objects, props);
 



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