Use accessor functions for data fields
The following data fields that were provided by PyGTK are not accessible directly in GTK3+pygi and need to be replaced by accessor calls: Adjustment.lower Adjustment.page_size Adjustment.upper Adjustment.value Bin.child Widget.parent Widget.style Widget.window Based on patches by Daniel Drake <dsd@laptop.org>. Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
This commit is contained in:
parent
4aacaaf56e
commit
c82a775267
@ -901,8 +901,8 @@ class Activity(Window, Gtk.Container):
|
|||||||
self.reveal()
|
self.reveal()
|
||||||
|
|
||||||
def __realize_cb(self, window):
|
def __realize_cb(self, window):
|
||||||
wm.set_bundle_id(window.window, self.get_bundle_id())
|
wm.set_bundle_id(window.get_window(), self.get_bundle_id())
|
||||||
wm.set_activity_id(window.window, str(self._activity_id))
|
wm.set_activity_id(window.get_window(), str(self._activity_id))
|
||||||
|
|
||||||
def __delete_event_cb(self, widget, event):
|
def __delete_event_cb(self, widget, event):
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -279,7 +279,7 @@ class NamingAlert(Gtk.Window):
|
|||||||
|
|
||||||
def __realize_cb(self, widget):
|
def __realize_cb(self, widget):
|
||||||
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
|
self.set_type_hint(Gdk.WindowTypeHint.DIALOG)
|
||||||
self.window.set_accept_focus(True)
|
self.get_window().set_accept_focus(True)
|
||||||
|
|
||||||
def __keep_cb(self, widget):
|
def __keep_cb(self, widget):
|
||||||
if self._favorite_icon.get_active():
|
if self._favorite_icon.get_active():
|
||||||
|
@ -228,7 +228,7 @@ class _IconBuffer(object):
|
|||||||
self.fill_color = None
|
self.fill_color = None
|
||||||
|
|
||||||
def _get_insensitive_pixbuf(self, pixbuf, widget):
|
def _get_insensitive_pixbuf(self, pixbuf, widget):
|
||||||
if not (widget and widget.style):
|
if not (widget and widget.get_style()):
|
||||||
return pixbuf
|
return pixbuf
|
||||||
|
|
||||||
icon_source = Gtk.IconSource()
|
icon_source = Gtk.IconSource()
|
||||||
@ -239,9 +239,10 @@ class _IconBuffer(object):
|
|||||||
icon_source.set_direction_wildcarded(False)
|
icon_source.set_direction_wildcarded(False)
|
||||||
icon_source.set_size_wildcarded(False)
|
icon_source.set_size_wildcarded(False)
|
||||||
|
|
||||||
pixbuf = widget.style.render_icon(icon_source, widget.get_direction(),
|
style = widget.get_style()
|
||||||
Gtk.StateType.INSENSITIVE, -1, widget,
|
pixbuf = style.render_icon(icon_source, widget.get_direction(),
|
||||||
'sugar-icon')
|
Gtk.StateType.INSENSITIVE, -1, widget,
|
||||||
|
'sugar-icon')
|
||||||
|
|
||||||
return pixbuf
|
return pixbuf
|
||||||
|
|
||||||
|
@ -47,8 +47,9 @@ class ObjectChooser(object):
|
|||||||
|
|
||||||
if parent is None:
|
if parent is None:
|
||||||
parent_xid = 0
|
parent_xid = 0
|
||||||
elif hasattr(parent, 'window') and hasattr(parent.window, 'xid'):
|
elif hasattr(parent, 'get_window') and hasattr(parent.get_window(),
|
||||||
parent_xid = parent.window.xid
|
'xid'):
|
||||||
|
parent_xid = parent.get_window().xid
|
||||||
else:
|
else:
|
||||||
parent_xid = parent
|
parent_xid = parent
|
||||||
|
|
||||||
|
@ -350,8 +350,9 @@ class Palette(PaletteWindow):
|
|||||||
|
|
||||||
def _update_accept_focus(self):
|
def _update_accept_focus(self):
|
||||||
accept_focus = len(self._content.get_children())
|
accept_focus = len(self._content.get_children())
|
||||||
if self.window:
|
window = self.get_window()
|
||||||
self.window.set_accept_focus(accept_focus)
|
if window:
|
||||||
|
window.set_accept_focus(accept_focus)
|
||||||
|
|
||||||
def __realize_cb(self, widget):
|
def __realize_cb(self, widget):
|
||||||
self._update_accept_focus()
|
self._update_accept_focus()
|
||||||
|
@ -386,7 +386,7 @@ class PaletteWindow(Gtk.Window):
|
|||||||
self.emit('popdown')
|
self.emit('popdown')
|
||||||
|
|
||||||
def get_rect(self):
|
def get_rect(self):
|
||||||
win_x, win_y = self.window.get_origin()
|
win_x, win_y = self.get_window().get_origin()
|
||||||
rectangle = self.get_allocation()
|
rectangle = self.get_allocation()
|
||||||
|
|
||||||
x = win_x + rectangle.x
|
x = win_x + rectangle.x
|
||||||
@ -715,8 +715,9 @@ class WidgetInvoker(Invoker):
|
|||||||
|
|
||||||
def get_rect(self):
|
def get_rect(self):
|
||||||
allocation = self._widget.get_allocation()
|
allocation = self._widget.get_allocation()
|
||||||
if self._widget.window is not None:
|
window = self._widget.get_window()
|
||||||
x, y = self._widget.window.get_origin()
|
if window is not None:
|
||||||
|
x, y = window.get_origin()
|
||||||
else:
|
else:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"Trying to position palette with invoker that's not realized.")
|
"Trying to position palette with invoker that's not realized.")
|
||||||
@ -843,8 +844,9 @@ class CellRendererInvoker(Invoker):
|
|||||||
|
|
||||||
def get_rect(self):
|
def get_rect(self):
|
||||||
allocation = self._tree_view.get_allocation()
|
allocation = self._tree_view.get_allocation()
|
||||||
if self._tree_view.window is not None:
|
window = self._tree_view.get_window()
|
||||||
x, y = self._tree_view.window.get_origin()
|
if window is not None:
|
||||||
|
x, y = window.get_origin()
|
||||||
else:
|
else:
|
||||||
logging.warning(
|
logging.warning(
|
||||||
"Trying to position palette with invoker that's not realized.")
|
"Trying to position palette with invoker that's not realized.")
|
||||||
|
@ -39,16 +39,18 @@ class ToolbarButton(ToolButton):
|
|||||||
self.connect('hierarchy-changed', self.__hierarchy_changed_cb)
|
self.connect('hierarchy-changed', self.__hierarchy_changed_cb)
|
||||||
|
|
||||||
def __hierarchy_changed_cb(self, tool_button, previous_toplevel):
|
def __hierarchy_changed_cb(self, tool_button, previous_toplevel):
|
||||||
if hasattr(self.parent, 'owner'):
|
parent = self.get_parent()
|
||||||
|
if hasattr(parent, 'owner'):
|
||||||
if self.page_widget and previous_toplevel is None:
|
if self.page_widget and previous_toplevel is None:
|
||||||
self._unparent()
|
self._unparent()
|
||||||
self.parent.owner.pack_start(self.page_widget, True, True, 0)
|
parent.owner.pack_start(self.page_widget, True, True, 0)
|
||||||
self.set_expanded(False)
|
self.set_expanded(False)
|
||||||
|
|
||||||
def get_toolbar_box(self):
|
def get_toolbar_box(self):
|
||||||
if not hasattr(self.parent, 'owner'):
|
parent = self.get_parent()
|
||||||
|
if not hasattr(parent, 'owner'):
|
||||||
return None
|
return None
|
||||||
return self.parent.owner
|
return parent.owner
|
||||||
|
|
||||||
toolbar_box = property(get_toolbar_box)
|
toolbar_box = property(get_toolbar_box)
|
||||||
|
|
||||||
@ -72,7 +74,7 @@ class ToolbarButton(ToolButton):
|
|||||||
|
|
||||||
def is_in_palette(self):
|
def is_in_palette(self):
|
||||||
return self.page is not None and \
|
return self.page is not None and \
|
||||||
self.page_widget.parent == self.props.palette
|
self.page_widget.get_parent() == self.props.palette
|
||||||
|
|
||||||
def is_expanded(self):
|
def is_expanded(self):
|
||||||
return self.page is not None and \
|
return self.page is not None and \
|
||||||
@ -95,9 +97,10 @@ class ToolbarButton(ToolButton):
|
|||||||
box = self.toolbar_box
|
box = self.toolbar_box
|
||||||
|
|
||||||
if box.expanded_button is not None:
|
if box.expanded_button is not None:
|
||||||
if box.expanded_button.window is not None:
|
button_window = box.expanded_button.get_window()
|
||||||
|
if button_window is not None:
|
||||||
# need to redraw it to erase arrow
|
# need to redraw it to erase arrow
|
||||||
box.expanded_button.window.invalidate_rect(None, True)
|
button_window.invalidate_rect(None, True)
|
||||||
box.expanded_button.set_expanded(False)
|
box.expanded_button.set_expanded(False)
|
||||||
box.expanded_button = self
|
box.expanded_button = self
|
||||||
|
|
||||||
@ -117,9 +120,10 @@ class ToolbarButton(ToolButton):
|
|||||||
self.props.palette.add(self.page_widget)
|
self.props.palette.add(self.page_widget)
|
||||||
|
|
||||||
def _unparent(self):
|
def _unparent(self):
|
||||||
if self.page_widget.parent is None:
|
page_parent = self.page_widget.get_parent()
|
||||||
|
if page_parent is None:
|
||||||
return
|
return
|
||||||
self.page_widget.parent.remove(self.page_widget)
|
page_parent.remove(self.page_widget)
|
||||||
|
|
||||||
def do_expose_event(self, event):
|
def do_expose_event(self, event):
|
||||||
if not self.is_expanded() or self.props.palette is not None and \
|
if not self.is_expanded() or self.props.palette is not None and \
|
||||||
@ -218,7 +222,7 @@ class _ToolbarPalette(PaletteWindow):
|
|||||||
self.set_group_id('toolbarbox')
|
self.set_group_id('toolbarbox')
|
||||||
|
|
||||||
def get_expanded_button(self):
|
def get_expanded_button(self):
|
||||||
return self.invoker.parent
|
return self.invoker.get_parent()
|
||||||
|
|
||||||
expanded_button = property(get_expanded_button)
|
expanded_button = property(get_expanded_button)
|
||||||
|
|
||||||
@ -272,9 +276,10 @@ class _Box(Gtk.EventBox):
|
|||||||
self.set_app_paintable(True)
|
self.set_app_paintable(True)
|
||||||
|
|
||||||
def do_expose_event(self, widget, event):
|
def do_expose_event(self, widget, event):
|
||||||
if self.parent.expanded_button is None:
|
expanded_button = self.get_parent().expanded_button
|
||||||
|
if expanded_button is None:
|
||||||
return
|
return
|
||||||
alloc = self.parent.expanded_button.allocation
|
alloc = expanded_button.allocation
|
||||||
self.get_style().paint_box(event.window,
|
self.get_style().paint_box(event.window,
|
||||||
Gtk.StateType.NORMAL, Gtk.ShadowType.IN, event.area, self,
|
Gtk.StateType.NORMAL, Gtk.ShadowType.IN, event.area, self,
|
||||||
'palette-invoker', -style.FOCUS_LINE_WIDTH, 0,
|
'palette-invoker', -style.FOCUS_LINE_WIDTH, 0,
|
||||||
@ -318,7 +323,7 @@ def _embed_page(box_class, page):
|
|||||||
|
|
||||||
|
|
||||||
def _get_embedded_page(page_widget):
|
def _get_embedded_page(page_widget):
|
||||||
return page_widget.get_child().child
|
return page_widget.get_child().get_child()
|
||||||
|
|
||||||
|
|
||||||
def _paint_arrow(widget, event, arrow_type):
|
def _paint_arrow(widget, event, arrow_type):
|
||||||
|
@ -85,32 +85,32 @@ class _TrayViewport(Gtk.Viewport):
|
|||||||
start = item.allocation.y
|
start = item.allocation.y
|
||||||
stop = item.allocation.y + item.allocation.height
|
stop = item.allocation.y + item.allocation.height
|
||||||
|
|
||||||
if start < adj.value:
|
if start < adj.get_value():
|
||||||
adj.value = start
|
adj.set_value(start)
|
||||||
elif stop > adj.value + adj.page_size:
|
elif stop > adj.get_value() + adj.get_page_size():
|
||||||
adj.value = stop - adj.page_size
|
adj.set_value(stop - adj.get_page_size())
|
||||||
|
|
||||||
def _scroll_next(self):
|
def _scroll_next(self):
|
||||||
allocation = self.get_allocation()
|
allocation = self.get_allocation()
|
||||||
if self.orientation == Gtk.Orientation.HORIZONTAL:
|
if self.orientation == Gtk.Orientation.HORIZONTAL:
|
||||||
adj = self.get_hadjustment()
|
adj = self.get_hadjustment()
|
||||||
new_value = adj.value + allocation.width
|
new_value = adj.get_value() + allocation.width
|
||||||
adj.value = min(new_value, adj.upper - allocation.width)
|
adj.set_value(min(new_value, adj.get_upper() - allocation.width))
|
||||||
else:
|
else:
|
||||||
adj = self.get_vadjustment()
|
adj = self.get_vadjustment()
|
||||||
new_value = adj.value + allocation.height
|
new_value = adj.get_value() + allocation.height
|
||||||
adj.value = min(new_value, adj.upper - allocation.height)
|
adj.set_value(min(new_value, adj.get_upper() - allocation.height))
|
||||||
|
|
||||||
def _scroll_previous(self):
|
def _scroll_previous(self):
|
||||||
allocation = self.get_allocation()
|
allocation = self.get_allocation()
|
||||||
if self.orientation == Gtk.Orientation.HORIZONTAL:
|
if self.orientation == Gtk.Orientation.HORIZONTAL:
|
||||||
adj = self.get_hadjustment()
|
adj = self.get_hadjustment()
|
||||||
new_value = adj.value - allocation.width
|
new_value = adj.get_value() - allocation.width
|
||||||
adj.value = max(adj.lower, new_value)
|
adj.set_value(max(adj.get_lower(), new_value))
|
||||||
else:
|
else:
|
||||||
adj = self.get_vadjustment()
|
adj = self.get_vadjustment()
|
||||||
new_value = adj.value - allocation.height
|
new_value = adj.get_value() - allocation.height
|
||||||
adj.value = max(adj.lower, new_value)
|
adj.set_value(max(adj.get_lower(), new_value))
|
||||||
|
|
||||||
def do_size_request(self, requisition):
|
def do_size_request(self, requisition):
|
||||||
child_requisition = self.get_child().size_request()
|
child_requisition = self.get_child().size_request()
|
||||||
@ -141,12 +141,13 @@ class _TrayViewport(Gtk.Viewport):
|
|||||||
self.notify('scrollable')
|
self.notify('scrollable')
|
||||||
|
|
||||||
def _adjustment_changed_cb(self, adjustment):
|
def _adjustment_changed_cb(self, adjustment):
|
||||||
if adjustment.value <= adjustment.lower:
|
if adjustment.get_value() <= adjustment.get_lower():
|
||||||
can_scroll_prev = False
|
can_scroll_prev = False
|
||||||
else:
|
else:
|
||||||
can_scroll_prev = True
|
can_scroll_prev = True
|
||||||
|
|
||||||
if adjustment.value + adjustment.page_size >= adjustment.upper:
|
if adjustment.get_value() + adjustment.get_page_size() >= \
|
||||||
|
adjustment.get_upper():
|
||||||
can_scroll_next = False
|
can_scroll_next = False
|
||||||
else:
|
else:
|
||||||
can_scroll_next = True
|
can_scroll_next = True
|
||||||
@ -409,7 +410,7 @@ class _IconWidget(Gtk.EventBox):
|
|||||||
self._icon.show()
|
self._icon.show()
|
||||||
|
|
||||||
def do_expose_event(self, event):
|
def do_expose_event(self, event):
|
||||||
palette = self.parent.palette
|
palette = self.get_parent().palette
|
||||||
if palette and palette.is_up():
|
if palette and palette.is_up():
|
||||||
invoker = palette.props.invoker
|
invoker = palette.props.invoker
|
||||||
invoker.draw_rectangle(event, palette)
|
invoker.draw_rectangle(event, palette)
|
||||||
|
@ -125,13 +125,14 @@ class Window(Gtk.Window):
|
|||||||
even after invoking on response on non-gtk events.
|
even after invoking on response on non-gtk events.
|
||||||
See #1423.
|
See #1423.
|
||||||
"""
|
"""
|
||||||
if self.window is None:
|
window = self.get_window()
|
||||||
|
if window is None:
|
||||||
self.show()
|
self.show()
|
||||||
return
|
return
|
||||||
timestamp = Gtk.get_current_event_time()
|
timestamp = Gtk.get_current_event_time()
|
||||||
if not timestamp:
|
if not timestamp:
|
||||||
timestamp = GdkX11.get_server_time(self.window)
|
timestamp = GdkX11.get_server_time(window)
|
||||||
self.window.focus(timestamp)
|
window.focus(timestamp)
|
||||||
|
|
||||||
def fullscreen(self):
|
def fullscreen(self):
|
||||||
palettegroup.popdown_all()
|
palettegroup.popdown_all()
|
||||||
@ -238,7 +239,7 @@ class Window(Gtk.Window):
|
|||||||
def __window_realize_cb(self, window):
|
def __window_realize_cb(self, window):
|
||||||
group = Gtk.Window()
|
group = Gtk.Window()
|
||||||
group.realize()
|
group.realize()
|
||||||
window.window.set_group(group.window)
|
window.get_window().set_group(group.get_window())
|
||||||
|
|
||||||
def __key_press_cb(self, widget, event):
|
def __key_press_cb(self, widget, event):
|
||||||
key = Gdk.keyval_name(event.keyval)
|
key = Gdk.keyval_name(event.keyval)
|
||||||
|
Loading…
Reference in New Issue
Block a user