Features/GTK3/Porting/Implode: Difference between revisions

Humitos (talk | contribs)
No edit summary
Humitos (talk | contribs)
 
(10 intermediate revisions by the same user not shown)
Line 8: Line 8:


There are some things related with <tt>gtk.DrawingArea</tt> 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.
There are some things related with <tt>gtk.DrawingArea</tt> 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 <tt>self.get_allocation_width</tt> to get the allocation size:
self.allocation.width
self.allocation.height
should be replaced by:
self.get_allocated_width()
self.get_allocated_height()


== Signals ==
== Signals ==


=== expose-event ===
=== expose-event ===
* http://developer.gnome.org/gtk3/3.5/GtkWidget.html#GtkWidget-draw


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:
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:
Line 20: Line 30:


=== size-allocate ===
=== size-allocate ===
* http://developer.gnome.org/gtk3/3.5/GtkWidget.html#GtkWidget-configure-event


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).
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).
Line 28: Line 36:


  def _configure_event_cb(self, widget, event):
  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


== Focus ==
== Focus ==
Line 74: Line 76:
  Rsvg.Handle.new_from_data(data)
  Rsvg.Handle.new_from_data(data)


= Invalidate rectangle =
<tt>Gdk.Window.invalidate_rect</tt> takes a ''Gdk.Rectangle'' instead a tuple in Gtk3.
rect = Gdk.Rectangle()
rect.x, rect.y, rect.width, rect.height = (0, 0, width, height)
self.get_window().invalidate_rect(rect, True)
= Notes =
* I had to add a third argument (None) to Gtk.Notebook.append_page but I don't know why
* Use '''json''' instead of ''simplejson'' or so
* Replace <tt>gtk.VISIBLE</tt> by '''Gtk.AccelFlags.VISIBLE'''
= 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?
* [<span style="color: green;">DONE</span>] <del>help dialogue is not working. It shows the example board but it's one pixel size when it opens</del>
* When the help dialogue is shown and you hover the animation with the mouse something strange happens and it starts to flap. [http://bugs.sugarlabs.org/attachment/ticket/3715/53.png Screenshot]


= Useful Links =
= Useful Links =


* http://developer.gnome.org/gtk3/3.5/GtkWidget.html#GtkWidget-draw
* http://developer.gnome.org/gtk3/3.5/GtkWidget.html#GtkWidget-configure-event
* http://developer.gnome.org/rsvg/stable/
* http://developer.gnome.org/rsvg/stable/
* http://developer.gnome.org/gdk3/stable/gdk3-Windows.html#gdk-window-invalidate-rect
* http://developer.gnome.org/gtk3/3.5/GtkWidget.html#gtk-widget-get-allocated-width
* http://developer.gnome.org/gtk3/3.5/GtkNotebook.html#gtk-notebook-append-page