Re: Working with GVariant in Python



On Mon, Jun 25, 2012 at 11:39 AM, Micah Carrick <micah quixotix com> wrote:
> I wrote a Python port[1] of the Bloatpad example application from the
> GtkApplication docs this weekend as I wanted to play around with those
> application menus. I ended up submitting a couple of bugs (678655 and
> 678673) for some of the issues I came across. One of the bugs I can *almost*
> figure out a fix for, but, those GVariants are throwing me.
>
> Here is how I got it the application to work:
>
> variant = GLib.Variant('s', "left")
> action = Gio.SimpleAction.new_stateful("justify", variant.get_type(),
> variant)

I'd like to know more, because I want that application menu for my app
but I haven't yet been able to figure out how to get the menu to show
up (when I add the gtkbuilder xml to my own, and then add the menu,
Gnome Shell loses the 'Quit' entry menu and just shows me a blank
menu. I can't seem to make the Bloatpad menu work for me at all).

> And here is how I think it should work in Python applications:
>
> action = Gio.SimpleAction.new_stateful("justify", "left")

That would be nice.

> Am I correct in thinking that we shouldn't need a Python application to be
> working directly with GVariants--that PyGObject should handle that under the
> hood? If so, could somebody point me in the right direction in learning
> where and how GVariants are converted to and from Python types?

Well, there's /usr/lib64/python2.7/site-packages/gi/overrides/GLib.py
for starters.

> [1] https://github.com/MicahCarrick/python-bloatpad

I will have a look at this...

-- 
http://exolucere.ca


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]