DnD of contact on a MUC window to invite

This commit is contained in:
Stephan Erb 2007-07-23 21:20:33 +00:00
parent 6033b20051
commit 07a3393b72
3 changed files with 18 additions and 6 deletions

View File

@ -138,7 +138,8 @@ class ChatControlBase(MessageControl):
self.handlers[id] = widget
# Init DND
self.TARGET_TYPE_URI_LIST = 80
self.dnd_list = [ ( 'text/uri-list', 0, self.TARGET_TYPE_URI_LIST ) ]
self.dnd_list = [ ( 'text/uri-list', 0, self.TARGET_TYPE_URI_LIST ),
('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_APP, 0)]
id = self.widget.connect('drag_data_received',
self._on_drag_data_received)
self.handlers[id] = self.widget

View File

@ -1655,8 +1655,18 @@ class GroupchatControl(ChatControlBase):
def _on_drag_data_received(self, widget, context, x, y, selection,
target_type, timestamp):
# TODO: Invite to groupchat on dnd of a contact
pass
# Invite contact to groupchat
treeview = gajim.interface.roster.tree
model = treeview.get_model()
data = selection.data
path = treeview.get_selection().get_selected_rows()[1][0]
iter = model.get_iter(path)
type = model[iter][2]
account = model[iter][4].decode('utf-8')
if type != 'contact': # source is not a contact
return
contact_jid = data.decode('utf-8')
gajim.connections[self.account].send_invite(self.room_jid, contact_jid)
def handle_message_textview_mykey_press(self, widget, event_keyval,
event_keymod):

View File

@ -5190,7 +5190,8 @@ class RosterWindow:
#signals
self.TARGET_TYPE_URI_LIST = 80
TARGETS = [('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0)]
TARGETS = [('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_APP | gtk.TARGET_SAME_WIDGET,
0)]
TARGETS2 = [('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0),
('text/uri-list', 0, self.TARGET_TYPE_URI_LIST)]
self.tree.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, TARGETS,