Port from GObject to GLib

This commit is contained in:
Rahul Bothra 2018-07-25 00:30:25 +05:30 committed by James Cameron
parent 6730d129cd
commit 13a2282e5e
23 changed files with 153 additions and 149 deletions

View File

@ -1,5 +1,5 @@
from gi.repository import Gtk
from gi.repository import GObject
from gi.repository import GLib
from sugar3.graphics.toolbarbox import ToolbarBox
from sugar3.graphics.progressicon import ProgressIcon
@ -51,7 +51,7 @@ def timeout_cb():
return True
GObject.timeout_add(50, timeout_cb)
GLib.timeout_add(50, timeout_cb)
if __name__ == '__main__':

View File

@ -582,7 +582,7 @@ class Activity(Window, Gtk.Container):
if not self._active and self._jobject:
self.save()
active = GObject.property(
active = GObject.Property(
type=bool, default=False, getter=get_active, setter=set_active)
'''
Whether an activity is active.
@ -621,7 +621,7 @@ class Activity(Window, Gtk.Container):
'''
self._max_participants = participants
max_participants = GObject.property(
max_participants = GObject.Property(
type=int, default=0, getter=get_max_participants,
setter=set_max_participants)

View File

@ -26,6 +26,7 @@ import logging
import dbus
from gi.repository import GObject
from gi.repository import GLib
from sugar3.activity.activityhandle import ActivityHandle
from sugar3 import util
@ -233,7 +234,7 @@ class ActivityCreationHandler(GObject.GObject):
stdout=log_file.fileno(),
stderr=log_file.fileno())
GObject.child_watch_add(child.pid,
GLib.child_watch_add(child.pid,
_child_watch_cb,
(log_file,
self._handle.activity_id))

View File

@ -90,9 +90,9 @@ class Alert(Gtk.EventBox):
}
__gproperties__ = {
'title': (str, None, None, None, GObject.PARAM_READWRITE),
'msg': (str, None, None, None, GObject.PARAM_READWRITE),
'icon': (object, None, None, GObject.PARAM_WRITABLE),
'title': (str, None, None, None, GObject.ParamFlags.READWRITE),
'msg': (str, None, None, None, GObject.ParamFlags.READWRITE),
'icon': (object, None, None, GObject.ParamFlags.WRITABLE),
}
def __init__(self, **kwargs):

View File

@ -151,7 +151,7 @@ class Animator(GObject.GObject):
if self._timeout_sid and \
not hasattr(self._widget, 'add_tick_callback'):
GObject.source_remove(self._timeout_sid)
GLib.source_remove(self._timeout_sid)
self._timeout_sid = 0
self.emit('completed')
if self._timeout_sid and hasattr(self._widget, 'add_tick_callback'):

View File

@ -138,7 +138,7 @@ class _ColorButton(Gtk.Button):
def get_color(self):
return self._color
color = GObject.property(type=object, getter=get_color, setter=set_color)
color = GObject.Property(type=object, getter=get_color, setter=set_color)
def set_icon_name(self, icon_name):
'''
@ -161,7 +161,7 @@ class _ColorButton(Gtk.Button):
'''
return self._preview.props.icon_name
icon_name = GObject.property(type=str,
icon_name = GObject.Property(type=str,
getter=get_icon_name, setter=set_icon_name)
def set_icon_size(self, icon_size):
@ -170,7 +170,7 @@ class _ColorButton(Gtk.Button):
def get_icon_size(self):
return self._preview.props.icon_size
icon_size = GObject.property(type=int,
icon_size = GObject.Property(type=int,
getter=get_icon_size, setter=set_icon_size)
def set_title(self, title):
@ -181,7 +181,7 @@ class _ColorButton(Gtk.Button):
def get_title(self):
return self._title
title = GObject.property(type=str, getter=get_title, setter=set_title)
title = GObject.Property(type=str, getter=get_title, setter=set_title)
def _set_has_invoker(self, has_invoker):
self._has_invoker = has_invoker
@ -189,9 +189,9 @@ class _ColorButton(Gtk.Button):
def _get_has_invoker(self):
return self._has_invoker
has_invoker = GObject.property(type=bool, default=True,
flags=GObject.PARAM_READWRITE |
GObject.PARAM_CONSTRUCT_ONLY,
has_invoker = GObject.Property(type=bool, default=True,
flags=GObject.ParamFlags.READWRITE |
GObject.ParamFlags.CONSTRUCT_ONLY,
getter=_get_has_invoker,
setter=_set_has_invoker)
@ -201,9 +201,9 @@ class _ColorButton(Gtk.Button):
def _get_has_palette(self):
return self._has_palette
has_palette = GObject.property(type=bool, default=True,
flags=GObject.PARAM_READWRITE |
GObject.PARAM_CONSTRUCT_ONLY,
has_palette = GObject.Property(type=bool, default=True,
flags=GObject.ParamFlags.READWRITE |
GObject.ParamFlags.CONSTRUCT_ONLY,
getter=_get_has_palette,
setter=_set_has_palette)
@ -213,9 +213,9 @@ class _ColorButton(Gtk.Button):
def _get_accept_drag(self):
return self._accept_drag
accept_drag = GObject.property(type=bool, default=True,
flags=GObject.PARAM_READWRITE |
GObject.PARAM_CONSTRUCT_ONLY,
accept_drag = GObject.Property(type=bool, default=True,
flags=GObject.ParamFlags.READWRITE |
GObject.ParamFlags.CONSTRUCT_ONLY,
getter=_get_accept_drag,
setter=_set_accept_drag)
@ -412,7 +412,7 @@ class _ColorPalette(Palette):
def get_color(self):
return self._color
color = GObject.property(type=object, getter=get_color, setter=set_color)
color = GObject.Property(type=object, getter=get_color, setter=set_color)
def _add_accelerator(tool_button):
@ -510,7 +510,7 @@ class ColorToolButton(Gtk.ToolItem):
'''
return self._accelerator
accelerator = GObject.property(type=str, setter=set_accelerator,
accelerator = GObject.Property(type=str, setter=set_accelerator,
getter=get_accelerator)
def create_palette(self):
@ -546,7 +546,7 @@ class ColorToolButton(Gtk.ToolItem):
self._palette_invoker.detach()
self._palette_invoker = palette_invoker
palette_invoker = GObject.property(
palette_invoker = GObject.Property(
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
def set_expanded(self, expanded):
@ -584,7 +584,7 @@ class ColorToolButton(Gtk.ToolItem):
'''
return self.get_child().props.color
color = GObject.property(type=object, getter=get_color, setter=set_color)
color = GObject.Property(type=object, getter=get_color, setter=set_color)
def set_icon_name(self, icon_name):
'''
@ -607,7 +607,7 @@ class ColorToolButton(Gtk.ToolItem):
'''
return self.get_child().props.icon_name
icon_name = GObject.property(type=str,
icon_name = GObject.Property(type=str,
getter=get_icon_name, setter=set_icon_name)
def set_icon_size(self, icon_size):
@ -622,7 +622,7 @@ class ColorToolButton(Gtk.ToolItem):
'''
return self.get_child().props.icon_size
icon_size = GObject.property(type=int,
icon_size = GObject.Property(type=int,
getter=get_icon_size, setter=set_icon_size)
def set_title(self, title):
@ -639,7 +639,7 @@ class ColorToolButton(Gtk.ToolItem):
'''
return self.get_child().props.title
title = GObject.property(type=str, getter=get_title, setter=set_title)
title = GObject.Property(type=str, getter=get_title, setter=set_title)
def do_draw(self, cr):
if self._palette and self._palette.is_up():

View File

@ -65,7 +65,7 @@ class ComboBox(Gtk.ComboBox):
return None
return row[0]
value = GObject.property(
value = GObject.Property(
type=object, getter=get_value, setter=None)
def _get_real_name_from_theme(self, name, size):

View File

@ -96,6 +96,7 @@ from ConfigParser import ConfigParser
import gi
gi.require_version('Rsvg', '2.0')
gi.require_version('Gtk', '3.0')
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import Gdk
@ -377,7 +378,7 @@ class _IconBuffer(object):
icon_width = pixbuf.get_width()
icon_height = pixbuf.get_height()
break
except GObject.GError:
except GLib.GError:
pass
if icon_width is None:
@ -495,7 +496,7 @@ class Icon(Gtk.Image):
self._file = file_name
self._buffer.file_name = file_name
file = GObject.property(type=object, setter=set_file, getter=get_file)
file = GObject.Property(type=object, setter=set_file, getter=get_file)
def get_pixbuf(self):
'''
@ -518,7 +519,7 @@ class Icon(Gtk.Image):
'''
self._buffer.pixbuf = pixbuf
pixbuf = GObject.property(type=object, setter=set_pixbuf,
pixbuf = GObject.Property(type=object, setter=set_pixbuf,
getter=get_pixbuf)
'''
icon.props.pixbuf -> see :any:`get_pixbuf` and :any:`set_pixbuf`
@ -627,7 +628,7 @@ class Icon(Gtk.Image):
self._buffer.xo_color = value
self.queue_draw()
xo_color = GObject.property(
xo_color = GObject.Property(
type=object, getter=None, setter=set_xo_color)
'''
icon.props.xo_color -> see :any:`set_xo_color`, note there is no getter
@ -653,7 +654,7 @@ class Icon(Gtk.Image):
'''
return self._buffer.fill_color
fill_color = GObject.property(
fill_color = GObject.Property(
type=object, getter=get_fill_color, setter=set_fill_color)
'''
icon.props.fill_color -> see :any:`get_fill_color`
@ -680,7 +681,7 @@ class Icon(Gtk.Image):
'''
return self._buffer.stroke_color
stroke_color = GObject.property(
stroke_color = GObject.Property(
type=object, getter=get_stroke_color, setter=set_stroke_color)
'''
icon.props.stroke_color -> see :any:`get_stroke_color`
@ -707,7 +708,7 @@ class Icon(Gtk.Image):
'''
return self._buffer.badge_name
badge_name = GObject.property(
badge_name = GObject.Property(
type=str, getter=get_badge_name, setter=set_badge_name)
'''
icon.props.badge_name -> see :any:`get_badge_name`
@ -733,7 +734,7 @@ class Icon(Gtk.Image):
self._alpha = value
self.queue_draw()
alpha = GObject.property(
alpha = GObject.Property(
type=float, setter=set_alpha)
'''
icon.props.alpha -> see :any:`set_alpha`, note no getter
@ -752,7 +753,7 @@ class Icon(Gtk.Image):
self._scale = value
self.queue_draw()
scale = GObject.property(
scale = GObject.Property(
type=float, setter=set_scale)
'''
icon.props.scale -> see :any:`set_scale`, note no getter
@ -861,7 +862,7 @@ class EventIcon(Gtk.EventBox):
def get_file_name(self):
return self._buffer.file_name
file_name = GObject.property(
file_name = GObject.Property(
type=object, getter=get_file_name, setter=set_file_name)
def set_icon_name(self, value):
@ -872,7 +873,7 @@ class EventIcon(Gtk.EventBox):
def get_icon_name(self):
return self._buffer.icon_name
icon_name = GObject.property(
icon_name = GObject.Property(
type=object, getter=get_icon_name, setter=set_icon_name)
def set_xo_color(self, value):
@ -880,7 +881,7 @@ class EventIcon(Gtk.EventBox):
self._buffer.xo_color = value
self.queue_draw()
xo_color = GObject.property(
xo_color = GObject.Property(
type=object, getter=None, setter=set_xo_color)
def set_fill_color(self, value):
@ -891,7 +892,7 @@ class EventIcon(Gtk.EventBox):
def get_fill_color(self):
return self._buffer.fill_color
fill_color = GObject.property(
fill_color = GObject.Property(
type=object, getter=get_fill_color, setter=set_fill_color)
def set_stroke_color(self, value):
@ -902,7 +903,7 @@ class EventIcon(Gtk.EventBox):
def get_stroke_color(self):
return self._buffer.stroke_color
stroke_color = GObject.property(
stroke_color = GObject.Property(
type=object, getter=get_stroke_color, setter=set_stroke_color)
def set_background_color(self, value):
@ -922,7 +923,7 @@ class EventIcon(Gtk.EventBox):
'''
return self._buffer.background_color
background_color = GObject.property(
background_color = GObject.Property(
type=object, getter=get_background_color, setter=set_background_color)
'''
event_icon.props.get_background_color -> see :any:`set_background_color`
@ -938,7 +939,7 @@ class EventIcon(Gtk.EventBox):
def get_size(self):
return self._buffer.width
pixel_size = GObject.property(
pixel_size = GObject.Property(
type=object, getter=get_size, setter=set_size)
def set_scale(self, value):
@ -949,7 +950,7 @@ class EventIcon(Gtk.EventBox):
def get_scale(self):
return self._buffer.scale
scale = GObject.property(
scale = GObject.Property(
type=float, getter=get_scale, setter=set_scale)
def set_alpha(self, alpha):
@ -957,7 +958,7 @@ class EventIcon(Gtk.EventBox):
self._alpha = alpha
self.queue_draw()
alpha = GObject.property(
alpha = GObject.Property(
type=float, setter=set_alpha)
def set_cache(self, value):
@ -977,7 +978,7 @@ class EventIcon(Gtk.EventBox):
'''
return self._buffer.cache
cache = GObject.property(
cache = GObject.Property(
type=bool, default=False, getter=get_cache, setter=set_cache)
'''
event_icon.props.cache -> see :any:`set_cache` and :any:`get_cache`
@ -991,7 +992,7 @@ class EventIcon(Gtk.EventBox):
def get_badge_name(self):
return self._buffer.badge_name
badge_name = GObject.property(
badge_name = GObject.Property(
type=object, getter=get_badge_name, setter=set_badge_name)
def create_palette(self):
@ -1035,7 +1036,7 @@ class EventIcon(Gtk.EventBox):
'''
self._palette_invoker.palette = palette
palette = GObject.property(
palette = GObject.Property(
type=object, setter=set_palette, getter=get_palette)
'''
event_icon.props.palette -> see :any:`get_palette` and :any:`set_palette`
@ -1048,7 +1049,7 @@ class EventIcon(Gtk.EventBox):
self._palette_invoker.detach()
self._palette_invoker = palette_invoker
palette_invoker = GObject.property(
palette_invoker = GObject.Property(
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
def set_tooltip(self, text):
@ -1202,13 +1203,13 @@ class CellRendererIcon(Gtk.CellRenderer):
if self._buffer.file_name != value:
self._buffer.file_name = value
file_name = GObject.property(type=str, setter=set_file_name)
file_name = GObject.Property(type=str, setter=set_file_name)
def set_icon_name(self, value):
if self._buffer.icon_name != value:
self._buffer.icon_name = value
icon_name = GObject.property(type=str, setter=set_icon_name)
icon_name = GObject.Property(type=str, setter=set_icon_name)
def get_xo_color(self):
return self._xo_color
@ -1216,40 +1217,40 @@ class CellRendererIcon(Gtk.CellRenderer):
def set_xo_color(self, value):
self._xo_color = value
xo_color = GObject.property(type=object,
xo_color = GObject.Property(type=object,
getter=get_xo_color, setter=set_xo_color)
def set_fill_color(self, value):
if self._fill_color != value:
self._fill_color = value
fill_color = GObject.property(type=object, setter=set_fill_color)
fill_color = GObject.Property(type=object, setter=set_fill_color)
def set_stroke_color(self, value):
if self._stroke_color != value:
self._stroke_color = value
stroke_color = GObject.property(type=object, setter=set_stroke_color)
stroke_color = GObject.Property(type=object, setter=set_stroke_color)
def set_prelit_fill_color(self, value):
if self._prelit_fill_color != value:
self._prelit_fill_color = value
prelit_fill_color = GObject.property(type=object,
prelit_fill_color = GObject.Property(type=object,
setter=set_prelit_fill_color)
def set_prelit_stroke_color(self, value):
if self._prelit_stroke_color != value:
self._prelit_stroke_color = value
prelit_stroke_color = GObject.property(type=object,
prelit_stroke_color = GObject.Property(type=object,
setter=set_prelit_stroke_color)
def set_background_color(self, value):
if self._buffer.background_color != value:
self._buffer.background_color = value
background_color = GObject.property(type=object,
background_color = GObject.Property(type=object,
setter=set_background_color)
def set_size(self, value):
@ -1259,7 +1260,7 @@ class CellRendererIcon(Gtk.CellRenderer):
self._cached_offsets = None
size = GObject.property(type=object, setter=set_size)
size = GObject.Property(type=object, setter=set_size)
def do_get_size(self, widget, cell_area, x_offset=None, y_offset=None,
width=None, height=None):

View File

@ -92,5 +92,5 @@ class MenuItem(Gtk.ImageMenuItem):
def get_accelerator(self):
return self._accelerator
accelerator = GObject.property(type=str, setter=set_accelerator,
accelerator = GObject.Property(type=str, setter=set_accelerator,
getter=get_accelerator)

View File

@ -38,8 +38,8 @@ class Notebook(Gtk.Notebook):
__gproperties__ = {
'can-close-tabs': (bool, None, None, False,
GObject.PARAM_READWRITE |
GObject.PARAM_CONSTRUCT_ONLY),
GObject.ParamFlags.READWRITE |
GObject.ParamFlags.CONSTRUCT_ONLY),
}
def __init__(self, **kwargs):

View File

@ -263,7 +263,7 @@ class Palette(PaletteWindow):
def get_primary_text(self):
return self._primary_text
primary_text = GObject.property(type=str,
primary_text = GObject.Property(type=str,
getter=get_primary_text,
setter=set_primary_text)
@ -306,7 +306,7 @@ class Palette(PaletteWindow):
def get_secondary_text(self):
return self._secondary_text
secondary_text = GObject.property(type=str, getter=get_secondary_text,
secondary_text = GObject.Property(type=str, getter=get_secondary_text,
setter=set_secondary_text)
def _show_icon(self):
@ -344,7 +344,7 @@ class Palette(PaletteWindow):
def get_icon(self):
return self._icon
icon = GObject.property(type=object, getter=get_icon, setter=set_icon)
icon = GObject.Property(type=object, getter=get_icon, setter=set_icon)
def __icon_button_release_event_cb(self, icon, event):
self.emit('activate')
@ -360,7 +360,7 @@ class Palette(PaletteWindow):
def get_icon_visible(self):
return self._icon_visilbe
icon_visible = GObject.property(type=bool,
icon_visible = GObject.Property(type=bool,
default=True,
getter=get_icon_visible,
setter=set_icon_visible)
@ -444,7 +444,7 @@ class Palette(PaletteWindow):
return self._widget
menu = GObject.property(type=object, getter=get_menu)
menu = GObject.Property(type=object, getter=get_menu)
def _invoker_right_click_cb(self, invoker):
self.popup(immediate=True)

View File

@ -456,7 +456,7 @@ class MouseSpeedDetector(GObject.GObject):
def stop(self):
if self._timeout_hid is not None:
GObject.source_remove(self._timeout_hid)
GLib.source_remove(self._timeout_hid)
self._timeout_hid = None
self._state = None
@ -568,7 +568,7 @@ class PaletteWindow(GObject.GObject):
def get_invoker(self):
return self._invoker
invoker = GObject.property(type=object,
invoker = GObject.Property(type=object,
getter=get_invoker,
setter=set_invoker)
@ -609,7 +609,7 @@ class PaletteWindow(GObject.GObject):
def get_group_id(self):
return self._group_id
group_id = GObject.property(type=str,
group_id = GObject.Property(type=str,
getter=get_group_id,
setter=set_group_id)
@ -1036,7 +1036,7 @@ class Invoker(GObject.GObject):
# palette owner.
GLib.idle_add(lambda old_palette=self._palette:
old_palette.destroy(),
priority=GObject.PRIORITY_LOW)
priority=GLib.PRIORITY_LOW)
self._palette = palette
@ -1044,7 +1044,7 @@ class Invoker(GObject.GObject):
self._palette.props.invoker = self
self._palette.connect('popdown', self.__palette_popdown_cb)
palette = GObject.property(
palette = GObject.Property(
type=object, setter=set_palette, getter=get_palette)
def get_cache_palette(self):
@ -1053,7 +1053,7 @@ class Invoker(GObject.GObject):
def set_cache_palette(self, cache_palette):
self._cache_palette = cache_palette
cache_palette = GObject.property(type=object, setter=set_cache_palette,
cache_palette = GObject.Property(type=object, setter=set_cache_palette,
getter=get_cache_palette)
"""Whether the invoker will cache the palette after its creation. Defaults
to True.
@ -1065,7 +1065,7 @@ class Invoker(GObject.GObject):
def set_toggle_palette(self, toggle_palette):
self._toggle_palette = toggle_palette
toggle_palette = GObject.property(type=object, setter=set_toggle_palette,
toggle_palette = GObject.Property(type=object, setter=set_toggle_palette,
getter=get_toggle_palette)
"""Whether the invoker will popup/popdown the Palette on
button left click/touch tap. Defaults to False.
@ -1077,7 +1077,7 @@ class Invoker(GObject.GObject):
def set_lock_palette(self, lock_palette):
self._lock_palette = lock_palette
lock_palette = GObject.property(type=object, setter=set_lock_palette,
lock_palette = GObject.Property(type=object, setter=set_lock_palette,
getter=get_lock_palette)
"""Whether the invoker will lock the Palette and
ignore mouse events. Defaults to False.
@ -1268,7 +1268,7 @@ class WidgetInvoker(Invoker):
def _get_widget(self):
return self._widget
widget = GObject.property(type=object, getter=_get_widget, setter=None)
widget = GObject.Property(type=object, getter=_get_widget, setter=None)
def __drawing_cb(self, widget, cr):
if not self.props.lock_palette:

View File

@ -111,7 +111,7 @@ class RadioToolButton(Gtk.RadioToolButton):
'''
return self._tooltip
tooltip = GObject.property(type=str, setter=set_tooltip,
tooltip = GObject.Property(type=str, setter=set_tooltip,
getter=get_tooltip)
def set_accelerator(self, accelerator):
@ -131,7 +131,7 @@ class RadioToolButton(Gtk.RadioToolButton):
'''
return self._accelerator
accelerator = GObject.property(type=str, setter=set_accelerator,
accelerator = GObject.Property(type=str, setter=set_accelerator,
getter=get_accelerator)
def set_icon_name(self, icon_name):
@ -155,7 +155,7 @@ class RadioToolButton(Gtk.RadioToolButton):
else:
return None
icon_name = GObject.property(type=str, setter=set_icon_name,
icon_name = GObject.Property(type=str, setter=set_icon_name,
getter=get_icon_name)
def set_xo_color(self, xo_color):
@ -176,7 +176,7 @@ class RadioToolButton(Gtk.RadioToolButton):
'''
return self._xo_color
xo_color = GObject.property(type=object, setter=set_xo_color,
xo_color = GObject.Property(type=object, setter=set_xo_color,
getter=get_xo_color)
def create_palette(self):
@ -188,7 +188,7 @@ class RadioToolButton(Gtk.RadioToolButton):
def set_palette(self, palette):
self._palette_invoker.palette = palette
palette = GObject.property(
palette = GObject.Property(
type=object, setter=set_palette, getter=get_palette)
def get_palette_invoker(self):
@ -198,7 +198,7 @@ class RadioToolButton(Gtk.RadioToolButton):
self._palette_invoker.detach()
self._palette_invoker = palette_invoker
palette_invoker = GObject.property(
palette_invoker = GObject.Property(
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
def do_draw(self, cr):
@ -239,7 +239,7 @@ class RadioToolButton(Gtk.RadioToolButton):
if self._hide_tooltip_on_click != hide_tooltip_on_click:
self._hide_tooltip_on_click = hide_tooltip_on_click
hide_tooltip_on_click = GObject.property(
hide_tooltip_on_click = GObject.Property(
type=bool, default=True, getter=get_hide_tooltip_on_click,
setter=set_hide_tooltip_on_click)

View File

@ -119,7 +119,7 @@ class ToggleToolButton(Gtk.ToggleToolButton):
else:
return None
icon_name = GObject.property(type=str, setter=set_icon_name,
icon_name = GObject.Property(type=str, setter=set_icon_name,
getter=get_icon_name)
def create_palette(self):
@ -131,7 +131,7 @@ class ToggleToolButton(Gtk.ToggleToolButton):
def set_palette(self, palette):
self._palette_invoker.palette = palette
palette = GObject.property(
palette = GObject.Property(
type=object, setter=set_palette, getter=get_palette)
def get_palette_invoker(self):
@ -141,7 +141,7 @@ class ToggleToolButton(Gtk.ToggleToolButton):
self._palette_invoker.detach()
self._palette_invoker = palette_invoker
palette_invoker = GObject.property(
palette_invoker = GObject.Property(
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
def set_tooltip(self, text):
@ -176,7 +176,7 @@ class ToggleToolButton(Gtk.ToggleToolButton):
'''
return self._accelerator
accelerator = GObject.property(type=str, setter=set_accelerator,
accelerator = GObject.Property(type=str, setter=set_accelerator,
getter=get_accelerator)
def do_draw(self, cr):

View File

@ -73,7 +73,7 @@ class ToolbarButton(ToolButton):
self.props.palette = _ToolbarPalette(invoker=ToolInvoker(self))
self._move_page_to_palette()
page = GObject.property(type=object, getter=get_page, setter=set_page)
page = GObject.Property(type=object, getter=get_page, setter=set_page)
def is_in_palette(self):
return self.page is not None and \
@ -187,7 +187,7 @@ class ToolbarBox(Gtk.VBox):
def set_padding(self, pad):
self._toolbar_alignment.set_padding(0, 0, pad, pad)
padding = GObject.property(type=object,
padding = GObject.Property(type=object,
getter=get_padding, setter=set_padding)
def modify_bg(self, state, color):

View File

@ -147,7 +147,7 @@ class ToolButton(Gtk.ToolButton):
'''
return self._tooltip
tooltip = GObject.property(type=str, setter=set_tooltip,
tooltip = GObject.Property(type=str, setter=set_tooltip,
getter=get_tooltip)
def get_hide_tooltip_on_click(self):
@ -169,7 +169,7 @@ class ToolButton(Gtk.ToolButton):
if self._hide_tooltip_on_click != hide_tooltip_on_click:
self._hide_tooltip_on_click = hide_tooltip_on_click
hide_tooltip_on_click = GObject.property(
hide_tooltip_on_click = GObject.Property(
type=bool, default=True, getter=get_hide_tooltip_on_click,
setter=set_hide_tooltip_on_click)
@ -189,7 +189,7 @@ class ToolButton(Gtk.ToolButton):
'''
return self._accelerator
accelerator = GObject.property(type=str, setter=set_accelerator,
accelerator = GObject.Property(type=str, setter=set_accelerator,
getter=get_accelerator)
def set_icon_name(self, icon_name):
@ -212,7 +212,7 @@ class ToolButton(Gtk.ToolButton):
else:
return None
icon_name = GObject.property(type=str, setter=set_icon_name,
icon_name = GObject.Property(type=str, setter=set_icon_name,
getter=get_icon_name)
def create_palette(self):
@ -224,7 +224,7 @@ class ToolButton(Gtk.ToolButton):
def set_palette(self, palette):
self._palette_invoker.palette = palette
palette = GObject.property(
palette = GObject.Property(
type=object, setter=set_palette, getter=get_palette)
def get_palette_invoker(self):
@ -234,7 +234,7 @@ class ToolButton(Gtk.ToolButton):
self._palette_invoker.detach()
self._palette_invoker = palette_invoker
palette_invoker = GObject.property(
palette_invoker = GObject.Property(
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
def do_draw(self, cr):

View File

@ -29,7 +29,7 @@ from sugar3.graphics import style
class ToolComboBox(Gtk.ToolItem):
__gproperties__ = {
'label-text': (str, None, None, None, GObject.PARAM_WRITABLE),
'label-text': (str, None, None, None, GObject.ParamFlags.WRITABLE),
}
def __init__(self, combo=None, **kwargs):

View File

@ -36,9 +36,9 @@ _NEXT_PAGE = 1
class _TrayViewport(Gtk.Viewport):
__gproperties__ = {
'scrollable': (bool, None, None, False, GObject.PARAM_READABLE),
'can-scroll-prev': (bool, None, None, False, GObject.PARAM_READABLE),
'can-scroll-next': (bool, None, None, False, GObject.PARAM_READABLE),
'scrollable': (bool, None, None, False, GObject.ParamFlags.READABLE),
'can-scroll-prev': (bool, None, None, False, GObject.ParamFlags.READABLE),
'can-scroll-next': (bool, None, None, False, GObject.ParamFlags.READABLE),
}
def __init__(self, orientation):
@ -239,9 +239,9 @@ class HTray(Gtk.EventBox):
__gproperties__ = {
'align': (int, None, None, 0, 1, ALIGN_TO_START,
GObject.PARAM_READWRITE |
GObject.PARAM_CONSTRUCT_ONLY),
'drag-active': (bool, None, None, False, GObject.PARAM_READWRITE),
GObject.ParamFlags.READWRITE |
GObject.ParamFlags.CONSTRUCT_ONLY),
'drag-active': (bool, None, None, False, GObject.ParamFlags.READWRITE),
}
def __init__(self, **kwargs):
@ -333,8 +333,8 @@ class VTray(Gtk.EventBox):
__gproperties__ = {
'align': (int, None, None, 0, 1, ALIGN_TO_START,
GObject.PARAM_READWRITE | GObject.PARAM_CONSTRUCT_ONLY),
'drag-active': (bool, None, None, False, GObject.PARAM_READWRITE),
GObject.ParamFlags.READWRITE | GObject.ParamFlags.CONSTRUCT_ONLY),
'drag-active': (bool, None, None, False, GObject.ParamFlags.READWRITE),
}
def __init__(self, **kwargs):
@ -495,7 +495,7 @@ class TrayIcon(Gtk.ToolItem):
def set_palette(self, palette):
self._palette_invoker.palette = palette
palette = GObject.property(
palette = GObject.Property(
type=object, setter=set_palette, getter=get_palette)
def get_palette_invoker(self):
@ -505,7 +505,7 @@ class TrayIcon(Gtk.ToolItem):
self._palette_invoker.detach()
self._palette_invoker = palette_invoker
palette_invoker = GObject.property(
palette_invoker = GObject.Property(
type=object, setter=set_palette_invoker, getter=get_palette_invoker)
def get_icon(self):

View File

@ -207,7 +207,7 @@ class Window(Gtk.Window):
self._unfullscreen_button.show()
if self._unfullscreen_button_timeout_id is not None:
GObject.source_remove(self._unfullscreen_button_timeout_id)
GLib.source_remove(self._unfullscreen_button_timeout_id)
self._unfullscreen_button_timeout_id = None
self._unfullscreen_button_timeout_id = \
@ -232,7 +232,7 @@ class Window(Gtk.Window):
self._unfullscreen_button.hide()
if self._unfullscreen_button_timeout_id:
GObject.source_remove(self._unfullscreen_button_timeout_id)
GLib.source_remove(self._unfullscreen_button_timeout_id)
self._unfullscreen_button_timeout_id = None
def set_canvas(self, canvas):
@ -395,7 +395,7 @@ class Window(Gtk.Window):
# Reset the timer
if self._unfullscreen_button_timeout_id is not None:
GObject.source_remove(self._unfullscreen_button_timeout_id)
GLib.source_remove(self._unfullscreen_button_timeout_id)
self._unfullscreen_button_timeout_id = None
self._unfullscreen_button_timeout_id = \
@ -446,7 +446,7 @@ class Window(Gtk.Window):
"""
return self._enable_fullscreen_mode
enable_fullscreen_mode = GObject.property(
enable_fullscreen_mode = GObject.Property(
type=object,
setter=set_enable_fullscreen_mode,
getter=get_enable_fullscreen_mode)

View File

@ -26,6 +26,7 @@ import fcntl
import tempfile
from gi.repository import GObject
from.gi.repository import GLib
import SimpleHTTPServer
import SocketServer
@ -60,12 +61,12 @@ class GlibTCPServer(SocketServer.TCPServer):
self.socket.setblocking(0) # Set nonblocking
# Watch the listener socket for data
GObject.io_add_watch(self.socket, GObject.IO_IN, self._handle_accept)
GLib.io_add_watch(self.socket, GLib.IO_IN, self._handle_accept)
def _handle_accept(self, source, condition):
"""Process incoming data on the server's socket by doing an accept()
via handle_request()."""
if not (condition & GObject.IO_IN):
if not (condition & GLib.IO_IN):
return True
self.handle_request()
return True
@ -103,17 +104,17 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
"""Serve a GET request."""
self._file = self.send_head()
if self._file:
self._srcid = GObject.io_add_watch(self.wfile, GObject.IO_OUT |
GObject.IO_ERR,
self._srcid = GLib.io_add_watch(self.wfile, GLib.IO_OUT |
GLib.IO_ERR,
self._send_next_chunk)
else:
self._cleanup()
def _send_next_chunk(self, source, condition):
if condition & GObject.IO_ERR:
if condition & GLib.IO_ERR:
self._cleanup()
return False
if not (condition & GObject.IO_OUT):
if not (condition & GLib.IO_OUT):
self._cleanup()
return False
data = self._file.read(self.CHUNK_SIZE)
@ -128,7 +129,7 @@ class ChunkedGlibHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
self._file.close()
self._file = None
if self._srcid > 0:
GObject.source_remove(self._srcid)
GLib.source_remove(self._srcid)
self._srcid = 0
if not self.wfile.closed:
self.wfile.flush()
@ -238,8 +239,8 @@ class GlibURLDownloader(GObject.GObject):
dir=self._destdir)
fcntl.fcntl(self._info.fp.fileno(), fcntl.F_SETFD, os.O_NDELAY)
self._srcid = GObject.io_add_watch(self._info.fp.fileno(),
GObject.IO_IN | GObject.IO_ERR,
self._srcid = GLib.io_add_watch(self._info.fp.fileno(),
GLib.IO_IN | GLib.IO_ERR,
self._read_next_chunk)
def cancel(self):
@ -264,11 +265,11 @@ class GlibURLDownloader(GObject.GObject):
return fname
def _read_next_chunk(self, source, condition):
if condition & GObject.IO_ERR:
if condition & GLib.IO_ERR:
self.cleanup(remove=True)
self.emit('error', 'Error downloading file.')
return False
elif not (condition & GObject.IO_IN):
elif not (condition & GLib.IO_IN):
# shouldn't get here, but...
return True
@ -298,7 +299,7 @@ class GlibURLDownloader(GObject.GObject):
def cleanup(self, remove=False):
if self._srcid > 0:
GObject.source_remove(self._srcid)
GLib.source_remove(self._srcid)
self._srcid = 0
del self._info
self._info = None

View File

@ -74,13 +74,13 @@ class Activity(GObject.GObject):
}
__gproperties__ = {
'id': (str, None, None, None, GObject.PARAM_READABLE),
'name': (str, None, None, None, GObject.PARAM_READWRITE),
'tags': (str, None, None, None, GObject.PARAM_READWRITE),
'color': (str, None, None, None, GObject.PARAM_READWRITE),
'type': (str, None, None, None, GObject.PARAM_READABLE),
'private': (bool, None, None, True, GObject.PARAM_READWRITE),
'joined': (bool, None, None, False, GObject.PARAM_READABLE),
'id': (str, None, None, None, GObject.ParamFlags.READABLE),
'name': (str, None, None, None, GObject.ParamFlags.READWRITE),
'tags': (str, None, None, None, GObject.ParamFlags.READWRITE),
'color': (str, None, None, None, GObject.ParamFlags.READWRITE),
'type': (str, None, None, None, GObject.ParamFlags.READABLE),
'private': (bool, None, None, True, GObject.ParamFlags.READWRITE),
'joined': (bool, None, None, False, GObject.ParamFlags.READABLE),
}
def __init__(self, account_path, connection, room_handle=None,

View File

@ -82,7 +82,7 @@ class BaseBuddy(GObject.GObject):
def set_key(self, key):
self._key = key
key = GObject.property(type=str, getter=get_key, setter=set_key)
key = GObject.Property(type=str, getter=get_key, setter=set_key)
def get_nick(self):
return self._nick
@ -90,7 +90,7 @@ class BaseBuddy(GObject.GObject):
def set_nick(self, nick):
self._nick = nick
nick = GObject.property(type=str, getter=get_nick, setter=set_nick)
nick = GObject.Property(type=str, getter=get_nick, setter=set_nick)
def get_color(self):
return self._color
@ -98,7 +98,7 @@ class BaseBuddy(GObject.GObject):
def set_color(self, color):
self._color = color
color = GObject.property(type=str, getter=get_color, setter=set_color)
color = GObject.Property(type=str, getter=get_color, setter=set_color)
def get_current_activity(self):
if self._current_activity is None:
@ -108,7 +108,7 @@ class BaseBuddy(GObject.GObject):
return activity
return None
current_activity = GObject.property(type=object,
current_activity = GObject.Property(type=object,
getter=get_current_activity)
def get_owner(self):
@ -117,7 +117,7 @@ class BaseBuddy(GObject.GObject):
def set_owner(self, owner):
self._owner = owner
owner = GObject.property(type=bool, getter=get_owner, setter=set_owner,
owner = GObject.Property(type=bool, getter=get_owner, setter=set_owner,
default=False)
def get_ip4_address(self):
@ -126,7 +126,7 @@ class BaseBuddy(GObject.GObject):
def set_ip4_address(self, ip4_address):
self._ip4_address = ip4_address
ip4_address = GObject.property(type=str, getter=get_ip4_address,
ip4_address = GObject.Property(type=str, getter=get_ip4_address,
setter=set_ip4_address)
def get_tags(self):
@ -135,7 +135,7 @@ class BaseBuddy(GObject.GObject):
def set_tags(self, tags):
self._tags = tags
tags = GObject.property(type=str, getter=get_tags, setter=set_tags)
tags = GObject.Property(type=str, getter=get_tags, setter=set_tags)
def object_path(self):
"""Retrieve our dbus object path"""

View File

@ -24,6 +24,7 @@ gi.require_version('Gtk', '3.0')
from gi.repository import Gio
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GLib
from gi.repository import GObject
_HAS_GST = True
@ -230,13 +231,13 @@ class SpeechManager(GObject.GObject):
def get_is_playing(self):
return self._is_playing
is_playing = GObject.property(type=bool, getter=get_is_playing,
is_playing = GObject.Property(type=bool, getter=get_is_playing,
setter=None, default=False)
def get_is_paused(self):
return self._is_paused
is_paused = GObject.property(type=bool, getter=get_is_paused,
is_paused = GObject.Property(type=bool, getter=get_is_paused,
setter=None, default=False)
def get_pitch(self):
@ -248,14 +249,14 @@ class SpeechManager(GObject.GObject):
def set_pitch(self, pitch):
self._pitch = pitch
if self._save_timeout_id != -1:
GObject.source_remove(self._save_timeout_id)
self._save_timeout_id = GObject.timeout_add(_SAVE_TIMEOUT, self.save)
GLib.source_remove(self._save_timeout_id)
self._save_timeout_id = GLib.timeout_add(_SAVE_TIMEOUT, self.save)
def set_rate(self, rate):
self._rate = rate
if self._save_timeout_id != -1:
GObject.source_remove(self._save_timeout_id)
self._save_timeout_id = GObject.timeout_add(_SAVE_TIMEOUT, self.save)
GLib.source_remove(self._save_timeout_id)
self._save_timeout_id = GLib.timeout_add(_SAVE_TIMEOUT, self.save)
def say_text(self, text, pitch=None, rate=None, lang_code=None):
if pitch is None: