use new dataform widget in groupchat config window
This commit is contained in:
parent
8fc93418a2
commit
3534bb30cd
|
@ -1232,11 +1232,12 @@ class Connection(ConnectionHandlers):
|
|||
item.setAttr('affiliation', affiliation)
|
||||
self.connection.send(iq)
|
||||
|
||||
def send_gc_config(self, room_jid, config):
|
||||
def send_gc_config(self, room_jid, form):
|
||||
iq = common.xmpp.Iq(typ = 'set', to = room_jid, queryNS =\
|
||||
common.xmpp.NS_MUC_OWNER)
|
||||
query = iq.getTag('query')
|
||||
self.build_data_from_dict(query, config)
|
||||
form.setAttr('type', 'submit')
|
||||
query.addChild(node = form)
|
||||
self.connection.send(iq)
|
||||
|
||||
def gpg_passphrase(self, passphrase):
|
||||
|
|
|
@ -1849,8 +1849,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
|||
node = q
|
||||
if not node:
|
||||
return
|
||||
dic = self.parse_data_form(node)
|
||||
self.dispatch('GC_CONFIG', (helpers.get_full_jid_from_iq(iq_obj), dic))
|
||||
self.dispatch('GC_CONFIG', (helpers.get_full_jid_from_iq(iq_obj), node))
|
||||
|
||||
def _MucAdminCB(self, con, iq_obj):
|
||||
gajim.log.debug('MucAdminCB')
|
||||
|
|
|
@ -28,6 +28,7 @@ import dialogs
|
|||
import cell_renderer_image
|
||||
import message_control
|
||||
import chat_control
|
||||
import dataforms_widget
|
||||
|
||||
try:
|
||||
import gtkspell
|
||||
|
@ -41,6 +42,7 @@ from common import connection
|
|||
from common import passwords
|
||||
from common import zeroconf
|
||||
from common import dbus_support
|
||||
from common import dataforms
|
||||
|
||||
from common.exceptions import GajimGeneralException
|
||||
|
||||
|
@ -2297,11 +2299,12 @@ class ServiceRegistrationWindow(DataFormWindow):
|
|||
self.window.destroy()
|
||||
|
||||
|
||||
class GroupchatConfigWindow(DataFormWindow):
|
||||
class GroupchatConfigWindow:
|
||||
'''GroupchatConfigWindow class'''
|
||||
def __init__(self, account, room_jid, config = None):
|
||||
DataFormWindow.__init__(self, account, config)
|
||||
def __init__(self, account, room_jid, form = None):
|
||||
self.account = account
|
||||
self.room_jid = room_jid
|
||||
self.form = form
|
||||
self.remove_button = {}
|
||||
self.affiliation_treeview = {}
|
||||
self.list_init = {} # list at the beginning
|
||||
|
@ -2310,9 +2313,25 @@ class GroupchatConfigWindow(DataFormWindow):
|
|||
'owner': _('Owner List'),
|
||||
'admin':_('Administrator List')}
|
||||
|
||||
# Draw the edit affiliation list things
|
||||
self.xml = gtkgui_helpers.get_glade('data_form_window.glade', 'data_form_window')
|
||||
self.window = self.xml.get_widget('data_form_window')
|
||||
self.window.set_transient_for(gajim.interface.roster.window)
|
||||
|
||||
if self.form:
|
||||
config_vbox = self.xml.get_widget('config_vbox')
|
||||
dataform = dataforms.ExtendForm(node = self.form)
|
||||
self.data_form_widget = dataforms_widget.DataFormWidget(dataform)
|
||||
# hide scrollbar of this data_form_widget, we already have in this
|
||||
# widget
|
||||
sw = self.data_form_widget.xml.get_widget('single_form_scrolledwindow')
|
||||
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
|
||||
|
||||
self.data_form_widget.show()
|
||||
config_vbox.pack_start(self.data_form_widget)
|
||||
|
||||
# Draw the edit affiliation list things
|
||||
add_on_vbox = self.xml.get_widget('add_on_vbox')
|
||||
|
||||
|
||||
for affiliation in ('outcast', 'member', 'owner', 'admin'):
|
||||
self.list_init[affiliation] = {}
|
||||
hbox = gtk.HBox(spacing = 5)
|
||||
|
@ -2369,7 +2388,11 @@ class GroupchatConfigWindow(DataFormWindow):
|
|||
gajim.connections[self.account].get_affiliation_list(self.room_jid,
|
||||
affiliation)
|
||||
|
||||
add_on_vbox.show_all()
|
||||
self.xml.signal_autoconnect(self)
|
||||
self.window.show_all()
|
||||
|
||||
def on_cancel_button_clicked(self, widget):
|
||||
self.window.destroy()
|
||||
|
||||
def on_cell_edited(self, cell, path, new_text):
|
||||
model = self.affiliation_treeview['outcast'].get_model()
|
||||
|
@ -2448,9 +2471,9 @@ class GroupchatConfigWindow(DataFormWindow):
|
|||
|
||||
def on_ok_button_clicked(self, widget):
|
||||
# We pressed OK button of the DataFormWindow
|
||||
if self.config:
|
||||
gajim.connections[self.account].send_gc_config(self.room_jid,
|
||||
self.config)
|
||||
if self.form:
|
||||
form = self.data_form_widget.data_form
|
||||
gajim.connections[self.account].send_gc_config(self.room_jid, form)
|
||||
for affiliation in ('outcast', 'member', 'owner', 'admin'):
|
||||
list = {}
|
||||
actual_jid_list = []
|
||||
|
|
|
@ -1119,7 +1119,7 @@ class Interface:
|
|||
gc_control.print_conversation(text)
|
||||
|
||||
def handle_event_gc_config(self, account, array):
|
||||
#('GC_CONFIG', account, (jid, config)) config is a dict
|
||||
#('GC_CONFIG', account, (jid, form)) config is a dict
|
||||
room_jid = array[0].split('/')[0]
|
||||
if room_jid in gajim.automatic_rooms[account]:
|
||||
# use default configuration
|
||||
|
|
Loading…
Reference in New Issue