本文整理汇总了Python中miro.frontends.widgets.gtk.wrappermap.wrapper函数的典型用法代码示例。如果您正苦于以下问题:Python wrapper函数的具体用法?Python wrapper怎么用?Python wrapper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wrapper函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_net_stop
def on_net_stop(self, uri):
if uri in self._downloads:
path = self._downloads.pop(uri)
wrappermap.wrapper(self).emit(
'download-finished',
'file://%s' % path.replace(os.sep, '/'))
return
wrappermap.wrapper(self).emit('net-stop')
示例2: do_button_release_event
def do_button_release_event(self, event):
if event.button != self.drag_button:
return
self.in_drag = False
if (self.is_continuous and
(0 <= event.x < self.allocation.width) and
(0 <= event.y < self.allocation.height)):
wrappermap.wrapper(self).emit('changed', self.get_value())
wrappermap.wrapper(self).emit('released')
示例3: do_button_press_event
def do_button_press_event(self, event):
if self.in_drag:
return
self.start_value = self.get_value()
self.in_drag = True
self.drag_button = event.button
self.drag_inbounds = True
self.move_slider_to_mouse(event.x, event.y)
self.grab_focus()
wrappermap.wrapper(self).emit('pressed')
示例4: do_motion_notify_event
def do_motion_notify_event(self, event):
DRAG_THRESHOLD = 15
if self.button_press_x is None:
# button not down
return
if (self.last_drag_event != 'right' and
event.x > self.button_press_x + DRAG_THRESHOLD):
wrappermap.wrapper(self).emit('dragged-right')
self.last_drag_event = 'right'
elif (self.last_drag_event != 'left' and
event.x < self.button_press_x - DRAG_THRESHOLD):
wrappermap.wrapper(self).emit('dragged-left')
self.last_drag_event = 'left'
示例5: on_uri_load
def on_uri_load(self, uri):
if wrappermap.wrapper(self).should_download_url(uri):
parsed = urlparse.urlparse(uri)
prefix, suffix = os.path.splitext(os.path.basename(parsed.path))
fd, path = tempfile.mkstemp(suffix=suffix, prefix=prefix)
os.close(fd)
self.browser.download_uri(uri, path)
self._downloads[uri] = path
return False
else:
rv = wrappermap.wrapper(self).should_load_url(uri)
if rv:
wrappermap.wrapper(self).url = uri
return rv
示例6: do_button_press_event
def do_button_press_event(self, event):
if self.drag_info is not None:
return
current_pos = self.get_slider_pos()
event_pos = self._event_pos(event)
pos_difference = abs(current_pos - event_pos)
# only move the slider if the click was outside its boundaries
# (#18840)
if pos_difference > self.slider_size() / 2.0:
self.move_slider(event_pos)
current_pos = event_pos
self.drag_info = _DragInfo(event.button, current_pos, event_pos)
self.grab_focus()
wrappermap.wrapper(self).emit('pressed')
示例7: on_render
def on_render(self, window, widget, background_area, cell_area, expose_area,
flags):
widget_wrapper = wrappermap.wrapper(widget)
cell_wrapper = wrappermap.wrapper(self)
selected = (flags & gtk.CELL_RENDERER_SELECTED)
if selected:
if widget.flags() & gtk.HAS_FOCUS:
state = gtk.STATE_SELECTED
else:
state = gtk.STATE_ACTIVE
else:
state = gtk.STATE_NORMAL
if cell_wrapper.IGNORE_PADDING:
area = background_area
else:
xpad = self.props.xpad
ypad = self.props.ypad
area = gtk.gdk.Rectangle(cell_area.x + xpad, cell_area.y + ypad,
cell_area.width - xpad * 2, cell_area.height - ypad * 2)
context = drawing.DrawingContext(window, area, expose_area)
if (selected and not widget_wrapper.draws_selection and
widget_wrapper.use_custom_style):
# Draw the base color as our background. This erases the gradient
# that GTK draws for selected items.
window.draw_rectangle(widget.style.base_gc[state], True,
background_area.x, background_area.y,
background_area.width, background_area.height)
context.style = drawing.DrawingStyle(widget_wrapper,
use_base_color=True, state=state)
widget_wrapper.layout_manager.update_cairo_context(context.context)
hotspot_tracker = widget_wrapper.hotspot_tracker
if (hotspot_tracker and hotspot_tracker.hit and
hotspot_tracker.column == self.column and
hotspot_tracker.path == self.path):
hotspot = hotspot_tracker.name
else:
hotspot = None
if (self.path, self.column) == widget_wrapper.hover_info:
hover = widget_wrapper.hover_pos
hover = (hover[0] - xpad, hover[1] - ypad)
else:
hover = None
# NOTE: CustomCellRenderer.cell_data_func() sets up its attributes
# from the model itself, so we don't have to worry about setting them
# here.
widget_wrapper.layout_manager.reset()
cell_wrapper.render(context, widget_wrapper.layout_manager, selected,
hotspot, hover)
示例8: move_slider_to_mouse
def move_slider_to_mouse(self, x, y):
if ((not 0 <= x < self.allocation.width) or
(not 0 <= y < self.allocation.height)):
self.handle_drag_out_of_bounds()
return
if self.is_horizontal():
pos = x
size = self.allocation.width
else:
pos = y
size = self.height
value = (self.max - self.min) * self.calc_percent(pos, size)
self.set_value(value)
wrappermap.wrapper(self).emit('moved', self.get_value())
if self.is_continuous():
wrappermap.wrapper(self).emit('changed', self.get_value())
示例9: move_slider
def move_slider(self, new_pos):
"""Move the slider so that it's centered on new_pos."""
if self.is_horizontal():
size = self.allocation.width
else:
size = self.allocation.height
slider_size = self.slider_size()
new_pos -= slider_size / 2
size -= slider_size
ratio = max(0, min(1, float(new_pos) / size))
self.set_value(ratio * (self.max - self.min))
wrappermap.wrapper(self).emit('moved', self.get_value())
if self.is_continuous():
wrappermap.wrapper(self).emit('changed', self.get_value())
示例10: do_expose_event
def do_expose_event(self, event):
wrapper = wrappermap.wrapper(self)
if self.flags() & gtk.NO_WINDOW:
drawing_area = self.allocation
else:
drawing_area = gtk.gdk.Rectangle(0, 0,
self.allocation.width, self.allocation.height)
context = DrawingContext(event.window, drawing_area, event.area)
context.style = DrawingStyle(wrapper)
if self.flags() & gtk.CAN_FOCUS:
focus_space = (self.style_get_property('focus-padding') +
self.style_get_property('focus-line-width'))
if not wrapper.squish_width:
context.width -= focus_space * 2
translate_x = focus_space
else:
translate_x = 0
if not wrapper.squish_height:
context.height -= focus_space * 2
translate_y = focus_space
else:
translate_y = 0
context.translate(translate_x, translate_y)
wrapper.layout_manager.update_cairo_context(context.context)
self.draw(wrapper, context)
示例11: cell_data_func
def cell_data_func(self, column, cell, model, it, attr_map):
item_list = wrappermap.wrapper(model).item_list
row = model.row_of_iter(it)
self.info = item_list.get_row(row)
self.attrs = item_list.get_attrs(self.info.id)
self.group_info = item_list.get_group_info(row)
cell.column = column
cell.path = row
示例12: on_hierarchy_changed
def on_hierarchy_changed(self, widget, previous_toplevel):
toplevel = widget.get_toplevel()
if not (toplevel.flags() & gtk.TOPLEVEL):
toplevel = None
if previous_toplevel != toplevel:
if self.use_custom_style_callback:
old_window = wrappermap.wrapper(previous_toplevel)
old_window.disconnect(self.use_custom_style_callback)
if toplevel is not None:
window = wrappermap.wrapper(toplevel)
callback_id = window.connect("use-custom-style-changed", self.on_use_custom_style_changed)
self.use_custom_style_callback = callback_id
else:
self.use_custom_style_callback = None
if previous_toplevel is None:
# Setup our initial state
self.on_use_custom_style_changed(window)
示例13: do_key_press_event
def do_key_press_event(self, event):
ret = keymap.translate_gtk_event(event)
if ret == None:
return gtk.Window.do_key_press_event(self, event)
key, modifiers = ret
if wrappermap.wrapper(self).emit('key-press', key, modifiers):
return # handler returned True, don't process the key more
return gtk.Window.do_key_press_event(self, event)
示例14: _on_activate
def _on_activate(self, menu_item):
self.emit("activate")
gtk_menubar = self._find_menubar()
if gtk_menubar is not None:
try:
menubar = wrappermap.wrapper(gtk_menubar)
except KeyError:
app.widgetapp.handle_soft_failure("menubar activate", "no wrapper for gtk.MenuBar", with_exception=True)
else:
menubar.emit("activate", self.name)
示例15: on_get_size
def on_get_size(self, widget, cell_area=None):
wrapper = wrappermap.wrapper(self)
widget_wrapper = wrappermap.wrapper(widget)
style = drawing.DrawingStyle(widget_wrapper, use_base_color=True)
# NOTE: CustomCellRenderer.cell_data_func() sets up its attributes
# from the model itself, so we don't have to worry about setting them
# here.
width, height = wrapper.get_size(style, widget_wrapper.layout_manager)
x_offset = self.props.xpad
y_offset = self.props.ypad
width += self.props.xpad * 2
height += self.props.ypad * 2
if cell_area:
x_offset += cell_area.x
y_offset += cell_area.x
extra_width = max(0, cell_area.width - width)
extra_height = max(0, cell_area.height - height)
x_offset += int(round(self.props.xalign * extra_width))
y_offset += int(round(self.props.yalign * extra_height))
return x_offset, y_offset, width, height