[dia] [api] more prop_list_add*() - especially for Text attributes



commit ff50637da2e397b158be2cf218a8234670eede33
Author: Hans Breuer <hans breuer org>
Date:   Fri Oct 12 14:37:39 2012 +0200

    [api] more prop_list_add*() - especially for Text attributes
    
    this relies on the previous restructuring commit

 lib/libdia.def   |    6 ++++-
 lib/properties.h |   10 +++++++++
 lib/proplist.c   |   60 +++++++++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 68 insertions(+), 8 deletions(-)
---
diff --git a/lib/libdia.def b/lib/libdia.def
index 4ae4e93..730b89f 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -296,7 +296,6 @@ EXPORTS
  pixbuf_encode_base64
  pixbuf_decode_base64
 
-
  dia_interactive_renderer_interface_get_type
  
  dialog_make
@@ -679,6 +678,11 @@ EXPORTS
  prop_list_add_real
  prop_list_add_string
  prop_list_add_show_background
+ prop_list_add_font
+ prop_list_add_fontsize
+ prop_list_add_enum
+ prop_list_add_text
+ prop_list_add_text_colour
  prop_list_free
  prop_list_from_descs
  prop_list_from_single
diff --git a/lib/properties.h b/lib/properties.h
index efb163e..ce0d93f 100644
--- a/lib/properties.h
+++ b/lib/properties.h
@@ -440,14 +440,24 @@ void prop_list_add_line_style  (GPtrArray *plist, LineStyle line_style, real das
 void prop_list_add_line_colour (GPtrArray *plist, const Color *color);
 void prop_list_add_fill_colour (GPtrArray *plist, const Color *color);
 void prop_list_add_show_background (GPtrArray *plist, gboolean fill);
+void prop_list_add_text_colour (GPtrArray *plist, const Color *color);
+/* addding a text(string) property - just the string no attributes */
+void prop_list_add_text (GPtrArray *plist, const char *name, const char *value);
+
 /* usually three variants: start_point, end_point, elem_corner */
 void prop_list_add_point (GPtrArray *plist, const char *name, const Point *point);
 /* quite generic, e.g. elem_width, elem_height, curve_distance */
 void prop_list_add_real (GPtrArray *plist, const char *name, real value);
+/* also called text_height */
+void prop_list_add_fontsize (GPtrArray *plist, const char *name, real value);
 /* addding a string property */
 void prop_list_add_string (GPtrArray *plist, const char *name, const char *value);
 /* addding a string property */
 void prop_list_add_filename (GPtrArray *plist, const char *name, const char *value);
+/* adding an enum given an int */
+void prop_list_add_enum (GPtrArray *plist, const char *name, int val);
+/* adding a font */
+void prop_list_add_font (GPtrArray *plist, const char *name, const DiaFont *font);
 
 /* Some predicates: */
 gboolean pdtpp_true(const PropDescription *pdesc); /* always true */
diff --git a/lib/proplist.c b/lib/proplist.c
index dd71cfd..8e7f28a 100644
--- a/lib/proplist.c
+++ b/lib/proplist.c
@@ -240,21 +240,23 @@ prop_list_add_line_style  (GPtrArray *plist, LineStyle line_style, real dash)
   ((LinestyleProperty *)prop)->dash = dash;
   g_ptr_array_add (plist, prop);
 }
-void
-prop_list_add_line_colour (GPtrArray *plist, const Color *color)
+static void
+_prop_list_add_colour (GPtrArray *plist, const char *name, const Color *color)
 {
-  Property *prop = make_new_prop ("line_colour", PROP_TYPE_COLOUR, 0);
+  Property *prop = make_new_prop (name, PROP_TYPE_COLOUR, 0);
 
   ((ColorProperty *)prop)->color_data = *color;
   g_ptr_array_add (plist, prop);
 }
 void
+prop_list_add_line_colour (GPtrArray *plist, const Color *color)
+{
+  _prop_list_add_colour (plist, "line_colour", color);
+}
+void
 prop_list_add_fill_colour (GPtrArray *plist, const Color *color)
 {
-  Property *prop = make_new_prop ("fill_colour", PROP_TYPE_COLOUR, 0);
-
-  ((ColorProperty *)prop)->color_data = *color;
-  g_ptr_array_add (plist, prop);
+  _prop_list_add_colour (plist, "fill_colour", color);
 }
 void
 prop_list_add_show_background (GPtrArray *plist, gboolean fill)
@@ -281,6 +283,14 @@ prop_list_add_real (GPtrArray *plist, const char *name, real value)
   g_ptr_array_add (plist, prop);
 }
 void
+prop_list_add_fontsize (GPtrArray *plist, const char *name, real value)
+{
+  Property *prop = make_new_prop (name, PROP_TYPE_FONTSIZE, 0);
+
+  ((RealProperty *)prop)->real_data = value;
+  g_ptr_array_add (plist, prop);
+}
+void
 prop_list_add_string (GPtrArray *plist, const char *name, const char *value)
 {
   Property *prop = make_new_prop (name, PROP_TYPE_STRING, 0);
@@ -290,6 +300,15 @@ prop_list_add_string (GPtrArray *plist, const char *name, const char *value)
   g_ptr_array_add (plist, prop);
 }
 void
+prop_list_add_text (GPtrArray *plist, const char *name, const char *value)
+{
+  Property *prop = make_new_prop (name, PROP_TYPE_TEXT, 0);
+
+  g_free (((TextProperty *)prop)->text_data);
+  ((TextProperty *)prop)->text_data = g_strdup (value);
+  g_ptr_array_add (plist, prop);
+}
+void
 prop_list_add_filename (GPtrArray *plist, const char *name, const char *value)
 {
   Property *prop = make_new_prop (name, PROP_TYPE_FILE, 0);
@@ -298,3 +317,30 @@ prop_list_add_filename (GPtrArray *plist, const char *name, const char *value)
   ((StringProperty *)prop)->string_data = g_strdup (value);
   g_ptr_array_add (plist, prop);
 }
+
+void
+prop_list_add_font (GPtrArray *plist, const char *name, const DiaFont *font)
+{
+  Property *prop = make_new_prop (name, PROP_TYPE_FONT, 0);
+  FontProperty *fp = (FontProperty *)prop;
+
+  if (fp->font_data == font)
+    return;
+  if (fp->font_data)
+    g_object_unref (fp->font_data);
+  fp->font_data = g_object_ref ((gpointer)font);
+  g_ptr_array_add (plist, prop);
+}
+void
+prop_list_add_enum (GPtrArray *plist, const char *name, int value)
+{
+  Property *prop = make_new_prop (name, PROP_TYPE_ENUM, 0);
+
+  ((EnumProperty *)prop)->enum_data = value;
+  g_ptr_array_add (plist, prop);
+}
+void
+prop_list_add_text_colour (GPtrArray *plist, const Color *color)
+{
+  _prop_list_add_colour (plist, "text_colour", color);
+}



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