Remember size of dettached composer window
This commit is contained in:
parent
f4a7fef7a1
commit
c1de366210
3 changed files with 61 additions and 2 deletions
|
|
@ -128,6 +128,12 @@
|
|||
<description>The zoom to apply on the conservation view.</description>
|
||||
</key>
|
||||
|
||||
<key name="composer-window-size" type="ai">
|
||||
<default>[-1,-1]</default>
|
||||
<summary>size of dettached composer window</summary>
|
||||
<description>The last recorded size of the dettached composer window.</description>
|
||||
</key>
|
||||
|
||||
<key name="migrated-config" type="b">
|
||||
<default>false</default>
|
||||
<summary>Whether we migrated the old settings</summary>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public class Configuration {
|
|||
public const string SPELL_CHECK_LANGUAGES = "spell-check-languages";
|
||||
public const string SEARCH_STRATEGY_KEY = "search-strategy";
|
||||
public const string CONVERSATION_VIEWER_ZOOM_KEY = "conversation-viewer-zoom";
|
||||
public const string COMPOSER_WINDOW_SIZE_KEY = "composer-window-size";
|
||||
|
||||
|
||||
public enum DesktopEnvironment {
|
||||
|
|
@ -172,6 +173,21 @@ public class Configuration {
|
|||
set { settings.set_double(CONVERSATION_VIEWER_ZOOM_KEY, value); }
|
||||
}
|
||||
|
||||
public int[] composer_window_size {
|
||||
owned get {
|
||||
int[] size = new int[2];
|
||||
var s = settings.get_value(COMPOSER_WINDOW_SIZE_KEY);
|
||||
if (s.n_children () == 2) {
|
||||
size = { (int) s.get_child_value(0), (int) s.get_child_value(1)};
|
||||
} else {
|
||||
size = {-1,-1};
|
||||
}
|
||||
return size;
|
||||
}
|
||||
set {
|
||||
settings.set_value(COMPOSER_WINDOW_SIZE_KEY, value);
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a configuration object.
|
||||
public Configuration(string schema_id) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ public class ComposerWindow : Gtk.ApplicationWindow, ComposerContainer {
|
|||
|
||||
private bool closing = false;
|
||||
|
||||
|
||||
public ComposerWindow(ComposerWidget composer) {
|
||||
Object(type: Gtk.WindowType.TOPLEVEL);
|
||||
this.composer = composer;
|
||||
|
|
@ -52,10 +51,48 @@ public class ComposerWindow : Gtk.ApplicationWindow, ComposerContainer {
|
|||
}
|
||||
|
||||
public override void show() {
|
||||
set_default_size(680, 600);
|
||||
Gdk.Screen? screen = get_screen();
|
||||
if (screen != null) {
|
||||
int screen_width = screen.get_width();
|
||||
int screen_height = screen.get_height();
|
||||
int[] size = GearyApplication.instance.config.composer_window_size;
|
||||
|
||||
//check if stored values are reasonable
|
||||
if (size[0] >= 0 && size[0] <= screen_width &&
|
||||
size[1] >= 0 && size[1] <= screen_height)
|
||||
set_default_size(size[0], size[1]);
|
||||
else
|
||||
set_default_size(680, 600);
|
||||
}
|
||||
|
||||
base.show();
|
||||
}
|
||||
|
||||
private void save_window_geometry () {
|
||||
Gdk.Screen? screen = get_screen();
|
||||
if (screen != null && !this.is_maximized) {
|
||||
int screen_width = screen.get_width();
|
||||
int screen_height = screen.get_height();
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
get_size(out width, out height);
|
||||
|
||||
// Only store if the values are reasonable-looking.
|
||||
if (width > 0 && width <= screen_width &&
|
||||
height > 0 && height <= screen_height)
|
||||
GearyApplication.instance.config.composer_window_size = { width, height };
|
||||
}
|
||||
}
|
||||
|
||||
// Fired on window resize. Save window size for the next start.
|
||||
public override void size_allocate(Gtk.Allocation allocation) {
|
||||
base.size_allocate(allocation);
|
||||
|
||||
this.save_window_geometry();
|
||||
}
|
||||
|
||||
public void close_container() {
|
||||
on_focus_out();
|
||||
this.composer.editor.focus_in_event.disconnect(on_focus_in);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue