]> saetta.ns0.it Git - libgtkform/commitdiff
Renamed GtkForm::get_field_from_name to
authorAndrea Zagli <azagli@libero.it>
Mon, 24 Aug 2009 16:40:18 +0000 (18:40 +0200)
committerAndrea Zagli <azagli@libero.it>
Mon, 24 Aug 2009 16:40:18 +0000 (18:40 +0200)
GtkForm::get_form_field_from_name.
Renamed GtkForm::gtk_form_get_widget_from_name to
GtkForm::get_form_widget_from_name.
Added GtkForm::get_widgets and GtkForm::get_objects_by_name.

src/form.c
src/form.h

index 583c55ad02174c53db2c387ebbbf8fbc6d99b076..a865d744b8bea9736a6e0c5d10682618812c5c59 100644 (file)
@@ -547,6 +547,7 @@ gtk_form_remove_field (GtkForm *form, GtkFormField *field)
 /**
  * gtk_form_add_fields:
  * @form: a #GtkForm object.
+ * @...: a NULL terminated list of #GtkFormFields to add.
  *
  */
 gboolean
@@ -569,13 +570,13 @@ gtk_form_add_fields (GtkForm *form, ...)
 }
 
 /**
- * gtk_form_get_field_from_name:
+ * gtk_form_get_form_field_from_name:
  * @form: a #GtkForm object.
  * @field_name:
  *
  */
 GtkFormField
-*gtk_form_get_field_from_name (GtkForm *form, const gchar *field_name)
+*gtk_form_get_form_field_from_name (GtkForm *form, const gchar *field_name)
 {
        GtkFormField *field = NULL;
        const gchar *name;
@@ -602,13 +603,14 @@ GtkFormField
 }
 
 /**
- * gtk_form_get_widget_from_name:
+ * gtk_form_get_form_widget_from_name:
  * @form: a #GtkForm object.
- * @widget_name:
+ * @widget_name: the #GtkFormWidget's name to return.
  *
+ * Returns: a #GtkFormWidget.
  */
 GtkFormWidget
-*gtk_form_get_widget_from_name (GtkForm *form, const gchar *widget_name)
+*gtk_form_get_form_widget_from_name (GtkForm *form, const gchar *widget_name)
 {
        GtkFormWidget *widget = NULL;
        GtkFormWidget *widget_ret = NULL;
@@ -637,6 +639,96 @@ GtkFormWidget
        return widget_ret;
 }
 
+/**
+ * gtk_form_get_objects:
+ * @form: a #GtkForm object.
+ *
+ * Returns: an array of all the #GtkWidget into the form. Must be free.
+ */ 
+GtkWidget
+**gtk_form_get_widgets (GtkForm *form)
+{
+       GtkFormPrivate *priv;
+
+       GtkWidget **ret;
+
+       GSList *fields;
+       guint l;
+
+       GtkFormWidget *form_widget;
+       GtkWidget *widget;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       ret = NULL;
+       l = 0;
+
+       fields = priv->fields;
+       while (fields != NULL)
+               {
+                       l++;
+                       ret = g_realloc (ret, l * sizeof (GtkWidget *));
+
+                       form_widget = gtk_form_field_get_gtk_form_widget ((GtkFormField *)fields->data);
+                       widget = gtk_form_widget_get_widget (form_widget);
+                       ret[l] = widget;
+
+                       fields = g_slist_next (fields);
+               }
+
+       return ret;
+}
+
+/**
+ * gtk_form_get_objects_by_name:
+ * @form: a #GtkForm object.
+ * @...: a NULL terminated list of objects name (gchar *) to return.
+ *
+ * Returns: an array of #GObject present in the #GtkBuilder object assigned to
+ * the form. Must be free.
+ */
+GObject
+**gtk_form_get_objects_by_name (GtkForm *form, ...)
+{
+       GObject **ret;
+
+       GtkFormPrivate *priv;
+
+       va_list vargs;
+       gchar *object_name;
+       guint l;
+
+       GObject *object;
+
+       g_return_val_if_fail (IS_GTK_FORM (form), NULL);
+
+       priv = GTK_FORM_GET_PRIVATE (form);
+
+       if (priv->gtkbuilder == NULL) return NULL;
+
+       ret = NULL;
+       l = 0;
+
+       va_start (vargs, form);
+
+       while ((object_name = va_arg (vargs, gchar *)) != NULL)
+               {
+                       object = gtk_builder_get_object (priv->gtkbuilder, object_name);
+                       if (object != NULL)
+                               {
+                                       l++;
+                                       ret = g_realloc (ret, l * sizeof (GObject *));
+                                       ret[l] = object;
+                               }
+               }
+
+       va_end (vargs);
+
+       return ret;
+}
+
 /**
  * gtk_form_clear:
  * @form: a #GtkForm object.
index 9bc1a8ee43b3b8aa9722107f44409f0afcc352e7..8fb0367b8255696897e41d3f7413d8d1ca28574b 100644 (file)
@@ -71,8 +71,11 @@ gboolean gtk_form_remove_field (GtkForm *form, GtkFormField *field);
 
 gboolean gtk_form_add_fields (GtkForm *form, ...);
 
-GtkFormField *gtk_form_get_field_from_name (GtkForm *form, const gchar *field_name);
-GtkFormWidget *gtk_form_get_widget_from_name (GtkForm *form, const gchar *widget_name);
+GtkFormField *gtk_form_get_form_field_from_name (GtkForm *form, const gchar *field_name);
+GtkFormWidget *gtk_form_get_form_widget_from_name (GtkForm *form, const gchar *widget_name);
+
+GtkWidget **gtk_form_get_widgets (GtkForm *form);
+GObject **gtk_form_get_objects_by_name (GtkForm *form, ...);
 
 gboolean gtk_form_clear (GtkForm *form);