use our roster filter as soon as we type a letter. Fixes #5221
[gajim.git] / src / groups.py
blobf38cce2381562cf3dec4b2c7d1ebf109a85ec294
1 # -*- coding:utf-8 -*-
2 ## src/groups.py
3 ##
4 ## Copyright (C) 2006-2010 Yann Leboulanger <asterix AT lagaule.org>
5 ## Copyright (C) 2006 Tomasz Melcer <liori AT exroot.org>
6 ##
7 ## This file is part of Gajim.
8 ##
9 ## Gajim is free software; you can redistribute it and/or modify
10 ## it under the terms of the GNU General Public License as published
11 ## by the Free Software Foundation; version 3 only.
13 ## Gajim is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ## GNU General Public License for more details.
18 ## You should have received a copy of the GNU General Public License
19 ## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
22 '''Window to create new post for discussion groups service.'''
24 from common import gajim, xmpp
25 import gtkgui_helpers
27 class GroupsPostWindow:
28 def __init__(self, account, servicejid, groupid):
29 """
30 Open new 'create post' window to create message for groupid on servicejid
31 service
32 """
33 assert isinstance(servicejid, basestring)
34 assert isinstance(groupid, basestring)
36 self.account = account
37 self.servicejid = servicejid
38 self.groupid = groupid
40 self.xml = gtkgui_helpers.get_gtk_builder('groups_post_window.ui')
41 self.window = self.xml.get_object('groups_post_window')
42 for name in ('from_entry', 'subject_entry', 'contents_textview'):
43 self.__dict__[name] = self.xml.get_object(name)
45 self.xml.connect_signals(self)
46 self.window.show_all()
48 def on_cancel_button_clicked(self, w):
49 """
50 Close window
51 """
52 self.window.destroy()
54 def on_send_button_clicked(self, w):
55 """
56 Gather info from widgets and send it as a message
57 """
58 # constructing item to publish... that's atom:entry element
59 item = xmpp.Node('entry', {'xmlns':'http://www.w3.org/2005/Atom'})
60 author = item.addChild('author')
61 author.addChild('name', {}, [self.from_entry.get_text()])
62 item.addChild('generator', {}, ['Gajim'])
63 item.addChild('title', {}, [self.subject_entry.get_text()])
64 item.addChild('id', {}, ['0'])
66 buf = self.contents_textview.get_buffer()
67 item.addChild('content', {}, [buf.get_text(buf.get_start_iter(), buf.get_end_iter())])
69 # publish it to node
70 gajim.connections[self.account].send_pb_publish(self.servicejid, self.groupid, item, '0')
72 # close the window
73 self.window.destroy()