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 Jan 27, 2018
1 parent b1af1c5 commit cc045b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions gramps/gui/views/pageview.py
Expand Up @@ -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()

Expand All @@ -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)

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 cc045b5

Please sign in to comment.