本文整理汇总了Python中sugar3.graphics.icon.EventIcon.connect方法的典型用法代码示例。如果您正苦于以下问题:Python EventIcon.connect方法的具体用法?Python EventIcon.connect怎么用?Python EventIcon.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sugar3.graphics.icon.EventIcon
的用法示例。
在下文中一共展示了EventIcon.connect方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _choose_activity
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
def _choose_activity(self):
if not hasattr(self, '_activity_sw'):
grid = Gtk.Grid()
self._reflection.activity.load_overlay_area(grid)
grid.show()
collapse_button = EventIcon(icon_name='delete', pixel_size=BUTTON_SIZE)
collapse_button.set_tooltip(_('Collapse'))
collapse_button.connect('button-press-event', self._reflection.activity.collapse_overlay_area)
grid.attach(collapse_button, 7, 0, 1, 1)
collapse_button.show()
bundle_icons = utils.get_bundle_icons()
x = 0
y = 1
for bundle_id in bundle_icons.keys():
icon_path = bundle_icons[bundle_id]
if icon_path is None:
continue
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
icon_path, style.GRID_CELL_SIZE, style.GRID_CELL_SIZE)
image = Gtk.Image.new_from_pixbuf(pixbuf)
button = Gtk.ToolButton()
button.set_icon_widget(image)
image.show()
button.connect('clicked', self._insert_activity, bundle_id)
grid.attach(button, x, y, 1, 1)
button.show()
x += 1
if x > 6:
y += 1
x = 0
self._reflection.activity.show_overlay_area()
self._reflection.activity.reset_cursor()
示例2: Picker
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
class Picker(Gtk.Grid):
def __init__(self, icon, label):
Gtk.Grid.__init__(self)
self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
icon_name=icon)
self.attach(self._button, 0, 0, 1, 1)
self._button.hide()
self._label = Gtk.Label(label.replace(' ', '\n'))
self._label.props.justify = Gtk.Justification.CENTER
self.attach(self._label, 0, 1, 1, 1)
self._label.hide()
def show_all(self):
self._button.show()
self._label.show()
self.show()
def hide_all(self):
self._button.hide()
self._label.hide()
self.hide()
def connect(self, callback, arg):
self._button.connect('activate', callback, arg)
def set_color(self, color):
self._button.xo_color = color
def set_icon(self, icon):
self._button.set_icon_name(icon)
示例3: Picker
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
class Picker(Gtk.Grid):
def __init__(self, icon, label):
Gtk.Grid.__init__(self)
self._button = EventIcon(pixel_size=style.LARGE_ICON_SIZE,
icon_name=icon)
self.attach(self._button, 0, 0, 1, 1)
self._button.hide()
self._label = Gtk.Label(label)
self.attach(self._label, 0, 1, 1, 1)
self._label.hide()
def show_all(self):
self._button.show()
self._label.show()
self.show()
def hide_all(self):
self._button.hide()
self._label.hide()
self.hide()
def connect(self, callback, arg):
self._button.connect('button-press-event', callback, arg)
def set_color(self, color):
self._button.xo_color = color
def set_icon(self, icon):
self._button.set_icon_name(icon)
示例4: _make_entry_widgets
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
def _make_entry_widgets(self):
'''We need to create a button for the smiley, a text entry, and a
send button.
All of this, along with the chatbox, goes into a grid.
---------------------------------------
| chat box |
| smiley button | entry | send button |
---------------------------------------
'''
if self._ebook_mode_detector.get_ebook_mode():
self._entry_height = int(style.GRID_CELL_SIZE * 1.5)
else:
self._entry_height = style.GRID_CELL_SIZE
entry_width = Gdk.Screen.width() - \
2 * (self._entry_height + style.GRID_CELL_SIZE)
self._chat_height = Gdk.Screen.height() - self._entry_height - \
style.GRID_CELL_SIZE
self._chat_width = Gdk.Screen.width()
self.chatbox.set_size_request(self._chat_width, self._chat_height)
self._entry_grid = Gtk.Grid()
self._entry_grid.set_size_request(
Gdk.Screen.width() - 2 * style.GRID_CELL_SIZE,
self._entry_height)
smiley_button = EventIcon(icon_name='smilies',
pixel_size=self._entry_height)
smiley_button.connect('button-press-event', self._smiley_button_cb)
self._entry_grid.attach(smiley_button, 0, 0, 1, 1)
smiley_button.show()
self._entry = Gtk.Entry()
self._entry.set_size_request(entry_width, self._entry_height)
self._entry.modify_bg(Gtk.StateType.INSENSITIVE,
style.COLOR_WHITE.get_gdk_color())
self._entry.modify_base(Gtk.StateType.INSENSITIVE,
style.COLOR_WHITE.get_gdk_color())
self._entry.set_sensitive(False)
self._entry.props.placeholder_text = \
_('You must be connected to a friend before starting to chat.')
self._entry.connect('focus-in-event', self._entry_focus_in_cb)
self._entry.connect('focus-out-event', self._entry_focus_out_cb)
self._entry.connect('activate', self._entry_activate_cb)
self._entry.connect('key-press-event', self._entry_key_press_cb)
self._entry_grid.attach(self._entry, 1, 0, 1, 1)
self._entry.show()
send_button = EventIcon(icon_name='send',
pixel_size=self._entry_height)
send_button.connect('button-press-event', self._send_button_cb)
self._entry_grid.attach(send_button, 2, 0, 1, 1)
send_button.show()
示例5: AgePicker
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
class AgePicker(Gtk.Grid):
age_changed_signal = GObject.Signal('age-changed',
arg_types=([int]))
def __init__(self, color, gender, age):
Gtk.Grid.__init__(self)
self._color = color
self._gender = gender
self._age = age
if self._gender is '':
# Used for graphic only; does not set user's gender preference.
self._gender = 'female'
self._icon = EventIcon(icon_name='%s-%d' % (self._gender, self._age),
pixel_size=style.LARGE_ICON_SIZE)
self._icon.connect('button-press-event', self.__pressed_cb)
self.attach(self._icon, 0, 0, 1, 1)
self._icon.show()
label = Gtk.Label()
label.set_text(AGE_LABELS[self._age])
self.attach(label, 0, 1, 1, 1)
label.show()
self.set_age()
def set_color(self, color, age):
self._color = color
self.set_age(age)
def set_age(self, age=None):
if age in AGES:
age_index = AGES.index(age)
else:
age_index = None
if age_index == self._age:
self._icon.props.xo_color = self._color
else:
self._icon.props.xo_color = _NOCOLOR
self._icon.show()
age = GObject.property(type=object, setter=set_age)
def set_gender(self, gender):
self._icon.set_icon_name('%s-%d' % (gender, self._age))
self._icon.show()
gender = GObject.property(type=object, setter=set_gender)
def __pressed_cb(self, button, event):
self.age_changed_signal.emit(self._age)
示例6: GenderPicker
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
class GenderPicker(Gtk.Grid):
gender_changed_signal = GObject.Signal('gender-changed', arg_types=([str]))
def __init__(self):
Gtk.Grid.__init__(self)
self.set_row_spacing(style.DEFAULT_SPACING)
self.set_column_spacing(style.DEFAULT_SPACING)
self._gender = load_gender()
self._buttons = []
self._nocolor = XoColor('#010101,#ffffff')
self._color = XoColor()
for i, gender in enumerate(GENDERS):
self._buttons.append(EventIcon(pixel_size=style.XLARGE_ICON_SIZE,
icon_name='%s-6' % (gender)))
self._buttons[-1].connect('button-press-event',
self._button_press_cb, i)
self.attach(self._buttons[-1], i * 2, 0, 1, 1)
self._buttons[-1].show()
self.reset_button = EventIcon(pixel_size=style.SMALL_ICON_SIZE,
icon_name='entry-cancel')
self.reset_button.connect('button-press-event',
self._reset_button_press_cb)
self.attach(self.reset_button, 1, 0, 1, 1)
self.reset_button.xo_color = XoColor('#010101,#a0a0a0')
self.reset_button.show()
def _reset_button_press_cb(self, widget, event):
self._set_gender('')
for i in range(len(GENDERS)):
self._buttons[i].xo_color = self._nocolor
def _button_press_cb(self, widget, event, gender_index):
if event.button == 1 and event.type == Gdk.EventType.BUTTON_PRESS:
self._set_gender(GENDERS[gender_index])
self._buttons[gender_index].xo_color = self._color
self._buttons[1 - gender_index].xo_color = self._nocolor
def get_gender(self):
return self._gender
def _set_gender(self, gender):
self.gender_changed_signal.emit(gender)
self._gender = gender
def update_color(self, color):
self._color = color
if self._gender in GENDERS:
self._buttons[GENDERS.index(self._gender)].xo_color = self._color
示例7: add_button
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
def add_button(self, icon_name, description, clicked_cb=None):
icon = EventIcon(icon_name=icon_name,
pixel_size=(style.GRID_CELL_SIZE*2)/5,
xo_color=XoColor('#ffffff,#ffffff'))
icon.props.palette = Palette(description)
self._top_bar.add(icon)
if clicked_cb:
def closure(widget, event):
alloc = widget.get_allocation()
if 0 < event.x < alloc.width and 0 < event.y < alloc.height:
clicked_cb(widget)
icon.connect('button-release-event', closure)
icon.show()
return icon
示例8: AddNewBar
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
class AddNewBar(Gtk.Box):
activate = GObject.Signal('activate', arg_types=[str])
def __init__(self, placeholder=None):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
self._button = EventIcon(icon_name='list-add')
self._button.connect('button-release-event',
self.__button_release_event_cb)
self._button.fill_color = style.COLOR_TOOLBAR_GREY.get_svg()
self._button.set_tooltip(_('Add New'))
self.pack_start(self._button, False, True, 0)
self._button.show()
self._entry = iconentry.IconEntry()
self._entry.connect('key-press-event', self.__key_press_cb)
if placeholder is None:
placeholder = _('Add new entry')
self._entry.set_placeholder_text(placeholder)
self._entry.add_clear_button()
self.pack_start(self._entry, True, True, 0)
self._entry.show()
def get_entry(self):
return self._entry
def get_button(self):
return self._button
def __key_press_cb(self, window, event):
if event.keyval == Gdk.KEY_Return:
return self._maybe_activate()
def __button_release_event_cb(self, button, event):
self._maybe_activate()
def _maybe_activate(self):
if self._entry.props.text:
self.activate.emit(self._entry.props.text)
self._entry.props.text = ''
return True
示例9: __init__
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
def __init__(self, parent):
Gtk.EventBox.__init__(self)
self._reflection = parent
self._collapse = True
self._collapse_id = None
self.modify_bg(
Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color())
self._title_color = self._reflection.activity.fg_color.get_html()
self._grid = Gtk.Grid()
self.add(self._grid)
self._grid.show()
self._grid.set_row_spacing(style.DEFAULT_PADDING)
self._grid.set_column_spacing(style.DEFAULT_SPACING)
self._grid.set_column_homogeneous(True)
self._grid.set_border_width(style.DEFAULT_PADDING)
row = 0
self._expand_button = EventIcon(icon_name='expand',
pixel_size=BUTTON_SIZE)
self._collapse_id = self._expand_button.connect('button-press-event',
self._expand_cb)
self._expand_button.set_tooltip(_('Expand'))
self._grid.attach(self._expand_button, 0, row, 1, 1)
self._expand_button.show()
self._title_align = Gtk.Alignment.new(
xalign=0, yalign=0.5, xscale=0, yscale=0)
self._title = Gtk.TextView()
self._title.set_size_request(ENTRY_WIDTH, -1)
self._title.set_wrap_mode(Gtk.WrapMode.WORD)
self._title_tag = self._title.get_buffer().create_tag(
'title', foreground=self._title_color, weight=Pango.Weight.BOLD,
size=12288)
iter_text = self._title.get_buffer().get_iter_at_offset(0)
self._title.get_buffer().insert_with_tags(
iter_text, self._reflection.data['title'], self._title_tag)
if self._reflection.activity.initiating:
self._title.connect('focus-out-event', self._title_focus_out_cb)
else:
self._title.set_editable(False)
self._title_align.add(self._title)
self._title.show()
self._grid.attach(self._title_align, 1, row, 5, 1)
self._title_align.show()
delete_button = EventIcon(icon_name='delete', pixel_size=BUTTON_SIZE)
delete_button.set_tooltip(_('Delete'))
delete_button.connect('button-press-event', self.__delete_cb)
self._grid.attach(delete_button, 6, row, 1, 1)
delete_button.show()
''' Notification that a new comment has been shared. '''
self.notify_button = EventIcon(icon_name='chat',
pixel_size=BUTTON_SIZE)
self._grid.attach(self.notify_button, 6, row, 1, 1)
row += 1
self._time_align = Gtk.Alignment.new(
xalign=0, yalign=0.5, xscale=0, yscale=0)
self._time = Gtk.Label()
self._time.set_size_request(ENTRY_WIDTH, -1)
self._time.set_justify(Gtk.Justification.LEFT)
self._time.set_use_markup(True)
try:
time_string = util.timestamp_to_elapsed_string(
int(self._reflection.data['modification_time']))
except Exception as e:
logging.error('Could not convert modification time %s: %s' %
(self._reflection.data['modification_time'], e))
self._reflection.data['modification_time'] = \
self._reflection.data['creation_time']
time_string = util.timestamp_to_elapsed_string(
int(self._reflection.data['modification_time']))
self._time.set_markup(
'<span foreground="#808080"><small><b>%s</b></small></span>' %
time_string)
self._time_align.add(self._time)
self._time.show()
self._grid.attach(self._time_align, 1, row, 5, 1)
self._time_align.show()
row += 1
label = ''
if 'tags' in self._reflection.data:
for tag in self._reflection.data['tags']:
if len(label) > 0:
label += ', '
label += tag
if self._reflection.activity.initiating and label == '':
label = _('Add a #tag')
self._tag_align = Gtk.Alignment.new(
xalign=0, yalign=0.5, xscale=0, yscale=0)
self._tag_view = Gtk.TextView()
self._tag_view.set_size_request(ENTRY_WIDTH, -1)
self._tag_view.set_wrap_mode(Gtk.WrapMode.WORD)
#.........这里部分代码省略.........
示例10: ReflectionGrid
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
class ReflectionGrid(Gtk.EventBox):
def __init__(self, parent):
Gtk.EventBox.__init__(self)
self._reflection = parent
self._collapse = True
self._collapse_id = None
self.modify_bg(
Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color())
self._title_color = self._reflection.activity.fg_color.get_html()
self._grid = Gtk.Grid()
self.add(self._grid)
self._grid.show()
self._grid.set_row_spacing(style.DEFAULT_PADDING)
self._grid.set_column_spacing(style.DEFAULT_SPACING)
self._grid.set_column_homogeneous(True)
self._grid.set_border_width(style.DEFAULT_PADDING)
row = 0
self._expand_button = EventIcon(icon_name='expand',
pixel_size=BUTTON_SIZE)
self._collapse_id = self._expand_button.connect('button-press-event',
self._expand_cb)
self._expand_button.set_tooltip(_('Expand'))
self._grid.attach(self._expand_button, 0, row, 1, 1)
self._expand_button.show()
self._title_align = Gtk.Alignment.new(
xalign=0, yalign=0.5, xscale=0, yscale=0)
self._title = Gtk.TextView()
self._title.set_size_request(ENTRY_WIDTH, -1)
self._title.set_wrap_mode(Gtk.WrapMode.WORD)
self._title_tag = self._title.get_buffer().create_tag(
'title', foreground=self._title_color, weight=Pango.Weight.BOLD,
size=12288)
iter_text = self._title.get_buffer().get_iter_at_offset(0)
self._title.get_buffer().insert_with_tags(
iter_text, self._reflection.data['title'], self._title_tag)
if self._reflection.activity.initiating:
self._title.connect('focus-out-event', self._title_focus_out_cb)
else:
self._title.set_editable(False)
self._title_align.add(self._title)
self._title.show()
self._grid.attach(self._title_align, 1, row, 5, 1)
self._title_align.show()
delete_button = EventIcon(icon_name='delete', pixel_size=BUTTON_SIZE)
delete_button.set_tooltip(_('Delete'))
delete_button.connect('button-press-event', self.__delete_cb)
self._grid.attach(delete_button, 6, row, 1, 1)
delete_button.show()
''' Notification that a new comment has been shared. '''
self.notify_button = EventIcon(icon_name='chat',
pixel_size=BUTTON_SIZE)
self._grid.attach(self.notify_button, 6, row, 1, 1)
row += 1
self._time_align = Gtk.Alignment.new(
xalign=0, yalign=0.5, xscale=0, yscale=0)
self._time = Gtk.Label()
self._time.set_size_request(ENTRY_WIDTH, -1)
self._time.set_justify(Gtk.Justification.LEFT)
self._time.set_use_markup(True)
try:
time_string = util.timestamp_to_elapsed_string(
int(self._reflection.data['modification_time']))
except Exception as e:
logging.error('Could not convert modification time %s: %s' %
(self._reflection.data['modification_time'], e))
self._reflection.data['modification_time'] = \
self._reflection.data['creation_time']
time_string = util.timestamp_to_elapsed_string(
int(self._reflection.data['modification_time']))
self._time.set_markup(
'<span foreground="#808080"><small><b>%s</b></small></span>' %
time_string)
self._time_align.add(self._time)
self._time.show()
self._grid.attach(self._time_align, 1, row, 5, 1)
self._time_align.show()
row += 1
label = ''
if 'tags' in self._reflection.data:
for tag in self._reflection.data['tags']:
if len(label) > 0:
label += ', '
label += tag
if self._reflection.activity.initiating and label == '':
label = _('Add a #tag')
self._tag_align = Gtk.Alignment.new(
xalign=0, yalign=0.5, xscale=0, yscale=0)
self._tag_view = Gtk.TextView()
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
def __init__(self, poll_activity):
Gtk.EventBox.__init__(self)
self.modify_bg(Gtk.StateType.NORMAL,
style.COLOR_WHITE.get_gdk_color())
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.add(box)
poll_activity.reset_poll()
label = Gtk.Label()
label.set_markup('<span size="xx-large" color="%s">%s</span>'
% (darker_color_str, _('Choose a Poll')))
label.set_halign(Gtk.Align.START)
label.props.margin_top = style.GRID_CELL_SIZE
label.props.margin_bottom = style.GRID_CELL_SIZE / 2
label.props.margin_left = style.GRID_CELL_SIZE
box.pack_start(label, False, False, 0)
poll_selector_box = Gtk.VBox()
poll_selector_box.props.margin_left = style.GRID_CELL_SIZE
poll_selector_box.props.margin_right = style.GRID_CELL_SIZE
scroll = Gtk.ScrolledWindow()
scroll.modify_bg(Gtk.StateType.NORMAL,
style.COLOR_WHITE.get_gdk_color())
scroll.set_valign(Gtk.Align.START)
scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
scroll.set_size_request(
-1, Gdk.Screen.height() - style.GRID_CELL_SIZE * 4)
scroll.add_with_viewport(poll_selector_box)
box.pack_start(scroll, True, True, 0)
for poll in poll_activity._polls:
sha = poll.sha
poll_row = Gtk.HBox()
poll_row.props.margin = 10
poll_selector_box.pack_start(poll_row, False, False, 0)
poll_selector_box.pack_start(Gtk.HSeparator(), False, False, 0)
evbox = Gtk.EventBox()
title = Gtk.Label()
title.set_markup(
'<span size="large">%s (%s)</span>' %
(GObject.markup_escape_text(poll.title),
GObject.markup_escape_text(poll.author)))
title.set_halign(Gtk.Align.START)
title.set_max_width_chars(55)
title.set_ellipsize(Pango.EllipsizeMode.END)
evbox.add(title)
poll_row.pack_start(evbox, True, True, 0)
poll_icon = PollIcon(poll)
poll_row.pack_start(poll_icon, False, False,
style.GRID_CELL_SIZE / 2)
if poll.active:
button = EventIcon(icon_name='activity-poll',
pixel_size=style.STANDARD_ICON_SIZE)
button.set_stroke_color('#888888')
else:
button = EventIcon(icon_name='toolbar-view',
pixel_size=style.STANDARD_ICON_SIZE)
button.set_fill_color('#888888')
evbox.set_events(Gdk.EventMask.BUTTON_PRESS_MASK)
evbox.connect('button-press-event',
poll_activity._select_poll_button_cb, sha)
poll_icon.connect('button-press-event',
poll_activity._select_poll_button_cb, sha)
button.connect('button-press-event',
poll_activity._select_poll_button_cb, sha)
poll_row.pack_start(button, False, False, style.GRID_CELL_SIZE / 2)
if poll.author == profile.get_nick_name():
button = EventIcon(icon_name='basket',
pixel_size=style.STANDARD_ICON_SIZE)
button.set_stroke_color('#888888')
button.connect('button-press-event',
poll_activity._delete_poll_button_cb, sha,
poll.title)
poll_row.pack_start(button, False, False, 0)
self.show_all()
示例12: ReflectionGrid
# 需要导入模块: from sugar3.graphics.icon import EventIcon [as 别名]
# 或者: from sugar3.graphics.icon.EventIcon import connect [as 别名]
class ReflectionGrid(Gtk.EventBox):
def __init__(self, parent):
Gtk.EventBox.__init__(self)
self._reflection = parent
self._collapse = True
self._collapse_id = None
self.modify_bg(Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color())
self._title_color = self._reflection.activity.fg_color.get_html()
self._grid = Gtk.Grid()
self.add(self._grid)
self._grid.show()
self._grid.set_row_spacing(style.DEFAULT_PADDING)
self._grid.set_column_spacing(style.DEFAULT_SPACING)
self._grid.set_column_homogeneous(True)
self._grid.set_border_width(style.DEFAULT_PADDING)
row = 0
self._expand_button = EventIcon(icon_name="expand", pixel_size=BUTTON_SIZE)
self._collapse_id = self._expand_button.connect("button-press-event", self._expand_cb)
self._grid.attach(self._expand_button, 0, row, 1, 1)
self._expand_button.show()
self._title_align = Gtk.Alignment.new(xalign=0, yalign=0.5, xscale=0, yscale=0)
self._title = Gtk.TextView()
self._title.set_size_request(ENTRY_WIDTH, -1)
self._title.set_wrap_mode(Gtk.WrapMode.WORD)
self._title_tag = self._title.get_buffer().create_tag(
"title", foreground=self._title_color, weight=Pango.Weight.BOLD, size=12288
)
iter_text = self._title.get_buffer().get_iter_at_offset(0)
self._title.get_buffer().insert_with_tags(iter_text, self._reflection.data["title"], self._title_tag)
if self._reflection.activity.initiating:
self._title.connect("focus-out-event", self._title_focus_out_cb)
else:
self._title.set_editable(False)
self._title_align.add(self._title)
self._title.show()
self._grid.attach(self._title_align, 1, row, 5, 1)
self._title_align.show()
""" Notification that a new comment has been shared. """
self.notify_button = EventIcon(icon_name="chat", pixel_size=BUTTON_SIZE)
self._grid.attach(self.notify_button, 6, row, 1, 1)
row += 1
self._time_align = Gtk.Alignment.new(xalign=0, yalign=0.5, xscale=0, yscale=0)
self._time = Gtk.Label()
self._time.set_size_request(ENTRY_WIDTH, -1)
self._time.set_justify(Gtk.Justification.LEFT)
self._time.set_use_markup(True)
try:
time_string = util.timestamp_to_elapsed_string(int(self._reflection.data["modification_time"]))
except Exception as e:
logging.error(
"Could not convert modification time %s: %s" % (self._reflection.data["modification_time"], e)
)
self._reflection.data["modification_time"] = self._reflection.data["creation_time"]
time_string = util.timestamp_to_elapsed_string(int(self._reflection.data["modification_time"]))
self._time.set_markup('<span foreground="#808080"><small><b>%s</b></small></span>' % time_string)
self._time_align.add(self._time)
self._time.show()
self._grid.attach(self._time_align, 1, row, 5, 1)
self._time_align.show()
row += 1
label = ""
if "tags" in self._reflection.data:
for tag in self._reflection.data["tags"]:
if len(label) > 0:
label += ", "
label += tag
if self._reflection.activity.initiating and label == "":
label = _("Add a #tag")
self._tag_align = Gtk.Alignment.new(xalign=0, yalign=0.5, xscale=0, yscale=0)
self._tag_view = Gtk.TextView()
self._tag_view.set_size_request(ENTRY_WIDTH, -1)
self._tag_view.set_wrap_mode(Gtk.WrapMode.WORD)
self._tag_view.get_buffer().set_text(label)
if self._reflection.activity.initiating:
self._tag_view.connect("focus-in-event", self._tag_focus_in_cb, _("Add a #tag"))
self._tag_view.connect("focus-out-event", self._tags_focus_out_cb)
else:
self._tag_view.set_editable(False)
self._tag_align.add(self._tag_view)
self._tag_view.show()
self._grid.attach(self._tag_align, 1, row, 5, 1)
if self._reflection.activity.initiating:
self._new_tag = EventIcon(icon_name="ok", pixel_size=BUTTON_SIZE)
self._new_tag.connect("button-press-event", self._tag_button_cb)
self._grid.attach(self._new_tag, 6, row, 1, 1)
row += 1
self._activities_align = Gtk.Alignment.new(xalign=0, yalign=0.5, xscale=0, yscale=0)
self._make_activities_grid()
#.........这里部分代码省略.........