Difference between revisions of "Features/GTK3/Porting/Implode"
|Line 90:||Line 90:|
= Useful Links =
= Useful Links =
|Line 98:||Line 107:|
Revision as of 06:59, 28 June 2012
This page is being performed while I'm porting Implode Activity to Gtk3.
There is a ticket with some useful information that I'm using on the porting and to keep tracking this port. Besides, this wiki page will be useful to write some code snippets about what are the difficulties that I'm having on the port and maybe can be useful for someone else.
I will take this guide as reference on the Gtk3 porting.
There are some things related with gtk.DrawingArea that we have to change when we are porting an activity to Gtk3. The names of the signals change and the way that they work as well.
Get allocation size
self.allocation property is no longer available and we should use self.get_allocation_width to get the allocation size:
should be replaced by:
This signal was override by draw and it have to be connected with the method that was connected with the expose-event before. The method itself does not change but the arguments that it receives do. This is the new definition of the function in my case:
def _draw_event_cb(self, widget, cr):
This signal was used to resize the gtk.DrawingArea every time the window grows and at the startup of the activity. This is useful to re-draw the widget for different resolutions (desktops and XOs for example).
I used the same function connected to this signal but I change the signal connected by configure-event. Here is the definition of the callback:
def _configure_event_cb(self, widget, event):
I just used the size-allocate signal to save the the dimensions of the widget (width and height), so I can use them later on the draw signal.
def _size_allocate_cb(self, widget, rect): self.width = rect.width self.height = rect.height
Implode defines a new widget called GridWidget and it should be focusable because we want to move a cursor with the key arrows on it. So, this widget was using:
but that method (set_flags) is no longer available and we have to replace it by:
Another thing related with the focus is to know who has the actual focus. In gtk2 it was done by
and in Gtk3 it should be replaced by:
Handling .svg with rsvg
rsvg is a library to manage .svg files. The only thing that I found that should be updated is the import and the loading of a rsvg from data.
Replace the usual import:
by the Gtk3 one:
from gi.repository import Rsvg
This way to load a rsvg from data should be replaced:
by this new way
Gdk.Window.invalidate_rect takes a Gdk.Rectangle instead a tuple in Gtk3.
rect = Gdk.Rectangle() rect.x, rect.y, rect.width, rect.height = (0, 0, width, height)
- I had to add a third argument (None) to Gtk.Notebook.append_page but I don't know why
Missing things (not ported yet)
- sugarless.py is not working. The board is not shown. Do we update this to keep it working? I mean, do we need to maintain this code?
- help dialogue is not working. It didn't show the example board when it opens