def test_add_friend(self):
     try:
         newBuddy = buddy.BaseBuddyModel()
         newBuddy.set_nick(self._buddyName)
         newBuddy.set_key(self._buddyKey)
         friend.get_model().add_friend(newBuddy)
         pass
     except:
         self.fail("unable to add buddy")
    def test_has_friend(self):
        try:
            newBuddy = buddy.BaseBuddyModel()
            newBuddy.set_nick(self._buddyName)
            newBuddy.set_key(self._buddyKey)
            friend.get_model().add_friend(newBuddy)

            hasFriend = friend.get_model().has_buddy(newBuddy)
            self.assertTrue(hasFriend)
        except:
            self.fail("unable to check for buddy")
Exemplo n.º 3
0
    def __init__(self):
        Gtk.Menu.__init__(self)

        if filetransfer.file_transfer_available():
            friends_model = friends.get_model()
            for friend in friends_model:
                if friend.is_present():
                    menu_item = MenuItem(text_label=friend.get_nick(),
                                         icon_name='computer-xo',
                                         xo_color=friend.get_color())
                    menu_item.connect('activate', self.__item_activate_cb,
                                      friend)
                    self.append(menu_item)
                    menu_item.show()

            if not self.get_children():
                menu_item = MenuItem(_('No friends present'))
                menu_item.set_sensitive(False)
                self.append(menu_item)
                menu_item.show()
        else:
            menu_item = MenuItem(_('No valid connection found'))
            menu_item.set_sensitive(False)
            self.append(menu_item)
            menu_item.show()
Exemplo n.º 4
0
    def __init__(self):
        Gtk.Menu.__init__(self)

        if filetransfer.file_transfer_available():
            friends_model = friends.get_model()
            for friend in friends_model:
                if friend.is_present():
                    menu_item = MenuItem(text_label=friend.get_nick(),
                                         icon_name='computer-xo',
                                         xo_color=friend.get_color())
                    menu_item.connect('activate', self.__item_activate_cb,
                                      friend)
                    self.append(menu_item)
                    menu_item.show()

            if not self.get_children():
                menu_item = MenuItem(_('No friends present'))
                menu_item.set_sensitive(False)
                self.append(menu_item)
                menu_item.show()
        else:
            menu_item = MenuItem(_('No valid connection found'))
            menu_item.set_sensitive(False)
            self.append(menu_item)
            menu_item.show()
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
0
    def _add_buddy_items(self):
        if friends.get_model().has_buddy(self._buddy):
            menu_item = MenuItem(_('Remove friend'), 'list-remove')
            menu_item.connect('activate', self._remove_friend_cb)
        else:
            menu_item = MenuItem(_('Make friend'), 'list-add')
            menu_item.connect('activate', self._make_friend_cb)

        self.menu.append(menu_item)
        menu_item.show()

        self._invite_menu = MenuItem('')
        self._invite_menu.connect('activate', self._invite_friend_cb)
        self.menu.append(self._invite_menu)

        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)
Exemplo n.º 9
0
    def _add_buddy_items(self):
        if friends.get_model().has_buddy(self._buddy):
            menu_item = MenuItem(_('Remove friend'), 'list-remove')
            menu_item.connect('activate', self._remove_friend_cb)
        else:
            menu_item = MenuItem(_('Make friend'), 'list-add')
            menu_item.connect('activate', self._make_friend_cb)

        self.menu.append(menu_item)
        menu_item.show()

        self._invite_menu = MenuItem('')
        self._invite_menu.connect('activate', self._invite_friend_cb)
        self.menu.append(self._invite_menu)

        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)
Exemplo n.º 10
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)
Exemplo n.º 11
0
 def _remove_friend_cb(self, menuitem):
     friends.get_model().remove(self._buddy)
Exemplo n.º 12
0
 def _make_friend_cb(self, menuitem):
     friends.get_model().make_friend(self._buddy)
Exemplo n.º 13
0
 def _remove_friend_cb(self, menuitem):
     friends.get_model().remove(self._buddy)
Exemplo n.º 14
0
 def _make_friend_cb(self, menuitem):
     friends.get_model().make_friend(self._buddy)
 def test_get_model(self):
     try:
         friendModel = friend.get_model()
         self.assertIsNotNone(friendModel)
     except:
         self.fail("unable to get friend model")