Skip to content
Snippets Groups Projects
Commit 2264da92 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

we can now send messages to groupchats

parent 4658ab89
No related branches found
No related tags found
No related merge requests found
......@@ -466,6 +466,12 @@ class GajimCore:
msg.setType('chat')
con.send(msg)
self.hub.sendPlugin('MSGSENT', ev[1], ev[2])
#('GC_MSG', account, (jid, msg))
elif ev[0] == 'GC_MSG':
msg = common.jabber.Message(ev[2][0], ev[2][1])
msg.setType('groupchat')
con.send(msg)
self.hub.sendPlugin('MSGSENT', ev[1], ev[2])
#('SUB', account, (jid, txt))
elif ev[0] == 'SUB':
log.debug('subscription request for %s' % ev[2][0])
......
......@@ -7110,12 +7110,12 @@ when NOT online</property>
<widget class="GtkTextView" id="textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="editable">False</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">False</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
......@@ -7142,6 +7142,8 @@ when NOT online</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">600</property>
<property name="default_height">400</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
......@@ -7153,6 +7155,7 @@ when NOT online</property>
<child>
<widget class="GtkVBox" id="vbox27">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
......@@ -7218,6 +7221,7 @@ when NOT online</property>
<widget class="GtkVPaned" id="vpaned2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">280</property>
<child>
<widget class="GtkNotebook" id="notebook">
......@@ -7233,7 +7237,7 @@ when NOT online</property>
<widget class="GtkHPaned" id="hpaned">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="position">50</property>
<property name="position">100</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow17">
......@@ -7274,12 +7278,12 @@ when NOT online</property>
<widget class="GtkTextView" id="conversation">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="editable">False</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="cursor_visible">True</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">False</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
<property name="pixels_inside_wrap">0</property>
......@@ -7344,7 +7348,7 @@ when NOT online</property>
<property name="overwrite">False</property>
<property name="accepts_tab">True</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_NONE</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">0</property>
<property name="pixels_below_lines">0</property>
......@@ -7353,6 +7357,7 @@ when NOT online</property>
<property name="right_margin">0</property>
<property name="indent">0</property>
<property name="text" translatable="yes"></property>
<signal name="key_press_event" handler="on_msg_key_press_event" last_modification_time="Thu, 05 Aug 2004 15:29:07 GMT"/>
</widget>
</child>
</widget>
......
......@@ -307,6 +307,25 @@ class gc:
"""When Cancel button is clicked"""
widget.get_toplevel().destroy()
def on_msg_key_press_event(self, widget, event):
"""When a key is pressed :
if enter is pressed without the shit key, message (if not empty) is sent
and printed in the conversation"""
if event.keyval == gtk.keysyms.Return:
if (event.state & gtk.gdk.SHIFT_MASK):
return 0
txt_buffer = widget.get_buffer()
start_iter = txt_buffer.get_start_iter()
end_iter = txt_buffer.get_end_iter()
txt = txt_buffer.get_text(start_iter, end_iter, 0)
print self.jid
if txt != '':
self.plugin.send('GC_MSG', self.account, (self.jid, txt))
txt_buffer.set_text('', -1)
widget.grab_focus()
return 1
return 0
def print_conversation(self, txt, contact = None, tim = None):
"""Print a line in the conversation :
if contact is set : it's a message from someone
......@@ -320,12 +339,12 @@ class gc:
tim = time.strftime("[%H:%M:%S]")
buffer.insert(end_iter, tim)
if contact:
#TODO it a message from me
if contact == '':
buffer.insert_with_tags_by_name(end_iter, '<'+contact+'> ', 'outgoing')
if contact == self.nick:
buffer.insert_with_tags_by_name(end_iter, '<'+contact+'> ', \
'outgoing')
else:
buffer.insert_with_tags_by_name(end_iter, '<' + \
contact + '> ', 'incoming')
buffer.insert_with_tags_by_name(end_iter, '<' + contact + '> ', \
'incoming')
buffer.insert(end_iter, txt+'\n')
else:
buffer.insert_with_tags_by_name(end_iter, txt+'\n', \
......@@ -333,12 +352,14 @@ class gc:
#scroll to the end of the textview
conversation.scroll_to_mark(buffer.get_mark('end'), 0.1, 0, 0, 0)
def __init__(self, jid, plugin, account):
def __init__(self, jid, nick, plugin, account):
self.jid = jid
self.nick = nick
self.plugin = plugin
self.account = account
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Gc', APP)
self.window = self.xml.get_widget('Gc')
self.list = self.xml.get_widget('list')
conversation = self.xml.get_widget('conversation')
buffer = conversation.get_buffer()
end_iter = buffer.get_end_iter()
......@@ -353,6 +374,8 @@ class gc:
color = self.plugin.config['statusmsgcolor']
self.tagStatus.set_property("foreground", color)
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
self.xml.signal_connect('on_msg_key_press_event', \
self.on_msg_key_press_event)
class join_gc:
def delete_event(self, widget):
......@@ -370,8 +393,8 @@ class join_gc:
server = self.xml.get_widget('entry_server').get_text()
passw = self.xml.get_widget('entry_pass').get_text()
jid = '%s@%s' % (room, server)
self.plugin.windows[self.account]['chats'][jid] = gc(jid, self.plugin,\
self.account)
self.plugin.windows[self.account]['chats'][jid] = gc(jid, nick, \
self.plugin, self.account)
#TODO: verify entries
self.plugin.send('GC_JOIN', self.account, (nick, room, server, passw))
widget.get_toplevel().destroy()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment