From cc045b557f57aa4b00bd5a0ab16ecd3a4e953b4f Mon Sep 17 00:00:00 2001 From: prculley Date: Wed, 27 Dec 2017 10:59:43 -0600 Subject: [PATCH] fix Sidebar to resize better Fixes #10334 Issue #10161 --- gramps/gui/views/pageview.py | 19 +++++++++++++++---- gramps/gui/widgets/grampletbar.py | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gramps/gui/views/pageview.py b/gramps/gui/views/pageview.py index 5d56d43a862..7f248780bb2 100644 --- a/gramps/gui/views/pageview.py +++ b/gramps/gui/views/pageview.py @@ -156,8 +156,19 @@ def build_interface(self): hpane = Gtk.Paned() vpane = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL) hpane.pack1(vpane, resize=True, shrink=False) - hpane.pack2(self.sidebar, resize=False, shrink=True) - self._setup_slider_config(hpane, 'hpane.slider-position') + hpane.pack2(self.sidebar, resize=False, shrink=False) + # we don't know width of the pane yet, so estimate based on width of + # Gramps main window (left hand bar about 150 pix) + width = self.uistate.window.get_allocation().width - 160 + # default will use natural size for sidebar until it gets to 400 pix + side_ch = self.sidebar.get_children() # Gtk Notebook + try: + vp_ch = side_ch[0].get_children() # Gtk Viewport child + ch_width = vp_ch[0].get_preferred_width()[0] + except AttributeError: + ch_width = 400 # needed if no Gramplet installed + pos = width - min(ch_width, 400) + self._setup_slider_config(hpane, 'hpane.slider-position', position=pos) hpane.show() vpane.show() @@ -171,11 +182,11 @@ def build_interface(self): return hpane - def _setup_slider_config(self, widget, setting): + def _setup_slider_config(self, widget, setting, position=-1): """ Setup the slider configuration setting. """ - self._config.register(setting, -1) + self._config.register(setting, position) widget.set_position(self._config.get(setting)) widget.connect('notify::position', self._position_changed, setting) diff --git a/gramps/gui/widgets/grampletbar.py b/gramps/gui/widgets/grampletbar.py index 6ec6f8e78b9..b5cae4bb86c 100644 --- a/gramps/gui/widgets/grampletbar.py +++ b/gramps/gui/widgets/grampletbar.py @@ -370,7 +370,7 @@ def __add_tab(self, gramplet): """ Add a tab to the notebook for the given gramplet. """ - width = min(int(self.uistate.screen_width() * 0.25), 400) + width = -1 # Allow tab width to adjust (smaller) to sidebar height = min(int(self.uistate.screen_height() * 0.20), 400) gramplet.set_size_request(width, height)