GNOME Bugzilla – Bug 611843
remember the size of the window and the pane's position
Last modified: 2012-10-22 17:10:47 UTC
As the title says. Baobab should remember its window width and height, and the position of the pane that separates it in two.
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.
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
(no idea why it got posted twice...)
Created attachment 226992 [details] [review] window: remember size and maximized state Updated patch for the vala rewriting
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...
(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
It's ok if we store the active-chart late. go ahead! (too bad we cannot backport it, but translator would hunt us down ;)
Attachment 226992 [details] pushed as c2bcb52 - window: remember size and maximized state