[latexila/latexila-2-6] Better way for shrinking the window when unmaximized
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/latexila-2-6] Better way for shrinking the window when unmaximized
- Date: Wed, 7 Nov 2012 19:24:35 +0000 (UTC)
commit 5a79e3241226b4c9192488edf48beecb0cfb3fe6
Author: SÃbastien Wilmet <swilmet gnome org>
Date: Wed Nov 7 20:08:06 2012 +0100
Better way for shrinking the window when unmaximized
Before, if the window was initially maximized, the default size of the
window was set smaller (100 pixels less) than the maximized size, with
the set_default_size() function.
But due to this smaller size, the paned positions were not restored
correctly. When restoring the positions, the window is not already
shown, and so the default size is taken. When the window is shown and
then maximized, the paned position has 100 more pixels. After several
restarts, the bottom panel was completely hidden.
src/main_window.vala | 41 +++++++++++++++++++++++++++++------------
1 files changed, 29 insertions(+), 12 deletions(-)
---
diff --git a/src/main_window.vala b/src/main_window.vala
index 112b459..6e9f2f9 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -247,6 +247,7 @@ public class MainWindow : Window
hide_completion_calltip_when_needed ();
support_drag_and_drop ();
+ shrink_window_when_unmaximized ();
delete_event.connect (() =>
{
@@ -538,6 +539,30 @@ public class MainWindow : Window
});
}
+ private void shrink_window_when_unmaximized ()
+ {
+ window_state_event.connect ((e) =>
+ {
+ Gdk.EventWindowState event = e;
+
+ // The window has been unmaximized.
+ if (Gdk.WindowState.MAXIMIZED in event.changed_mask &&
+ ! (Gdk.WindowState.MAXIMIZED in event.new_window_state))
+ {
+ int width = screen.get_width ();
+ int height = screen.get_height ();
+
+ resize (width - 100, height - 100);
+
+ // Signal handled.
+ return true;
+ }
+
+ // Propagate the event further.
+ return false;
+ });
+ }
+
private void show_or_hide_widgets ()
{
GLib.Settings settings = new GLib.Settings ("org.gnome.latexila.preferences.ui");
@@ -949,18 +974,10 @@ public class MainWindow : Window
settings_window.set_int ("state", state);
// get width and height of the window
- int w, h;
- get_size (out w, out h);
-
- // If window is maximized, store sizes that are a bit smaller than full screen,
- // else making window non-maximized the next time will have no effect.
- if (Gdk.WindowState.MAXIMIZED in state)
- {
- w -= 100;
- h -= 100;
- }
-
- settings_window.set ("size", "(ii)", w, h);
+ int width;
+ int height;
+ get_size (out width, out height);
+ settings_window.set ("size", "(ii)", width, height);
settings_window.set_int ("side-panel-size", _main_hpaned.get_position ());
settings_window.set_int ("vertical-paned-position", _vpaned.get_position ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]