elementary / elementary/granite
Python bindings issues
- Dominant language
- Vala
- Stars
- 329
- Forks
- 65
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 31
Description
I'm trying to use libgranite from python via gir bindings and running into a couple of issues with them.
First, .gir file that's produced during the build is missing a `shared-library=` attribute, as a result you can't instantiate any Granite.* classes:
```
$ python3 -c 'from gi.repository import Granite; Granite.WidgetsSourceList()'
...
TypeError: could not get a reference to type class
```
I reported this at first to Debian ([bug](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911910), [patch](https://sources.debian.org/patches/granite/5.1.0-2/set-shared-library-attribute.patch/)) as I thought it was distro problem, but the culprit seems to build scripts in this repository and seems to also affect Elementary OS. Please consider cherrypicking their patch.
Second issue I ran into is that overriding `get_context_menu` virtual method for Granite.Widgets.SourceList.Item doesn't work, and as a result I can't create a custom menu for SourceList:
```
#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Granite', '1.0')
from gi.repository import Granite, Gtk
class Item(Granite.WidgetsSourceListItem):
def __init__(self):
super().__init__(name='item')
def do_get_context_menu(self):
print('do_get_context_menu called')
return Gtk.Menu()
item = Item()
print(item.get_context_menu())
```
Output: None, and my virtual method override (with `do_` prefix) never gets called.
Not sure if the bug is in granite or vala or (py-)gobject. Do you have any ideas how make it work from python?
Contributor guide
Assessment
This issue has not been assessed yet.