Difference between revisions of "Features/GTK3/Porting/InfoSlicer"
m (moved User:Humitos/PortingInfoSlicer to Features/GTK3/Porting/InfoSlicer: Moved to make it available / editable by anybody) |
|
(No difference)
|
Revision as of 13:26, 4 July 2012
This page is being performed while I'm porting InfoSlicer 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.
Remove hippo
First of all, I had to remove the hippo related things and the sugar-port (ticket) wrapper.
Code Snippets
Signals
Change TYPE_PYOBJECT type from a signal
We should replace the TYPE_PYOBJECT
'article-selected' : (SIGNAL_RUN_FIRST, None, [TYPE_PYOBJECT]),
by the Python's object type
'article-selected' : (GObject.SignalFlags.RUN_FIRST, None, [object]),
Working with threads
InfoSlicer uses threads to retrieve the information from internet (Wikipedia articles). The pygi script will replace it by Gdk.threads_init() by I found this is not the correct way to do this. In fact, I was dealing with some strange behaviour of the Activity because of this. So, I used:
from gi.repository import GObject GObject.threads_init()
gtk.gdk._2BUTTON_PRESS
We should replace:
gtk.gdk._2BUTTON_PRESS gtk.gdk._3BUTTON_PRESS
by:
Gdk.EventType._2BUTTON_PRESS Gdk.EventType._3BUTTON_PRESS
Gtk.TextBuffer.get_slice() needs a new argument
We need a new argument to indicate if we want to include the hidden_chars as well. It wasn't required in gtk2 and by default it was True
buf = gtk.TextBuffer() buf.get_slice(start, end)
replaced by:
buf = Gtk.TextBuffer() buf.get_slice(start, end, include_hidden_chars)
Alerts
We have to change the way that alerts were shown because self.notify_alert is no longer available after applying this patch
Example about how to use the different types of alerts:
- A simple alert:
from sugar3.graphics.alert import Alert # Create a new simple alert alert = Alert() # Populate the title and text body of the alert. alert.props.title = _('Title of Alert Goes Here') alert.props.msg = _('Text message of alert goes here') # Call the add_alert() method (inherited via the sugar3.graphics.Window # superclass of Activity) to add this alert to the activity window. self.add_alert(alert) alert.show()
- NotifyAlert
from sugar3.graphics.alert import NotifyAlert
def __alert_notify_response_cb(alert, response_id, activity): activity.remove_alert(alert)
alert = NotifyAlert(5) alert.props.title = _('Nothing to publish') alert.props.msg = _('Mark arcticles from "Custom" ' 'panel and try again.') alert.connect('response', __alert_notify_response_cb, activity) activity.add_alert(alert) alert.show()
Missing / Problematic things (not ported yet)
- Select text from the Edit View (TextView) and the Home View. This error happens in many places of the code.
Traceback (most recent call last): File "/home/humitos/Activities/InfoSlicer.activity/infoslicer/widgets/Readonly_Textbox.py", line 116, in motion_notify self.emit("motion-notify-event", event) TypeError: could not convert type EventMotion to GdkEvent required for parameter 0
- In the Edit View I cannot drag & drop images to my article (there is no error in the log)
- Issue related with "adding rows to the TreeView": https://bugzilla.gnome.org/show_bug.cgi?id=679415
Useful links
- Ticket that removes hippo and sugar-port: http://bugs.sugarlabs.org/ticket/3743