we can now send messages to groupchats
This commit is contained in:
parent
4658ab8927
commit
2264da922b
3 changed files with 50 additions and 16 deletions
|
@ -466,6 +466,12 @@ class GajimCore:
|
||||||
msg.setType('chat')
|
msg.setType('chat')
|
||||||
con.send(msg)
|
con.send(msg)
|
||||||
self.hub.sendPlugin('MSGSENT', ev[1], ev[2])
|
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))
|
#('SUB', account, (jid, txt))
|
||||||
elif ev[0] == 'SUB':
|
elif ev[0] == 'SUB':
|
||||||
log.debug('subscription request for %s' % ev[2][0])
|
log.debug('subscription request for %s' % ev[2][0])
|
||||||
|
|
|
@ -7110,12 +7110,12 @@ when NOT online</property>
|
||||||
<widget class="GtkTextView" id="textview">
|
<widget class="GtkTextView" id="textview">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">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="overwrite">False</property>
|
||||||
<property name="accepts_tab">True</property>
|
<property name="accepts_tab">True</property>
|
||||||
<property name="justification">GTK_JUSTIFY_LEFT</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="cursor_visible">False</property>
|
||||||
<property name="pixels_above_lines">0</property>
|
<property name="pixels_above_lines">0</property>
|
||||||
<property name="pixels_below_lines">0</property>
|
<property name="pixels_below_lines">0</property>
|
||||||
<property name="pixels_inside_wrap">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="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||||
<property name="modal">False</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="resizable">True</property>
|
||||||
<property name="destroy_with_parent">False</property>
|
<property name="destroy_with_parent">False</property>
|
||||||
<property name="decorated">True</property>
|
<property name="decorated">True</property>
|
||||||
|
@ -7153,6 +7155,7 @@ when NOT online</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkVBox" id="vbox27">
|
<widget class="GtkVBox" id="vbox27">
|
||||||
|
<property name="border_width">5</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="spacing">0</property>
|
<property name="spacing">0</property>
|
||||||
|
@ -7218,6 +7221,7 @@ when NOT online</property>
|
||||||
<widget class="GtkVPaned" id="vpaned2">
|
<widget class="GtkVPaned" id="vpaned2">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="position">280</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkNotebook" id="notebook">
|
<widget class="GtkNotebook" id="notebook">
|
||||||
|
@ -7233,7 +7237,7 @@ when NOT online</property>
|
||||||
<widget class="GtkHPaned" id="hpaned">
|
<widget class="GtkHPaned" id="hpaned">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="position">50</property>
|
<property name="position">100</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkScrolledWindow" id="scrolledwindow17">
|
<widget class="GtkScrolledWindow" id="scrolledwindow17">
|
||||||
|
@ -7274,12 +7278,12 @@ when NOT online</property>
|
||||||
<widget class="GtkTextView" id="conversation">
|
<widget class="GtkTextView" id="conversation">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">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="overwrite">False</property>
|
||||||
<property name="accepts_tab">True</property>
|
<property name="accepts_tab">True</property>
|
||||||
<property name="justification">GTK_JUSTIFY_LEFT</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="cursor_visible">False</property>
|
||||||
<property name="pixels_above_lines">0</property>
|
<property name="pixels_above_lines">0</property>
|
||||||
<property name="pixels_below_lines">0</property>
|
<property name="pixels_below_lines">0</property>
|
||||||
<property name="pixels_inside_wrap">0</property>
|
<property name="pixels_inside_wrap">0</property>
|
||||||
|
@ -7344,7 +7348,7 @@ when NOT online</property>
|
||||||
<property name="overwrite">False</property>
|
<property name="overwrite">False</property>
|
||||||
<property name="accepts_tab">True</property>
|
<property name="accepts_tab">True</property>
|
||||||
<property name="justification">GTK_JUSTIFY_LEFT</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="cursor_visible">True</property>
|
||||||
<property name="pixels_above_lines">0</property>
|
<property name="pixels_above_lines">0</property>
|
||||||
<property name="pixels_below_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="right_margin">0</property>
|
||||||
<property name="indent">0</property>
|
<property name="indent">0</property>
|
||||||
<property name="text" translatable="yes"></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>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -307,6 +307,25 @@ class gc:
|
||||||
"""When Cancel button is clicked"""
|
"""When Cancel button is clicked"""
|
||||||
widget.get_toplevel().destroy()
|
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):
|
def print_conversation(self, txt, contact = None, tim = None):
|
||||||
"""Print a line in the conversation :
|
"""Print a line in the conversation :
|
||||||
if contact is set : it's a message from someone
|
if contact is set : it's a message from someone
|
||||||
|
@ -320,12 +339,12 @@ class gc:
|
||||||
tim = time.strftime("[%H:%M:%S]")
|
tim = time.strftime("[%H:%M:%S]")
|
||||||
buffer.insert(end_iter, tim)
|
buffer.insert(end_iter, tim)
|
||||||
if contact:
|
if contact:
|
||||||
#TODO it a message from me
|
if contact == self.nick:
|
||||||
if contact == '':
|
buffer.insert_with_tags_by_name(end_iter, '<'+contact+'> ', \
|
||||||
buffer.insert_with_tags_by_name(end_iter, '<'+contact+'> ', 'outgoing')
|
'outgoing')
|
||||||
else:
|
else:
|
||||||
buffer.insert_with_tags_by_name(end_iter, '<' + \
|
buffer.insert_with_tags_by_name(end_iter, '<' + contact + '> ', \
|
||||||
contact + '> ', 'incoming')
|
'incoming')
|
||||||
buffer.insert(end_iter, txt+'\n')
|
buffer.insert(end_iter, txt+'\n')
|
||||||
else:
|
else:
|
||||||
buffer.insert_with_tags_by_name(end_iter, txt+'\n', \
|
buffer.insert_with_tags_by_name(end_iter, txt+'\n', \
|
||||||
|
@ -333,12 +352,14 @@ class gc:
|
||||||
#scroll to the end of the textview
|
#scroll to the end of the textview
|
||||||
conversation.scroll_to_mark(buffer.get_mark('end'), 0.1, 0, 0, 0)
|
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.jid = jid
|
||||||
|
self.nick = nick
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
self.account = account
|
self.account = account
|
||||||
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Gc', APP)
|
self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Gc', APP)
|
||||||
self.window = self.xml.get_widget('Gc')
|
self.window = self.xml.get_widget('Gc')
|
||||||
|
self.list = self.xml.get_widget('list')
|
||||||
conversation = self.xml.get_widget('conversation')
|
conversation = self.xml.get_widget('conversation')
|
||||||
buffer = conversation.get_buffer()
|
buffer = conversation.get_buffer()
|
||||||
end_iter = buffer.get_end_iter()
|
end_iter = buffer.get_end_iter()
|
||||||
|
@ -353,6 +374,8 @@ class gc:
|
||||||
color = self.plugin.config['statusmsgcolor']
|
color = self.plugin.config['statusmsgcolor']
|
||||||
self.tagStatus.set_property("foreground", color)
|
self.tagStatus.set_property("foreground", color)
|
||||||
self.xml.signal_connect('gtk_widget_destroy', self.delete_event)
|
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:
|
class join_gc:
|
||||||
def delete_event(self, widget):
|
def delete_event(self, widget):
|
||||||
|
@ -370,8 +393,8 @@ class join_gc:
|
||||||
server = self.xml.get_widget('entry_server').get_text()
|
server = self.xml.get_widget('entry_server').get_text()
|
||||||
passw = self.xml.get_widget('entry_pass').get_text()
|
passw = self.xml.get_widget('entry_pass').get_text()
|
||||||
jid = '%s@%s' % (room, server)
|
jid = '%s@%s' % (room, server)
|
||||||
self.plugin.windows[self.account]['chats'][jid] = gc(jid, self.plugin,\
|
self.plugin.windows[self.account]['chats'][jid] = gc(jid, nick, \
|
||||||
self.account)
|
self.plugin, self.account)
|
||||||
#TODO: verify entries
|
#TODO: verify entries
|
||||||
self.plugin.send('GC_JOIN', self.account, (nick, room, server, passw))
|
self.plugin.send('GC_JOIN', self.account, (nick, room, server, passw))
|
||||||
widget.get_toplevel().destroy()
|
widget.get_toplevel().destroy()
|
||||||
|
|
Loading…
Add table
Reference in a new issue