added saving the current window size

This commit is contained in:
Dmitriy Yefremov
2017-10-18 16:44:20 +03:00
parent a15b7261a5
commit c0f4a3b7dc
2 changed files with 19 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ from threading import Thread
from main.eparser import get_channels, get_bouquets, get_bouquet
from main.eparser.__constants import SERVICE_TYPE
from main.ftp import download_data, upload_data
from main.properties import get_config
from main.properties import get_config, write_config
from . import Gtk, Gdk
from .satellites_dialog import show_satellites_dialog
from .settings_dialog import show_settings_dialog
@@ -30,7 +30,8 @@ def on_about_app(item):
def get_handlers():
return {
"on_close_main_window": Gtk.main_quit,
"on_close_main_window": on_quit,
"on_resize": on_resize,
"on_about_app": on_about_app,
"on_preferences": on_preferences,
"on_download": on_download,
@@ -56,6 +57,17 @@ def get_handlers():
}
def on_quit(*args):
""" Called before app quit """
write_config(__options) # storing current config
Gtk.main_quit()
def on_resize(window):
""" Stores new size properties for main window after resize """
__options["window_size"] = window.get_size()
def on_up(item):
pass
@@ -263,6 +275,10 @@ def init_ui():
builder.add_from_file("ui/main_window.glade")
global __main_window
__main_window = builder.get_object("main_window")
main_window_size = __options.get("window_size", None)
# Setting the last size of the window if it was saved
if main_window_size:
__main_window.resize(*main_window_size)
global __services_view
__services_view = builder.get_object("services_tree_view")
global __fav_view

View File

@@ -140,6 +140,7 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">DemonEditor</property>
<property name="icon_name">accessories-text-editor</property>
<signal name="check-resize" handler="on_resize" swapped="no"/>
<signal name="delete-event" handler="on_close_main_window" swapped="no"/>
<child>
<object class="GtkBox" id="box1">