Re: GtkListStore->insert()

From: Date: Thu, 13 Oct 2005 04:54:00 +0000
Subject: Re: GtkListStore->insert()
References: 1  Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-1807@lists.php.net to get a copy of this message
Scott, Good try, but it needs some more work. You may want to take a look at the PyGTK implementation of the same in gtktreeview.override file _wrap_gtk_list_store_insert(PyGObject *self, PyObject *args, PyObject *kwargs) -Andrei On Oct 12, 2005, at 4:20 PM, Scott Mattocks wrote:
As a follow up to my earlier message, I have made an attempt to make GtkListStore::insert work like append and prepend. I don't really know what I am doing but this worked for me. Please let me know if I am wasting my time because a) you don't want to override these methods or b) this is the saddest piece of code you have ever seen. If this patch is helpful I will try to override insert_after and insert_before. Thanks, Scott Index: ext/gtk+/gtktreeview.overrides =================================================================== RCS file: /repository/php-gtk/ext/gtk+/gtktreeview.overrides,v retrieving revision 1.18 diff -u -r1.18 gtktreeview.overrides
--- ext/gtk+/gtktreeview.overrides    11 Oct 2005 12:38:15 -0000    1.18
+++ ext/gtk+/gtktreeview.overrides    12 Oct 2005 23:13:03 -0000
@@ -161,6 +161,61 @@ } %% +add-arginfo GtkListStore insert +static +ZEND_BEGIN_ARG_INFO_EX(ARGINFO_NAME, 0, 0, 0)
+    ZEND_ARG_INFO(0, position)
+ZEND_END_ARG_INFO(); + +%% +override gtk_list_store_insert +PHP_METHOD +{
+    /* Set up stuff that is beyond my understanding.*/
+    /* There is some sort of triple pointer I think.*/
+    GtkTreeIter iter;
+    zval ***items;
+    gint position;
+
+    /* Get the number of arguments passed to the method.*/
+    int argc = ZEND_NUM_ARGS();
+
+    /* This method may not be called statically.*/
+    NOT_STATIC_METHOD();
+
+    /* Check the number of arguments given. It must be one.*/
+    if (argc != 1) {
+        php_error(E_WARNING, "%s::%s() requires exactly 1 argument, %d given",
+                  get_active_class_name(NULL TSRMLS_CC), get_active_function_name(TSRMLS_C), argc);
+        return;
+    }
+
+    /* Get the arguments passed in. (Argument really)*/
+    items = php_gtk_func_args(argc);
+
+    /* It's been way too long. I really don't remember what this does.*/
+    zval *zposition = *items[0];
+    /* Call some function to get the value from a pointer?*/
+    position = Z_LVAL_P(zposition);
+
+    /* Check for a negative position. If we don't we get a nasty Gtk+ */
+    /* error message. */
+    if (position < 0) {
+        php_error(E_WARNING, "%s::%s() requires argument 1 to be greater than zero, %d given",
+                  get_active_class_name(NULL TSRMLS_CC), get_active_function_name(TSRMLS_C), position);
+        return;
+    }
+
+    /* Now we should have the data we need.*/
+    /* Call the actual Gtk+ function.*/
+    gtk_list_store_insert(GTK_LIST_STORE(PHPG_GOBJECT(this_ptr)), &iter, position);
+
+    /* I am guessing that this sets the return value to the iter*/
+    /* that was just assigned.*/
+    phpg_gboxed_new(&return_value, GTK_TYPE_TREE_ITER, &iter, TRUE, TRUE TSRMLS_CC);
+} + +%% add-arginfo GtkListStore set static ZEND_BEGIN_ARG_INFO(ARGINFO_NAME, 0) --PHP-GTK Development Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.gtk.dev (#1807) next »