diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:48:42 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:48:45 +0900 |
commit | 265684897ba0b24e28710a988cab901acbec1775 (patch) | |
tree | 332d43c2c54979ddb5390359f6ab1d865bdda3b6 /gi/overrides | |
parent | 01ddc2783a1d721a003f181000e266acde134d19 (diff) | |
download | pygobject2-265684897ba0b24e28710a988cab901acbec1775.tar.gz pygobject2-265684897ba0b24e28710a988cab901acbec1775.tar.bz2 pygobject2-265684897ba0b24e28710a988cab901acbec1775.zip |
Imported Upstream version 3.7.90
Change-Id: I6f093f89379c4f834493e7edf7a32b8c4ad32393
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'gi/overrides')
-rw-r--r-- | gi/overrides/Gtk.py | 42 | ||||
-rw-r--r-- | gi/overrides/__init__.py | 3 |
2 files changed, 32 insertions, 13 deletions
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py index 25f127f..002f22b 100644 --- a/gi/overrides/Gtk.py +++ b/gi/overrides/Gtk.py @@ -48,6 +48,22 @@ python module to use with Gtk 2.0" warnings.warn(warn_msg, RuntimeWarning) +def _construct_target_list(targets): + """Create a list of TargetEntry items from a list of tuples in the form (target, flags, info) + + The list can also contain existing TargetEntry items in which case the existing entry + is re-used in the return list. + """ + target_entries = [] + for entry in targets: + if not isinstance(entry, Gtk.TargetEntry): + entry = Gtk.TargetEntry.new(*entry) + target_entries.append(entry) + return target_entries + +__all__.append('_construct_target_list') + + class Widget(Gtk.Widget): def translate_coordinates(self, dest_widget, src_x, src_y): @@ -59,6 +75,17 @@ class Widget(Gtk.Widget): def render_icon(self, stock_id, size, detail=None): return super(Widget, self).render_icon(stock_id, size, detail) + def drag_dest_set_target_list(self, target_list): + if not isinstance(target_list, Gtk.TargetList): + target_list = Gtk.TargetList.new(_construct_target_list(target_list)) + super(Widget, self).drag_dest_set_target_list(target_list) + + def drag_source_set_target_list(self, target_list): + if not isinstance(target_list, Gtk.TargetList): + target_list = Gtk.TargetList.new(_construct_target_list(target_list)) + super(Widget, self).drag_source_set_target_list(target_list) + + Widget = override(Widget) __all__.append('Widget') @@ -1160,7 +1187,7 @@ class TreePath(Gtk.TreePath): def __new__(cls, path=0): if isinstance(path, int): path = str(path) - elif isinstance(path, tuple): + elif not isinstance(path, _basestring): path = ":".join(str(val) for val in path) if len(path) == 0: @@ -1306,23 +1333,14 @@ class TreeView(Gtk.TreeView, Container): if success: return (path, pos,) - def _construct_target_list(self, targets): - # FIXME: this should most likely be part of Widget or a global helper - # function - target_entries = [] - for t in targets: - entry = Gtk.TargetEntry.new(*t) - target_entries.append(entry) - return target_entries - def enable_model_drag_source(self, start_button_mask, targets, actions): - target_entries = self._construct_target_list(targets) + target_entries = _construct_target_list(targets) super(TreeView, self).enable_model_drag_source(start_button_mask, target_entries, actions) def enable_model_drag_dest(self, targets, actions): - target_entries = self._construct_target_list(targets) + target_entries = _construct_target_list(targets) super(TreeView, self).enable_model_drag_dest(target_entries, actions) diff --git a/gi/overrides/__init__.py b/gi/overrides/__init__.py index b7d365c..0bd94b8 100644 --- a/gi/overrides/__init__.py +++ b/gi/overrides/__init__.py @@ -55,7 +55,8 @@ class overridefunc(object): if not hasattr(func, '__info__'): raise TypeError("func must be an gi function") from ..importer import modules - self.module = modules[func.__module__]._introspection_module + module_name = func.__module__.rsplit('.', 1)[-1] + self.module = modules[module_name]._introspection_module def __call__(self, func): def wrapper(*args, **kwargs): |