def __init__(self):
        Gtk.Grid.__init__(self)

        self.load_from_journal = self.build_zone('load-from-journal',
             _('Load from Journal'))
        self.download_from_internet = self.build_zone('download',
            _('Download from internet'))
        self.remove_extensions = self.build_zone('remove-extension',
            _('Remove installed extensions'))

        separator = Gtk.VSeparator()
        separator2 = Gtk.VSeparator()
        height = Gdk.Screen.height() - 50
        separator.set_size_request(-1, height)
        separator2.set_size_request(-1, height)

        self.attach(self.load_from_journal, 0, 0, 1, 1)
        self.attach(separator, 1, 0, 1, 1)
        self.attach(self.download_from_internet, 2, 0, 1, 1)
        self.attach(separator2, 3, 0, 1, 1)
        #self.attach(self.remove_extensions, 4, 0, 1, 1)

        services = get_webaccount_services()
        if len(services) == 0:
            self.__set_sensitive(self.remove_extensions, False)

        self.show_all()
Esempio n. 2
0
    def __init__(self, model, alerts):
        SectionView.__init__(self)

        self._model = model
        self.restart_alerts = alerts

        services = get_webaccount_services()
        if len(services) == 0:
            label = Gtk.Label()
            label.set_markup(
                '<span size="x-large" weight="bold">' +
                glib.markup_escape_text(
                    _('No web services are installed.\n'
                      'Please visit %s for more details.' %
                      'http://wiki.sugarlabs.org/go/WebServices')) +
                '</span>')
            label.show()
            self.add(label)
            return

        vbox = Gtk.VBox()
        hbox = Gtk.HBox(style.DEFAULT_SPACING)

        self._service_config_box = Gtk.VBox()

        for service in services:
            icon = CanvasIcon(icon_name=service.get_icon_name())
            icon.connect('button_press_event',
                         service.config_service_cb,
                         self._service_config_box)
            icon.show()
            hbox.pack_start(icon, False, False, 0)

        hbox.show()
        vbox.pack_start(hbox, False, False, 0)

        scrolled = Gtk.ScrolledWindow()
        vbox.pack_start(scrolled, True, True, 0)

        self.add(vbox)
        scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scrolled.show()

        workspace = Gtk.VBox()
        scrolled.add_with_viewport(workspace)
        workspace.show()

        workspace.add(self._service_config_box)
        workspace.show_all()
        vbox.show()
Esempio n. 3
0
    def __init__(self, model, alerts):
        SectionView.__init__(self)

        self._model = model
        self.restart_alerts = alerts

        services = get_webaccount_services()
        if len(services) == 0:
            label = Gtk.Label()
            label.set_markup(
                '<span size="x-large" weight="bold">' +
                GLib.markup_escape_text(
                    _('No web services are installed.\n'
                      'Please visit %s for more details.' %
                      'http://wiki.sugarlabs.org/go/WebServices')) + '</span>')
            label.show()
            self.add(label)
            return

        vbox = Gtk.VBox()
        hbox = Gtk.HBox(style.DEFAULT_SPACING)

        self._service_config_box = Gtk.VBox()

        for service in services:
            icon = CanvasIcon(icon_name=service.get_icon_name())
            icon.connect('button_press_event', service.config_service_cb,
                         self._service_config_box)
            icon.show()
            hbox.pack_start(icon, False, False, 0)

        hbox.show()
        vbox.pack_start(hbox, False, False, 0)

        scrolled = Gtk.ScrolledWindow()
        vbox.pack_start(scrolled, True, True, 0)

        self.add(vbox)
        scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scrolled.show()

        workspace = Gtk.VBox()
        scrolled.add_with_viewport(workspace)
        workspace.show()

        workspace.add(self._service_config_box)
        workspace.show_all()
        vbox.show()
    def __init__(self, activity):
        Gtk.Grid.__init__(self)
        self.activity = activity

        pos = 0
        current = 0
        services = get_webaccount_services()
        paths = _get_webservice_module_paths()
        paths_cp = _get_webaccount_paths()

        for service in services:
            icon = service.get_icon_name()
            name = _get_service_name(paths[current])
            service_ = self.build_extension(icon, paths[current],
                paths_cp[current], name)
            self.attach(service_, 0, pos, 1, 1)

            pos += 1
            current += 1

        self.show_all()
Esempio n. 5
0
    def __init__(self, model, alerts):
        SectionView.__init__(self)

        self._model = model
        self.restart_alerts = alerts

        services = get_webaccount_services()

        grid = Gtk.Grid()

        if len(services) == 0:
            grid.set_row_spacing(style.DEFAULT_SPACING)

            icon = Icon(
                pixel_size=style.LARGE_ICON_SIZE,
                icon_name="module-webaccount",
                stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
                fill_color=style.COLOR_TRANSPARENT.get_svg(),
            )

            grid.attach(icon, 0, 0, 1, 1)
            icon.show()

            label = Gtk.Label()
            label.set_justify(Gtk.Justification.CENTER)
            label.set_markup(
                '<span foreground="%s" size="large">%s</span>'
                % (
                    style.COLOR_BUTTON_GREY.get_html(),
                    GLib.markup_escape_text(
                        _(
                            "No web services are installed.\n"
                            "Please visit %s for more details." % "http://wiki.sugarlabs.org/go/WebServices"
                        )
                    ),
                )
            )
            label.show()
            grid.attach(label, 0, 1, 1, 1)

            alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)
            alignment.add(grid)
            grid.show()

            self.add(alignment)
            alignment.show()
            return

        grid.set_row_spacing(style.DEFAULT_SPACING * 4)
        grid.set_column_spacing(style.DEFAULT_SPACING * 4)
        grid.set_border_width(style.DEFAULT_SPACING * 2)
        grid.set_column_homogeneous(True)

        width = Gdk.Screen.width() - 2 * style.GRID_CELL_SIZE
        nx = int(width / (style.GRID_CELL_SIZE + style.DEFAULT_SPACING * 4))

        self._service_config_box = Gtk.VBox()

        x = 0
        y = 0
        for service in services:
            service_grid = Gtk.Grid()
            background_box = Gtk.EventBox()
            background_box.modify_bg(Gtk.StateType.NORMAL, style.COLOR_WHITE.get_gdk_color())
            icon = CanvasIcon(icon_name=service.get_icon_name())
            background_box.add(icon)
            icon.show()

            service_grid.attach(background_box, x, y, 1, 1)
            background_box.show()

            background_box.connect("button_press_event", service.config_service_cb, self._service_config_box)

            label = Gtk.Label()
            label.set_justify(Gtk.Justification.CENTER)
            name = get_service_name(service)
            label.set_markup(name)
            service_grid.attach(label, x, y + 1, 1, 1)
            label.show()

            grid.attach(service_grid, x, y, 1, 1)
            service_grid.show()

            x += 1
            if x == nx:
                x = 0
                y += 1

        alignment = Gtk.Alignment.new(0.5, 0, 0, 0)
        alignment.add(grid)
        grid.show()

        vbox = Gtk.VBox()
        vbox.pack_start(alignment, False, False, 0)
        alignment.show()

        scrolled = Gtk.ScrolledWindow()
        vbox.pack_start(scrolled, True, True, 0)

        self.add(vbox)
        scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scrolled.show()

        workspace = Gtk.VBox()
        scrolled.add_with_viewport(workspace)
        workspace.show()

        workspace.add(self._service_config_box)
        workspace.show_all()
        vbox.show()
Esempio n. 6
0
    def __init__(self, model, alerts):
        SectionView.__init__(self)

        self._model = model
        self.restart_alerts = alerts

        services = get_webaccount_services()

        grid = Gtk.Grid()

        if len(services) == 0:
            grid.set_row_spacing(style.DEFAULT_SPACING)

            icon = Icon(pixel_size=style.LARGE_ICON_SIZE,
                        icon_name='module-webaccount',
                        stroke_color=style.COLOR_BUTTON_GREY.get_svg(),
                        fill_color=style.COLOR_TRANSPARENT.get_svg())

            grid.attach(icon, 0, 0, 1, 1)
            icon.show()

            label = Gtk.Label()
            label.set_justify(Gtk.Justification.CENTER)
            label.set_markup(
                '<span foreground="%s" size="large">%s</span>'
                % (style.COLOR_BUTTON_GREY.get_html(),
                   GLib.markup_escape_text(
                       _('No web services are installed.\n'
                         'Please visit %s for more details.' %
                         'http://wiki.sugarlabs.org/go/WebServices'))))
            label.show()
            grid.attach(label, 0, 1, 1, 1)

            alignment = Gtk.Alignment.new(0.5, 0.5, 0.1, 0.1)
            alignment.add(grid)
            grid.show()

            self.add(alignment)
            alignment.show()
            return

        grid.set_row_spacing(style.DEFAULT_SPACING * 4)
        grid.set_column_spacing(style.DEFAULT_SPACING * 4)
        grid.set_border_width(style.DEFAULT_SPACING * 2)
        grid.set_column_homogeneous(True)

        width = Gdk.Screen.width() - 2 * style.GRID_CELL_SIZE
        nx = int(width / (style.GRID_CELL_SIZE + style.DEFAULT_SPACING * 4))

        self._service_config_box = Gtk.VBox()

        x = 0
        y = 0
        for service in services:
            service_grid = Gtk.Grid()
            icon = CanvasIcon(icon_name=service.get_icon_name())
            icon.show()
            service_grid.attach(icon, x, y, 1, 1)

            icon.connect('activate', service.config_service_cb, None,
                         self._service_config_box)

            label = Gtk.Label()
            label.set_justify(Gtk.Justification.CENTER)
            name = get_service_name(service)
            label.set_markup(name)
            service_grid.attach(label, x, y + 1, 1, 1)
            label.show()

            grid.attach(service_grid, x, y, 1, 1)
            service_grid.show()

            x += 1
            if x == nx:
                x = 0
                y += 1

        alignment = Gtk.Alignment.new(0.5, 0, 0, 0)
        alignment.add(grid)
        grid.show()

        vbox = Gtk.VBox()
        vbox.pack_start(alignment, False, False, 0)
        alignment.show()

        scrolled = Gtk.ScrolledWindow()
        vbox.pack_start(scrolled, True, True, 0)

        self.add(vbox)
        scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        scrolled.show()

        workspace = Gtk.VBox()
        scrolled.add_with_viewport(workspace)
        workspace.show()

        workspace.add(self._service_config_box)
        workspace.show_all()
        vbox.show()
Esempio n. 7
0
import sys

from gi.repository import Gtk

from jarabe import config
from jarabe.webservice.account import Account
from jarabe.webservice import accountsmanager

ACCOUNT_NAME = 'mock'

tests_dir = os.getcwd()
extension_dir = os.path.join(tests_dir, 'extensions')

os.environ["MOCK_ACCOUNT_STATE"] = str(Account.STATE_VALID)
config.ext_path = extension_dir
sys.path.append(config.ext_path)

window = Gtk.Window()
box = Gtk.HBox()
box.show()
window.add(box)

services = accountsmanager.get_webaccount_services()
for service in services:
    if service.get_icon_name() == ACCOUNT_NAME:
        service.config_service_cb(None, None, box)

window.show()

Gtk.main()
Esempio n. 8
0
 def test_get_webaccount_services(self):
     services = accountsmanager.get_webaccount_services()
     self.assertTrue(len(services) > 0)