Skip to content

Commit

Permalink
fix Sidebar to resize better
Browse files Browse the repository at this point in the history
Fixes #10334
Issue #10161
  • Loading branch information
prculley committed Feb 8, 2018
1 parent 0445004 commit 7f8f0b8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions gramps/gui/views/pageview.py
Expand Up @@ -156,8 +156,7 @@ 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)
hpane.show()
vpane.show()

Expand All @@ -168,14 +167,31 @@ def build_interface(self):
self._setup_slider_config(vpane, 'vpane.slider-position')

self.sidebar_toggled(self.sidebar.get_property('visible'))
self.hpane_sig = hpane.connect("draw", self.set_page_slider)

return hpane

def _setup_slider_config(self, widget, setting):
def set_page_slider(self, widget, dummy):
""" Setup slider. We have the page realized at this point. """
widget.disconnect(self.hpane_sig)
# get current width of pane
width = widget.get_allocated_width()
# 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] + 3
except AttributeError:
ch_width = 300 # needed if no Gramplet installed
pos = width - min(ch_width, 400)
self._setup_slider_config(widget, 'hpane.slider-position',
position=pos)

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)

Expand Down
2 changes: 1 addition & 1 deletion gramps/gui/widgets/grampletbar.py
Expand Up @@ -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)

Expand Down

0 comments on commit 7f8f0b8

Please sign in to comment.