mirror of
https://github.com/GradienceTeam/Gradience.git
synced 2024-07-08 19:57:48 +00:00
Fix for constant disk i/o activity when resizing main Gradience window (#446)
Window properties `default-width` and `default-height` are changed constantly throughout entire time the program is running, and when we combine this with binding properties using `Gio.Settings.bind()` function in GIO's API, it creates a read/write disk spam (which is a appropriate behavior according to official documentation for [`G_SETTINGS_BIND_SET`](https://docs.gtk.org/gio/flags.SettingsBindFlags.html#set)). This PR moves setting window properties to a new function which is executed only one time (when closing a program) and sets those properties when initializing a main window. This fix should resolve issue #339.
This commit is contained in:
commit
7b7b5dd52e
|
@ -96,7 +96,13 @@ class GradienceApplication(Adw.Application):
|
|||
|
||||
self.win = self.props.active_window
|
||||
if not self.win:
|
||||
self.win = GradienceMainWindow(application=self)
|
||||
self.win = GradienceMainWindow(
|
||||
application=self,
|
||||
default_height=self.settings.get_int("window-height"),
|
||||
default_width=self.settings.get_int("window-width"),
|
||||
fullscreened=self.settings.get_boolean("window-fullscreen"),
|
||||
maximized=self.settings.get_boolean("window-maximized")
|
||||
)
|
||||
self.plugins_list = GradiencePluginsList(self.win)
|
||||
self.setup_plugins()
|
||||
|
||||
|
|
|
@ -64,22 +64,9 @@ class GradienceMainWindow(Adw.ApplicationWindow):
|
|||
|
||||
self.settings = Gio.Settings(app_id)
|
||||
|
||||
self.settings.bind(
|
||||
"window-width", self, "default-width", Gio.SettingsBindFlags.DEFAULT
|
||||
)
|
||||
|
||||
self.settings.bind(
|
||||
"window-height", self, "default-height", Gio.SettingsBindFlags.DEFAULT
|
||||
)
|
||||
self.settings.bind(
|
||||
"window-maximized", self, "maximized", Gio.SettingsBindFlags.DEFAULT
|
||||
)
|
||||
|
||||
self.settings.bind(
|
||||
"window-fullscreen", self, "fullscreened", Gio.SettingsBindFlags.DEFAULT
|
||||
)
|
||||
|
||||
self.connect("close-request", self.on_close_request)
|
||||
self.connect("unrealize", self.save_window_props)
|
||||
|
||||
self.style_manager = self.get_application().style_manager
|
||||
self.first_apply = True
|
||||
|
||||
|
@ -117,6 +104,15 @@ class GradienceMainWindow(Adw.ApplicationWindow):
|
|||
return True
|
||||
self.close()
|
||||
|
||||
def save_window_props(self, *args):
|
||||
win_size = self.get_default_size()
|
||||
|
||||
self.settings.set_int("window-width", win_size.width)
|
||||
self.settings.set_int("window-height", win_size.height)
|
||||
|
||||
self.settings.set_boolean("window-maximized", self.is_maximized())
|
||||
self.settings.set_boolean("window-fullscreen", self.is_fullscreen())
|
||||
|
||||
def on_monet_file_chooser_response(self, widget, response):
|
||||
if response == Gtk.ResponseType.ACCEPT:
|
||||
self.monet_image_file = self.monet_file_chooser_dialog.get_file()
|
||||
|
|
Loading…
Reference in a new issue