Trivial GTK3 porting fixes
Fix some trivial issues missed earlier: various missing imports, some minor API changes to adapt to, do_size_request simple porting, etc. Signed-off-by: Daniel Drake <dsd@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
This commit is contained in:
parent
827ab7218a
commit
15946211cf
@ -58,6 +58,7 @@ from functools import partial
|
|||||||
from gi.repository import GConf
|
from gi.repository import GConf
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from gi.repository import Gdk
|
from gi.repository import Gdk
|
||||||
|
from gi.repository import GdkPixbuf
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
|
@ -20,6 +20,7 @@ import os
|
|||||||
|
|
||||||
from gi.repository import Gio
|
from gi.repository import Gio
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import Gdk
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
from gi.repository import GConf
|
from gi.repository import GConf
|
||||||
|
|
||||||
@ -194,18 +195,18 @@ class NamingAlert(Gtk.Window):
|
|||||||
header = self._create_header()
|
header = self._create_header()
|
||||||
body.pack_start(header, False, False, style.DEFAULT_PADDING)
|
body.pack_start(header, False, False, style.DEFAULT_PADDING)
|
||||||
|
|
||||||
body.pack_start(self._create_separator(style.DEFAULT_SPACING, True, True, 0), False, False, 0)
|
body.pack_start(self._create_separator(style.DEFAULT_SPACING), False, False, 0)
|
||||||
|
|
||||||
body.pack_start(self._create_label(_('Description:', True, True, 0)), False, False, 0)
|
body.pack_start(self._create_label(_('Description:')), False, False, 0)
|
||||||
|
|
||||||
description = self._activity.metadata.get('description', '')
|
description = self._activity.metadata.get('description', '')
|
||||||
description_box, self._description = self._create_text_view(description)
|
description_box, self._description = self._create_text_view(description)
|
||||||
body.pack_start(description_box, True, True, 0)
|
body.pack_start(description_box, True, True, 0)
|
||||||
|
|
||||||
body.pack_start(self._create_separator(style.DEFAULT_PADDING, True, True, 0), False, False, 0)
|
body.pack_start(self._create_separator(style.DEFAULT_PADDING), False, False, 0)
|
||||||
|
|
||||||
|
|
||||||
body.pack_start(self._create_label(_('Tags:', True, True, 0)), False, False, 0)
|
body.pack_start(self._create_label(_('Tags:')), False, False, 0)
|
||||||
|
|
||||||
tags = self._activity.metadata.get('tags', '')
|
tags = self._activity.metadata.get('tags', '')
|
||||||
tags_box, self._tags = self._create_text_view(tags)
|
tags_box, self._tags = self._create_text_view(tags)
|
||||||
|
@ -231,7 +231,7 @@ class RawObject(object):
|
|||||||
'uid': file_path,
|
'uid': file_path,
|
||||||
'title': os.path.basename(file_path),
|
'title': os.path.basename(file_path),
|
||||||
'timestamp': stat.st_mtime,
|
'timestamp': stat.st_mtime,
|
||||||
'mime_type': Gio.content_type_guess(filename=file_path),
|
'mime_type': Gio.content_type_guess(file_path, None)[0],
|
||||||
'activity': '',
|
'activity': '',
|
||||||
'activity_id': '',
|
'activity_id': '',
|
||||||
'icon-color': client.get_string('/desktop/sugar/user/color'),
|
'icon-color': client.get_string('/desktop/sugar/user/color'),
|
||||||
|
@ -354,10 +354,13 @@ class _TimeoutIcon(Gtk.Alignment):
|
|||||||
self._draw(context)
|
self._draw(context)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def do_size_request(self, requisition):
|
def do_get_preferred_width(self):
|
||||||
requisition.height, requisition.width = \
|
width = Gtk.icon_size_lookup(Gtk.IconSize.BUTTON)[1]
|
||||||
Gtk.icon_size_lookup(Gtk.IconSize.BUTTON)
|
return width, width
|
||||||
self._text.size_request()
|
|
||||||
|
def do_get_preferred_height(self):
|
||||||
|
height = Gtk.icon_size_lookup(Gtk.IconSize.BUTTON)[2]
|
||||||
|
return height, height
|
||||||
|
|
||||||
def _draw(self, context):
|
def _draw(self, context):
|
||||||
w = self.get_allocated_width()
|
w = self.get_allocated_width()
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
# Boston, MA 02111-1307, USA.
|
# Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
|
from gi.repository import Gdk
|
||||||
|
from gi.repository import GdkPixbuf
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
import struct
|
import struct
|
||||||
@ -261,7 +263,7 @@ class _ColorPalette(Palette):
|
|||||||
self._swatch_tray = Gtk.Table()
|
self._swatch_tray = Gtk.Table()
|
||||||
|
|
||||||
self._picker_hbox.pack_start(self._swatch_tray, True, True, 0)
|
self._picker_hbox.pack_start(self._swatch_tray, True, True, 0)
|
||||||
self._picker_hbox.pack_start(Gtk.VSeparator(, True, True, 0),
|
self._picker_hbox.pack_start(Gtk.VSeparator(), True, True,
|
||||||
padding=style.DEFAULT_SPACING)
|
padding=style.DEFAULT_SPACING)
|
||||||
|
|
||||||
self._chooser_table = Gtk.Table(3, 2)
|
self._chooser_table = Gtk.Table(3, 2)
|
||||||
|
@ -21,6 +21,7 @@ STABLE.
|
|||||||
|
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import GdkPixbuf
|
||||||
|
|
||||||
|
|
||||||
class ComboBox(Gtk.ComboBox):
|
class ComboBox(Gtk.ComboBox):
|
||||||
|
@ -27,6 +27,8 @@ import logging
|
|||||||
|
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import Gdk
|
||||||
|
from gi.repository import GdkPixbuf
|
||||||
import cairo
|
import cairo
|
||||||
|
|
||||||
from sugar3.graphics import style
|
from sugar3.graphics import style
|
||||||
|
@ -15,7 +15,10 @@
|
|||||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
# Boston, MA 02111-1307, USA.
|
# Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
from gi.repository import GObject
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import Gdk
|
||||||
|
from gi.repository import GdkPixbuf
|
||||||
|
|
||||||
from sugar3.graphics import style
|
from sugar3.graphics import style
|
||||||
from sugar3.graphics.icon import _SVGLoader
|
from sugar3.graphics.icon import _SVGLoader
|
||||||
|
@ -23,6 +23,7 @@ import logging
|
|||||||
|
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import Gdk
|
||||||
import dbus
|
import dbus
|
||||||
|
|
||||||
from sugar3.datastore import datastore
|
from sugar3.datastore import datastore
|
||||||
|
@ -20,6 +20,7 @@ STABLE.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
from gi.repository import GObject
|
||||||
|
|
||||||
|
|
||||||
class Panel(Gtk.VBox):
|
class Panel(Gtk.VBox):
|
||||||
|
@ -50,7 +50,7 @@ class Toolbox(Gtk.VBox):
|
|||||||
self._separator.modify_bg(Gtk.StateType.NORMAL,
|
self._separator.modify_bg(Gtk.StateType.NORMAL,
|
||||||
style.COLOR_PANEL_GREY.get_gdk_color())
|
style.COLOR_PANEL_GREY.get_gdk_color())
|
||||||
self._separator.set_size_request(1, style.TOOLBOX_SEPARATOR_HEIGHT)
|
self._separator.set_size_request(1, style.TOOLBOX_SEPARATOR_HEIGHT)
|
||||||
self.pack_start(self._separator, False)
|
self.pack_start(self._separator, False, False, 0)
|
||||||
|
|
||||||
self._notebook.connect('notify::page', self._notify_page_cb)
|
self._notebook.connect('notify::page', self._notify_page_cb)
|
||||||
|
|
||||||
@ -59,8 +59,9 @@ class Toolbox(Gtk.VBox):
|
|||||||
|
|
||||||
def add_toolbar(self, name, toolbar):
|
def add_toolbar(self, name, toolbar):
|
||||||
label = Gtk.Label(label=name)
|
label = Gtk.Label(label=name)
|
||||||
width, height_ = label.size_request()
|
req = label.size_request()
|
||||||
label.set_size_request(max(width, style.TOOLBOX_TAB_LABEL_WIDTH), -1)
|
label.set_size_request(max(req.width, style.TOOLBOX_TAB_LABEL_WIDTH),
|
||||||
|
-1)
|
||||||
label.set_alignment(0.0, 0.5)
|
label.set_alignment(0.0, 0.5)
|
||||||
|
|
||||||
event_box = Gtk.EventBox()
|
event_box = Gtk.EventBox()
|
||||||
|
@ -76,14 +76,15 @@ class _TrayViewport(Gtk.Viewport):
|
|||||||
assert item in self.traybar.get_children()
|
assert item in self.traybar.get_children()
|
||||||
|
|
||||||
# Get the allocation, and make sure that it is visible
|
# Get the allocation, and make sure that it is visible
|
||||||
|
allocation = item.get_allocation()
|
||||||
if self.orientation == Gtk.Orientation.HORIZONTAL:
|
if self.orientation == Gtk.Orientation.HORIZONTAL:
|
||||||
adj = self.get_hadjustment()
|
adj = self.get_hadjustment()
|
||||||
start = item.allocation.x
|
start = allocation.x
|
||||||
stop = item.allocation.x + item.allocation.width
|
stop = allocation.x + allocation.width
|
||||||
else:
|
else:
|
||||||
adj = self.get_vadjustment()
|
adj = self.get_vadjustment()
|
||||||
start = item.allocation.y
|
start = allocation.y
|
||||||
stop = item.allocation.y + item.allocation.height
|
stop = allocation.y + allocation.height
|
||||||
|
|
||||||
if start < adj.get_value():
|
if start < adj.get_value():
|
||||||
adj.set_value(start)
|
adj.set_value(start)
|
||||||
@ -112,14 +113,17 @@ class _TrayViewport(Gtk.Viewport):
|
|||||||
new_value = adj.get_value() - allocation.height
|
new_value = adj.get_value() - allocation.height
|
||||||
adj.set_value(max(adj.get_lower(), new_value))
|
adj.set_value(max(adj.get_lower(), new_value))
|
||||||
|
|
||||||
def do_size_request(self, requisition):
|
def do_get_preferred_width(self):
|
||||||
child_requisition = self.get_child().size_request()
|
|
||||||
if self.orientation == Gtk.Orientation.HORIZONTAL:
|
if self.orientation == Gtk.Orientation.HORIZONTAL:
|
||||||
requisition[0] = 0
|
return Gtk.Viewport.do_get_preferred_width(self)
|
||||||
requisition[1] = child_requisition[1]
|
child_minimum, child_natural = self.get_child().get_preferred_size()
|
||||||
else:
|
return child_minimum.width, child_natural.width
|
||||||
requisition[0] = child_requisition[0]
|
|
||||||
requisition[1] = 0
|
def do_get_preferred_height(self):
|
||||||
|
if self.orientation != Gtk.Orientation.HORIZONTAL:
|
||||||
|
return Gtk.Viewport.do_get_preferred_width(self)
|
||||||
|
child_minimum, child_natural = self.get_child().get_preferred_size()
|
||||||
|
return child_minimum.height, child_natural.height
|
||||||
|
|
||||||
def do_get_property(self, pspec):
|
def do_get_property(self, pspec):
|
||||||
if pspec.name == 'scrollable':
|
if pspec.name == 'scrollable':
|
||||||
|
@ -22,6 +22,7 @@ STABLE.
|
|||||||
|
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
from gi.repository import Gdk
|
from gi.repository import Gdk
|
||||||
|
from gi.repository import GdkX11
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT = 2
|
|||||||
class UnfullscreenButton(Gtk.Window):
|
class UnfullscreenButton(Gtk.Window):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
GObject.GObject.__init__(self)
|
Gtk.Window.__init__(self)
|
||||||
|
|
||||||
self.set_decorated(False)
|
self.set_decorated(False)
|
||||||
self.set_resizable(False)
|
self.set_resizable(False)
|
||||||
@ -46,12 +47,10 @@ class UnfullscreenButton(Gtk.Window):
|
|||||||
self.props.accept_focus = False
|
self.props.accept_focus = False
|
||||||
|
|
||||||
#Setup estimate of width, height
|
#Setup estimate of width, height
|
||||||
w, h = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
|
valid_, w, h = Gtk.icon_size_lookup(Gtk.IconSize.LARGE_TOOLBAR)
|
||||||
self._width = w
|
self._width = w
|
||||||
self._height = h
|
self._height = h
|
||||||
|
|
||||||
self.connect('size-request', self._size_request_cb)
|
|
||||||
|
|
||||||
screen = self.get_screen()
|
screen = self.get_screen()
|
||||||
screen.connect('size-changed', self._screen_size_changed_cb)
|
screen.connect('size-changed', self._screen_size_changed_cb)
|
||||||
|
|
||||||
@ -73,10 +72,11 @@ class UnfullscreenButton(Gtk.Window):
|
|||||||
x = Gdk.Screen.width() - self._width
|
x = Gdk.Screen.width() - self._width
|
||||||
self.move(x, 0)
|
self.move(x, 0)
|
||||||
|
|
||||||
def _size_request_cb(self, widget, req):
|
def do_get_preferred_width(self):
|
||||||
self._width = req.width
|
minimum, natural = Gtk.Window.do_get_preferred_width(self)
|
||||||
self._height = req.height
|
self._width = minimum
|
||||||
self._reposition()
|
self._reposition()
|
||||||
|
return minimum, natural
|
||||||
|
|
||||||
def _screen_size_changed_cb(self, screen):
|
def _screen_size_changed_cb(self, screen):
|
||||||
self._reposition()
|
self._reposition()
|
||||||
@ -193,7 +193,7 @@ class Window(Gtk.Window):
|
|||||||
self.__vbox.remove(self._toolbar_box)
|
self.__vbox.remove(self._toolbar_box)
|
||||||
|
|
||||||
if toolbar_box:
|
if toolbar_box:
|
||||||
self.__vbox.pack_start(toolbar_box, False)
|
self.__vbox.pack_start(toolbar_box, False, False, 0)
|
||||||
self.__vbox.reorder_child(toolbar_box, 0)
|
self.__vbox.reorder_child(toolbar_box, 0)
|
||||||
|
|
||||||
self._toolbar_box = toolbar_box
|
self._toolbar_box = toolbar_box
|
||||||
@ -206,18 +206,18 @@ class Window(Gtk.Window):
|
|||||||
box.remove(self.tray)
|
box.remove(self.tray)
|
||||||
|
|
||||||
if position == Gtk.PositionType.LEFT:
|
if position == Gtk.PositionType.LEFT:
|
||||||
self.__hbox.pack_start(tray, False)
|
self.__hbox.pack_start(tray, False, False, 0)
|
||||||
elif position == Gtk.PositionType.RIGHT:
|
elif position == Gtk.PositionType.RIGHT:
|
||||||
self.__hbox.pack_end(tray, False)
|
self.__hbox.pack_end(tray, False, False, 0)
|
||||||
elif position == Gtk.PositionType.BOTTOM:
|
elif position == Gtk.PositionType.BOTTOM:
|
||||||
self.__vbox.pack_end(tray, False)
|
self.__vbox.pack_end(tray, False, False, 0)
|
||||||
|
|
||||||
self.tray = tray
|
self.tray = tray
|
||||||
|
|
||||||
def add_alert(self, alert):
|
def add_alert(self, alert):
|
||||||
self._alerts.append(alert)
|
self._alerts.append(alert)
|
||||||
if len(self._alerts) == 1:
|
if len(self._alerts) == 1:
|
||||||
self.__vbox.pack_start(alert, False)
|
self.__vbox.pack_start(alert, False, False, 0)
|
||||||
if self._toolbar_box is not None:
|
if self._toolbar_box is not None:
|
||||||
self.__vbox.reorder_child(alert, 1)
|
self.__vbox.reorder_child(alert, 1)
|
||||||
else:
|
else:
|
||||||
@ -230,7 +230,7 @@ class Window(Gtk.Window):
|
|||||||
if alert.get_parent() is not None:
|
if alert.get_parent() is not None:
|
||||||
self.__vbox.remove(alert)
|
self.__vbox.remove(alert)
|
||||||
if len(self._alerts) >= 1:
|
if len(self._alerts) >= 1:
|
||||||
self.__vbox.pack_start(self._alerts[0], False)
|
self.__vbox.pack_start(self._alerts[0], False, False, 0)
|
||||||
if self._toolbar_box is not None:
|
if self._toolbar_box is not None:
|
||||||
self.__vbox.reorder_child(self._alerts[0], 1)
|
self.__vbox.reorder_child(self._alerts[0], 1)
|
||||||
else:
|
else:
|
||||||
|
@ -82,9 +82,9 @@ def get_sugar_window_type(wnck_window):
|
|||||||
|
|
||||||
def set_activity_id(window, activity_id):
|
def set_activity_id(window, activity_id):
|
||||||
_property_change_trapped(window, '_SUGAR_ACTIVITY_ID', 'STRING', 8,
|
_property_change_trapped(window, '_SUGAR_ACTIVITY_ID', 'STRING', 8,
|
||||||
Gdk.PROP_MODE_REPLACE, activity_id)
|
Gdk.PropMode.REPLACE, activity_id)
|
||||||
|
|
||||||
|
|
||||||
def set_bundle_id(window, bundle_id):
|
def set_bundle_id(window, bundle_id):
|
||||||
_property_change_trapped(window, '_SUGAR_BUNDLE_ID', 'STRING', 8,
|
_property_change_trapped(window, '_SUGAR_BUNDLE_ID', 'STRING', 8,
|
||||||
Gdk.PROP_MODE_REPLACE, bundle_id)
|
Gdk.PropMode.REPLACE, bundle_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user