Re: Defeated
| From: | Steph | Date: | Thu, 20 Oct 2005 12:47:26 +0000 |
| Subject: | Re: Defeated | ||
| Groups: | php.gtk.dev | ||
| Request: | Send a blank email to php-gtk-dev+get-1866@lists.php.net to get a copy of this message | ||
Forget it, I played with the script I have here & the original function and
it works now (in as much as it reaches the marshal). I'm trying to figure
out wtf I was doing before to prevent it...
----- Original Message -----
From: "Steph" <steph@zend.com>
To: "Tom Rogers" <trogers@kwikin.com>
Cc: "PHP-GTK dev" <php-gtk-dev@lists.php.net>; "Andrei"
<andrei@gravitonic.com>
Sent: Thursday, October 20, 2005 1:23 PM
Subject: Re: [PHP-GTK-DEV] Defeated
> ? My problem was not EVER reaching the callback marshal, which is why I
> didn't start working on it!!
>
> I think perhaps it would be fairly useful to see a working PHP script at
> this point - the things you are saying here are alien, so it's possible I
> just don't know how to use the callback in Glade...
>
> - Steph
>
>
>
> ----- Original Message -----
> From: "Tom Rogers" <trogers@kwikin.com>
> To: "Steph" <steph@zend.com>
> Cc: "PHP-GTK dev" <php-gtk-dev@lists.php.net>; "Andrei"
> <andrei@gravitonic.com>
> Sent: Thursday, October 20, 2005 9:29 AM
> Subject: Re: [PHP-GTK-DEV] Defeated
>
>
> > Hi Steph,
> >
> > Tuesday, October 18, 2005, 1:24:06 AM, you wrote:
> > S> I just spent some hours trying to get
> > S> glade_xml_signal_connect() working. I
> > S> knew it'd be a bit of a challenge, but it's more of an Everest than
the
> > S> anticipated large Alp.
> >
> > S> Quite possibly I'm attacking it from the wrong direction anyway. I'd
> have
> > S> _liked_ to use phpg_signal_connect_impl(), but a) it isn't exporting
> nicely
> > S> when I force it (possibly that's a win32 thing?), and b) it's
> effectively
> > S> private to /main at present (deliberately so?).
> >
> > S> I ended up with g_signal_connect() and friends - convenience
functions
> in
> > S> glib - but somehow the data isn't even getting far enough to prove me
> wrong
> > S> over that. It never reaches the marshal function
> (GladeXMLConnectFunc), and
> > S> I've been looking at it for so long now I'm absolutely out of ideas
as
> to
> > S> why.
> >
> > S> glade_xml_signal_connect() is the difficult one of the generic
GladeXML
> > S> signal methods, the others will fall into place almost as soon as
this
> one's
> > S> working.
> >
> > S> Any heroes out there?
> >
> > S> - Steph
> >
> > S> ps my effort's attached as a unified diff
> >
> > This works for me as a basic test and will need more work :)
> >
> > static void glade_signal_marshal(const gchar *handler_name, GObject
*obj,
> const gchar *signal_name,
> > const gchar *signal_data, GObject *connect_object, gboolean after,
> gpointer data)
> > {
> > phpg_cb_data_t *cbd = (phpg_cb_data_t *)data;
> > char *callback_name;
> > guint signal_id, handler_id;
> > GQuark detail = 0;
> > GClosure *closure = NULL;
> > TSRMLS_FETCH();
> >
> > fprintf(stdout, "DEBUG: reached the marshal function %s :
> %s\n",handler_name,signal_name); // I never get this far - why?
> >
> > if (!zend_is_callable(cbd->callback, 0, &callback_name)) {
> > php_error(E_WARNING, "unable to call GladeXML callback '%s'
> specified in %s on line %ld",
> > callback_name, cbd->src_filename, cbd->src_lineno);
> > efree(callback_name);
> > return;
> > }
> >
> > /* If we ever reach here, this is where cbd->user_args should be
> checked... */
> > if (!g_signal_parse_name(signal_name, G_OBJECT_TYPE(obj),
&signal_id,
> &detail, TRUE)) {
> > php_error(E_WARNING, "%s(): unknown signal name '%s'",
> get_active_function_name(TSRMLS_C), signal_name);
> > return;
> > }
> >
> > closure = phpg_closure_new(cbd->callback, cbd->user_args,
> PHPG_CONNECT_NORMAL TSRMLS_CC);
> > handler_id = g_signal_connect_closure_by_id(obj, signal_id, detail,
> closure, after);
> >
> > efree(callback_name);
> > }
> >
> > static PHP_METHOD(GladeXML, signal_connect)
> > {
> > char *signal = NULL;
> > zval *callback = NULL, *extra = NULL;
> > zend_bool free_signal;
> > phpg_cb_data_t *data;
> >
> > NOT_STATIC_METHOD();
> >
> > if (!php_gtk_parse_varargs(ZEND_NUM_ARGS(), 2, &extra, "uV",
&signal,
> &free_signal, &callback))
> > return;
> >
> > zval_add_ref(&callback);
> > data = phpg_cb_data_new(callback, extra TSRMLS_CC);
> >
> > fprintf(stdout, "signal name is %s on line 175\n", signal);
> >
> > glade_xml_signal_connect_full(GLADE_XML(PHPG_GOBJECT(this_ptr)),
> signal,
> >
> (GladeXMLConnectFunc)glade_signal_marshal, data);
> >
> > if (free_signal) g_free(signal);
> >
> > RETURN_NULL();
> > }
> >
> >
> > The function name in the xml file was
> >
> > <child>
> > <widget class="GtkImageMenuItem" id="open1">
> > <property name="visible">True</property>
> > <property name="label">gtk-open</property>
> > <property name="use_stock">True</property>
> > <signal name="activate" handler="on_open1_activate"
> last_modification_time="Tue, 18 Oct 2005 00:12:42 GMT"/>
> > </widget>
> > </child>
> >
> > so my php function call was:
> >
> > $glade->signal_connect('on_open1_activate','on_open1_activate');
> >
> > my call back function I also called 'on_open1_activate'
> >
> > Hope this helps a bit
> >
> > --
> > regards,
> > Tom
> >
>