def _refresh_resume_palette(self): if self._metadata.get('activity_id', ''): # TRANS: Action label for resuming an activity. self._resume.set_tooltip(_('Resume')) else: # TRANS: Action label for starting an entry. self._resume.set_tooltip(_('Start')) palette = self._resume.get_palette() if self._resume_menu is not None: self._resume_menu.destroy() self._resume_menu = PaletteMenuBox() palette.set_content(self._resume_menu) self._resume_menu.show() for activity_info in misc.get_activities(self._metadata): menu_item = PaletteMenuItem(file_name=activity_info.get_icon(), text_label=activity_info.get_name()) menu_item.connect('activate', self._resume_menu_item_activate_cb, activity_info.get_bundle_id()) self._resume_menu.append_item(menu_item) menu_item.show() if not misc.can_resume(self._metadata): self._resume.set_tooltip(_('No activity to start entry'))
def _resume_clicked_cb(self, button): if not misc.can_resume(self._metadata): palette = self._resume.get_palette() palette.popup(immediate=True) misc.resume(self._metadata, alert_window=journalwindow.get_journal_window())
def __init__(self, journalactivity, metadata, detail=False): self._journalactivity = journalactivity self._metadata = metadata activity_icon = Icon(pixel_size=style.STANDARD_ICON_SIZE) activity_icon.props.file = misc.get_icon_name(metadata) color = misc.get_icon_color(metadata) activity_icon.props.xo_color = color if 'title' in metadata: title = metadata['title'] else: title = _('Untitled') Palette.__init__(self, primary_text=title, icon=activity_icon) description = metadata.get('description', '') if description: self.set_secondary_text(description) if misc.can_resume(metadata): if metadata.get('activity_id', ''): resume_label = _('Resume') resume_with_label = _('Resume with') else: resume_label = _('Start') resume_with_label = _('Start with') menu_item = MenuItem(resume_label, 'activity-start') menu_item.connect('activate', self.__start_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(resume_with_label, 'activity-start') self.menu.append(menu_item) menu_item.show() start_with_menu = StartWithMenu(self._metadata) menu_item.set_submenu(start_with_menu) elif metadata.get('activity', None) == PROJECT_BUNDLE_ID: open_label = _('Open') menu_item = MenuItem(open_label, 'project-box') menu_item.connect('activate', self.__open_project_activate_cb) self.menu.append(menu_item) menu_item.show() else: menu_item = MenuItem(_('No activity to start entry')) menu_item.set_sensitive(False) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Copy to')) icon = Icon(icon_name='edit-copy', xo_color=color, pixel_size=style.SMALL_ICON_SIZE) menu_item.set_image(icon) self.menu.append(menu_item) menu_item.show() copy_menu = CopyMenu(self._journalactivity, self.__get_uid_list_cb) copy_menu.connect('volume-error', self.__volume_error_cb) menu_item.set_submenu(copy_menu) if not metadata.get('activity', None) == PROJECT_BUNDLE_ID: menu_item = MenuItem(_('Send to project...'), 'project-box') menu_item.connect('activate', self.__copy_to_project_activated_cb) self.menu.append(menu_item) menu_item.show() if self._metadata['mountpoint'] == '/': menu_item = MenuItem(_('Duplicate')) icon = Icon(icon_name='edit-duplicate', xo_color=color, pixel_size=style.SMALL_ICON_SIZE) menu_item.set_image(icon) menu_item.connect('activate', self.__duplicate_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Send to'), 'document-send') self.menu.append(menu_item) menu_item.show() friends_menu = FriendsMenu() friends_menu.connect('friend-selected', self.__friend_selected_cb) menu_item.set_submenu(friends_menu) if detail is True: menu_item = MenuItem(_('View Details'), 'go-right') menu_item.connect('activate', self.__detail_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Erase'), 'list-remove') menu_item.connect('activate', self.__erase_activate_cb) self.menu.append(menu_item) menu_item.show()
def __init__(self, journalactivity, metadata, detail=False): self._journalactivity = journalactivity self._metadata = metadata activity_icon = Icon(icon_size=Gtk.IconSize.LARGE_TOOLBAR) activity_icon.props.file = misc.get_icon_name(metadata) color = misc.get_icon_color(metadata) activity_icon.props.xo_color = color if 'title' in metadata: title = GObject.markup_escape_text(metadata['title']) else: title = GLib.markup_escape_text(_('Untitled')) Palette.__init__(self, primary_text=title, icon=activity_icon) if misc.can_resume(metadata): if metadata.get('activity_id', ''): resume_label = _('Resume') resume_with_label = _('Resume with') else: resume_label = _('Start') resume_with_label = _('Start with') menu_item = MenuItem(resume_label, 'activity-start') menu_item.connect('activate', self.__start_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(resume_with_label, 'activity-start') self.menu.append(menu_item) menu_item.show() start_with_menu = StartWithMenu(self._metadata) menu_item.set_submenu(start_with_menu) else: menu_item = MenuItem(_('No activity to start entry')) menu_item.set_sensitive(False) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Copy to')) icon = Icon(icon_name='edit-copy', xo_color=color, icon_size=Gtk.IconSize.MENU) menu_item.set_image(icon) self.menu.append(menu_item) menu_item.show() copy_menu = CopyMenu(self._journalactivity, self.__get_uid_list_cb) copy_menu.connect('volume-error', self.__volume_error_cb) menu_item.set_submenu(copy_menu) if self._metadata['mountpoint'] == '/': menu_item = MenuItem(_('Duplicate')) icon = Icon(icon_name='edit-duplicate', xo_color=color, icon_size=Gtk.IconSize.MENU) menu_item.set_image(icon) menu_item.connect('activate', self.__duplicate_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Send to'), 'document-send') self.menu.append(menu_item) menu_item.show() friends_menu = FriendsMenu() friends_menu.connect('friend-selected', self.__friend_selected_cb) menu_item.set_submenu(friends_menu) if detail is True: menu_item = MenuItem(_('View Details'), 'go-right') menu_item.connect('activate', self.__detail_activate_cb) self.menu.append(menu_item) menu_item.show() menu_item = MenuItem(_('Erase'), 'list-remove') menu_item.connect('activate', self.__erase_activate_cb) self.menu.append(menu_item) menu_item.show()