Features/GTK3/Porting/GetBooks: Difference between revisions

Humitos (talk | contribs)
Humitos (talk | contribs)
No edit summary
Line 51: Line 51:


If you have an XO, I'm sure you want to take a look at [[User:Humitos/x2x|this]]...
If you have an XO, I'm sure you want to take a look at [[User:Humitos/x2x|this]]...
= Code Snippets =
On this section I will explain all the things that I had to do manually and took me some time to find out. Some of them are really simple but time-consuming so the idea is to reduce that time as much as we can.
== Migrate custom signals ==
If you have defined custom gtk objects with custom signal you should migrate them to [http://python-gtk-3-tutorial.readthedocs.org/en/latest/objects.html the new way] to do this.
You should replace this:
from gobject import signal_new, TYPE_INT, TYPE_STRING, TYPE_BOOLEAN, \
TYPE_PYOBJECT, TYPE_NONE, SIGNAL_RUN_LAST
signal_new('extlistview-modified', gtk.TreeView, SIGNAL_RUN_LAST, TYPE_NONE,
            ())
by adding the signal definition inside the object that you are creating using the <tt>__gsignals__</tt> dictionary like this (in this case Gtk.TreeView is the class that our object inherits):
from gi.repository import GObject
class ExtListViewColumn(Gtk.TreeViewColumn):
    __gsignals__ = {
      'extlistview-modified': (GObject.SignalFlags.RUN_LAST, None,
                              ()),
        }
The last argument of the signal definition are the argument types that the callback will receive. For example, that tuple could be (str, int) if the callback receives two arguments, a string and an integer (first and second argument position)


= References / Useful links =
= References / Useful links =
Line 56: Line 84:
* Guide you should follow: http://wiki.sugarlabs.org/go/Features/GTK3/Porting
* Guide you should follow: http://wiki.sugarlabs.org/go/Features/GTK3/Porting
* PyGtk documentation
* PyGtk documentation
** Gtk3: http://python-gtk-3-tutorial.readthedocs.org/en/latest/objects.html#objects
** Gtk3: http://python-gtk-3-tutorial.readthedocs.org
** gtk2: http://www.pygtk.org/docs/pygobject/gobject-functions.html
** gtk2: http://www.pygtk.org/docs/pygtk/
* Reference Manual
* Reference Manual
** Gtk3: http://developer.gnome.org/gtk3/3.4/
** Gtk3: http://developer.gnome.org/gtk3/3.4/