com gtk/php-gtk: Allowing GtkWidget::drag_dest_find_t arget to omit the second parameter: TODO2 ext /gtk+/gtkdrag.overrides

[email protected] (David Soria Parra)
Newsgroups php.gtk.cvs
Message-ID <[email protected]>
Commit:    356e392b4f4040416b2391a4ac0c3c3f898b8642
Author:    Christian Weiske <[email protected]>         Wed, 3 May 2006 16:56:31 +0000
Parents:   3646021a98de01670eab57ac0810e6e8e6b09cbd
Branches:  master

Link:       http://git.php.net/?p=gtk/php-gtk.git;a=commitdiff;h=356e392b4f4040416b2391a4ac0c3c3f898b8642

Log:
Allowing GtkWidget::drag_dest_find_target to omit the second parameter

Changed paths:
  M  TODO2
  M  ext/gtk+/gtkdrag.overrides


Diff:
356e392b4f4040416b2391a4ac0c3c3f898b8642
diff --git a/TODO2 b/TODO2
index 81576a2..e38fb37 100644
--- a/TODO2
+++ b/TODO2
@@ -115,9 +115,6 @@ Classes and Functions
 	constructor	create_from_xpm_d()
 * GtkPlug/GtkSocket
 * Support (array) cast for GtkTreeModelRow and possibly unset()
-* GtkWindow
-    drag_dest_find_target should accept NULL as second parameter, and even omitting the second one
-     (as the gtk docs state)
 
 Fix
 ~~~
diff --git a/ext/gtk+/gtkdrag.overrides b/ext/gtk+/gtkdrag.overrides
index 0537d6e..daca98a 100644
--- a/ext/gtk+/gtkdrag.overrides
+++ b/ext/gtk+/gtkdrag.overrides
@@ -175,7 +175,7 @@ PHP_METHOD
 %%
 add-arginfo GtkWidget drag_dest_find_target
 static
-ZEND_BEGIN_ARG_INFO(ARGINFO_NAME, 0)
+ZEND_BEGIN_ARG_INFO_EX(ARGINFO_NAME, 0, 0, 1)
     ZEND_ARG_OBJ_INFO(0, context, GdkDragContext, 1)
     ZEND_ARG_INFO(0, targets)
 ZEND_END_ARG_INFO();
@@ -184,25 +184,30 @@ ZEND_END_ARG_INFO();
 override gtk_drag_dest_find_target
 PHP_METHOD
 {
-    zval *php_targets, *php_context;
+    zval *php_targets = NULL, *php_context;
     GtkTargetEntry *entries;
-    GtkTargetList *tlist;
+    GtkTargetList *tlist = NULL;
     GdkAtom atom;
     int n;
 
     NOT_STATIC_METHOD();
 
-    if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "Oa", &php_context, gdkdragcontext_ce, &php_targets)) {
+    if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "O|a", &php_context, gdkdragcontext_ce, &php_targets)) {
         return;
     }
 
-    entries = phpg_parse_target_entries(php_targets, &n TSRMLS_CC);
-	tlist = gtk_target_list_new(entries, n);
-	efree(entries);
+    if (php_targets) {
+        entries = phpg_parse_target_entries(php_targets, &n TSRMLS_CC);
+        tlist = gtk_target_list_new(entries, n);
+        efree(entries);
+    }
 
     atom = gtk_drag_dest_find_target(GTK_WIDGET(PHPG_GOBJECT(this_ptr)),
-                                     GDK_DRAG_CONTEXT(PHPG_GOBJECT(php_context)), tlist);
-    gtk_target_list_unref(tlist);
+                                    GDK_DRAG_CONTEXT(PHPG_GOBJECT(php_context)), tlist);
+
+    if (php_targets) {
+        gtk_target_list_unref(tlist);
+    }
 
     RETURN_STRING(gdk_atom_name(atom), 0);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.