Ejemplo n.º 1
0
    def build_icons(self, category):
        icons = SUGAR_ICONS[category]

        if len(icons) < 1:
            return Gtk.EventBox()

        store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str)

        icon_view = Gtk.IconView.new_with_model(store)
        icon_view.set_selection_mode(Gtk.SelectionMode.SINGLE)
        icon_view.connect('selection-changed', self.set_icon, store)
        icon_view.set_pixbuf_column(0)
        icon_view.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('#D5D5D5'))

        for icon in icons:
            info = self.theme.lookup_icon(icon, 55,
                                          Gtk.IconLookupFlags.FORCE_SVG)
            icon_path = info.get_filename()
            if category == _('Documents'):
                icon_path = os.path.join(get_documents_path(), icon + ".svg")

            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                icon_path, 55, 55)
            store.insert(-1, [pixbuf, icon, icon_path])

        expand = Gtk.Expander()
        expand.set_label(category)
        expand.add(icon_view)
        return expand
Ejemplo n.º 2
0
    def __model_ready_cb(self, tree_model):
        self._stop_progress_bar()

        self._scroll_position = self.tree_view.props.vadjustment.props.value
        logging.debug('ListView.__model_ready_cb %r', self._scroll_position)

        if self.tree_view.window is not None:
            # prevent glitches while later vadjustment setting, see #1235
            self.tree_view.get_bin_window().hide()

        # Cannot set it up earlier because will try to access the model
        # and it needs to be ready.
        self.tree_view.set_model(self._model)

        self.tree_view.props.vadjustment.props.value = self._scroll_position
        self.tree_view.props.vadjustment.value_changed()

        if self.tree_view.window is not None:
            # prevent glitches while later vadjustment setting, see #1235
            self.tree_view.get_bin_window().show()

        if len(tree_model) == 0:
            if self._is_query_empty():
                if self._query['mountpoints'] == ['/']:
                    self._show_message(_('Your Journal is empty'))
                elif self._query['mountpoints'] == \
                        [model.get_documents_path()]:
                    self._show_message(_('Your documents folder is empty'))
                else:
                    self._show_message(_('The device is empty'))
            else:
                self._show_message(_('No matching entries'),
                                   show_clear_query=True)
        else:
            self._clear_message()
Ejemplo n.º 3
0
    def __model_ready_cb(self, tree_model):
        self._stop_progress_bar()

        self._scroll_position = self.icon_view.props.vadjustment.props.value
        logging.debug('IconView.__model_ready_cb %r', self._scroll_position)

        # Cannot set it up earlier because will try to access the model
        # and it needs to be ready.
        self.icon_view.set_model(self._model)

        self.icon_view.props.vadjustment.props.value = self._scroll_position
        self.icon_view.props.vadjustment.value_changed()

        if len(tree_model) == 0:
            documents_path = model.get_documents_path()
            if self._is_query_empty():
                if self._query['mountpoints'] == ['/']:
                    self._show_message(_('Your Journal is empty'))
                elif documents_path and self._query['mountpoints'] == \
                        [documents_path]:
                    self._show_message(_('Your documents folder is empty'))
                else:
                    self._show_message(_('The device is empty'))
            else:
                self._show_message(
                    _('No matching entries'),
                    show_clear_query=self._toolbar.is_filter_changed())
        else:
            self._clear_message()
Ejemplo n.º 4
0
    def build_icons(self):
        store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str)

        icon_view = Gtk.IconView.new_with_model(store)
        icon_view.set_selection_mode(Gtk.SelectionMode.SINGLE)
        icon_view.connect('selection-changed', self.set_icon, store)
        icon_view.set_pixbuf_column(0)
        icon_view.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('#D5D5D5'))

        for icon in get_user_icons():
            info = self.theme.lookup_icon(icon, 55,
                    Gtk.IconLookupFlags.FORCE_SVG)
            if not info:
                continue
            icon_path = os.path.join(get_user_path(), icon + ".svg")
            if not os.path.exists(icon_path):
                icon_path = os.path.join(get_documents_path(), icon + ".svg")

            if not os.path.exists(icon_path):
                icon_path = info.get_filename()

            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                        icon_path, 55, 55)
            store.insert(-1, [pixbuf, icon, icon_path])

        return icon_view
Ejemplo n.º 5
0
    def __model_ready_cb(self, tree_model):
        self._stop_progress_bar()

        self._scroll_position = self.icon_view.props.vadjustment.props.value
        logging.debug('IconView.__model_ready_cb %r', self._scroll_position)

        # Cannot set it up earlier because will try to access the model
        # and it needs to be ready.
        self.icon_view.set_model(self._model)

        self.icon_view.props.vadjustment.props.value = self._scroll_position
        self.icon_view.props.vadjustment.value_changed()

        if len(tree_model) == 0:
            documents_path = model.get_documents_path()
            if self._is_query_empty():
                if self._query['mountpoints'] == ['/']:
                    self._show_message(_('Your Journal is empty'))
                elif documents_path and self._query['mountpoints'] == \
                        [documents_path]:
                    self._show_message(_('Your documents folder is empty'))
                else:
                    self._show_message(_('The device is empty'))
            else:
                self._show_message(_('No matching entries'),
                                   show_clear_query=True)
        else:
            self._clear_message()
Ejemplo n.º 6
0
    def __init__(self):
        Gtk.Window.__init__(self)

        self.set_destroy_with_parent(True)

        self.theme = Gtk.IconTheme.get_default()
        self.theme.append_search_path(get_documents_path())

        self._icon = None
        grid = Gtk.Grid()

        self.x, self.y = (Gdk.Screen.width() / 1.5, Gdk.Screen.height() / 1.5)
        self.set_size_request(self.x, self.y)

        self.icons = None
        toolbox = self.build_toolbar()
        self.icons = self.build_scroll()

        grid.attach(toolbox, 0, 1, 1, 1)
        grid.attach(self.icons, 0, 2, 1, 1)

        self.set_decorated(False)
        self.set_skip_pager_hint(True)
        self.set_skip_taskbar_hint(True)
        self.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        self.set_resizable(False)
        self.set_modal(True)

        self.add(grid)
        self.show_all()
Ejemplo n.º 7
0
    def __model_ready_cb(self, tree_model):
        self._stop_progress_bar()

        self._scroll_position = self.tree_view.props.vadjustment.props.value
        logging.debug('ListView.__model_ready_cb %r', self._scroll_position)

        if self.tree_view.window is not None:
            # prevent glitches while later vadjustment setting, see #1235
            self.tree_view.get_bin_window().hide()

        # Cannot set it up earlier because will try to access the model
        # and it needs to be ready.
        self.tree_view.set_model(self._model)

        self.tree_view.props.vadjustment.props.value = self._scroll_position
        self.tree_view.props.vadjustment.value_changed()

        if self.tree_view.window is not None:
            # prevent glitches while later vadjustment setting, see #1235
            self.tree_view.get_bin_window().show()

        if len(tree_model) == 0:
            if self._is_query_empty():
                if self._query['mountpoints'] == ['/']:
                    self._show_message(_('Your Journal is empty'))
                elif self._query['mountpoints'] == \
                        [model.get_documents_path()]:
                    self._show_message(_('Your documents folder is empty'))
                else:
                    self._show_message(_('The device is empty'))
            else:
                self._show_message(_('No matching entries'),
                                   show_clear_query=True)
        else:
            self._clear_message()
Ejemplo n.º 8
0
    def build_icons(self, category):
        icons = SUGAR_ICONS[category]

        if len(icons) < 1:
            return Gtk.EventBox()

        store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str)

        icon_view = Gtk.IconView.new_with_model(store)
        icon_view.set_selection_mode(Gtk.SelectionMode.SINGLE)
        icon_view.connect('selection-changed', self.set_icon, store)
        icon_view.set_pixbuf_column(0)
        icon_view.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('#D5D5D5'))

        for icon in icons:
            info = self.theme.lookup_icon(icon, 55,
                                          Gtk.IconLookupFlags.FORCE_SVG)
            icon_path = info.get_filename()
            if category == _('Documents'):
                icon_path = os.path.join(get_documents_path(), icon + ".svg")

            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(icon_path, 55, 55)
            store.insert(-1, [pixbuf, icon, icon_path])

        expand = Gtk.Expander()
        expand.set_label(category)
        expand.add(icon_view)
        return expand
Ejemplo n.º 9
0
def get_document_icons():
    icons = os.listdir(get_documents_path())
    icons_ = []
    for icon in icons:
        if icon.endswith('.svg'):
            icons_.append(icon[:-4])

    return icons_
Ejemplo n.º 10
0
    def _refresh_copy_palette(self):
        palette = self._copy.get_palette()

        for menu_item in palette.menu.get_children():
            palette.menu.remove(menu_item)
            menu_item.destroy()

        clipboard_menu = ClipboardMenu(self._metadata)
        clipboard_menu.set_image(Icon(icon_name='toolbar-edit',
                                      icon_size=Gtk.IconSize.MENU))
        clipboard_menu.connect('volume-error', self.__volume_error_cb)
        palette.menu.append(clipboard_menu)
        clipboard_menu.show()

        if self._metadata['mountpoint'] != '/':
            client = GConf.Client.get_default()
            color = XoColor(client.get_string('/desktop/sugar/user/color'))
            journal_menu = VolumeMenu(self._metadata, _('Journal'), '/')
            journal_menu.set_image(Icon(icon_name='activity-journal',
                                        xo_color=color,
                                        icon_size=Gtk.IconSize.MENU))
            journal_menu.connect('volume-error', self.__volume_error_cb)
            palette.menu.append(journal_menu)
            journal_menu.show()

        documents_path = model.get_documents_path()
        if documents_path is not None and not \
                self._metadata['uid'].startswith(documents_path):
            documents_menu = VolumeMenu(self._metadata, _('Documents'),
                                        documents_path)
            documents_menu.set_image(Icon(icon_name='user-documents',
                                          icon_size=Gtk.IconSize.MENU))
            documents_menu.connect('volume-error', self.__volume_error_cb)
            palette.menu.append(documents_menu)
            documents_menu.show()

        volume_monitor = Gio.VolumeMonitor.get()
        icon_theme = Gtk.IconTheme.get_default()
        for mount in volume_monitor.get_mounts():
            if self._metadata['mountpoint'] == mount.get_root().get_path():
                continue
            volume_menu = VolumeMenu(self._metadata, mount.get_name(),
                                     mount.get_root().get_path())
            for name in mount.get_icon().props.names:
                if icon_theme.has_icon(name):
                    volume_menu.set_image(Icon(icon_name=name,
                                               icon_size=Gtk.IconSize.MENU))
                    break
            volume_menu.connect('volume-error', self.__volume_error_cb)
            palette.menu.append(volume_menu)
            volume_menu.show()

        for account in accountsmanager.get_configured_accounts():
            menu = account.get_share_menu(self._metadata)
            palette.menu.append(menu)
Ejemplo n.º 11
0
    def _refresh_copy_palette(self):
        palette = self._copy.get_palette()

        for menu_item in palette.menu.get_children():
            palette.menu.remove(menu_item)
            menu_item.destroy()

        clipboard_menu = ClipboardMenu(self._metadata)
        clipboard_menu.set_image(
            Icon(icon_name='toolbar-edit', icon_size=Gtk.IconSize.MENU))
        clipboard_menu.connect('volume-error', self.__volume_error_cb)
        palette.menu.append(clipboard_menu)
        clipboard_menu.show()

        if self._metadata['mountpoint'] != '/':
            client = GConf.Client.get_default()
            color = XoColor(client.get_string('/desktop/sugar/user/color'))
            journal_menu = VolumeMenu(self._metadata, _('Journal'), '/')
            journal_menu.set_image(
                Icon(icon_name='activity-journal',
                     xo_color=color,
                     icon_size=Gtk.IconSize.MENU))
            journal_menu.connect('volume-error', self.__volume_error_cb)
            palette.menu.append(journal_menu)
            journal_menu.show()

        documents_path = model.get_documents_path()
        if documents_path is not None and not \
                self._metadata['uid'].startswith(documents_path):
            documents_menu = VolumeMenu(self._metadata, _('Documents'),
                                        documents_path)
            documents_menu.set_image(
                Icon(icon_name='user-documents', icon_size=Gtk.IconSize.MENU))
            documents_menu.connect('volume-error', self.__volume_error_cb)
            palette.menu.append(documents_menu)
            documents_menu.show()

        volume_monitor = Gio.VolumeMonitor.get()
        icon_theme = Gtk.IconTheme.get_default()
        for mount in volume_monitor.get_mounts():
            if self._metadata['mountpoint'] == mount.get_root().get_path():
                continue
            volume_menu = VolumeMenu(self._metadata, mount.get_name(),
                                     mount.get_root().get_path())
            for name in mount.get_icon().props.names:
                if icon_theme.has_icon(name):
                    volume_menu.set_image(
                        Icon(icon_name=name, icon_size=Gtk.IconSize.MENU))
                    break
            volume_menu.connect('volume-error', self.__volume_error_cb)
            palette.menu.append(volume_menu)
            volume_menu.show()
Ejemplo n.º 12
0
    def _create_menu_items(self):
        if self._add_clipboard_menu:
            clipboard_menu = ClipboardMenu(self._get_uid_list_cb)
            clipboard_menu.set_image(
                Icon(icon_name='toolbar-edit',
                     pixel_size=style.SMALL_ICON_SIZE))
            clipboard_menu.connect('volume-error', self.__volume_error_cb)
            self._menu.append(clipboard_menu)
            clipboard_menu.show()

        if self._journalactivity.get_mount_point() != '/':
            color = profile.get_color()
            journal_menu = VolumeMenu(self._journalactivity,
                                      self._get_uid_list_cb, _('Journal'), '/')
            journal_menu.set_image(
                Icon(icon_name='activity-journal',
                     xo_color=color,
                     pixel_size=style.SMALL_ICON_SIZE))
            journal_menu.connect('volume-error', self.__volume_error_cb)
            self._menu.append(journal_menu)
            journal_menu.show()

        documents_path = model.get_documents_path()
        if documents_path is not None and \
                self._journalactivity.get_mount_point() != documents_path:
            documents_menu = VolumeMenu(self._journalactivity,
                                        self._get_uid_list_cb, _('Documents'),
                                        documents_path)
            documents_menu.set_image(
                Icon(icon_name='user-documents',
                     pixel_size=style.SMALL_ICON_SIZE))
            documents_menu.connect('volume-error', self.__volume_error_cb)
            self._menu.append(documents_menu)
            documents_menu.show()

        volume_monitor = Gio.VolumeMonitor.get()
        self._volumes = {}
        for mount in volume_monitor.get_mounts():
            self._add_mount(mount)

        self._mount_added_hid = volume_monitor.connect('mount-added',
                                                       self.__mount_added_cb)
        self._mount_removed_hid = volume_monitor.connect(
            'mount-removed', self.__mount_removed_cb)

        if self._add_webservices_menu:
            for account in accountsmanager.get_configured_accounts():
                if hasattr(account, 'get_shared_journal_entry'):
                    entry = account.get_shared_journal_entry()
                    if hasattr(entry, 'get_share_menu'):
                        self._menu.append(
                            entry.get_share_menu(self._get_uid_list_cb))
Ejemplo n.º 13
0
    def set_icon(self, widget, model):
        try:
            iter_ = model.get_iter(widget.get_selected_items()[0])
        except:
            return

        icon_name = model.get(iter_, 1)[0]
        icon_path = model.get(iter_, 2)[0]
        self._icon = icon_name
        if icon_path.startswith(get_documents_path()):
            destination = os.path.join(self.end_path, icon_name + ".svg")
            shutil.copy(icon_path, destination)
        self.destroy()
Ejemplo n.º 14
0
    def _set_up_documents_button(self):
        documents_path = model.get_documents_path()
        if documents_path is not None:
            button = DocumentsButton(documents_path)
            button.props.group = self._volume_buttons[0]
            button.set_palette(Palette(_('Documents')))
            button.connect('toggled', self._button_toggled_cb)
            button.show()

            position = self.get_item_index(self._volume_buttons[-1]) + 1
            self.insert(button, position)
            self._volume_buttons.append(button)
            self.show()
Ejemplo n.º 15
0
    def set_icon(self, widget, model):
        try:
            iter_ = model.get_iter(widget.get_selected_items()[0])
        except:
            return

        icon_name = model.get(iter_, 1)[0]
        icon_path = model.get(iter_, 2)[0]
        self._icon = icon_name
        if icon_path.startswith(get_documents_path()):
            destination = os.path.join(self.end_path, icon_name + ".svg")
            shutil.copy(icon_path, destination)
        self.destroy()
Ejemplo n.º 16
0
    def __model_ready_cb(self, tree_model):
        self._stop_progress_bar()

        self._scroll_position = self.tree_view.props.vadjustment.props.value
        logging.debug('ListView.__model_ready_cb %r', self._scroll_position)

        x11_window = self.tree_view.get_window()

        if x11_window is not None:
            # prevent glitches while later vadjustment setting, see #1235
            self.tree_view.get_bin_window().hide()

        # if the selection was preserved, restore it
        if self._backup_selected is not None:
            tree_model.restore_selection(self._backup_selected)
            self.emit('selection-changed', len(self._backup_selected))

        # Cannot set it up earlier because will try to access the model
        # and it needs to be ready.
        self.tree_view.set_model(self._model)

        self.tree_view.props.vadjustment.props.value = self._scroll_position
        self.tree_view.props.vadjustment.value_changed()

        if x11_window is not None:
            # prevent glitches while later vadjustment setting, see #1235
            self.tree_view.get_bin_window().show()

        if len(tree_model) == 0:
            if self._query.get('project_id', None):
                self._show_message(_('Your project is empty'))
            else:
                documents_path = model.get_documents_path()
                if self._is_query_empty():
                    if self._query['mountpoints'] == ['/']:
                        self._show_message(_('Your Journal is empty'))
                    elif documents_path and self._query['mountpoints'] == \
                            [documents_path]:
                        self._show_message(_('Your documents folder is empty'))
                    else:
                        self._show_message(_('The device is empty'))
                else:
                    show_message_text = _('No matching entries')
                    if self.get_projects_view_active():
                        show_message_text = _('No Projects')

                    self._show_message(
                        show_message_text,
                        show_clear_query=self._can_clear_query())
        else:
            self._clear_message()
Ejemplo n.º 17
0
    def _create_menu_items(self):
        if self._add_clipboard_menu:
            clipboard_menu = ClipboardMenu(self._get_uid_list_cb)
            clipboard_menu.set_image(Icon(icon_name='toolbar-edit',
                                          icon_size=Gtk.IconSize.MENU))
            clipboard_menu.connect('volume-error', self.__volume_error_cb)
            self._menu.append(clipboard_menu)
            clipboard_menu.show()

        if self._journalactivity.get_mount_point() != '/':
            client = GConf.Client.get_default()
            color = XoColor(client.get_string('/desktop/sugar/user/color'))
            journal_menu = VolumeMenu(self._journalactivity,
                                      self._get_uid_list_cb, _('Journal'), '/')
            journal_menu.set_image(Icon(icon_name='activity-journal',
                                        xo_color=color,
                                        icon_size=Gtk.IconSize.MENU))
            journal_menu.connect('volume-error', self.__volume_error_cb)
            self._menu.append(journal_menu)
            journal_menu.show()

        documents_path = model.get_documents_path()
        if documents_path is not None and \
                self._journalactivity.get_mount_point() != documents_path:
            documents_menu = VolumeMenu(self._journalactivity,
                                        self._get_uid_list_cb, _('Documents'),
                                        documents_path)
            documents_menu.set_image(Icon(icon_name='user-documents',
                                          icon_size=Gtk.IconSize.MENU))
            documents_menu.connect('volume-error', self.__volume_error_cb)
            self._menu.append(documents_menu)
            documents_menu.show()

        volume_monitor = Gio.VolumeMonitor.get()
        self._volumes = {}
        for mount in volume_monitor.get_mounts():
            self._add_mount(mount)

        self._mount_added_hid = volume_monitor.connect('mount-added',
                                                       self.__mount_added_cb)
        self._mount_removed_hid = volume_monitor.connect(
            'mount-removed',
            self.__mount_removed_cb)

        if self._add_webservices_menu:
            for account in accountsmanager.get_configured_accounts():
                if hasattr(account, 'get_shared_journal_entry'):
                    entry = account.get_shared_journal_entry()
                    if hasattr(entry, 'get_share_menu'):
                        self._menu.append(entry.get_share_menu(
                                          self._get_uid_list_cb))
Ejemplo n.º 18
0
    def __model_ready_cb(self, tree_model):
        self._stop_progress_bar()

        self._scroll_position = self.tree_view.props.vadjustment.props.value
        logging.debug('ListView.__model_ready_cb %r', self._scroll_position)

        x11_window = self.tree_view.get_window()

        if x11_window is not None:
            # prevent glitches while later vadjustment setting, see #1235
            self.tree_view.get_bin_window().hide()

        # if the selection was preserved, restore it
        if self._backup_selected is not None:
            tree_model.restore_selection(self._backup_selected)
            self.emit('selection-changed', len(self._backup_selected))

        # Cannot set it up earlier because will try to access the model
        # and it needs to be ready.
        self.tree_view.set_model(self._model)

        self.tree_view.props.vadjustment.props.value = self._scroll_position
        self.tree_view.props.vadjustment.value_changed()

        if x11_window is not None:
            # prevent glitches while later vadjustment setting, see #1235
            self.tree_view.get_bin_window().show()

        if len(tree_model) == 0:
            if self._query.get('project_id', None):
                self._show_message(_('Your project is empty'))
            else:
                documents_path = model.get_documents_path()
                if self._is_query_empty():
                    if self._query['mountpoints'] == ['/']:
                        self._show_message(_('Your Journal is empty'))
                    elif documents_path and self._query['mountpoints'] == \
                            [documents_path]:
                        self._show_message(_('Your documents folder is empty'))
                    else:
                        self._show_message(_('The device is empty'))
                else:
                    show_message_text = _('No matching entries')
                    if self.get_projects_view_active():
                        show_message_text = _('No Projects')

                    self._show_message(show_message_text,
                        show_clear_query=self._can_clear_query())
        else:
            self._clear_message()
Ejemplo n.º 19
0
    def _set_up_documents_button(self):
        documents_path = model.get_documents_path()
        if documents_path is not None:
            button = DocumentsButton(documents_path)
            button.props.group = self._volume_buttons[0]
            label = GLib.markup_escape_text(_("Documents"))
            button.set_palette(Palette(label))
            button.connect("toggled", self._button_toggled_cb)
            button.show()

            position = self.get_item_index(self._volume_buttons[-1]) + 1
            self.insert(button, position)
            self._volume_buttons.append(button)
            self.show()
Ejemplo n.º 20
0
    def _create_menu_items(self):
        if self._add_clipboard_menu:
            clipboard_menu = ClipboardMenu(self._get_uid_list_cb)
            clipboard_menu.set_image(
                Icon(icon_name='toolbar-edit', icon_size=Gtk.IconSize.MENU))
            clipboard_menu.connect('volume-error', self.__volume_error_cb)
            self._menu.append(clipboard_menu)
            clipboard_menu.show()

        if self._journalactivity.get_mount_point() != '/':
            client = GConf.Client.get_default()
            color = XoColor(client.get_string('/desktop/sugar/user/color'))
            journal_menu = VolumeMenu(self._journalactivity,
                                      self._get_uid_list_cb, _('Journal'), '/')
            journal_menu.set_image(
                Icon(icon_name='activity-journal',
                     xo_color=color,
                     icon_size=Gtk.IconSize.MENU))
            journal_menu.connect('volume-error', self.__volume_error_cb)
            self._menu.append(journal_menu)
            journal_menu.show()

        documents_path = model.get_documents_path()
        if documents_path is not None and \
                self._journalactivity.get_mount_point() != documents_path:
            documents_menu = VolumeMenu(self._journalactivity,
                                        self._get_uid_list_cb, _('Documents'),
                                        documents_path)
            documents_menu.set_image(
                Icon(icon_name='user-documents', icon_size=Gtk.IconSize.MENU))
            documents_menu.connect('volume-error', self.__volume_error_cb)
            self._menu.append(documents_menu)
            documents_menu.show()

        volume_monitor = Gio.VolumeMonitor.get()
        self._volumes = {}
        for mount in volume_monitor.get_mounts():
            self._add_mount(mount)

        self._mount_added_hid = volume_monitor.connect('mount-added',
                                                       self.__mount_added_cb)
        self._mount_removed_hid = volume_monitor.connect(
            'mount-removed', self.__mount_removed_cb)

        if self._add_webservices_menu:
            for account in accountsmanager.get_configured_accounts():
                self._menu.append(
                    account.get_shared_journal_entry().get_share_menu(
                        self._get_uid_list_cb))
Ejemplo n.º 21
0
    def __init__(self, metadata):
        Gtk.Menu.__init__(self)

        self._metadata = metadata

        clipboard_menu = ClipboardMenu(self._metadata)
        clipboard_menu.set_image(Icon(icon_name='toolbar-edit',
                                      icon_size=Gtk.IconSize.MENU))
        clipboard_menu.connect('volume-error', self.__volume_error_cb)
        self.append(clipboard_menu)
        clipboard_menu.show()

        if self._metadata['mountpoint'] != '/':
            client = GConf.Client.get_default()
            color = XoColor(client.get_string('/desktop/sugar/user/color'))
            journal_menu = VolumeMenu(self._metadata, _('Journal'), '/')
            journal_menu.set_image(Icon(icon_name='activity-journal',
                                        xo_color=color,
                                        icon_size=Gtk.IconSize.MENU))
            journal_menu.connect('volume-error', self.__volume_error_cb)
            self.append(journal_menu)
            journal_menu.show()

        documents_path = model.get_documents_path()
        if documents_path is not None and not \
                self._metadata['uid'].startswith(documents_path):
            documents_menu = VolumeMenu(self._metadata, _('Documents'),
                                        documents_path)
            documents_menu.set_image(Icon(icon_name='user-documents',
                                          icon_size=Gtk.IconSize.MENU))
            documents_menu.connect('volume-error', self.__volume_error_cb)
            self.append(documents_menu)
            documents_menu.show()

        volume_monitor = Gio.VolumeMonitor.get()
        icon_theme = Gtk.IconTheme.get_default()
        for mount in volume_monitor.get_mounts():
            if self._metadata['mountpoint'] == mount.get_root().get_path():
                continue
            volume_menu = VolumeMenu(self._metadata, mount.get_name(),
                                   mount.get_root().get_path())
            for name in mount.get_icon().props.names:
                if icon_theme.has_icon(name):
                    volume_menu.set_image(Icon(icon_name=name,
                                               icon_size=Gtk.IconSize.MENU))
                    break
            volume_menu.connect('volume-error', self.__volume_error_cb)
            self.append(volume_menu)
            volume_menu.show()
Ejemplo n.º 22
0
    def _create_menu_items(self):
        if self._add_clipboard_menu:
            clipboard_menu = ClipboardMenu(self._get_uid_list_cb)
            clipboard_menu.set_image(Icon(icon_name="toolbar-edit", icon_size=Gtk.IconSize.MENU))
            clipboard_menu.connect("volume-error", self.__volume_error_cb)
            self._menu.append(clipboard_menu)
            clipboard_menu.show()

        if self._journalactivity.get_mount_point() != "/":
            client = GConf.Client.get_default()
            color = XoColor(client.get_string("/desktop/sugar/user/color"))
            journal_menu = VolumeMenu(self._journalactivity, self._get_uid_list_cb, _("Journal"), "/")
            journal_menu.set_image(Icon(icon_name="activity-journal", xo_color=color, icon_size=Gtk.IconSize.MENU))
            journal_menu.connect("volume-error", self.__volume_error_cb)
            self._menu.append(journal_menu)
            journal_menu.show()

        documents_path = model.get_documents_path()
        if documents_path is not None and self._journalactivity.get_mount_point() != documents_path:
            documents_menu = VolumeMenu(self._journalactivity, self._get_uid_list_cb, _("Documents"), documents_path)
            documents_menu.set_image(Icon(icon_name="user-documents", icon_size=Gtk.IconSize.MENU))
            documents_menu.connect("volume-error", self.__volume_error_cb)
            self._menu.append(documents_menu)
            documents_menu.show()

        volume_monitor = Gio.VolumeMonitor.get()
        self._volumes = {}
        for mount in volume_monitor.get_mounts():
            self._add_mount(mount)

        self._mount_added_hid = volume_monitor.connect("mount-added", self.__mount_added_cb)
        self._mount_removed_hid = volume_monitor.connect("mount-removed", self.__mount_removed_cb)

        if self._add_webservices_menu:
            for account in accountsmanager.get_configured_accounts():
                self._menu.append(account.get_shared_journal_entry().get_share_menu(self._get_uid_list_cb))
Ejemplo n.º 23
0
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

from gi.repository import Gio

from jarabe.journal.model import get_documents_path
from jarabe.desktop.homebackgroundbox import BACKGROUND_DIR
from jarabe.desktop.homebackgroundbox import BACKGROUND_IMAGE_PATH_KEY
from jarabe.desktop.homebackgroundbox import BACKGROUND_ALPHA_LEVEL_KEY
from jarabe.desktop.homebackgroundbox import DEFAULT_BACKGROUND_ALPHA_LEVEL

import os

BACKGROUNDS_DIRS = (os.path.join('/usr', 'share', 'backgrounds'),
                    get_documents_path())


def set_background_image_path(file_path):
    settings = Gio.Settings(BACKGROUND_DIR)
    if file_path is None:
        settings.set_string(BACKGROUND_IMAGE_PATH_KEY, '')
    else:
        settings.set_string(BACKGROUND_IMAGE_PATH_KEY, str(file_path))
    return 1


def get_background_image_path():
    settings = Gio.Settings(BACKGROUND_DIR)
    return settings.get_string(BACKGROUND_IMAGE_PATH_KEY)
Ejemplo n.º 24
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

from gi.repository import GConf

from jarabe.journal.model import get_documents_path
from jarabe.desktop.homebackgroundbox import BACKGROUND_IMAGE_PATH_STRING
from jarabe.desktop.homebackgroundbox import BACKGROUND_ALPHA_LEVEL_STRING
from jarabe.desktop.homebackgroundbox import DEFAULT_BACKGROUND_ALPHA_LEVEL

import os

BACKGROUNDS_DIRS = (os.path.join('/usr', 'share',
                                 'backgrounds'), get_documents_path())


def set_background_image_path(file_path):
    client = GConf.Client.get_default()
    if file_path is None:
        client.set_string(BACKGROUND_IMAGE_PATH_STRING, '')
    else:
        client.set_string(BACKGROUND_IMAGE_PATH_STRING, str(file_path))
    return 1


def get_background_image_path():
    client = GConf.Client.get_default()
    return client.get_string(BACKGROUND_IMAGE_PATH_STRING)
Ejemplo n.º 25
0
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#

from gi.repository import GConf
from gi.repository import GdkPixbuf

from sugar3.graphics import style
from jarabe.journal.model import get_documents_path
from jarabe.desktop.homebackgroundbox import BACKGROUND_IMAGE_PATH_STRING
from jarabe.desktop.homebackgroundbox import BACKGROUND_ALPHA_LEVEL_STRING
from jarabe.desktop.homebackgroundbox import DEFAULT_BACKGROUND_ALPHA_LEVEL

import os

BACKGROUNDS_DIRS = (os.path.join('/usr', 'share', 'backgrounds'),
                    get_documents_path())


def set_background_image_path(file_path):
    client = GConf.Client.get_default()
    if file_path is None:
        client.set_string(BACKGROUND_IMAGE_PATH_STRING, '')
    else:
        client.set_string(BACKGROUND_IMAGE_PATH_STRING, str(file_path))
    return 1


def get_background_image_path():
    client = GConf.Client.get_default()
    return client.get_string(BACKGROUND_IMAGE_PATH_STRING)