Features/GTK3/Porting: Difference between revisions
Merge useful content from https://wiki.sugarlabs.org/go/Features/GTK3/Porting/GetBooks Tag: visualeditor-switched |
No edit summary Tag: visualeditor-switched |
||
| Line 12: | Line 12: | ||
#Resolve any existing pull requests before porting to avoid conflicts at a later stage. | #Resolve any existing pull requests before porting to avoid conflicts at a later stage. | ||
#Run this [http://git.gnome.org/browse/pygobject/tree/pygi-convert.sh script] that will convert automatically things as much as it can. This is to avoid some stressful manually conversions that a "simple script" can do using ''sed'' :) | #Run this [http://git.gnome.org/browse/pygobject/tree/pygi-convert.sh script] that will convert automatically things as much as it can. This is to avoid some stressful manually conversions that a "simple script" can do using ''sed'' :) | ||
#Follow the [[Development Team/Code guidelines|Code Guidelines]] during all the porting process | #Follow the [[Development Team/Code guidelines|Code Guidelines]] during all the porting process | ||
#Make the API changes in sugar-toolkit-gtk3 | #Make the API changes in sugar-toolkit-gtk3 | ||
#Write comments on the code, by adding '''# README:''', '''# TODO:''' and '''# FIXME:''' explaining what are the problems that you are having with that chunk of code. Put a link if it's necessary | #Write comments on the code, by adding '''# README:''', '''# TODO:''' and '''# FIXME:''' explaining what are the problems that you are having with that chunk of code. Put a link if it's necessary | ||
== | ==API changes in sugar-toolkit == | ||
* | * The keep button has been removed | ||
* | * The old-style toolbar has been removed | ||
* set_toolbar_box is used instead of set_toolbox (see in [http://git.sugarlabs.org/~walter/abacus/walter-cairo/commit/6871dd340a89ade3b5361457e1bd1d58276a8efc Abacus]) | *<code>set_toolbar_box</code> is used instead of <code>set_toolbox</code> (see in [http://git.sugarlabs.org/~walter/abacus/walter-cairo/commit/6871dd340a89ade3b5361457e1bd1d58276a8efc Abacus]) | ||
* | * Remove import of deprecated ActivityToolbox (see [http://git.sugarlabs.org/hello-world/mainline/commit/22060a3063b2d6fd38d6b1cd8d44946170255af3 hello-world]) | ||
* | * Support for <code>service_name</code> and <code>class</code> tags in activity.info has been removed. Use <code>bundle_id</code> instead of <code>service_name</code> and <code>exec</code> instead of <code>class</code> (see in [http://git.sugarlabs.org/record/mainline/commit/6e8968c71e474e2d8d86886badf5cf7d70217dc5 Record]) | ||
* <code>sugar3.activity.Activity</code> | * <code>sugar3.activity.Activity</code> does not have the ''window'' attribute. Use the <code>.get_window()</code> method instead. | ||
==Port the activity from GTK2 to GTK3== | ==Port the activity from GTK2 to GTK3== | ||
| Line 34: | Line 32: | ||
from gi.repository import Gtk | from gi.repository import Gtk | ||
Note that require_version needs to called only the first time when Gtk is being imported. | Note that <code>require_version</code> needs to called only the first time when Gtk is being imported. | ||
Similar imports that may be used are: | |||
<pre> | <pre> | ||
from gi.repository import Gdk, Pango, Gobject | from gi.repository import Gdk, Pango, Gobject | ||
| Line 65: | Line 63: | ||
from sugar3.activity import activity | from sugar3.activity import activity | ||
The changes that were needed to port the hello-world activity can be seen in [https://github.com/sugarlabs/hello-world/commit/508e1c518b56cbde5508e560c8a2ff38a3518583 this commit.] | |||
The changes that were needed to port the hello-world activity can be seen in [ | |||
====Simple example on creating a toolbar==== | ====Simple example on creating a toolbar==== | ||