remember in every view cat the last used view
svn: r14232
This commit is contained in:
parent
6c7fcf4607
commit
63652c3239
@ -261,7 +261,6 @@ register('preferences.fprefix', 'F%04d')
|
|||||||
register('preferences.hide-ep-msg', False)
|
register('preferences.hide-ep-msg', False)
|
||||||
register('preferences.invalid-date-format', "<b>%s</b>")
|
register('preferences.invalid-date-format', "<b>%s</b>")
|
||||||
register('preferences.iprefix', 'I%04d')
|
register('preferences.iprefix', 'I%04d')
|
||||||
register('preferences.last-view', '')
|
|
||||||
register('preferences.name-format', 1)
|
register('preferences.name-format', 1)
|
||||||
register('preferences.no-given-text', "[%s]" % _("Missing Given Name"))
|
register('preferences.no-given-text', "[%s]" % _("Missing Given Name"))
|
||||||
register('preferences.no-record-text', "[%s]" % _("Missing Record"))
|
register('preferences.no-record-text', "[%s]" % _("Missing Record"))
|
||||||
@ -279,6 +278,8 @@ register('preferences.rprefix', 'R%04d')
|
|||||||
register('preferences.sprefix', 'S%04d')
|
register('preferences.sprefix', 'S%04d')
|
||||||
register('preferences.todo-color', '#ff0000')
|
register('preferences.todo-color', '#ff0000')
|
||||||
register('preferences.use-last-view', True)
|
register('preferences.use-last-view', True)
|
||||||
|
register('preferences.last-view', '')
|
||||||
|
register('preferences.last-views', [])
|
||||||
|
|
||||||
register('researcher.researcher-addr', '')
|
register('researcher.researcher-addr', '')
|
||||||
register('researcher.researcher-city', '')
|
register('researcher.researcher-city', '')
|
||||||
|
@ -870,15 +870,17 @@ class ViewManager(CLIManager):
|
|||||||
self.cat_view_group = None
|
self.cat_view_group = None
|
||||||
|
|
||||||
use_text = config.get('interface.sidebar-text')
|
use_text = config.get('interface.sidebar-text')
|
||||||
|
#obtain which views should be the active ones
|
||||||
index = 0
|
current_cat, current_cat_view, default_cat_views = \
|
||||||
for cat_views in self.views:
|
self.__views_to_show(config.get('preferences.use-last-view'))
|
||||||
|
|
||||||
|
for indexcat, cat_views in enumerate(self.views):
|
||||||
#for every category, we create a button in the sidebar and a main
|
#for every category, we create a button in the sidebar and a main
|
||||||
#workspace in which to show the view
|
#workspace in which to show the view
|
||||||
nr_views = len(cat_views)
|
nr_views = len(cat_views)
|
||||||
uimenuitems = ''
|
uimenuitems = ''
|
||||||
uitoolitems = ''
|
uitoolitems = ''
|
||||||
self.view_toggle_actions[index] = []
|
self.view_toggle_actions[indexcat] = []
|
||||||
self.pages.append([])
|
self.pages.append([])
|
||||||
nrpage = 0
|
nrpage = 0
|
||||||
for pdata, page_def in cat_views:
|
for pdata, page_def in cat_views:
|
||||||
@ -913,7 +915,7 @@ class ViewManager(CLIManager):
|
|||||||
page_cat)
|
page_cat)
|
||||||
|
|
||||||
# create the button and add it to the sidebar
|
# create the button and add it to the sidebar
|
||||||
button = self.__make_sidebar_button(use_text, index,
|
button = self.__make_sidebar_button(use_text, indexcat,
|
||||||
page_translated_category,
|
page_translated_category,
|
||||||
page_stock)
|
page_stock)
|
||||||
|
|
||||||
@ -937,7 +939,7 @@ class ViewManager(CLIManager):
|
|||||||
uimenuitems += '\n<menuitem action="%s"/>' % pageid
|
uimenuitems += '\n<menuitem action="%s"/>' % pageid
|
||||||
uitoolitems += '\n<toolitem action="%s"/>' % pageid
|
uitoolitems += '\n<toolitem action="%s"/>' % pageid
|
||||||
# id, stock, button text, UI, tooltip, page
|
# id, stock, button text, UI, tooltip, page
|
||||||
self.view_toggle_actions[index].append((pageid,
|
self.view_toggle_actions[indexcat].append((pageid,
|
||||||
page.get_viewtype_stock(),
|
page.get_viewtype_stock(),
|
||||||
pdata.name, '<CONTROL>%i' % (nrpage+1), page_title,
|
pdata.name, '<CONTROL>%i' % (nrpage+1), page_title,
|
||||||
nrpage))
|
nrpage))
|
||||||
@ -945,12 +947,10 @@ class ViewManager(CLIManager):
|
|||||||
nrpage += 1
|
nrpage += 1
|
||||||
if nr_views > 1:
|
if nr_views > 1:
|
||||||
#allow for switching views in a category
|
#allow for switching views in a category
|
||||||
self.ui_category[index] = UICATEGORY % (uimenuitems,
|
self.ui_category[indexcat] = UICATEGORY % (uimenuitems,
|
||||||
uitoolitems)
|
uitoolitems)
|
||||||
index += 1
|
#set view cat to last used in this category
|
||||||
|
self.notebook_cat[-1].set_current_page(default_cat_views[indexcat])
|
||||||
current_cat, current_cat_view = self.__view_to_show(
|
|
||||||
config.get('preferences.use-last-view'))
|
|
||||||
|
|
||||||
self.active_page = self.pages[current_cat][current_cat_view]
|
self.active_page = self.pages[current_cat][current_cat_view]
|
||||||
self.buttons[current_cat].set_active(True)
|
self.buttons[current_cat].set_active(True)
|
||||||
@ -958,30 +958,34 @@ class ViewManager(CLIManager):
|
|||||||
self.notebook.set_current_page(current_cat)
|
self.notebook.set_current_page(current_cat)
|
||||||
self.notebook_cat[current_cat].set_current_page(current_cat_view)
|
self.notebook_cat[current_cat].set_current_page(current_cat_view)
|
||||||
|
|
||||||
def __view_to_show(self, use_last = True):
|
def __views_to_show(self, use_last = True):
|
||||||
"""
|
"""
|
||||||
Determine based on preference setting which view should be shown
|
Determine based on preference setting which views should be shown
|
||||||
"""
|
"""
|
||||||
current_cat = 0
|
current_cat = 0
|
||||||
current_cat_view = 0
|
current_cat_view = 0
|
||||||
|
default_cat_views = [0] * len(self.views)
|
||||||
if use_last:
|
if use_last:
|
||||||
current_page_id = config.get('preferences.last-view')
|
current_page_id = config.get('preferences.last-view')
|
||||||
|
default_page_ids = config.get('preferences.last-views')
|
||||||
found = False
|
found = False
|
||||||
for cat_views in self.views:
|
for indexcat, cat_views in enumerate(self.views):
|
||||||
current_cat_view = 0
|
cat_view = 0
|
||||||
for pdata, page_def in cat_views:
|
for pdata, page_def in cat_views:
|
||||||
if pdata.id == current_page_id:
|
if not found:
|
||||||
found = True
|
if pdata.id == current_page_id:
|
||||||
break
|
current_cat = indexcat
|
||||||
else:
|
current_cat_view = cat_view
|
||||||
current_cat_view += 1
|
default_cat_views[indexcat] = cat_view
|
||||||
if found:
|
found = True
|
||||||
break
|
break
|
||||||
current_cat += 1
|
if pdata.id in default_page_ids:
|
||||||
|
default_cat_views[indexcat] = cat_view
|
||||||
|
cat_view += 1
|
||||||
if not found:
|
if not found:
|
||||||
current_cat = 0
|
current_cat = 0
|
||||||
current_cat_view = 0
|
current_cat_view = 0
|
||||||
return current_cat, current_cat_view
|
return current_cat, current_cat_view, default_cat_views
|
||||||
|
|
||||||
def __make_sidebar_button(self, use_text, index, page_title, page_stock):
|
def __make_sidebar_button(self, use_text, index, page_title, page_stock):
|
||||||
"""
|
"""
|
||||||
@ -1151,12 +1155,17 @@ class ViewManager(CLIManager):
|
|||||||
view_page = self.notebook_cat[category_page].get_current_page()
|
view_page = self.notebook_cat[category_page].get_current_page()
|
||||||
if self.dbstate.open:
|
if self.dbstate.open:
|
||||||
self.__disconnect_previous_page()
|
self.__disconnect_previous_page()
|
||||||
|
|
||||||
if len(self.pages) > 0:
|
if len(self.pages) > 0:
|
||||||
self.active_page = self.pages[category_page][view_page]
|
self.active_page = self.pages[category_page][view_page]
|
||||||
self.active_page.set_active()
|
self.active_page.set_active()
|
||||||
config.set('preferences.last-view',
|
newcurpageid = self.views[category_page][view_page][0].id
|
||||||
self.views[category_page][view_page][0].id)
|
config.set('preferences.last-view', newcurpageid)
|
||||||
|
olddefaults = config.get('preferences.last-views')
|
||||||
|
if len(olddefaults) != len(self.pages):
|
||||||
|
#number views changed, we cannot trust the old
|
||||||
|
olddefaults = [''] * len(self.pages)
|
||||||
|
olddefaults[category_page] = newcurpageid
|
||||||
|
config.set('preferences.last-views', olddefaults)
|
||||||
config.save()
|
config.save()
|
||||||
|
|
||||||
self.__connect_active_page(category_page, view_page)
|
self.__connect_active_page(category_page, view_page)
|
||||||
|
Loading…
Reference in New Issue
Block a user