def create_menu_item(history_item):
     """Create a MenuItem for the back or forward palettes."""
     title = history_item.get_title() or _('No Title')
     menu_item = PaletteMenuItem(text_label=title)
     menu_item.connect('activate', self._history_item_activated_cb,
                       history_item)
     return menu_item
Beispiel #2
0
    def create_palette(self):
        if not self._palette_enabled:
            self._palette_enabled = True
            return

        palette = BuddyMenu(get_owner_instance())

        client = GConf.Client.get_default()
        if client.get_bool('/desktop/sugar/show_register'):
            backup_url = client.get_string('/desktop/sugar/backup_url')

            if not backup_url:
                self._register_menu = PaletteMenuItem(_('Register'),
                                                      'media-record')
            else:
                self._register_menu = PaletteMenuItem(_('Register again'),
                                                      'media-record')

            self._register_menu.connect('activate',
                                        self.__register_activate_cb)
            palette.menu_box.pack_end(self._register_menu, True, True, 0)
            self._register_menu.show()

        self.connect_to_palette_pop_events(palette)

        return palette
Beispiel #3
0
    def __init__(self, name):
        Gtk.VBox.__init__(self)
        self._name = name

        self._notifications_box = Gtk.VBox()
        self._notifications_box.show()

        self._scrolled_window = Gtk.ScrolledWindow()
        self._scrolled_window.add_with_viewport(self._notifications_box)
        self._scrolled_window.set_policy(Gtk.PolicyType.NEVER,
                                         Gtk.PolicyType.AUTOMATIC)
        self._scrolled_window.show()

        separator = PaletteMenuItemSeparator()
        separator.show()

        clear_item = PaletteMenuItem(_('Clear notifications'), 'dialog-cancel')
        clear_item.connect('activate', self.__clear_cb)
        clear_item.show()

        self.add(self._scrolled_window)
        self.add(separator)
        self.add(clear_item)

        self._service = notifications.get_service()
        entries = self._service.retrieve_by_name(self._name)

        if entries:
            for entry in entries:
                self._add(entry['summary'], entry['body'])

        self._service.notification_received.connect(
            self.__notification_received_cb)

        self.connect('destroy', self.__destroy_cb)
Beispiel #4
0
    def create_palette(self):
        if not self._palette_enabled:
            self._palette_enabled = True
            return

        palette = BuddyMenu(get_owner_instance())

        settings = Gio.Settings('org.sugarlabs')
        if settings.get_boolean('show-register'):
            backup_url = settings.get_string('backup-url')

            if not backup_url:
                self._register_menu = PaletteMenuItem(_('Register'),
                                                      'media-record')
            else:
                self._register_menu = PaletteMenuItem(_('Register again'),
                                                      'media-record')

            self._register_menu.connect('activate',
                                        self.__register_activate_cb)
            palette.menu_box.pack_end(self._register_menu, True, True, 0)
            self._register_menu.show()

        self.connect_to_palette_pop_events(palette)

        return palette
Beispiel #5
0
    def _create_palette(self):
        icon_name = get_icon_state(_AP_ICON_NAME, self._strength)
        self._palette_icon = Icon(icon_name=icon_name,
                                  icon_size=style.STANDARD_ICON_SIZE,
                                  badge_name=self.props.badge_name)

        label = glib.markup_escape_text(self._display_name)
        p = palette.Palette(primary_text=label, icon=self._palette_icon)

        self.menu_box = Gtk.VBox()

        self._connect_item = PaletteMenuItem(_('Connect'))
        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='dialog-ok')
        self._connect_item.set_image(icon)
        self._connect_item.connect('activate', self.__connect_activate_cb)
        self.menu_box.add(self._connect_item)

        self._disconnect_item = PaletteMenuItem(_('Disconnect'))
        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='media-eject')
        self._disconnect_item.set_image(icon)
        self._disconnect_item.connect('activate',
                                      self.__disconnect_activate_cb)
        self.menu_box.add(self._disconnect_item)

        p.set_content(self.menu_box)
        self.menu_box.show_all()

        self.connect_to_palette_pop_events(p)

        return p
Beispiel #6
0
    def _create_palette(self):
        self._palette_icon = Icon( \
                icon_name=self._ICON_NAME + str(self._channel),
                icon_size=style.STANDARD_ICON_SIZE)

        text = _('Ad-hoc Network %d') % (self._channel, )
        palette_ = palette.Palette(glib.markup_escape_text(text),
                                   icon=self._palette_icon)

        self.menu_box = Gtk.VBox()

        self._connect_item = PaletteMenuItem(_('Connect'))
        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='dialog-ok')
        self._connect_item.set_image(icon)
        self._connect_item.connect('activate', self.__connect_activate_cb)
        self.menu_box.add(self._connect_item)

        self._disconnect_item = PaletteMenuItem(_('Disconnect'))
        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='media-eject')
        self._disconnect_item.set_image(icon)
        self._disconnect_item.connect('activate',
                                      self.__disconnect_activate_cb)
        self.menu_box.add(self._disconnect_item)

        palette_.set_content(self.menu_box)
        self.menu_box.show_all()
        self._disconnect_item.hide()

        self.connect_to_palette_pop_events(palette_)

        return palette_
Beispiel #7
0
    def __init__(self, activity_info):
        ActivityPalette.__init__(self, activity_info)

        self._bundle_id = activity_info.get_bundle_id()
        self._version = activity_info.get_activity_version()

        registry = bundleregistry.get_registry()
        self._favorite = registry.is_bundle_favorite(self._bundle_id,
                                                     self._version)

        self._favorite_item = PaletteMenuItem()
        self._favorite_icon = Icon(icon_name='emblem-favorite',
                                   icon_size=Gtk.IconSize.MENU)
        self._favorite_item.set_image(self._favorite_icon)
        self._favorite_icon.show()
        self._favorite_item.connect('activate',
                                    self.__change_favorite_activate_cb)
        self.menu_box.append_item(self._favorite_item)
        self._favorite_item.show()

        if activity_info.is_user_activity():
            self._add_erase_option(registry, activity_info)

        registry = bundleregistry.get_registry()
        self._activity_changed_sid = registry.connect(
            'bundle_changed', self.__activity_changed_cb)
        self._update_favorite_item()

        self.menu_box.connect('destroy', self.__destroy_cb)
Beispiel #8
0
    def __init__(self, invite):
        Palette.__init__(self, '')

        self._invite = invite

        self.menu_box = PaletteMenuBox()
        self.set_content(self.menu_box)
        self.menu_box.show()

        menu_item = PaletteMenuItem(_('Join'), icon_name='dialog-ok')
        menu_item.connect('activate', self.__join_activate_cb)
        self.menu_box.append_item(menu_item)
        menu_item.show()

        menu_item = PaletteMenuItem(_('Decline'), icon_name='dialog-cancel')
        menu_item.connect('activate', self.__decline_activate_cb)
        self.menu_box.append_item(menu_item)
        menu_item.show()

        bundle_id = invite.get_bundle_id()

        registry = bundleregistry.get_registry()
        self._bundle = registry.get_bundle(bundle_id)
        if self._bundle:
            name = self._bundle.get_name()
        else:
            name = bundle_id

        self.set_primary_text(name)
Beispiel #9
0
    def __init__(self, file_name, document_path, activity_name, title,
                 bundle=False):
        RadioToolButton.__init__(self)

        self._document_path = document_path
        self._title = title
        self._jobject = None
        self._activity_name = activity_name

        self.props.tooltip = _('Instance Source')

        settings = Gio.Settings('org.sugarlabs.user')
        self._color = settings.get_string('color')
        icon = Icon(file=file_name,
                    pixel_size=style.STANDARD_ICON_SIZE,
                    xo_color=XoColor(self._color))
        self.set_icon_widget(icon)
        icon.show()

        box = PaletteMenuBox()
        self.props.palette.set_content(box)
        box.show()

        if bundle:
            menu_item = PaletteMenuItem(_('Duplicate'), 'edit-duplicate',
                                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__show_duplicate_alert)
        else:
            menu_item = PaletteMenuItem(_('Keep'), 'document-save',
                                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__keep_in_journal_cb)

        box.append_item(menu_item)
        menu_item.show()
Beispiel #10
0
    def create_palette(self):
        if not self._palette_enabled:
            self._palette_enabled = True
            return

        palette = BuddyMenu(get_owner_instance())

        settings = Gio.Settings('org.sugarlabs')
        if settings.get_boolean('show-register'):
            backup_url = settings.get_string('backup-url')

            if not backup_url:
                self._register_menu = PaletteMenuItem(_('Register'),
                                                      'media-record')
            else:
                self._register_menu = PaletteMenuItem(_('Register again'),
                                                      'media-record')

            self._register_menu.connect('activate',
                                        self.__register_activate_cb)
            palette.menu_box.pack_end(self._register_menu, True, True, 0)
            self._register_menu.show()

        self.connect_to_palette_pop_events(palette)

        return palette
Beispiel #11
0
    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'))
Beispiel #12
0
    def _create_palette(self):
        self._palette_icon = Icon(
            icon_name=self._ICON_NAME + str(self._channel),
            pixel_size=style.STANDARD_ICON_SIZE)

        palette_ = palette.Palette(_('Ad-hoc Network %d') % (self._channel, ),
                                   icon=self._palette_icon)

        self.menu_box = Gtk.VBox()

        self._connect_item = PaletteMenuItem(_('Connect'))
        icon = Icon(pixel_size=style.SMALL_ICON_SIZE, icon_name='dialog-ok')
        self._connect_item.set_image(icon)
        self._connect_item.connect('activate', self.__connect_activate_cb)
        self.menu_box.add(self._connect_item)

        self._disconnect_item = PaletteMenuItem(_('Disconnect'))
        icon = Icon(pixel_size=style.SMALL_ICON_SIZE, icon_name='media-eject')
        self._disconnect_item.set_image(icon)
        self._disconnect_item.connect(
            'activate', self.__disconnect_activate_cb)
        self.menu_box.add(self._disconnect_item)

        palette_.set_content(self.menu_box)
        self.menu_box.show_all()
        self._disconnect_item.hide()

        self.connect_to_palette_pop_events(palette_)

        return palette_
Beispiel #13
0
    def _create_palette(self):
        icon_name = get_icon_state(_AP_ICON_NAME, self._strength)
        self._palette_icon = Icon(icon_name=icon_name,
                                  icon_size=style.STANDARD_ICON_SIZE,
                                  badge_name=self.props.badge_name)

        label = GLib.markup_escape_text(self._display_name)
        p = palette.Palette(primary_text=label, icon=self._palette_icon)

        self.menu_box = Gtk.VBox()

        self._connect_item = PaletteMenuItem(_('Connect'))
        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='dialog-ok')
        self._connect_item.set_image(icon)
        self._connect_item.connect('activate', self.__connect_activate_cb)
        self.menu_box.add(self._connect_item)

        self._disconnect_item = PaletteMenuItem(_('Disconnect'))
        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='media-eject')
        self._disconnect_item.set_image(icon)
        self._disconnect_item.connect('activate', self.__disconnect_activate_cb)
        self.menu_box.add(self._disconnect_item)

        p.set_content(self.menu_box)
        self.menu_box.show_all()

        self.connect_to_palette_pop_events(p)

        return p
Beispiel #14
0
 def set_registered(self):
     self.palette.menu_box.remove(self._register_menu)
     self._register_menu = PaletteMenuItem(_('Register again'),
                                           'media-record')
     self._register_menu.connect('activate', self.__register_activate_cb)
     self.palette.menu_box.pack_end(self._register_menu, True, True, 0)
     self._register_menu.show()
Beispiel #15
0
    def setup_rollover_options(self, info):
        palette = Palette(info, text_maxlen=50)
        self.set_palette(palette)

        box = PaletteMenuBox()
        palette.set_content(box)
        box.show()

        menu_item = PaletteMenuItem(_('Remove'), 'list-remove')
        menu_item.connect('activate', self.item_remove_cb)
        box.append_item(menu_item)
        menu_item.show()

        separator = PaletteMenuItemSeparator()
        box.append_item(separator)
        separator.show()

        textview = Gtk.TextView()
        textview.props.height_request = style.GRID_CELL_SIZE * 2
        textview.props.width_request = style.GRID_CELL_SIZE * 3
        textview.props.hexpand = True
        textview.props.vexpand = True
        box.append_item(textview)
        textview.show()

        buffer = textview.get_buffer()
        if self.notes is None:
            buffer.set_text(_('Take notes on this page'))
        else:
            buffer.set_text(self.notes)
        buffer.connect('changed', self.__buffer_changed_cb)
Beispiel #16
0
    def __init__(self, activity_info, journal_entries):
        ActivityPalette.__init__(self, activity_info)

        if not journal_entries:
            xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
                                          style.COLOR_WHITE.get_svg()))
        else:
            xo_color = misc.get_icon_color(journal_entries[0])

        self.props.icon = Icon(file=activity_info.get_icon(),
                               xo_color=xo_color,
                               pixel_size=style.STANDARD_ICON_SIZE)

        if journal_entries:
            self.props.secondary_text = journal_entries[0]['title']

            menu_items = []
            for entry in journal_entries:
                icon_file_name = misc.get_icon_name(entry)
                color = misc.get_icon_color(entry)

                menu_item = PaletteMenuItem(text_label=entry['title'],
                                            file_name=icon_file_name,
                                            xo_color=color)
                menu_item.connect('activate', self.__resume_entry_cb, entry)
                menu_items.append(menu_item)
                menu_item.show()

            if journal_entries:
                separator = PaletteMenuItemSeparator()
                menu_items.append(separator)
                separator.show()

            for i in range(0, len(menu_items)):
                self.menu_box.pack_start(menu_items[i], True, True, 0)
Beispiel #17
0
    def create_palette(self):
        primary_text = GLib.markup_escape_text(self._model.bundle.get_name())
        secondary_text = GLib.markup_escape_text(self._model.get_name())
        palette_icon = Icon(file=self._model.bundle.get_icon(),
                            xo_color=self._model.get_color())
        palette_icon.props.icon_size = Gtk.IconSize.LARGE_TOOLBAR
        palette = Palette(None,
                          primary_text=primary_text,
                          secondary_text=secondary_text,
                          icon=palette_icon)

        private = self._model.props.private
        joined = get_owner_instance() in self._model.props.buddies

        menu_box = PaletteMenuBox()

        if joined:
            item = PaletteMenuItem(_('Resume'))
            icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='activity-start')
            item.set_image(icon)
            item.connect('activate', self.__palette_item_clicked_cb)
            menu_box.append_item(item)
        elif not private:
            item = PaletteMenuItem(_('Join'))
            icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='activity-start')
            item.set_image(icon)
            item.connect('activate', self.__palette_item_clicked_cb)
            menu_box.append_item(item)

        palette.set_content(menu_box)
        menu_box.show_all()

        self.connect_to_palette_pop_events(palette)
        return palette
Beispiel #18
0
    def __init__(self, text_label=None):
        PaletteMenuItem.__init__(self, text_label=None, text_maxlen=0)

        self.id_enter_notify_cb = self.connect('enter-notify-event',
                                               self.__enter_notify_cb)
        self.id_leave_notify_cb = self.connect('leave-notify-event',
                                               self.__leave_notify_cb)
        self.set_label(text_label)
Beispiel #19
0
    def _add_erase_option(self, registry, activity_info):
        menu_item = PaletteMenuItem(_("Erase"), "list-remove")
        menu_item.connect("activate", self.__erase_activate_cb)
        self.menu_box.append_item(menu_item)
        menu_item.show()

        if not os.access(activity_info.get_path(), os.W_OK) or registry.is_activity_protected(self._bundle_id):
            menu_item.props.sensitive = False
Beispiel #20
0
    def __init__(self, text_label=None):
        PaletteMenuItem.__init__(self, text_label=None, text_maxlen=0)

        self.id_enter_notify_cb = self.connect('enter-notify-event',
                                               self.__enter_notify_cb)
        self.id_leave_notify_cb = self.connect('leave-notify-event',
                                               self.__leave_notify_cb)
        self.set_label(text_label)
Beispiel #21
0
 def create_menu_item(history_item, item_index):
     """Create a MenuItem for the back or forward palettes."""
     title = history_item.get_title()
     if not isinstance(title, unicode):
         title = unicode(title, "utf-8")
     # This is a fix until the Sugar MenuItem is fixed:
     menu_item = PaletteMenuItem(text_label=title)
     menu_item.connect("activate", self._history_item_activated_cb, item_index)
     return menu_item
Beispiel #22
0
 def create_menu_item(history_item):
     """Create a MenuItem for the back or forward palettes."""
     title = history_item.get_title() or _('No Title')
     if not isinstance(title, unicode):
         title = unicode(title, 'utf-8')
     # This is a fix until the Sugar MenuItem is fixed:
     menu_item = PaletteMenuItem(text_label=title)
     menu_item.connect('activate', self._history_item_activated_cb,
                       history_item)
     return menu_item
Beispiel #23
0
 def create_menu_item(history_item, item_index):
     """Create a MenuItem for the back or forward palettes."""
     title = history_item.get_title()
     if not isinstance(title, unicode):
         title = unicode(title, 'utf-8')
     # This is a fix until the Sugar MenuItem is fixed:
     menu_item = PaletteMenuItem(text_label=title)
     menu_item.connect('activate', self._history_item_activated_cb,
                       item_index)
     return menu_item
Beispiel #24
0
    def _add_copy_menu_item(self):
        if self._recd.buddy and not self._recd.downloadedFromBuddy:
            return

        self._copy_menu_item = PaletteMenuItem(_('Copy to clipboard'),
                                               icon_name='edit-copy')
        self._copy_menu_item_handler = self._copy_menu_item.connect(
            'activate', self._copy_clipboard_clicked)
        self._box.append_item(self._copy_menu_item)
        self._copy_menu_item.show()
Beispiel #25
0
    def setup_palette(self):
        activity_name = self._home_activity.get_activity_name()
        if activity_name:
            self.props.primary_text = glib.markup_escape_text(activity_name)

        title = self._home_activity.get_title()
        if title and title != activity_name:
            self.props.secondary_text = glib.markup_escape_text(title)

        self.menu_box = PaletteMenuBox()

        menu_item = PaletteMenuItem(_('Resume'), 'activity-start')
        menu_item.connect('activate', self.__resume_activate_cb)
        self.menu_box.append_item(menu_item)

        # TODO: share-with, keep

        menu_item = PaletteMenuItem(_('View Source'), 'view-source')
        menu_item.connect('activate', self.__view_source__cb)
        self.menu_box.append_item(menu_item)

        separator = PaletteMenuItemSeparator()
        self.menu_box.append_item(separator)
        separator.show()

        menu_item = PaletteMenuItem(_('Stop'), 'activity-stop')
        menu_item.connect('activate', self.__stop_activate_cb)
        self.menu_box.append_item(menu_item)

        self.set_content(self.menu_box)
        self.menu_box.show_all()
Beispiel #26
0
 def _add_menu(self, option, icon=None, activate_cb=None):
     if icon is not None:
         menu_item = PaletteMenuItem(icon_name=icon)
         if activate_cb is not None:
             menu_item.connect('activate', activate_cb, [option, icon])
     else:
         menu_item = PaletteMenuItem()
         if activate_cb is not None:
             menu_item.connect('activate', activate_cb, option)
     menu_item.set_label(option)
     self._menu_box.append_item(menu_item)
     menu_item.show()
Beispiel #27
0
    def __init__(self, abi, abi_signal, do_abi_cb, icon_name, label,
                 button, on_abi_cb=None, button_icon_name=None):
        self._icon_name = icon_name
        # _button_icon_name is used only in the first case of
        # the list menu
        self._button_icon_name = button_icon_name
        self._button = button
        PaletteMenuItem.__init__(self, icon_name=icon_name, text_label=label)

        self._abi_handler = abi.connect(abi_signal, self.__abi_cb,
                                        abi_signal, on_abi_cb)
        self.connect('activate', self.__activated_cb, abi, do_abi_cb)
Beispiel #28
0
    def __init__(self, abi, abi_signal, do_abi_cb, icon_name, label,
                 button, on_abi_cb=None, button_icon_name=None):
        self._icon_name = icon_name
        # _button_icon_name is used only in the first case of
        # the list menu
        self._button_icon_name = button_icon_name
        self._button = button
        PaletteMenuItem.__init__(self, icon_name=icon_name, text_label=label)

        self._abi_handler = abi.connect(abi_signal, self.__abi_cb,
                                        abi_signal, on_abi_cb)
        self.connect('activate', self.__activated_cb, abi, do_abi_cb)
Beispiel #29
0
    def __init__(self):
        label = GLib.markup_escape_text(_('Wireless modem'))
        Palette.__init__(self, primary_text=label)

        self._current_state = None
        self._failed_connection = False

        self.info_box = Gtk.VBox()

        self._toggle_state_item = PaletteMenuItem('')
        self._toggle_state_item.connect('activate', self.__toggle_state_cb)
        self.info_box.pack_start(self._toggle_state_item, True, True, 0)
        self._toggle_state_item.show()

        self.error_title_label = Gtk.Label(label="")
        self.error_title_label.set_alignment(0, 0.5)
        self.error_title_label.set_line_wrap(True)
        self.info_box.pack_start(self.error_title_label, True, True, 0)
        self.error_description_label = Gtk.Label(label="")
        self.error_description_label.set_alignment(0, 0.5)
        self.error_description_label.set_line_wrap(True)
        self.info_box.pack_start(self.error_description_label, True, True, 0)

        self.connection_info_box = Gtk.HBox()
        icon = Icon(icon_name='data-upload', pixel_size=style.SMALL_ICON_SIZE)
        self.connection_info_box.pack_start(icon, True, True, 0)
        icon.show()

        self._data_label_up = Gtk.Label()
        self._data_label_up.props.xalign = 0.0
        label_alignment = self._add_widget_with_padding(self._data_label_up)
        self.connection_info_box.pack_start(label_alignment, True, True, 0)
        self._data_label_up.show()
        label_alignment.show()

        icon = Icon(icon_name='data-download',
                    pixel_size=style.SMALL_ICON_SIZE)
        self.connection_info_box.pack_start(icon, True, True, 0)
        icon.show()
        self._data_label_down = Gtk.Label()
        self._data_label_down.props.xalign = 0.0
        label_alignment = self._add_widget_with_padding(self._data_label_down)
        self.connection_info_box.pack_start(label_alignment, True, True, 0)
        self._data_label_down.show()
        label_alignment.show()

        self.info_box.pack_start(self.connection_info_box, True, True, 0)

        self.info_box.show()
        self.set_content(self.info_box)

        self.update_state(_GSM_STATE_NOT_READY)
Beispiel #30
0
class OwnerIcon(BuddyIcon):
    __gtype_name__ = 'SugarFavoritesOwnerIcon'

    __gsignals__ = {
        'register-activate': (GObject.SignalFlags.RUN_FIRST, None,
                              ([])),
    }

    def __init__(self, size):
        BuddyIcon.__init__(self, buddy=get_owner_instance(), pixel_size=size)

        self.palette_invoker.cache_palette = True

        self._palette_enabled = False
        self._register_menu = None

        # This is a workaround to skip the callback for
        # enter-notify-event in the parent class the first time.
        def __enter_notify_event_cb(icon, event):
            self.unset_state_flags(Gtk.StateFlags.PRELIGHT)
            self.disconnect(self._enter_notify_hid)

        self._enter_notify_hid = self.connect('enter-notify-event',
                                              __enter_notify_event_cb)

    def create_palette(self):
        if not self._palette_enabled:
            self._palette_enabled = True
            return

        palette = BuddyMenu(get_owner_instance())

        client = GConf.Client.get_default()
        backup_url = client.get_string('/desktop/sugar/backup_url')

        if not backup_url:
            self._register_menu = PaletteMenuItem(_('Register'),
                                                  'media-record')
        else:
            self._register_menu = PaletteMenuItem(_('Register again'),
                                                  'media-record')

        self._register_menu.connect('activate', self.__register_activate_cb)
        palette.menu_box.pack_end(self._register_menu, True, True, 0)
        self._register_menu.show()

        self.connect_to_palette_pop_events(palette)

        return palette

    def __register_activate_cb(self, menuitem):
        self.emit('register-activate')

    def set_registered(self):
        self.palette.menu_box.remove(self._register_menu)
        self._register_menu = PaletteMenuItem(_('Register again'),
                                              'media-record')
        self._register_menu.connect('activate', self.__register_activate_cb)
        self.palette.menu_box.pack_end(self._register_menu, True, True, 0)
        self._register_menu.show()
Beispiel #31
0
    def __init__(self):
        ToolButton.__init__(self)

        self._property = 'timestamp'
        self._order = Gtk.SortType.ASCENDING

        self.props.tooltip = _('Sort view')
        self.props.icon_name = 'view-lastedit'

        self.props.hide_tooltip_on_click = False
        self.palette_invoker.props.toggle_palette = True

        menu_box = PaletteMenuBox()
        self.props.palette.set_content(menu_box)
        menu_box.show()

        for property_, icon, label in self._SORT_OPTIONS:
            button = PaletteMenuItem(label)
            button_icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name=icon)
            button.set_image(button_icon)
            button_icon.show()
            button.connect('activate', self.__sort_type_changed_cb, property_,
                           icon)
            button.show()
            menu_box.append_item(button)
Beispiel #32
0
    def __init__(self):
        ToolButton.__init__(self)

        self._property = 'timestamp'
        self._order = Gtk.SortType.ASCENDING

        self.props.tooltip = _('Sort view')
        self.props.icon_name = 'view-lastedit'

        self.props.hide_tooltip_on_click = False
        self.palette_invoker.props.toggle_palette = True

        menu_box = PaletteMenuBox()
        self.props.palette.set_content(menu_box)
        menu_box.show()

        sort_options = [
            ('timestamp', 'view-lastedit', _('Sort by date modified')),
            ('creation_time', 'view-created', _('Sort by date created')),
            ('filesize', 'view-size', _('Sort by size')),
        ]

        for property_, icon, label in sort_options:
            button = PaletteMenuItem(label)
            button_icon = Icon(pixel_size=style.SMALL_ICON_SIZE,
                               icon_name=icon)
            button.set_image(button_icon)
            button_icon.show()
            button.connect('activate', self.__sort_type_changed_cb, property_,
                           icon)
            button.show()
            menu_box.append_item(button)
Beispiel #33
0
    def __init__(self, url):
        Palette.__init__(self, url)
        self.owns_clipboard = False
        self.url = self._url_check_protocol(url)

        menu_box = Gtk.VBox()
        self.set_content(menu_box)
        menu_box.show()
        self._content.set_border_width(1)
        menu_item = PaletteMenuItem(_('Copy to Clipboard'), 'edit-copy')
        menu_item.connect('activate', self._copy_to_clipboard_cb)
        menu_box.pack_start(menu_item, False, False, 0)
        menu_item.show()
        self.props.invoker = ContentInvoker()
Beispiel #34
0
 def _add_menu(self, font_name, activate_cb):
     label = '<span font="%s">%s</span>' % (font_name, font_name)
     menu_item = PaletteMenuItem()
     menu_item.set_label(label)
     menu_item.connect("activate", activate_cb, font_name)
     self._menu_box.append_item(menu_item)
     menu_item.show()
Beispiel #35
0
    def __init__(self, file_name, document_path, activity_name, title,
                 bundle=False):
        RadioToolButton.__init__(self)

        self._document_path = document_path
        self._title = title
        self._jobject = None
        self._activity_name = activity_name

        self.props.tooltip = _('Instance Source')

        settings = Gio.Settings('org.sugarlabs.user')
        self._color = settings.get_string('color')
        icon = Icon(file=file_name,
                    pixel_size=style.STANDARD_ICON_SIZE,
                    xo_color=XoColor(self._color))
        self.set_icon_widget(icon)
        icon.show()

        box = PaletteMenuBox()
        self.props.palette.set_content(box)
        box.show()

        if bundle:
            menu_item = PaletteMenuItem(_('Duplicate'), 'edit-duplicate',
                                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__show_duplicate_alert)
        else:
            menu_item = PaletteMenuItem(_('Keep'), 'document-save',
                                        xo_color=XoColor(self._color))
            menu_item.connect('activate', self.__keep_in_journal_cb)

        box.append_item(menu_item)
        menu_item.show()
Beispiel #36
0
    def __init__(self):
        label = GLib.markup_escape_text(ACCOUNT_NAME)
        account_icon = Icon(icon_name=ACCOUNT_ICON,
                            xo_color=profile.get_color(),
                            icon_size=Gtk.IconSize.MENU)

        Palette.__init__(self, primary_text=label, icon=account_icon)

        self.menu_box = PaletteMenuBox()

        self.menu_item = PaletteMenuItem(_('Update'), 'view-refresh')
        self.menu_box.append_item(self.menu_item)

        self.set_content(self.menu_box)
        self.menu_box.show_all()
Beispiel #37
0
    def _create_palette(self):
        _palette = palette.Palette(_('Mesh Network %d') % (self._channel, ))

        self.menu_box = Gtk.VBox()

        self._connect_item = PaletteMenuItem(_('Connect'))
        icon = Icon(pixel_size=style.SMALL_ICON_SIZE, icon_name='dialog-ok')
        self._connect_item.set_image(icon)
        self._connect_item.connect('activate', self.__connect_activate_cb)
        self.menu_box.add(self._connect_item)

        _palette.set_content(self.menu_box)
        self.menu_box.show_all()

        return _palette
Beispiel #38
0
def set_palette_list(instrument_list):
    text_label = instrument_list[0]['instrument_desc']
    file_name = instrument_list[0]['file_name']
    _menu_item = PaletteMenuItem(text_label=text_label, file_name=file_name)
    req2 = _menu_item.get_preferred_size()[1]
    menuitem_width = req2.width
    menuitem_height = req2.height

    palette_width = Gdk.Screen.width() - style.GRID_CELL_SIZE * 3
    palette_height = Gdk.Screen.height() - style.GRID_CELL_SIZE * 3

    nx = min(int(palette_width / menuitem_width), MAX_PALETTE_WIDTH)
    ny = min(int(palette_height / menuitem_height), len(instrument_list) + 1)
    if ny >= len(instrument_list):
        nx = 1
        ny = len(instrument_list)

    grid = Gtk.Grid()
    grid.set_row_spacing(style.DEFAULT_PADDING)
    grid.set_column_spacing(0)
    grid.set_border_width(0)
    grid.show()

    x = 0
    y = 0

    for item in sorted(
            instrument_list,
            cmp=lambda x, y: cmp(x['instrument_desc'], y['instrument_desc'])):
        menu_item = PaletteMenuItem(text_label=item['instrument_desc'],
                                    file_name=item['file_name'])
        menu_item.connect('button-release-event', item['callback'], item)

        # menu_item.connect('button-release-event', lambda x: x, item)
        grid.attach(menu_item, x, y, 1, 1)
        x += 1
        if x == nx:
            x = 0
            y += 1

        menu_item.show()

    if palette_height < (y * menuitem_height + style.GRID_CELL_SIZE):
        # if the grid is bigger than the palette, put in a scrolledwindow
        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(Gtk.PolicyType.NEVER,
                                   Gtk.PolicyType.AUTOMATIC)
        scrolled_window.set_size_request(nx * menuitem_width,
                                         (ny + 1) * menuitem_height)
        scrolled_window.add_with_viewport(grid)
        return scrolled_window
    else:
        return grid
Beispiel #39
0
 def set_registered(self):
     self.palette.menu_box.remove(self._register_menu)
     self._register_menu = PaletteMenuItem(_('Register again'),
                                           'media-record')
     self._register_menu.connect('activate', self.__register_activate_cb)
     self.palette.menu_box.pack_end(self._register_menu, True, True, 0)
     self._register_menu.show()
Beispiel #40
0
    def _create_palette(self):
        text = _('Mesh Network %d') % (self._channel, )
        _palette = palette.Palette(glib.markup_escape_text(text))

        self.menu_box = Gtk.VBox()

        self._connect_item = PaletteMenuItem(_('Connect'))
        icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name='dialog-ok')
        self._connect_item.set_image(icon)
        self._connect_item.connect('activate', self.__connect_activate_cb)
        self.menu_box.add(self._connect_item)

        _palette.set_content(self.menu_box)
        self.menu_box.show_all()

        return _palette
Beispiel #41
0
    def __init__(self, activity_info):
        ActivityPalette.__init__(self, activity_info)

        self._bundle_id = activity_info.get_bundle_id()
        self._version = activity_info.get_activity_version()

        registry = bundleregistry.get_registry()
        self._favorite = registry.is_bundle_favorite(self._bundle_id,
                                                     self._version)

        self._favorite_item = PaletteMenuItem()
        self._favorite_icon = Icon(icon_name='emblem-favorite',
                                   icon_size=Gtk.IconSize.MENU)
        self._favorite_item.set_image(self._favorite_icon)
        self._favorite_icon.show()
        self._favorite_item.connect('activate',
                                    self.__change_favorite_activate_cb)
        self.menu_box.append_item(self._favorite_item)
        self._favorite_item.show()

        if activity_info.is_user_activity():
            self._add_erase_option(registry, activity_info)

        registry = bundleregistry.get_registry()
        self._activity_changed_sid = \
            registry.connect('bundle_changed',
                             self.__activity_changed_cb)

        self._update_favorite_item()

        self.menu_box.connect('destroy', self.__destroy_cb)
Beispiel #42
0
    def __init__(self, activity_info):
        self._activity_info = activity_info

        color = profile.get_color()
        activity_icon = Icon(file=activity_info.get_icon(), xo_color=color, pixel_size=style.STANDARD_ICON_SIZE)

        name = activity_info.get_name()
        Palette.__init__(self, primary_text=GLib.markup_escape_text(name), icon=activity_icon)

        xo_color = XoColor("%s,%s" % (style.COLOR_WHITE.get_svg(), style.COLOR_TRANSPARENT.get_svg()))
        self.menu_box = PaletteMenuBox()
        menu_item = PaletteMenuItem(text_label=_("Start new"), file_name=activity_info.get_icon(), xo_color=xo_color)
        menu_item.connect("activate", self.__start_activate_cb)
        self.menu_box.pack_end(menu_item, True, True, 0)
        menu_item.show()
        self.set_content(self.menu_box)
        self.menu_box.show_all()
Beispiel #43
0
    def __init__(self):
        ToolButton.__init__(self)

        self._property = 'timestamp'
        self._order = Gtk.SortType.ASCENDING

        self.props.tooltip = _('Sort view')
        self.props.icon_name = 'view-lastedit'

        self.props.hide_tooltip_on_click = False
        self.palette_invoker.props.toggle_palette = True

        menu_box = PaletteMenuBox()
        self.props.palette.set_content(menu_box)
        menu_box.show()

        for property_, icon, label in self._SORT_OPTIONS:
            button = PaletteMenuItem(label)
            button_icon = Icon(icon_size=Gtk.IconSize.MENU, icon_name=icon)
            button.set_image(button_icon)
            button_icon.show()
            button.connect('activate',
                           self.__sort_type_changed_cb,
                           property_,
                           icon)
            button.show()
            menu_box.append_item(button)
Beispiel #44
0
    def __init__(self):
        ToolButton.__init__(self)

        self._property = 'timestamp'
        self._order = Gtk.SortType.ASCENDING

        self.props.tooltip = _('Sort view')
        self.props.icon_name = 'view-lastedit'

        self.props.hide_tooltip_on_click = False
        self.palette_invoker.props.toggle_palette = True

        menu_box = PaletteMenuBox()
        self.props.palette.set_content(menu_box)
        menu_box.show()

        sort_options = [
            ('timestamp', 'view-lastedit', _('Sort by date modified')),
            ('creation_time', 'view-created', _('Sort by date created')),
            ('filesize', 'view-size', _('Sort by size')),
        ]

        for property_, icon, label in sort_options:
            button = PaletteMenuItem(label)
            button_icon = Icon(pixel_size=style.SMALL_ICON_SIZE,
                               icon_name=icon)
            button.set_image(button_icon)
            button_icon.show()
            button.connect('activate',
                           self.__sort_type_changed_cb,
                           property_,
                           icon)
            button.show()
            menu_box.append_item(button)
Beispiel #45
0
 def _add_menu(self, font_name, activate_cb):
     label = '<span font="%s">%s</span>' % (font_name, font_name)
     menu_item = PaletteMenuItem()
     menu_item.set_label(label)
     menu_item.connect('activate', activate_cb, font_name)
     self._menu_box.append_item(menu_item)
     menu_item.show()
Beispiel #46
0
def add_menu(icon_name, tooltip, tool_name, button, activate_cb):
    menu_item = PaletteMenuItem(icon_name=icon_name, text_label=tooltip)
    menu_item.connect('activate', activate_cb, tool_name)
    menu_item.icon_name = icon_name
    button.menu_box.append_item(menu_item)
    menu_item.show()
    return menu_item
Beispiel #47
0
    def __init__(self, primary_text, model):
        Palette.__init__(self, label=primary_text)

        self._model = model

        box = PaletteMenuBox()
        self.set_content(box)
        box.show()

        self._mute_item = PaletteMenuItem('')
        self._mute_icon = Icon(pixel_size=style.SMALL_ICON_SIZE)
        self._mute_item.set_image(self._mute_icon)
        box.append_item(self._mute_item)
        self._mute_item.show()
        self._mute_item.connect('activate', self.__mute_activate_cb)

        separator = PaletteMenuItemSeparator()
        box.append_item(separator)
        separator.show()

        vol_step = sound.VOLUME_STEP
        self._adjustment = Gtk.Adjustment(value=self._model.props.level,
                                          lower=0,
                                          upper=100 + vol_step,
                                          step_incr=vol_step,
                                          page_incr=vol_step,
                                          page_size=vol_step)

        hscale = Gtk.HScale()
        hscale.props.draw_value = False
        hscale.set_adjustment(self._adjustment)
        hscale.set_digits(0)
        box.append_item(hscale, vertical_padding=0)
        hscale.show()

        self._adjustment_handler_id = \
            self._adjustment.connect('value_changed',
                                     self.__adjustment_changed_cb)

        self._model_notify_level_handler_id = \
            self._model.connect('notify::level', self.__level_changed_cb)
        self._model.connect('notify::muted', self.__muted_changed_cb)

        self.connect('popup', self.__popup_cb)
    def __init__(self, row, tree_view, collab):
        Palette.__init__(self, primary_text=_(row[MainList.COLUMN_TYPE]))
        self._collab = collab
        self._row = row
        self._tree_view = tree_view

        box = PaletteMenuBox()
        self.set_content(box)
        box.show()

        menu_item = PaletteMenuItem(_('Edit'), icon_name='toolbar-edit')
        menu_item.connect('activate', lambda *args: tree_view.edit(row))
        box.append_item(menu_item)
        menu_item.show()

        menu_item = PaletteMenuItem(_('Delete'), icon_name='edit-delete')
        menu_item.connect('activate', self.__delete_cb) 
        box.append_item(menu_item)
        menu_item.show()
Beispiel #49
0
    def _add_copy_menu_item(self):
        if self._recd.buddy and not self._recd.downloadedFromBuddy:
            return

        self._copy_menu_item = PaletteMenuItem(
            _('Copy to clipboard'), icon_name='edit-copy')
        self._copy_menu_item_handler = self._copy_menu_item.connect(
            'activate', self._copy_clipboard_clicked)
        self._box.append_item(self._copy_menu_item)
        self._copy_menu_item.show()
Beispiel #50
0
    def _add_buddy_items(self):
        menu_item = None
        if friends.get_model().has_buddy(self._buddy):
            menu_item = PaletteMenuItem(_('Remove friend'), 'list-remove')
            menu_item.connect('activate', self._remove_friend_cb)
        else:
            menu_item = PaletteMenuItem(_('Make friend'), 'list-add')
            menu_item.connect('activate', self._make_friend_cb)

        self.menu_box.pack_start(menu_item, True, True, 0)

        self._invite_menu = PaletteMenuItem('')
        self._invite_menu.connect('activate', self._invite_friend_cb)
        self.menu_box.pack_start(self._invite_menu, True, True, 0)

        home_model = shell.get_model()
        self._active_activity_changed_hid = home_model.connect(
            'active-activity-changed', self._cur_activity_changed_cb)
        activity = home_model.get_active_activity()
        self._update_invite_menu(activity)
Beispiel #51
0
class OwnerIcon(BuddyIcon):
    __gtype_name__ = 'SugarFavoritesOwnerIcon'

    __gsignals__ = {
        'register-activate': (GObject.SignalFlags.RUN_FIRST, None,
                              ([])),
    }

    def __init__(self, size):
        BuddyIcon.__init__(self, buddy=get_owner_instance(), pixel_size=size)

        self.palette_invoker.cache_palette = True

        self._palette_enabled = False
        self._register_menu = None

    def create_palette(self):
        if not self._palette_enabled:
            self._palette_enabled = True
            return

        palette = BuddyMenu(get_owner_instance())

        client = GConf.Client.get_default()
        backup_url = client.get_string('/desktop/sugar/backup_url')

        if not backup_url:
            self._register_menu = PaletteMenuItem(_('Register'),
                                                  'media-record')
        else:
            self._register_menu = PaletteMenuItem(_('Register again'),
                                                  'media-record')

        self._register_menu.connect('activate', self.__register_activate_cb)
        palette.menu_box.pack_end(self._register_menu, True, True, 0)
        self._register_menu.show()

        self.connect_to_palette_pop_events(palette)

        return palette

    def __register_activate_cb(self, menuitem):
        self.emit('register-activate')

    def set_registered(self):
        self.palette.menu_box.remove(self._register_menu)
        self._register_menu = PaletteMenuItem(_('Register again'),
                                              'media-record')
        self._register_menu.connect('activate', self.__register_activate_cb)
        self.palette.menu_box.pack_end(self._register_menu, True, True, 0)
        self._register_menu.show()
Beispiel #52
0
    def __init__(self):
        label = GLib.markup_escape_text(_('Wireless modem'))
        Palette.__init__(self, primary_text=label)

        self._current_state = None
        self._failed_connection = False

        self.info_box = Gtk.VBox()

        self._toggle_state_item = PaletteMenuItem('')
        self._toggle_state_item.connect('activate', self.__toggle_state_cb)
        self.info_box.pack_start(self._toggle_state_item, True, True, 0)
        self._toggle_state_item.show()

        self.error_title_label = Gtk.Label(label="")
        self.error_title_label.set_alignment(0, 0.5)
        self.error_title_label.set_line_wrap(True)
        self.info_box.pack_start(self.error_title_label, True, True, 0)
        self.error_description_label = Gtk.Label(label="")
        self.error_description_label.set_alignment(0, 0.5)
        self.error_description_label.set_line_wrap(True)
        self.info_box.pack_start(self.error_description_label, True, True, 0)

        self.connection_info_box = Gtk.HBox()
        icon = Icon(icon_name='data-upload',
                    pixel_size=style.SMALL_ICON_SIZE)
        self.connection_info_box.pack_start(icon, True, True, 0)
        icon.show()

        self._data_label_up = Gtk.Label()
        self._data_label_up.props.xalign = 0.0
        label_alignment = self._add_widget_with_padding(self._data_label_up)
        self.connection_info_box.pack_start(label_alignment, True, True, 0)
        self._data_label_up.show()
        label_alignment.show()

        icon = Icon(icon_name='data-download',
                    pixel_size=style.SMALL_ICON_SIZE)
        self.connection_info_box.pack_start(icon, True, True, 0)
        icon.show()
        self._data_label_down = Gtk.Label()
        self._data_label_down.props.xalign = 0.0
        label_alignment = self._add_widget_with_padding(self._data_label_down)
        self.connection_info_box.pack_start(label_alignment, True, True, 0)
        self._data_label_down.show()
        label_alignment.show()

        self.info_box.pack_start(self.connection_info_box, True, True, 0)

        self.info_box.show()
        self.set_content(self.info_box)

        self.update_state(_GSM_STATE_NOT_READY)
Beispiel #53
0
    def __init__(self, activity_info):
        self._activity_info = activity_info

        color = profile.get_color()
        activity_icon = Icon(file=activity_info.get_icon(),
                             xo_color=color,
                             pixel_size=style.STANDARD_ICON_SIZE)

        name = activity_info.get_name()
        Palette.__init__(self,
                         primary_text=GLib.markup_escape_text(name),
                         icon=activity_icon)

        xo_color = XoColor(
            '%s,%s' %
            (style.COLOR_WHITE.get_svg(), style.COLOR_TRANSPARENT.get_svg()))
        self.menu_box = PaletteMenuBox()
        menu_item = PaletteMenuItem(text_label=_('Start new'),
                                    file_name=activity_info.get_icon(),
                                    xo_color=xo_color)
        menu_item.connect('activate', self.__start_activate_cb)
        self.menu_box.pack_end(menu_item, True, True, 0)
        menu_item.show()
        self.set_content(self.menu_box)
        self.menu_box.show_all()
Beispiel #54
0
    def __init__(self, name):
        Gtk.VBox.__init__(self)
        self._name = name

        self._notifications_box = Gtk.VBox()
        self._notifications_box.show()

        self._scrolled_window = Gtk.ScrolledWindow()
        self._scrolled_window.add_with_viewport(self._notifications_box)
        self._scrolled_window.set_policy(Gtk.PolicyType.NEVER,
                                         Gtk.PolicyType.AUTOMATIC)
        self._scrolled_window.show()

        separator = PaletteMenuItemSeparator()
        separator.show()

        clear_item = PaletteMenuItem(_('Clear notifications'), 'dialog-cancel')
        clear_item.connect('activate', self.__clear_cb)
        clear_item.show()

        self.add(self._scrolled_window)
        self.add(separator)
        self.add(clear_item)

        self._service = notifications.get_service()
        entries = self._service.retrieve_by_name(self._name)

        if entries:
            for entry in entries:
                self._add(entry['summary'], entry['body'])

        self._service.notification_received.connect(
            self.__notification_received_cb)

        self.connect('destroy', self.__destroy_cb)
Beispiel #55
0
    def setup_rollover_options(self, info):
        palette = Palette(info, text_maxlen=50)
        self.set_palette(palette)

        box = PaletteMenuBox()
        palette.set_content(box)
        box.show()

        menu_item = PaletteMenuItem(_('Remove'), 'list-remove')
        menu_item.connect('activate', self.item_remove_cb)
        box.append_item(menu_item)
        menu_item.show()

        separator = PaletteMenuItemSeparator()
        box.append_item(separator)
        separator.show()

        textview = Gtk.TextView()
        textview.props.height_request = style.GRID_CELL_SIZE * 2
        textview.props.width_request = style.GRID_CELL_SIZE * 3
        textview.props.hexpand = True
        textview.props.vexpand = True
        box.append_item(textview)
        textview.show()

        buffer = textview.get_buffer()
        if self.notes is None:
            buffer.set_text(_('Take notes on this page'))
        else:
            buffer.set_text(self.notes)
        buffer.connect('changed', self.__buffer_changed_cb)
Beispiel #56
0
    def __init__(self, activity_info):
        self._activity_info = activity_info

        client = GConf.Client.get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))
        activity_icon = Icon(file=activity_info.get_icon(),
                             xo_color=color,
                             icon_size=Gtk.IconSize.LARGE_TOOLBAR)

        name = activity_info.get_name()
        Palette.__init__(self,
                         primary_text=glib.markup_escape_text(name),
                         icon=activity_icon)

        xo_color = XoColor(
            '%s,%s' %
            (style.COLOR_WHITE.get_svg(), style.COLOR_TRANSPARENT.get_svg()))
        self.menu_box = PaletteMenuBox()
        menu_item = PaletteMenuItem(text_label=_('Start new'),
                                    file_name=activity_info.get_icon(),
                                    xo_color=xo_color)
        menu_item.connect('activate', self.__start_activate_cb)
        self.menu_box.pack_end(menu_item, True, True, 0)
        menu_item.show()
        self.set_content(self.menu_box)
        self.menu_box.show_all()
Beispiel #57
0
class OwnerIcon(BuddyIcon):
    __gtype_name__ = 'SugarFavoritesOwnerIcon'

    __gsignals__ = {
        'register-activate': (GObject.SignalFlags.RUN_FIRST, None, ([])),
    }

    def __init__(self, size):
        BuddyIcon.__init__(self, buddy=get_owner_instance(), pixel_size=size)

        self.palette_invoker.cache_palette = True

        self._palette_enabled = False
        self._register_menu = None

    def create_palette(self):
        if not self._palette_enabled:
            self._palette_enabled = True
            return

        palette = BuddyMenu(get_owner_instance())

        client = GConf.Client.get_default()
        backup_url = client.get_string('/desktop/sugar/backup_url')

        if not backup_url:
            self._register_menu = PaletteMenuItem(_('Register'),
                                                  'media-record')
        else:
            self._register_menu = PaletteMenuItem(_('Register again'),
                                                  'media-record')

        self._register_menu.connect('activate', self.__register_activate_cb)
        palette.menu_box.pack_end(self._register_menu, True, True, 0)
        self._register_menu.show()

        self.connect_to_palette_pop_events(palette)

        return palette

    def __register_activate_cb(self, menuitem):
        self.emit('register-activate')

    def set_registered(self):
        self.palette.menu_box.remove(self._register_menu)
        self._register_menu = PaletteMenuItem(_('Register again'),
                                              'media-record')
        self._register_menu.connect('activate', self.__register_activate_cb)
        self.palette.menu_box.pack_end(self._register_menu, True, True, 0)
        self._register_menu.show()
Beispiel #58
0
    def __init__(self, activity_info, journal_entries):
        ActivityPalette.__init__(self, activity_info)

        if not journal_entries:
            xo_color = XoColor('%s,%s' % (style.COLOR_BUTTON_GREY.get_svg(),
                                          style.COLOR_WHITE.get_svg()))
        else:
            xo_color = misc.get_icon_color(journal_entries[0])

        self.props.icon = Icon(file=activity_info.get_icon(),
                               xo_color=xo_color,
                               pixel_size=style.STANDARD_ICON_SIZE)

        if journal_entries:
            self.props.secondary_text = journal_entries[0]['title']

            menu_items = []
            for entry in journal_entries:
                icon_file_name = misc.get_icon_name(entry)
                color = misc.get_icon_color(entry)

                menu_item = PaletteMenuItem(text_label=entry['title'],
                                            file_name=icon_file_name,
                                            xo_color=color)
                menu_item.connect('activate', self.__resume_entry_cb, entry)
                menu_items.append(menu_item)
                menu_item.show()

            if journal_entries:
                separator = PaletteMenuItemSeparator()
                menu_items.append(separator)
                separator.show()

            for i in range(0, len(menu_items)):
                self.menu_box.pack_start(menu_items[i], True, True, 0)
Beispiel #59
0
    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'))