Re: Some GList* overrides

From: Date: Thu, 02 Feb 2006 07:11:18 +0000
Subject: Re: Some GList* overrides
References: 1  Groups: php.gtk.dev 
Request: Send a blank email to php-gtk-dev+get-2315@lists.php.net to get a copy of this message
Christian, Have you actually tested these methods? Do they work?
+ +%% +override gdk_display_list_devices +PHP_METHOD +{
+    GList *list, *item;
+
+    NOT_STATIC_METHOD();
+
+    if (!php_gtk_parse_args(ZEND_NUM_ARGS(), ""))
+        return;
+
+    list = gdk_display_list_devices(GDK_DISPLAY(PHPG_GOBJECT(this_ptr)));
+
+    array_init(return_value);
+    for (item = list; item; item = item->next) {
+        zval *php_item = NULL;
+        phpg_gobject_new(&php_item, G_OBJECT(item->data) TSRMLS_CC);
+        add_next_index_zval(return_value, php_item);
+    }
+
+    g_list_free(list);
+} + %% }}}
You should not free the list here. It's statically allocated. Check the API docs.
+ +%% {{{ GtkCellView + +%% +override gtk_cell_view_get_cell_renderers +PHP_METHOD +{
+    GList *list, *item;
+
+    NOT_STATIC_METHOD();
+
+    if (!php_gtk_parse_args(ZEND_NUM_ARGS(), ""))
+        return;
+
+    list = gtk_cell_view_get_cell_renderers(GTK_CELL_VIEW(PHPG_GOBJECT(this_ptr)));
+
+    array_init(return_value);
+    for (item = list; item; item = item->next) {
+        zval *php_item = NULL;
+        phpg_gobject_new(&php_item, G_OBJECT(item->data) TSRMLS_CC);
+        add_next_index_zval(return_value, php_item);
+    }
+
+    g_list_free(list);
+} + +%% }}}
Have you checked PyGTK implementation of this method? It seems they do some additional checks. But then again, gtk_tree_view_column_get_cell_renderers() doesn't. Up to you. -Andrei

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