← Back to team overview

unity-dev team mailing list archive

Re: [Ayatana-dev] Unity Lens: results model and items with no valid URI

 

On Wed, 2011-05-11 at 14:15 +0200, Johannes H. Jensen wrote:
> Hi again,
> 
> After some helpful advice in #pygtk, I found the problem with my
> activate() implementation. The name should be 'do_activate' in order
> to implement the C method 'activate':
> 
> def do_activate(*args):
>         print "activate:", args
> 
>         return Unity.ActivationStatus.ACTIVATED_HIDE_DASH
> 
> After this change, my do_activate method is at least called. However,
> there's another problem:
> 
> Apparently, the Unity.Activation interface is incompatible with pygi
> because of the use of callbacks:
> 
> void activate (const gchar* uri, GAsyncReadyCallback _callback_,
> gpointer _user_data_);
> 
> When do_activate is called from libunity, this is the output:
> 
> ** (process:23642): WARNING **: You are trying to use an API which
> returns a callback.Callback returns can not be supported. Returning
> None instead.
> activate: ('@\xbfT\x02', None, None)
> 
> So not only is the callback argument skipped (None), but the other
> arguments (self, uri) are also bogus...
> 
> I'm not sure where to go from here, but it seems to be that
> implementing Unity.Activation in python is not possible at this point.

Hi,

Thanks for persevering with this Johannes!

I think the underlying problem is that the interface is defined as async
in the Vala code (of lp:libunity). This is no problem at all in Vala,
and only a minor inconvenience in C, but with GI-bound languages such as
Python this may become a problem (or in the specific case of PyGI we now
*know* it's a problem).

I can't recall exactly why it was made async originally, but of the top
of my head I can't think of any reason it needs to be that way. So maybe
file a bug against libunity (also add a task on unity itself) requesting
that the method be converted into a normal synchronous ala:

  UnityActivationStatus  activate (const gchar *uri);

Libunity will have to see some breakage for Oneiric anyway, so this one
may as well go with it.

Cheers,
Mikkel


> On Tue, May 10, 2011 at 10:01 PM, Johannes H. Jensen
> <joh@xxxxxxxxxxxxxxxxx> wrote:
> > Greetings,
> >
> > Recompiled libunity with debugging symbols, here's a more helpful backtrace:
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x0000000000000000 in ?? ()
> > (gdb) bt
> > #0  0x0000000000000000 in ?? ()
> > #1  0x00007ffff38566c2 in unity_activation_activate (self=0x966460,
> >    uri=0xca2c20 "unity-tomboy://e9ccd176-1f2a-4e14-9b48-25c105c7cf01",
> >    _callback_=0x7ffff3851ca6
> > <unity_place_service_impl_activate_ready>, _user_data_=0xca2850)
> >    at unity-place-activation.c:97
> > #2  0x00007ffff3851dcc in unity_place_service_impl_real_activate_co
> > (data=0xca2850)
> >    at unity-place.c:4118
> > #3  0x00007ffff3851c5e in unity_place_service_impl_real_activate
> > (base=0xbf7cc0,
> >    uri=0xc9adc0 "unity-tomboy://e9ccd176-1f2a-4e14-9b48-25c105c7cf01",
> >    _callback_=0x7ffff3856cce <_dbus_unity_activation_activate_ready>,
> > _user_data_=0x968060)
> >    at unity-place.c:4075
> > #4  0x00007ffff38566c2 in unity_activation_activate (self=0xbf7cc0,
> >    uri=0xc9adc0 "unity-tomboy://e9ccd176-1f2a-4e14-9b48-25c105c7cf01",
> >    _callback_=0x7ffff3856cce <_dbus_unity_activation_activate_ready>,
> > _user_data_=0x968060)
> >    at unity-place-activation.c:97
> > #5  0x00007ffff3856cb8 in _dbus_unity_activation_activate
> > (self=0xbf7cc0, parameters=0xca4af0,
> >    invocation=0x968060) at unity-place-activation.c:211
> > #6  0x00007ffff3856e5b in unity_activation_dbus_interface_method_call
> > (connection=0x95b830,
> >    sender=0xc9eae0 ":1.184", object_path=0xcab970
> > "/net/launchpad/unityplacetomboy",
> >    interface_name=0x95b640 "com.canonical.Unity.Activation",
> > method_name=0xc67fe0 "Activate",
> >    parameters=0xca4af0, invocation=0x968060, user_data=0xc71070)
> >    at unity-place-activation.c:246
> > #7  0x00007ffff4bff350 in call_in_idle_cb (user_data=0x968060)
> >    at /build/buildd/glib2.0-2.28.6/./gio/gdbusconnection.c:4434
> > #8  0x00007ffff50cbbcd in g_main_dispatch (context=0x964530)
> >    at /build/buildd/glib2.0-2.28.6/./glib/gmain.c:2440
> > #9  g_main_context_dispatch (context=0x964530)
> >    at /build/buildd/glib2.0-2.28.6/./glib/gmain.c:3013
> > #10 0x00007ffff50cc3a8 in g_main_context_iterate (context=0x964530,
> >    block=<value optimized out>, dispatch=1, self=<value optimized out>)
> >    at /build/buildd/glib2.0-2.28.6/./glib/gmain.c:3091
> > #11 0x00007ffff50cc9f2 in g_main_loop_run (loop=0xc72860)
> >    at /build/buildd/glib2.0-2.28.6/./glib/gmain.c:3299
> > #12 0x00007ffff42db051 in ?? () from
> > /usr/lib/python2.7/dist-packages/glib/_glib.so
> > #13 0x00000000004970ef in PyEval_EvalFrameEx ()
> > #14 0x000000000049d325 in PyEval_EvalCodeEx ()
> > #15 0x00000000004ecb02 in PyEval_EvalCode ()
> > #16 0x00000000004fdc74 in ?? ()
> > #17 0x000000000042c182 in PyRun_FileExFlags ()
> > #18 0x000000000042cb4a in PyRun_SimpleFileExFlags ()
> > #19 0x0000000000418c9e in Py_Main ()
> > #20 0x00007ffff69c2eff in __libc_start_main () from
> > /lib/x86_64-linux-gnu/libc.so.6
> > #21 0x00000000004c62b1 in _start ()
> >
> > As far as I can tell, I'm not implementing the interface properly in
> > python... Any ideas?
> >
> >
> > Best regards,
> >
> > Johannes
> >
> >
> >
> > On Mon, May 2, 2011 at 1:00 PM, Johannes H. Jensen
> > <joh@xxxxxxxxxxxxxxxxx> wrote:
> >> Hi,
> >>
> >> So I'm trying to implement these activation hooks in Python, but I'm
> >> kinda stuck.
> >>
> >> I've got the Daemon class implementing Unity.Activation, with the
> >> constructor passing self to the Unity.PlaceController activation
> >> property:
> >>
> >> class Daemon(GObject.Object, Unity.Activation):
> >>    def __init__ (self):
> >>        GObject.Object.__init__(self)    # Important!
> >>        << snip >>
> >>        self._ctrl = Unity.PlaceController.new
> >> ("/net/launchpad/unityplacetomboy")
> >>        self._ctrl.add_entry (self._entry)
> >>        self._ctrl.props.activation = self
> >>        self._ctrl.export ()
> >>
> >>    def activate(self, uri):
> >>        print "activate:" + uri
> >>        return Unity.ActivationStatus.ACTIVATED_HIDE_DASH
> >>
> >>
> >> As far as I can see, this is how it's done in
> >> unity-place-applications. However, calling the Activation method of
> >> the dbus object (using d-feet, with a bogus url) results in a
> >> segfault:
> >>
> >> Program received signal SIGSEGV, Segmentation fault.
> >> 0x0000000000000000 in ?? ()
> >> (gdb) bt
> >> #0  0x0000000000000000 in ?? ()
> >> #1  0x00007ffff384b7db in ?? () from /usr/lib/libunity.so.4
> >> #2  0x00007ffff3858368 in ?? () from /usr/lib/libunity.so.4
> >> #3  0x00007ffff4bff350 in ?? () from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
> >> #4  0x00007ffff50cbbcd in g_main_context_dispatch ()
> >>   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
> >> #5  0x00007ffff50cc3a8 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
> >> #6  0x00007ffff50cc9f2 in g_main_loop_run ()
> >>   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
> >> #7  0x00007ffff42db051 in ?? ()
> >>   from /usr/lib/python2.7/dist-packages/glib/_glib.so
> >> #8  0x00000000004970ef in PyEval_EvalFrameEx ()
> >> #9  0x000000000049d325 in PyEval_EvalCodeEx ()
> >> #10 0x00000000004ecb02 in PyEval_EvalCode ()
> >> #11 0x00000000004fdc74 in ?? ()
> >> #12 0x000000000042c182 in PyRun_FileExFlags ()
> >> #13 0x000000000042cb4a in PyRun_SimpleFileExFlags ()
> >> #14 0x0000000000418c9e in Py_Main ()
> >> #15 0x00007ffff69c2eff in __libc_start_main ()
> >>   from /lib/x86_64-linux-gnu/libc.so.6
> >> #16 0x00000000004c62b1 in _start ()
> >>
> >> Debugging symbols are missing from libunity and I can't find any -dbg
> >> package... Any thoughts on what I might be doing wrong?
> >>
> >>
> >> Regards,
> >>
> >> Johannes
> >>
> >>
> >>
> >> On Tue, Apr 12, 2011 at 11:36 AM, Mikkel Kamstrup Erlandsen
> >> <mikkel.kamstrup@xxxxxxxxxxxxx> wrote:
> >>> On Tue, 2011-04-12 at 02:13 +0200, Johannes H. Jensen wrote:
> >>>> Greetings,
> >>>>
> >>>> I'm writing a Unity Lens for Tomboy Notes. Reading through the docs, I
> >>>> find that each item in the results model needs a "uri" which is to be
> >>>> opened when the item is activated by the user. However, tomboy notes
> >>>> only have an internal URI, one which is not recognized by GNOME or
> >>>> Unity.
> >>>>
> >>>> A a note can be opened with a simple D-Bus call to Tomboy, but how can
> >>>> the activation of an item in the results model be used to trigger such
> >>>> a call? As far as I can see, there exists no signal for this
> >>>> purpose...
> >>>
> >>> Hi Johannes,
> >>>
> >>> This sounds awesome :-)
> >>>
> >>> For these cases Unity has an "Activation" API that can trigger callbacks
> >>> back to the daemon when the user clicks a result. It's described here
> >>> https://wiki.ubuntu.com/Unity/Lenses#Activation%20Hooks. The Apps place
> >>> use it to open the Software Center on the correct app when you click one
> >>> in the Apps Available for Download group. Check out
> >>> lp:unity-place-applications to see a working example of this.
> >>>
> >>> The usual way of doing this is to construct some private URI scheme like
> >>> unity-tomboy://$internal_tomboy_uri and register activation for that
> >>> with an entry like the following in your .place file:
> >>>
> >>> [Activation]
> >>> URIPattern=unity-tomboy://.+
> >>>
> >>> You must hen implement the Unity.Activation interface from libunity and
> >>> register it to your Unity.PlaceController. The registration is easy as
> >>> the activation backend is just a property on the controller. So it's
> >>> just ctrl.activation = my_activation_instance.
> >>>
> >>> Honestly, I am not exactly sure how to implement Unity.Activation from
> >>> Python, but from Vala or C it should be straight forward.
> >>>
> >>> Cheers,
> >>> Mikkel
> >>>
> >>>
> >>
> >





Follow ups

References