Commit 43f07c19 authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

Merge destroy handlers, connect ESC key, remove transient

parent d106c0d3
......@@ -251,8 +251,7 @@ def on_manage_proxies(action, param):
if 'manage_proxies' in app.interface.instances:
app.interface.instances['manage_proxies'].window.present()
else:
app.interface.instances['manage_proxies'] = \
ManageProxies(interface.roster.window)
app.interface.instances['manage_proxies'] = ManageProxies()
# Admin Actions
......
......@@ -29,7 +29,8 @@
<property name="default_width">500</property>
<property name="default_height">440</property>
<property name="type_hint">dialog</property>
<signal name="destroy" handler="on_manage_proxies_window_destroy" swapped="no"/>
<signal name="destroy" handler="_on_destroy" swapped="no"/>
<signal name="key-press-event" handler="_on_key_press" swapped="no"/>
<child>
<placeholder/>
</child>
......
......@@ -1025,7 +1025,7 @@ def on_manage_proxies_button_clicked(self, widget):
if 'manage_proxies' in app.interface.instances:
app.interface.instances['manage_proxies'].window.present()
else:
app.interface.instances['manage_proxies'] = ManageProxies(self)
app.interface.instances['manage_proxies'] = ManageProxies()
def update_proxy_list(self):
our_proxy = app.config.get('global_proxy')
......
......@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import Gtk
from gajim.common import app
from gajim.common.i18n import _
......@@ -22,15 +22,16 @@
class ManageProxies:
def __init__(self, transient_for=None):
def __init__(self):
self._ui = get_builder('manage_proxies_window.ui')
self._ui.manage_proxies_window.set_transient_for(transient_for)
self.window = self._ui.manage_proxies_window
self.window.set_transient_for(app.app.get_active_window())
self.init_list()
self.block_signal = False
self._ui.connect_signals(self)
self._ui.manage_proxies_window.connect('destroy', self._on_destroy)
self._ui.manage_proxies_window.show_all()
self.window.show_all()
# hide the BOSH fields by default
self.show_bosh_fields()
self._ui.boshuri_entry.hide()
......@@ -76,12 +77,6 @@ def init_list(self):
self.fill_proxies_treeview()
self._ui.proxytype_combobox.set_active(0)
def on_manage_proxies_window_destroy(self, _widget):
window = app.get_app_window('AccountsWindow')
if window is not None:
window.update_proxy_list()
del app.interface.instances['manage_proxies']
def on_add_proxy_button_clicked(self, _widget):
model = self._ui.proxies_treeview.get_model()
proxies = app.config.get_per('proxies')
......@@ -101,6 +96,8 @@ def on_remove_proxy_button_clicked(self, _widget):
if not iter_:
return
proxy = model[iter_][0]
if proxy == _('None'):
return
model.remove(iter_)
app.config.del_per('proxies', proxy)
self._ui.remove_proxy_button.set_sensitive(False)
......@@ -268,7 +265,16 @@ def on_proxypass_entry_changed(self, widget):
proxy = self._ui.proxyname_entry.get_text()
app.config.set_per('proxies', proxy, 'pass', value)
def _on_key_press(self, widget, event):
if event.keyval == Gdk.KEY_Escape:
self.window.destroy()
def _on_destroy(self, *args):
window = app.get_app_window('Preferences')
if window is not None:
window.update_proxy_list()
window_pref = app.get_app_window('Preferences')
window_accounts = app.get_app_window('AccountsWindow')
if window_pref is not None:
window_pref.update_proxy_list()
if window_accounts is not None:
window_accounts.update_proxy_list()
self.window.destroy()
del app.interface.instances['manage_proxies']
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment