]> Pileus Git - ~andy/gtk/commitdiff
New function for language bindings.
authorJonathan Blandford <jrb@redhat.com>
Sat, 30 Jun 2001 21:15:27 +0000 (21:15 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Sat, 30 Jun 2001 21:15:27 +0000 (21:15 +0000)
Sat Jun 30 17:13:51 2001  Jonathan Blandford  <jrb@redhat.com>

* gtk/gtkliststore.c (gtk_list_store_newv): New function for
  language bindings.

* gtk/gtkteststore.c (gtk_test_store_newv): New function for
  language bindings.

gtk/gtkliststore.c
gtk/gtktreestore.c
gtk/gtktreestore.h
gtk/gtktreeview.c

index 5c0f29ef338eb39a4524574aa08d2b2564a2512b..4c315d472c85670a7f3971062c369997108e710f 100644 (file)
@@ -285,6 +285,43 @@ gtk_list_store_new (gint n_columns,
   return retval;
 }
 
+
+/**
+ * gtk_list_store_newv:
+ * @n_columns: number of columns in the list store
+ * @types: an array of #GType types for the columns, from first to last
+ *
+ * Non vararg creation function.  Used primarily by language bindings.
+ *
+ * Return value: a new #GtkListStore
+ **/
+GtkListStore *
+gtk_list_store_newv (gint   n_columns,
+                    GType *types)
+{
+  GtkListStore *retval;
+  gint i;
+
+  g_return_val_if_fail (n_columns > 0, NULL);
+
+  retval = GTK_LIST_STORE (g_object_new (gtk_list_store_get_type (), NULL));
+  gtk_list_store_set_n_columns (retval, n_columns);
+
+  for (i = 0; i < n_columns; i++)
+    {
+      if (! _gtk_tree_data_list_check_type (types[i]))
+       {
+         g_warning ("%s: Invalid type %s passed to gtk_list_store_new_with_types\n", G_STRLOC, g_type_name (types[i]));
+         g_object_unref (G_OBJECT (retval));
+         return NULL;
+       }
+
+      gtk_list_store_set_column_type (retval, i, types[i]);
+    }
+
+  return retval;
+}
+
 static void
 gtk_list_store_set_n_columns (GtkListStore *list_store,
                              gint          n_columns)
index 8032294dce796b56295f958af625e6a37a95be17..e4e55e2d46f95c76536b7cf2f1626cad731c9b94 100644 (file)
@@ -242,6 +242,18 @@ gtk_tree_store_init (GtkTreeStore *tree_store)
   tree_store->sort_column_id = -1;
 }
 
+/**
+ * gtk_tree_store_new:
+ * @n_columns: number of columns in the tree store
+ * @Varargs: all #GType types for the columns, from first to last
+ *
+ * Creates a new tree store as with @n_columns columns each of the types passed
+ * in.  As an example, gtk_tree_store_new (3, G_TYPE_INT, G_TYPE_STRING,
+ * GDK_TYPE_PIXBUF); will create a new GtkTreeStore with three columns, of type
+ * int, string and GDkPixbuf respectively.
+ *
+ * Return value: a new #GtkTreeStore
+ **/
 GtkTreeStore *
 gtk_tree_store_new (gint n_columns,
                               ...)
@@ -272,6 +284,40 @@ gtk_tree_store_new (gint n_columns,
 
   return retval;
 }
+/**
+ * gtk_tree_store_newv:
+ * @n_columns: number of columns in the tree store
+ * @types: an array of #GType types for the columns, from first to last
+ *
+ * Non vararg creation function.  Used primarily by language bindings.
+ *
+ * Return value: a new #GtkTreeStore
+ **/
+GtkTreeStore *
+gtk_tree_store_newv (gint   n_columns,
+                    GType *types)
+{
+  GtkTreeStore *retval;
+  gint i;
+
+  g_return_val_if_fail (n_columns > 0, NULL);
+
+  retval = GTK_TREE_STORE (g_object_new (GTK_TYPE_TREE_STORE, NULL));
+  gtk_tree_store_set_n_columns (retval, n_columns);
+
+   for (i = 0; i < n_columns; i++)
+    {
+      if (! _gtk_tree_data_list_check_type (types[i]))
+       {
+         g_warning ("%s: Invalid type %s passed to gtk_tree_store_new_with_types\n", G_STRLOC, g_type_name (types[i]));
+         g_object_unref (G_OBJECT (retval));
+         return NULL;
+       }
+      gtk_tree_store_set_column_type (retval, i, types[i]);
+    }
+
+  return retval;
+}
 
 /**
  * gtk_tree_store_set_n_columns:
@@ -281,7 +327,7 @@ gtk_tree_store_new (gint n_columns,
  * As a side effect of calling this function, all sort columns that overlap with
  * the current number of columns will be removed.
  **/
-void
+static void
 gtk_tree_store_set_n_columns (GtkTreeStore *tree_store,
                              gint          n_columns)
 {
@@ -326,7 +372,7 @@ gtk_tree_store_set_n_columns (GtkTreeStore *tree_store,
  * subclasses of those types such as %GDK_TYPE_PIXBUF.
  *
  **/
-void
+static void
 gtk_tree_store_set_column_type (GtkTreeStore *tree_store,
                                gint          column,
                                GType         type)
index 37eb935f987afc52a3851a83b725710d88e4dcb0..32f558ad097f6623e03a09708222cd7beb18a76a 100644 (file)
@@ -61,6 +61,8 @@ struct _GtkTreeStoreClass
 GtkType       gtk_tree_store_get_type        (void);
 GtkTreeStore *gtk_tree_store_new             (gint          n_columns,
                                              ...);
+GtkTreeStore *gtk_tree_store_newv            (gint          n_columns,
+                                             GType        *types);
 void          gtk_tree_store_set_value       (GtkTreeStore *tree_store,
                                              GtkTreeIter  *iter,
                                              gint          column,
index d226e86c768144c4bd9ac49bd0b141c271f691a9..212ad31780d4afa28c41f2703e54310e12adcb88 100644 (file)
@@ -6895,10 +6895,8 @@ gtk_tree_view_scroll_to_cell (GtkTreeView       *tree_view,
    */
 
   g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
-  g_return_if_fail (row_align >= 0.0);
-  g_return_if_fail (row_align <= 1.0);
-  g_return_if_fail (col_align >= 0.0);
-  g_return_if_fail (col_align <= 1.0);
+  g_return_if_fail (row_align >= 0.0 && row_align <= 1.0);
+  g_return_if_fail (col_align >= 0.0 && col_align <= 1.0);
   g_return_if_fail (path != NULL || column != NULL);
 
   row_align = CLAMP (row_align, 0.0, 1.0);