Move Preferences into own module

- Port Preferences to Gtk.ApplicationWindow
This commit is contained in:
Philipp Hörist 2018-08-06 19:44:51 +02:00 committed by Philipp Hörist
parent 42adff1b1b
commit c778ed6917
8 changed files with 3868 additions and 3872 deletions

View File

@ -69,11 +69,10 @@ def tree_model_pre_order(model, treeiter):
class AdvancedConfigurationWindow(object):
def __init__(self):
def __init__(self, transient):
self.xml = gtkgui_helpers.get_gtk_builder('advanced_configuration_window.ui')
self.window = self.xml.get_object('advanced_configuration_window')
self.window.set_transient_for(
app.interface.instances['preferences'].window)
self.window.set_transient_for(transient)
self.entry = self.xml.get_object('advanced_entry')
self.desc_label = self.xml.get_object('advanced_desc_label')
self.restart_box = self.xml.get_object('restart_box')

View File

@ -28,6 +28,7 @@ from gajim import disco
from gajim.gtk.history_sync import HistorySyncAssistant
from gajim.gtk.server_info import ServerInfoDialog
from gajim.gtk.mam_preferences import MamPreferences
from gajim.gtk.preferences import Preferences
from gajim.gtk import JoinGroupchatWindow
from gajim.gtk import StartChatDialog
from gajim.gtk import AddNewContactWindow
@ -50,11 +51,11 @@ def on_add_contact_jid(action, param):
def on_preferences(action, param):
if 'preferences' in interface.instances:
interface.instances['preferences'].window.present()
window = app.get_app_window(Preferences)
if window is None:
Preferences()
else:
interface.instances['preferences'] = \
config.PreferencesWindow()
window.present()
def on_plugins(action, param):

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<requires lib="gtk+" version="3.20"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">1440</property>
@ -179,14 +179,6 @@
<column type="gchararray"/>
</columns>
</object>
<object class="GtkWindow" id="preferences_window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Preferences</property>
<property name="role">preferences</property>
<property name="type_hint">dialog</property>
<signal name="destroy" handler="on_preferences_window_destroy" swapped="no"/>
<signal name="key-press-event" handler="on_preferences_window_key_press_event" swapped="no"/>
<child>
<object class="GtkNotebook" id="preferences_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
@ -2959,9 +2951,4 @@ to discover one from server.</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
<placeholder/>
</child>
</object>
</interface>

View File

@ -34,11 +34,10 @@ from gajim.gtk.util import get_builder
class GajimThemesWindow:
def __init__(self):
def __init__(self, transient):
self.xml = get_builder('gajim_themes_window.ui')
self.window = self.xml.get_object('gajim_themes_window')
self.window.set_transient_for(app.interface.instances[
'preferences'].window)
self.window.set_transient_for(transient)
self.options = ['account', 'group', 'contact', 'banner']
self.options_combobox = self.xml.get_object('options_combobox')
@ -85,8 +84,9 @@ class GajimThemesWindow:
return True # do NOT destroy the window
def on_close_button_clicked(self, widget):
if 'preferences' in app.interface.instances:
app.interface.instances['preferences'].update_theme_list()
window = app.get_app_window('Preferences')
if window is not None:
window.update_theme_list()
self.window.hide()
def on_theme_cell_edited(self, cell, row, new_name):

1140
gajim/gtk/preferences.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1916,10 +1916,6 @@ class Interface:
if not emot_theme:
return
transient_for = None
if 'preferences' in app.interface.instances:
transient_for = app.interface.instances['preferences'].window
themes = helpers.get_available_emoticon_themes()
if emot_theme not in themes:
if 'font-emoticons' in themes:
@ -1935,7 +1931,7 @@ class Interface:
_('Emoticons disabled'),
_('Your configured emoticons theme could not be loaded.'
' See the log for more details.'),
transient_for=transient_for)
transient_for=app.get_app_window('Preferences'))
app.config.set('emoticons_theme', '')
return

View File

@ -365,10 +365,12 @@ class StatusIcon:
win.hide()
def on_preferences_menuitem_activate(self, widget):
if 'preferences' in app.interface.instances:
app.interface.instances['preferences'].window.present()
from gajim.gtk.preferences import Preferences
window = app.get_app_window(Preferences)
if window is None:
Preferences()
else:
app.interface.instances['preferences'] = config.PreferencesWindow()
window.present()
def on_quit_menuitem_activate(self, widget):
app.interface.roster.on_quit_request()