Пример #1
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
Пример #2
0
    def __init__(self):
        logging.debug('STARTUP: Loading the group view')

        gobject.GObject.__init__(self)

        self._box = hippo.CanvasBox()
        self._box.props.background_color = style.COLOR_WHITE.get_int()
        self.set_root(self._box)

        self._friends = {}

        self._layout = SpreadLayout()
        self._box.set_layout(self._layout)

        client = gconf.client_get_default()
        color = XoColor(client.get_string('/desktop/sugar/user/color'))

        self._owner_icon = CanvasIcon(icon_name='computer-xo', cache=True,
                                      xo_color=color)
        self._owner_icon.props.size = style.LARGE_ICON_SIZE

        self._owner_icon.set_palette(BuddyMenu(get_owner_instance()))
        self._layout.add(self._owner_icon)

        friends_model = friends.get_model()

        for friend in friends_model:
            self.add_friend(friend)

        friends_model.connect('friend-added', self._friend_added_cb)
        friends_model.connect('friend-removed', self._friend_removed_cb)
Пример #3
0
    def __init__(self):
        GObject.GObject.__init__(self)

        self._buddies = {None: get_owner_instance()}
        self._activities = {}
        self._link_local_account = None
        self._server_account = None
        self._shell_model = shell.get_model()

        client = GConf.Client.get_default()
        client.add_dir('/desktop/sugar/collaboration',
                       GConf.ClientPreloadType.PRELOAD_NONE)
        client.notify_add('/desktop/sugar/collaboration/jabber_server',
                          self.__jabber_server_changed_cb, None)
        client.add_dir(
            '/desktop/sugar/user/nick', GConf.ClientPreloadType.PRELOAD_NONE)
        client.notify_add(
            '/desktop/sugar/user/nick', self.__nick_changed_cb, None)

        bus = dbus.Bus()
        obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, ACCOUNT_MANAGER_PATH)
        account_manager = dbus.Interface(obj, ACCOUNT_MANAGER)
        account_manager.Get(ACCOUNT_MANAGER, 'ValidAccounts',
                            dbus_interface=PROPERTIES_IFACE,
                            reply_handler=self.__got_accounts_cb,
                            error_handler=self.__error_handler_cb)
Пример #4
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
Пример #5
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())
        p_icon = Icon(file=self._model.bundle.get_icon(),
                      xo_color=self._model.get_color())
        p_icon.props.icon_size = gtk.ICON_SIZE_LARGE_TOOLBAR
        p = palette.Palette(None,
                            primary_text=primary_text,
                            secondary_text=secondary_text,
                            icon=p_icon)

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

        if joined:
            item = MenuItem(_('Resume'), 'activity-start')
            item.connect('activate', self._clicked_cb)
            item.show()
            p.menu.append(item)
        elif not private:
            item = MenuItem(_('Join'), 'activity-start')
            item.connect('activate', self._clicked_cb)
            item.show()
            p.menu.append(item)

        return p
Пример #6
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
Пример #7
0
    def __init__(self):
        GObject.GObject.__init__(self)

        self._buddies = {None: get_owner_instance()}
        self._activities = {}
        self._link_local_account = None
        self._server_account = None
        self._shell_model = shell.get_model()

        self._settings_collaboration = \
            Gio.Settings('org.sugarlabs.collaboration')
        self._settings_collaboration.connect('changed::jabber-server',
                                             self.__jabber_server_changed_cb,
                                             None)
        self._settings_user = Gio.Settings('org.sugarlabs.user')
        self._settings_user.connect('changed::nick', self.__nick_changed_cb,
                                    None)

        bus = dbus.Bus()
        obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, ACCOUNT_MANAGER_PATH)
        account_manager = dbus.Interface(obj, ACCOUNT_MANAGER)
        account_manager.Get(ACCOUNT_MANAGER,
                            'ValidAccounts',
                            dbus_interface=PROPERTIES_IFACE,
                            reply_handler=self.__got_accounts_cb,
                            error_handler=self.__error_handler_cb)
Пример #8
0
    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
Пример #9
0
    def __init__(self):
        layout = SpreadLayout()

        # Round off icon size to an even number to ensure that the icon
        self._owner_icon = BuddyIcon(buddy=get_owner_instance(),
                                     pixel_size=style.XLARGE_ICON_SIZE & ~1)
        ViewContainer.__init__(self, layout, self._owner_icon)

        self._animator = animator.Animator(0.3)
        self._animator.connect('completed', self._animation_completed_cb)
Пример #10
0
    def __init__(self, size):
        BuddyIcon.__init__(self, buddy=get_owner_instance(), pixel_size=size)

        # 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)
Пример #11
0
    def __init__(self):
        layout = SpreadLayout()

        # Round off icon size to an even number to ensure that the icon
        owner = get_owner_instance()
        self._owner_icon = Icon(icon_name='computer-xo',
                                xo_color=owner.get_color(),
                                pixel_size=style.XLARGE_ICON_SIZE & ~1)
        ViewContainer.__init__(self, layout, self._owner_icon)

        self._animator = animator.Animator(0.3, widget=self)
        self._animator.connect('completed', self._animation_completed_cb)
Пример #12
0
    def __init__(self):
        layout = SpreadLayout()

        # Round off icon size to an even number to ensure that the icon
        owner = get_owner_instance()
        self._owner_icon = Icon(icon_name='computer-xo',
                                xo_color=owner.get_color(),
                                pixel_size=style.XLARGE_ICON_SIZE & ~1)
        ViewContainer.__init__(self, layout, self._owner_icon)

        self._animator = animator.Animator(0.3, widget=self)
        self._animator.connect('completed', self._animation_completed_cb)
Пример #13
0
    def __neighborhood_activity_added_cb(self, neighborhood_model,
                                         shared_activity):
        logging.debug('FriendsTray.__neighborhood_activity_added_cb')
        active_activity = shell.get_model().get_active_activity()
        if active_activity.get_activity_id() != shared_activity.activity_id:
            return

        self.clear()

        # always display ourselves
        self.add_buddy(get_owner_instance())

        self._set_current_activity(shared_activity.activity_id)
Пример #14
0
    def __active_activity_changed_cb(self, home_model, home_activity):
        logging.debug('FriendsTray.__active_activity_changed_cb')
        self.clear()

        # always display ourselves
        self.add_buddy(get_owner_instance())

        if home_activity is None:
            return

        activity_id = home_activity.get_activity_id()
        if activity_id is None:
            return

        self._set_current_activity(activity_id)
Пример #15
0
    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)
Пример #16
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()
        backup_url = client.get_string('/desktop/sugar/backup_url')
        if not backup_url:
            self._register_menu = MenuItem(_('Register'), 'media-record')
            self._register_menu.connect('activate', self.__register_activate_cb)
            palette.menu.append(self._register_menu)
            self._register_menu.show()

        return palette
Пример #17
0
    def __init__(self):
        gobject.GObject.__init__(self)

        self._box = hippo.CanvasBox()
        self._box.props.background_color = style.COLOR_WHITE.get_int()
        self.set_root(self._box)

        self._layout = _Layout()
        self._box.set_layout(self._layout)

        self._my_icon = BuddyIcon(buddy=get_owner_instance(),
                                  size=style.XLARGE_ICON_SIZE)
        self._box.append(self._my_icon)

        self._animator = animator.Animator(0.3)
        self._animator.connect('completed', self._animation_completed_cb)
Пример #18
0
    def __init__(self, toolbar):
        logging.debug('STARTUP: Loading the mesh view')

        layout = SpreadLayout()

        # Round off icon size to an even number to ensure that the icon
        owner_icon = BuddyIcon(get_owner_instance(),
                               style.STANDARD_ICON_SIZE & ~1)
        ViewContainer.__init__(self, layout, owner_icon)
        self.set_can_focus(False)

        self.wireless_networks = {}
        self._adhoc_manager = None
        self._adhoc_networks = []

        self._model = neighborhood.get_model()
        self._buddies = {}
        self._activities = {}
        self._mesh = []
        self._buddy_to_activity = {}
        self._suspended = True
        self._query = ''

        toolbar.connect('query-changed', self._toolbar_query_changed_cb)
        toolbar.search_entry.connect('icon-press',
                                     self.__clear_icon_pressed_cb)

        for buddy_model in self._model.get_buddies():
            self._add_buddy(buddy_model)

        self._model.connect('buddy-added', self._buddy_added_cb)
        self._model.connect('buddy-removed', self._buddy_removed_cb)

        for activity_model in self._model.get_activities():
            self._add_activity(activity_model)

        self._model.connect('activity-added', self._activity_added_cb)
        self._model.connect('activity-removed', self._activity_removed_cb)

        netmgr_observer = NetworkManagerObserver(self)
        netmgr_observer.listen()
Пример #19
0
    def __init__(self, toolbar):
        logging.debug('STARTUP: Loading the group view')

        layout = SpreadLayout()

        # Round off icon size to an even number to ensure that the icon
        owner_icon = BuddyIcon(get_owner_instance(),
                               style.LARGE_ICON_SIZE & ~1)
        ViewContainer.__init__(self, layout, owner_icon)

        self._query = ''
        toolbar.connect('query-changed', self._toolbar_query_changed_cb)
        toolbar.search_entry.connect('icon-press',
                                     self.__clear_icon_pressed_cb)
        self._friends = {}

        friends_model = friends.get_model()

        for friend in friends_model:
            self.add_friend(friend)

        friends_model.connect('friend-added', self._friend_added_cb)
        friends_model.connect('friend-removed', self._friend_removed_cb)
Пример #20
0
    def _add_selection(self, object_id, selection):
        if not selection.get_data():
            return

        selection_data = selection.get_data()

        selection_type_atom = selection.get_data_type()
        selection_type = selection_type_atom.name()

        logging.debug('ClipboardTray: adding type %r', selection_type)

        cb_service = clipboard.get_instance()
        if selection_type == 'text/uri-list':
            uris = selection.get_uris()
            if len(uris) > 1:
                raise NotImplementedError('Multiple uris in text/uri-list'
                                          ' still not supported.')
            file_name = uris[0]
            buddies = neighborhood.get_model().get_buddies()
            mime_type = mime.get_for_file(file_name)
            title = os.path.basename(file_name)
            dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.YES_NO, "Do you want to start file transfer ?")
            response = dialog.run()
            dialog.destroy()
            if response == Gtk.ResponseType.YES:
                for buddy in buddies:
                    if buddy != get_owner_instance():
                        filetransfer.start_transfer(buddy, file_name, title, "dummy", mime_type)
            cb_service.add_object_format(object_id,
                                         selection_type,
                                         uris[0],
                                         on_disk=True)
        else:
            cb_service.add_object_format(object_id,
                                         selection_type,
                                         selection_data,
                                         on_disk=False)
Пример #21
0
    def create_palette(self):
        primary_text = self._model.bundle.get_name()
        secondary_text = self._model.get_name()
        palette_icon = Icon(file=self._model.bundle.get_icon(),
                            pixel_size=style.STANDARD_ICON_SIZE,
                            xo_color=self._model.get_color())
        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
        is_joinable = self._is_joinable is None or self._is_joinable()

        menu_box = PaletteMenuBox()

        if joined:
            item = PaletteMenuItem(_('Resume'))
            icon = Icon(
                pixel_size=style.SMALL_ICON_SIZE, icon_name='activity-start')
            item.set_image(icon)
            item.connect('activate', self.__palette_item_clicked_cb)
            menu_box.append_item(item)
        elif not private and is_joinable:
            item = PaletteMenuItem(_('Join'))
            icon = Icon(
                pixel_size=style.SMALL_ICON_SIZE, 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
Пример #22
0
    def __init__(self):
        GObject.GObject.__init__(self)

        self._buddies = {None: get_owner_instance()}
        self._activities = {}
        self._link_local_account = None
        self._server_account = None
        self._shell_model = shell.get_model()

        self._settings_collaboration = \
            Gio.Settings('org.sugarlabs.collaboration')
        self._settings_collaboration.connect(
            'changed::jabber-server', self.__jabber_server_changed_cb)
        self._settings_user = Gio.Settings('org.sugarlabs.user')
        self._settings_user.connect(
            'changed::nick', self.__nick_changed_cb)

        bus = dbus.Bus()
        obj = bus.get_object(ACCOUNT_MANAGER_SERVICE, ACCOUNT_MANAGER_PATH)
        account_manager = dbus.Interface(obj, ACCOUNT_MANAGER)
        account_manager.Get(ACCOUNT_MANAGER, 'ValidAccounts',
                            dbus_interface=PROPERTIES_IFACE,
                            reply_handler=self.__got_accounts_cb,
                            error_handler=self.__error_handler_cb)
Пример #23
0
    def __init__(self, size):
        BuddyIcon.__init__(self, buddy=get_owner_instance(), size=size)

        self._palette_enabled = False
        self._register_menu = None