Add a boxed type for nul-terminated string arrays. (#110528)
authorMatthias Clasen <maclas@gmx.de>
Fri, 9 Jan 2004 22:39:55 +0000 (22:39 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 9 Jan 2004 22:39:55 +0000 (22:39 +0000)
Fri Jan  9 23:41:00 2004  Matthias Clasen  <maclas@gmx.de>

* gboxed.h:
* gboxed.c (g_strv_get_type): Add a boxed type for nul-terminated
string arrays.  (#110528)

docs/reference/ChangeLog
docs/reference/gobject/gobject-sections.txt
docs/reference/gobject/tmpl/gboxed.sgml
gobject/ChangeLog
gobject/gboxed.c
gobject/gboxed.h

index 84e8aea..b6928ea 100644 (file)
@@ -1,3 +1,8 @@
+Fri Jan  9 23:40:23 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gobject/tmpl/gboxed.sgml: 
+       * gobject/gobject-sections.txt: Add G_TYPE_STRV and GStrv.
+
 Fri Dec 26 02:04:49 2003  Matthias Clasen  <maclas@gmx.de>
 
        * glib/glib-sections.txt: Add g_ptr_array_foreach().
index e3d5d32..ab4622c 100644 (file)
@@ -291,12 +291,15 @@ g_pointer_type_register_static
 
 <SUBSECTION>
 G_TYPE_GSTRING
+G_TYPE_STRV
+GStrv
 
 <SUBSECTION Standard>
 G_TYPE_IS_BOXED
 
 <SUBSECTION Private>
 g_gstring_get_type
+g_strv_get_type
 </SECTION>
 
 <SECTION>
index 9a3d974..289edd7 100644 (file)
@@ -82,3 +82,39 @@ The #GType for #GString.
 
 
 
+<!-- ##### MACRO G_TYPE_STRV ##### -->
+<para>
+The #GType for a boxed type holding a %NULL-terminated array of strings.
+</para>
+<para>
+The code fragments in the following example show the use of a property of
+type #G_TYPE_STRV with g_object_class_install_property(), g_object_set()
+and g_object_get().
+</para>
+<informalexample><programlisting>
+g_object_class_install_property (object_class,
+                                 PROP_AUTHORS,
+                                 g_param_spec_boxed ("authors",
+                                                     _("Authors"),
+                                                     _("List of authors"),
+                                                     G_TYPE_STRV,
+                                                     G_PARAM_READWRITE));
+
+
+gchar *authors[] = { "Owen", "Tim", NULL };
+g_object_set (obj, "authors", authors, NULL);
+
+
+gchar *writers[];
+g_object_get (obj, "authors", &amp;writers, NULL);
+/* do something with writers */
+g_strfreev (writers);
+</programlisting></informalexample>
+
+@Since: 2.4
+
+<!-- ##### TYPEDEF GStrv ##### -->
+<para>
+A C representable type name for #G_TYPE_STRV.
+</para>
+
index 845c839..6868f4d 100644 (file)
@@ -1,3 +1,9 @@
+Fri Jan  9 23:41:00 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gboxed.h:
+       * gboxed.c (g_strv_get_type): Add a boxed type for nul-terminated
+       string arrays.  (#110528)
+
 Fri Jan  9 15:34:15 2004  Tim Janik  <timj@gtk.org>
 
        * gtype.h: added convenience macros G_IMPLEMENT_INTERFACE() and
index f62647f..54a1b49 100644 (file)
@@ -171,6 +171,18 @@ g_value_array_get_type (void)
 }
 
 GType
+g_strv_get_type (void)
+{
+  static GType type_id = 0;
+
+  if (!type_id)
+    type_id = g_boxed_type_register_static ("GStrv",
+                                           (GBoxedCopyFunc) g_strdupv,
+                                           (GBoxedFreeFunc) g_strfreev);
+  return type_id;
+}
+
+GType
 g_gstring_get_type (void)
 {
   static GType type_id = 0;
index 7e57c5c..b4bf15d 100644 (file)
@@ -60,6 +60,7 @@ GType g_boxed_type_register_static            (const gchar    *name,
 #define        G_TYPE_CLOSURE          (g_closure_get_type ())
 #define        G_TYPE_VALUE            (g_value_get_type ())
 #define        G_TYPE_VALUE_ARRAY      (g_value_array_get_type ())
+#define        G_TYPE_STRV             (g_strv_get_type ())
 #define        G_TYPE_GSTRING          (g_gstring_get_type ())
 
 
@@ -72,7 +73,10 @@ void g_value_set_boxed_take_ownership        (GValue         *value,
 GType  g_closure_get_type      (void)  G_GNUC_CONST;
 GType  g_value_get_type        (void)  G_GNUC_CONST;
 GType  g_value_array_get_type  (void)  G_GNUC_CONST;
-GType  g_gstring_get_type      (void)  G_GNUC_CONST;
+GType  g_strv_get_type         (void)  G_GNUC_CONST;
+GType  g_gstring_get_type      (void)  G_GNUC_CONST;
+
+typedef gchar** GStrv;
      
 G_END_DECLS