← Back to team overview

unity-dev team mailing list archive

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

 

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