Saves title override; removed title_id

svn: r16994
This commit is contained in:
Doug Blank 2011-03-30 20:00:19 +00:00
parent 452538b370
commit 1d2ed8bf36

View File

@ -81,7 +81,6 @@ def GET_AVAILABLE_GRAMPLETS(name):
"height": gplug.height,
"expand": gplug.expand,
"title": gplug.gramplet_title, # translated
"title_id": gplug.gramplet_title_id, # untranslated
"content": gplug.gramplet,
"detached_width": gplug.detached_width,
"detached_height": gplug.detached_height,
@ -779,7 +778,6 @@ class GridGramplet(GuiGramplet):
"""
result = self.set_title(widget.get_text())
if result: # if ok to set title to that
self.title_override = True
self.titlelabel.show()
widget.hide()
return False # Return False for gtk requirement
@ -899,10 +897,12 @@ class GridGramplet(GuiGramplet):
self.scrolledwindow.set_size_request(-1, self.height)
self.set_state(self.gstate)
def set_title(self, new_title):
def set_title(self, new_title, set_override=True):
# can't do it if already titled that way
if self.title == new_title: return True
if new_title in self.pane.gramplet_map: return False
if set_override:
self.title_override = True
del self.pane.gramplet_map[self.title]
self.title = new_title
if self.detached_window:
@ -971,18 +971,21 @@ class GrampletPane(gtk.ScrolledWindow):
all_opts["state"] = "maximized"
if "title" not in all_opts:
all_opts["title"] = _("Untitled Gramplet")
all_opts["title_id"] = "Untitled Gramplet"
set_override = False
else:
set_override = True
# May have to change title
g = make_requested_gramplet(GridGramplet, self, all_opts,
self.dbstate, self.uistate)
if g:
g.title_override = set_override # to continue to override, when this is saved
# make a unique title:
unique = g.get_title()
cnt = 1
while unique in self.gramplet_map:
unique = g.get_title() + ("-%d" % cnt)
cnt += 1
g.set_title(unique)
g.set_title(unique, set_override=False)
self.gramplet_map[unique] = g
self.frame_map[str(g.mainframe)] = g
else:
@ -1137,8 +1140,9 @@ class GrampletPane(gtk.ScrolledWindow):
fp.write(("[%s]" + NL) % gramplet.gname)
for key in base_opts:
if key == "content": continue
elif key == "title": continue
elif key == "title_id": continue
elif key == "title":
if gramplet.title_override:
fp.write(("title=%s" + NL)% base_opts[key])
elif key == "tname": continue
elif key == "column": continue
elif key == "row": continue
@ -1169,8 +1173,9 @@ class GrampletPane(gtk.ScrolledWindow):
fp.write(("[%s]" + NL) % gramplet.title)
for key in base_opts:
if key == "content": continue
elif key == "title": continue
elif key == "title_id": continue
elif key == "title":
if self.title_override:
fp.write(("title=%s" + NL)% base_opts[key])
elif key == "tname": continue
elif key == "version": continue # code, don't save
elif key == "gramps": continue # code, don't save