[Git][gajim/gajim][master] Accounts: Update proxy combobox correctly

Philipp Hörist gitlab at dev.gajim.org
Tue Jan 22 22:00:31 CET 2019


Philipp Hörist pushed to branch master at gajim / gajim


Commits:
dad99f85 by Philipp Hörist at 2019-01-22T21:00:20Z
Accounts: Update proxy combobox correctly

- - - - -


1 changed file:

- gajim/options_dialog.py


Changes:

=====================================
gajim/options_dialog.py
=====================================
@@ -477,11 +477,11 @@ class ProxyComboOption(GenericOption):
         GenericOption.__init__(self, *args)
 
         self.combo = Gtk.ComboBoxText()
-        self.update_values()
-
-        self.combo.connect('changed', self.on_value_change)
         self.combo.set_valign(Gtk.Align.CENTER)
 
+        self._signal_id = None
+        self.update_values()
+
         button = get_image_button(
             'preferences-system-symbolic', _('Manage Proxies'))
         button.set_action_name('app.manage-proxies')
@@ -491,7 +491,18 @@ class ProxyComboOption(GenericOption):
         self.option_box.pack_start(button, False, True, 0)
         self.show_all()
 
+    def _block_signal(self, state):
+        if state:
+            if self._signal_id is None:
+                return
+            self.combo.disconnect(self._signal_id)
+        else:
+            self._signal_id = self.combo.connect('changed',
+                                                 self.on_value_change)
+            self.combo.emit('changed')
+
     def update_values(self):
+        self._block_signal(True)
         proxies = app.config.get_per('proxies')
         proxies.insert(0, _('No Proxy'))
         self.combo.remove_all()
@@ -499,9 +510,13 @@ class ProxyComboOption(GenericOption):
             self.combo.insert_text(-1, value)
             if value == self.option_value or index == 0:
                 self.combo.set_active(index)
+        self._block_signal(False)
 
     def on_value_change(self, combo):
-        self.set_value(combo.get_active_text())
+        if combo.get_active() == 0:
+            self.set_value('')
+        else:
+            self.set_value(combo.get_active_text())
 
     def on_row_activated(self):
         pass



View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/dad99f85fccf30ab91b4c7babf2a24c1faeabb0e

-- 
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/dad99f85fccf30ab91b4c7babf2a24c1faeabb0e
You're receiving this email because of your account on dev.gajim.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gajim.org/pipermail/commits/attachments/20190122/f1bbfb84/attachment-0001.html>


More information about the Commits mailing list