After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 611843 - remember the size of the window and the pane's position
remember the size of the window and the pane's position
Status: RESOLVED FIXED
Product: baobab
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Baobab Maintainers
Baobab Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-03-04 21:10 UTC by Jean-François Fortin Tam
Modified: 2012-10-22 17:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch to implement this feature (6.06 KB, patch)
2011-08-13 08:49 UTC, Paolo Bacchilega
needs-work Details | Review
window: remember size and maximized state (4.19 KB, patch)
2012-10-22 13:23 UTC, Stefano Facchini
committed Details | Review

Description Jean-François Fortin Tam 2010-03-04 21:10:44 UTC
As the title says. Baobab should remember its window width and height, and the position of the pane that separates it in two.
Comment 1 Paolo Bacchilega 2011-08-13 08:49:04 UTC
Created attachment 193746 [details] [review]
proposed patch to implement this feature

This is a patch against the gnome-3-0 branch that implements this feature.
Comment 2 Paolo Borelli 2011-08-13 09:19:16 UTC
Review of attachment 193746 [details] [review]:

Hi Paolo, thanks for the patch! Any specifi reason why it is targeted to the branch instead of master? I'd like to see it committed on master once the issues below are addressed

::: baobab/data/org.gnome.baobab.gschema.xml.in
@@ -32,2 +32,3 @@
       <_description>Which type of chart should be displayed.</_description>
     </key>
+    <key name="window-width" type="i">

You can use a single window-size setting of type (ii) since width and height are always used in a pair.

For other application I usually prefer to store the window state in its own subsection of the schema... you may have a look at gedit schema if you are ok with the idea.

::: baobab/src/baobab.c
@@ +1229,3 @@
+	hpaned_main = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "hpaned_main"));
+	g_settings_set_int (baobab.ui_settings, BAOBAB_SETTINGS_DIRECTORY_PANE_WIDTH, gtk_paned_get_position (GTK_PANED (hpaned_main)));
+

Here you need to also handle the maximized state: if the window is maximixed, then w and h should not be saved otherwise next time you end up with with an umaximized window that had the size of the whole screen.
We can either decide to also save and restore the maximixed state, or simply not save the size if the window is maximized.

Also, if one would want to be very picky, the proper way to track the size would be to connect to the configure event, store w and h in memory and then save it on exit, so that if the window is resized and then maximixed and then closed you still save the correct w and h... gedit has code to do that if you want to have a look, though it may a bit excessive for something like baobab.

I'd be ok with just not saving w and h if the window is maximized

@@ +1334,3 @@
+	window_height = g_settings_get_int (baobab.ui_settings, BAOBAB_SETTINGS_WINDOW_HEIGHT);
+	if ((window_width <= 0) || (window_height <= 0)) {
+		window_width = 800;

let's use #defined for the default value constants
Comment 3 Paolo Borelli 2011-08-13 09:19:16 UTC
Review of attachment 193746 [details] [review]:

Hi Paolo, thanks for the patch! Any specifi reason why it is targeted to the branch instead of master? I'd like to see it committed on master once the issues below are addressed

::: baobab/data/org.gnome.baobab.gschema.xml.in
@@ -32,2 +32,3 @@
       <_description>Which type of chart should be displayed.</_description>
     </key>
+    <key name="window-width" type="i">

You can use a single window-size setting of type (ii) since width and height are always used in a pair.

For other application I usually prefer to store the window state in its own subsection of the schema... you may have a look at gedit schema if you are ok with the idea.

::: baobab/src/baobab.c
@@ +1229,3 @@
+	hpaned_main = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "hpaned_main"));
+	g_settings_set_int (baobab.ui_settings, BAOBAB_SETTINGS_DIRECTORY_PANE_WIDTH, gtk_paned_get_position (GTK_PANED (hpaned_main)));
+

Here you need to also handle the maximized state: if the window is maximixed, then w and h should not be saved otherwise next time you end up with with an umaximized window that had the size of the whole screen.
We can either decide to also save and restore the maximixed state, or simply not save the size if the window is maximized.

Also, if one would want to be very picky, the proper way to track the size would be to connect to the configure event, store w and h in memory and then save it on exit, so that if the window is resized and then maximixed and then closed you still save the correct w and h... gedit has code to do that if you want to have a look, though it may a bit excessive for something like baobab.

I'd be ok with just not saving w and h if the window is maximized

@@ +1334,3 @@
+	window_height = g_settings_get_int (baobab.ui_settings, BAOBAB_SETTINGS_WINDOW_HEIGHT);
+	if ((window_width <= 0) || (window_height <= 0)) {
+		window_width = 800;

let's use #defined for the default value constants
Comment 4 Paolo Borelli 2011-08-13 09:20:00 UTC
(no idea why it got posted twice...)
Comment 5 Stefano Facchini 2012-10-22 13:23:17 UTC
Created attachment 226992 [details] [review]
window: remember size and maximized state

Updated patch for the vala rewriting
Comment 6 Paolo Borelli 2012-10-22 16:48:59 UTC
Review of attachment 226992 [details] [review]:

::: src/baobab-application.vala
@@ +81,3 @@
             prefs_settings = new Settings ("org.gnome.baobab.preferences");
+
+            ui_settings.delay ();

Why apply the delay strategy to all the ui settings? or we do not have nothing there?

::: src/baobab-window.vala
@@ -165,0 +165,9 @@
+            // Setup window geometry saving
+            Gdk.WindowState window_state = (Gdk.WindowState) ui_settings.get_int ("window-state");
+            if (Gdk.WindowState.MAXIMIZED in window_state) {
... 6 more ...

I guess we should resize before maximizing, so that when unmaximizing we get the right size...
Comment 7 Paolo Borelli 2012-10-22 16:48:59 UTC
Review of attachment 226992 [details] [review]:

::: src/baobab-application.vala
@@ +81,3 @@
             prefs_settings = new Settings ("org.gnome.baobab.preferences");
+
+            ui_settings.delay ();

Why apply the delay strategy to all the ui settings? or we do not have nothing there?

::: src/baobab-window.vala
@@ -165,0 +165,9 @@
+            // Setup window geometry saving
+            Gdk.WindowState window_state = (Gdk.WindowState) ui_settings.get_int ("window-state");
+            if (Gdk.WindowState.MAXIMIZED in window_state) {
... 6 more ...

I guess we should resize before maximizing, so that when unmaximizing we get the right size...
Comment 8 Stefano Facchini 2012-10-22 17:01:16 UTC
(In reply to comment #7)
> Review of attachment 226992 [details] [review]:
> 
> ::: src/baobab-application.vala
> @@ +81,3 @@
>              prefs_settings = new Settings ("org.gnome.baobab.preferences");
> +
> +            ui_settings.delay ();
> 
> Why apply the delay strategy to all the ui settings? or we do not have nothing
> there?
> 

We have the "active-chart" setting, so we can:
  1. do ui_settings.apply() after chainging active-chart
  2. use a different subschema for window geometry


> ::: src/baobab-window.vala
> @@ -165,0 +165,9 @@
> +            // Setup window geometry saving
> +            Gdk.WindowState window_state = (Gdk.WindowState)
> ui_settings.get_int ("window-state");
> +            if (Gdk.WindowState.MAXIMIZED in window_state) {
> ... 6 more ...
> 
> I guess we should resize before maximizing, so that when unmaximizing we get
> the right size...

gtk_window_resize() works also when the window is maximized
Comment 9 Paolo Borelli 2012-10-22 17:08:08 UTC
It's ok if we store the active-chart late.

go ahead!


(too bad we cannot backport it, but translator would hunt us down ;)
Comment 10 Stefano Facchini 2012-10-22 17:10:43 UTC
Attachment 226992 [details] pushed as c2bcb52 - window: remember size and maximized state