File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 66 <summary >Selected terminal emulator</summary >
77 <description >The terminal emulator selected by the user.</description >
88 </key >
9+ <key name =" window-width" type =" i" >
10+ <default >900</default >
11+ <summary >Window width</summary >
12+ <description >The width of the main window when last closed.</description >
13+ </key >
14+ <key name =" window-height" type =" i" >
15+ <default >700</default >
16+ <summary >Window height</summary >
17+ <description >The height of the main window when last closed.</description >
18+ </key >
919 </schema >
1020</schemalist >
Original file line number Diff line number Diff line change @@ -116,6 +116,12 @@ impl DistroShelfWindow {
116116 . property ( "root-store" , root_store)
117117 . build ( ) ;
118118
119+ // Restore window size from settings
120+ let settings = gio:: Settings :: new ( "com.ranfdev.DistroShelf" ) ;
121+ let width = settings. int ( "window-width" ) ;
122+ let height = settings. int ( "window-height" ) ;
123+ this. set_default_size ( width, height) ;
124+
119125 this. setup_gactions ( ) ;
120126 let this_clone = this. clone ( ) ;
121127 this. root_store ( )
@@ -162,6 +168,16 @@ impl DistroShelfWindow {
162168 this. build_sidebar ( ) ;
163169 this. root_store ( ) . load_containers ( ) ;
164170
171+ // Save window size when closing
172+ let this_clone = this. clone ( ) ;
173+ this. connect_close_request ( move |_| {
174+ let ( width, height) = this_clone. default_size ( ) ;
175+ let settings = gio:: Settings :: new ( "com.ranfdev.DistroShelf" ) ;
176+ let _ = settings. set_int ( "window-width" , width) ;
177+ let _ = settings. set_int ( "window-height" , height) ;
178+ glib:: Propagation :: Proceed
179+ } ) ;
180+
165181 this
166182 }
167183
You can’t perform that action at this time.
0 commit comments