ability to remove a PEP node
This commit is contained in:
parent
c1ed365521
commit
1b90552446
|
@ -30,6 +30,18 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="spacing">6</property>
|
<property name="spacing">6</property>
|
||||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkButton" id="delete_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
|
||||||
|
<property name="label" translatable="yes">gtk-delete</property>
|
||||||
|
<property name="use_stock">True</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
|
<signal name="clicked" handler="on_delete_button_clicked"/>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkButton" id="configure_button">
|
<widget class="GtkButton" id="configure_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -63,6 +75,9 @@
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkButton" id="close_button">
|
<widget class="GtkButton" id="close_button">
|
||||||
|
@ -75,7 +90,7 @@
|
||||||
<signal name="clicked" handler="on_close_button_clicked"/>
|
<signal name="clicked" handler="on_close_button_clicked"/>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="position">1</property>
|
<property name="position">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -50,7 +50,15 @@ class ConnectionPubSub:
|
||||||
d = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB)
|
d = query.addChild('pubsub', namespace=xmpp.NS_PUBSUB)
|
||||||
d = d.addChild('delete', {'node': node})
|
d = d.addChild('delete', {'node': node})
|
||||||
|
|
||||||
self.connection.send(query)
|
def response(con, resp, jid, node):
|
||||||
|
if resp.getType() == 'result':
|
||||||
|
self.dispatch('PUBSUB_NODE_REMOVED', (jid, node))
|
||||||
|
else:
|
||||||
|
msg = resp.getErrorMsg()
|
||||||
|
self.dispatch('PUBSUB_NODE_NOT_REMOVED', (jid, node, msg))
|
||||||
|
|
||||||
|
self.connection.SendAndCallForResponse(query, response, {'jid': jid,
|
||||||
|
'node': node})
|
||||||
|
|
||||||
def send_pb_create(self, jid, node, configure = False, configure_form = None):
|
def send_pb_create(self, jid, node, configure = False, configure_form = None):
|
||||||
'''Creates new node.'''
|
'''Creates new node.'''
|
||||||
|
|
|
@ -3674,6 +3674,7 @@ class ManagePEPServicesWindow:
|
||||||
self.window = self.xml.get_widget('manage_pep_services_window')
|
self.window = self.xml.get_widget('manage_pep_services_window')
|
||||||
self.window.set_transient_for(gajim.interface.roster.window)
|
self.window.set_transient_for(gajim.interface.roster.window)
|
||||||
self.xml.get_widget('configure_button').set_sensitive(False)
|
self.xml.get_widget('configure_button').set_sensitive(False)
|
||||||
|
self.xml.get_widget('delete_button').set_sensitive(False)
|
||||||
self.xml.signal_autoconnect(self)
|
self.xml.signal_autoconnect(self)
|
||||||
self.account = account
|
self.account = account
|
||||||
|
|
||||||
|
@ -3691,6 +3692,7 @@ class ManagePEPServicesWindow:
|
||||||
|
|
||||||
def on_services_selection_changed(self, sel):
|
def on_services_selection_changed(self, sel):
|
||||||
self.xml.get_widget('configure_button').set_sensitive(True)
|
self.xml.get_widget('configure_button').set_sensitive(True)
|
||||||
|
self.xml.get_widget('delete_button').set_sensitive(True)
|
||||||
|
|
||||||
def init_services(self):
|
def init_services(self):
|
||||||
self.treeview = self.xml.get_widget('services_treeview')
|
self.treeview = self.xml.get_widget('services_treeview')
|
||||||
|
@ -3714,6 +3716,24 @@ class ManagePEPServicesWindow:
|
||||||
if 'jid' in item and item['jid'] == our_jid and 'node' in item:
|
if 'jid' in item and item['jid'] == our_jid and 'node' in item:
|
||||||
self.treestore.append([item['node']])
|
self.treestore.append([item['node']])
|
||||||
|
|
||||||
|
def node_removed(self, node):
|
||||||
|
model = self.treeview.get_model()
|
||||||
|
iter = model.get_iter_root()
|
||||||
|
while iter:
|
||||||
|
if model[iter][0] == node:
|
||||||
|
model.remove(iter)
|
||||||
|
break
|
||||||
|
iter = model.get_iter_next(iter)
|
||||||
|
|
||||||
|
def on_delete_button_clicked(self, widget):
|
||||||
|
selection = self.treeview.get_selection()
|
||||||
|
if not selection:
|
||||||
|
return
|
||||||
|
model, iter = selection.get_selected()
|
||||||
|
node = model[iter][0]
|
||||||
|
our_jid = gajim.get_jid_from_account(self.account)
|
||||||
|
gajim.connections[self.account].send_pb_delete(our_jid, node)
|
||||||
|
|
||||||
def on_configure_button_clicked(self, widget):
|
def on_configure_button_clicked(self, widget):
|
||||||
selection = self.treeview.get_selection()
|
selection = self.treeview.get_selection()
|
||||||
if not selection:
|
if not selection:
|
||||||
|
|
16
src/gajim.py
16
src/gajim.py
|
@ -2196,7 +2196,7 @@ class Interface:
|
||||||
is_modal = False, ok_handler = on_ok)
|
is_modal = False, ok_handler = on_ok)
|
||||||
|
|
||||||
def handle_event_pep_config(self, account, data):
|
def handle_event_pep_config(self, account, data):
|
||||||
# ('PEP_ACCESS_MODEL', account, (node, form))
|
# ('PEP_CONFIG', account, (node, form))
|
||||||
if self.instances[account].has_key('pep_services'):
|
if self.instances[account].has_key('pep_services'):
|
||||||
self.instances[account]['pep_services'].config(data[0], data[1])
|
self.instances[account]['pep_services'].config(data[0], data[1])
|
||||||
|
|
||||||
|
@ -2293,6 +2293,18 @@ class Interface:
|
||||||
dialog = dialogs.YesNoDialog(pritext, sectext, checktext,
|
dialog = dialogs.YesNoDialog(pritext, sectext, checktext,
|
||||||
on_response_yes=on_yes, on_response_no=on_no)
|
on_response_yes=on_yes, on_response_no=on_no)
|
||||||
|
|
||||||
|
def handle_event_pubsub_node_removed(self, account, data):
|
||||||
|
# ('PUBSUB_NODE_REMOVED', account, (jid, node))
|
||||||
|
if self.instances[account].has_key('pep_services'):
|
||||||
|
if data[0] == gajim.get_jid_from_account(account):
|
||||||
|
self.instances[account]['pep_services'].node_removed(data[1])
|
||||||
|
|
||||||
|
def handle_event_pubsub_node_not_removed(self, account, data):
|
||||||
|
# ('PUBSUB_NODE_NOT_REMOVED', account, (jid, node, msg))
|
||||||
|
if data[0] == gajim.get_jid_from_account(account):
|
||||||
|
dialogs.WarningDialog(_('PEP node was not removed'),
|
||||||
|
_('PEP node %s was not removed: %s') % (data[1], data[2]))
|
||||||
|
|
||||||
def read_sleepy(self):
|
def read_sleepy(self):
|
||||||
'''Check idle status and change that status if needed'''
|
'''Check idle status and change that status if needed'''
|
||||||
if not self.sleeper.poll():
|
if not self.sleeper.poll():
|
||||||
|
@ -2648,6 +2660,8 @@ class Interface:
|
||||||
'SSL_ERROR': self.handle_event_ssl_error,
|
'SSL_ERROR': self.handle_event_ssl_error,
|
||||||
'FINGERPRINT_ERROR': self.handle_event_fingerprint_error,
|
'FINGERPRINT_ERROR': self.handle_event_fingerprint_error,
|
||||||
'PLAIN_CONNECTION': self.handle_event_plain_connection,
|
'PLAIN_CONNECTION': self.handle_event_plain_connection,
|
||||||
|
'PUBSUB_NODE_REMOVED': self.handle_event_pubsub_node_removed,
|
||||||
|
'PUBSUB_NODE_NOT_REMOVED': self.handle_event_pubsub_node_not_removed,
|
||||||
}
|
}
|
||||||
gajim.handlers = self.handlers
|
gajim.handlers = self.handlers
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue