Filter presence by activity
This commit is contained in:
parent
0cae557ab5
commit
9db404afb9
@ -31,6 +31,9 @@ class BrowserActivity(activity.Activity):
|
|||||||
self._share_service = None
|
self._share_service = None
|
||||||
self._model = None
|
self._model = None
|
||||||
|
|
||||||
|
def get_default_type(self):
|
||||||
|
return _BROWSER_ACTIVITY_TYPE
|
||||||
|
|
||||||
def _update_shared_location(self):
|
def _update_shared_location(self):
|
||||||
address = self.embed.get_address()
|
address = self.embed.get_address()
|
||||||
self._model.set_value('address', address)
|
self._model.set_value('address', address)
|
||||||
|
@ -9,6 +9,7 @@ class PresenceWindow(gtk.Window):
|
|||||||
_MODEL_COL_NICK = 0
|
_MODEL_COL_NICK = 0
|
||||||
_MODEL_COL_ICON = 1
|
_MODEL_COL_ICON = 1
|
||||||
_MODEL_COL_BUDDY = 2
|
_MODEL_COL_BUDDY = 2
|
||||||
|
_MODEL_COL_VISIBLE = 3
|
||||||
|
|
||||||
def __init__(self, activity_container):
|
def __init__(self, activity_container):
|
||||||
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
|
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
|
||||||
@ -23,6 +24,18 @@ class PresenceWindow(gtk.Window):
|
|||||||
|
|
||||||
self._setup_ui()
|
self._setup_ui()
|
||||||
|
|
||||||
|
def _is_buddy_visible(self, buddy):
|
||||||
|
activity_type = self._activity.get_default_type()
|
||||||
|
buddy.get_service_of_type(activity, activity_type)
|
||||||
|
|
||||||
|
def _update_buddies_visibility(self):
|
||||||
|
for row in self._buddy_store:
|
||||||
|
row[_MODEL_COL_VISIBLE] = self._is_buddy_visible(row[_MODEL_COL_BUDDY])
|
||||||
|
|
||||||
|
def set_activity(self, activity):
|
||||||
|
self._activity = activity
|
||||||
|
self._update_buddies_visibility()
|
||||||
|
|
||||||
def _setup_ui(self):
|
def _setup_ui(self):
|
||||||
vbox = gtk.VBox(False, 6)
|
vbox = gtk.VBox(False, 6)
|
||||||
vbox.set_border_width(12)
|
vbox.set_border_width(12)
|
||||||
@ -32,9 +45,12 @@ class PresenceWindow(gtk.Window):
|
|||||||
vbox.pack_start(label, False)
|
vbox.pack_start(label, False)
|
||||||
label.show()
|
label.show()
|
||||||
|
|
||||||
self._buddy_list_model = gtk.ListStore(gobject.TYPE_STRING,
|
self._buddy_store = gtk.ListStore(gobject.TYPE_STRING,
|
||||||
gtk.gdk.Pixbuf,
|
gtk.gdk.Pixbuf,
|
||||||
gobject.TYPE_PYOBJECT)
|
gobject.TYPE_PYOBJECT,
|
||||||
|
bool)
|
||||||
|
self._buddy_list_model = self._buddy_store.filter_new()
|
||||||
|
self._buddy_list_model.set_visible_column(self._MODEL_COL_VISIBLE)
|
||||||
|
|
||||||
sw = gtk.ScrolledWindow()
|
sw = gtk.ScrolledWindow()
|
||||||
sw.set_shadow_type(gtk.SHADOW_IN)
|
sw.set_shadow_type(gtk.SHADOW_IN)
|
||||||
@ -107,7 +123,8 @@ class PresenceWindow(gtk.Window):
|
|||||||
aniter = self._buddy_list_model.append(None)
|
aniter = self._buddy_list_model.append(None)
|
||||||
self._buddy_list_model.set(aniter,
|
self._buddy_list_model.set(aniter,
|
||||||
self._MODEL_COL_NICK, buddy.get_nick_name(),
|
self._MODEL_COL_NICK, buddy.get_nick_name(),
|
||||||
self._MODEL_COL_BUDDY, buddy)
|
self._MODEL_COL_BUDDY, buddy,
|
||||||
|
self._MODEL_COL_VISIBLE, self._is_buddy_visible(buddy))
|
||||||
buddy.connect('icon-changed', self.__buddy_icon_changed_cb)
|
buddy.connect('icon-changed', self.__buddy_icon_changed_cb)
|
||||||
|
|
||||||
def _on_buddy_disappeared_cb(self, pservice, buddy):
|
def _on_buddy_disappeared_cb(self, pservice, buddy):
|
||||||
|
@ -250,6 +250,16 @@ class ActivityContainer(dbus.service.Object):
|
|||||||
# Create our owner service
|
# Create our owner service
|
||||||
self._owner = ShellOwner()
|
self._owner = ShellOwner()
|
||||||
|
|
||||||
|
self._presence_window = PresenceWindow(self)
|
||||||
|
self._presence_window.set_transient_for(self.window)
|
||||||
|
|
||||||
|
wm = WindowManager(self._presence_window)
|
||||||
|
|
||||||
|
wm.set_width(0.15, WindowManager.SCREEN_RELATIVE)
|
||||||
|
wm.set_height(1.0, WindowManager.SCREEN_RELATIVE)
|
||||||
|
wm.set_position(WindowManager.LEFT)
|
||||||
|
wm.manage()
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
|
||||||
@ -259,6 +269,9 @@ class ActivityContainer(dbus.service.Object):
|
|||||||
def __focus_error_cb(self, error):
|
def __focus_error_cb(self, error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def set_current_activity(self, activity):
|
||||||
|
self.current_activity = activity
|
||||||
|
self._presence_window.set_activity(activity)
|
||||||
|
|
||||||
def notebook_tab_changed(self, notebook, page, page_number):
|
def notebook_tab_changed(self, notebook, page, page_number):
|
||||||
#print "in notebook_tab_changed"
|
#print "in notebook_tab_changed"
|
||||||
@ -272,7 +285,7 @@ class ActivityContainer(dbus.service.Object):
|
|||||||
self.current_activity.peer_service.lost_focus(reply_handler = self.__focus_reply_cb, error_handler = self.__focus_error_cb)
|
self.current_activity.peer_service.lost_focus(reply_handler = self.__focus_reply_cb, error_handler = self.__focus_error_cb)
|
||||||
|
|
||||||
if self.has_activity(new_activity):
|
if self.has_activity(new_activity):
|
||||||
self.current_activity = new_activity
|
self.set_current_activity(new_activity)
|
||||||
|
|
||||||
if self.current_activity != None:
|
if self.current_activity != None:
|
||||||
if self.has_activity(self.current_activity):
|
if self.has_activity(self.current_activity):
|
||||||
@ -405,16 +418,6 @@ def main():
|
|||||||
wm.show()
|
wm.show()
|
||||||
wm.manage()
|
wm.manage()
|
||||||
|
|
||||||
presence_window = PresenceWindow(activity_container)
|
|
||||||
presence_window.set_transient_for(activity_container.window)
|
|
||||||
|
|
||||||
wm = WindowManager(presence_window)
|
|
||||||
|
|
||||||
wm.set_width(0.15, WindowManager.SCREEN_RELATIVE)
|
|
||||||
wm.set_height(1.0, WindowManager.SCREEN_RELATIVE)
|
|
||||||
wm.set_position(WindowManager.LEFT)
|
|
||||||
wm.manage()
|
|
||||||
|
|
||||||
group_chat = GroupChat()
|
group_chat = GroupChat()
|
||||||
group_chat.set_transient_for(activity_container.window)
|
group_chat.set_transient_for(activity_container.window)
|
||||||
group_chat.set_decorated(False)
|
group_chat.set_decorated(False)
|
||||||
|
Loading…
Reference in New Issue
Block a user