Add gadgets by translated name; save by real name
svn: r9655
This commit is contained in:
parent
6456384658
commit
ce1030db89
@ -53,6 +53,7 @@ debug = False
|
|||||||
def register_gadget(data_dict):
|
def register_gadget(data_dict):
|
||||||
global AVAILABLE_GADGETS
|
global AVAILABLE_GADGETS
|
||||||
base_opts = {"name":"Unnamed Gadget",
|
base_opts = {"name":"Unnamed Gadget",
|
||||||
|
"tname": _("Unnamed Gadget"),
|
||||||
"state":"maximized",
|
"state":"maximized",
|
||||||
"column": -1, "row": -1,
|
"column": -1, "row": -1,
|
||||||
"data": []}
|
"data": []}
|
||||||
@ -86,6 +87,14 @@ def get_gadget_options_by_name(name):
|
|||||||
print ("Unknown gadget name: '%s'" % name)
|
print ("Unknown gadget name: '%s'" % name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_gadget_options_by_tname(name):
|
||||||
|
if debug: print "name:", name
|
||||||
|
for key in AVAILABLE_GADGETS:
|
||||||
|
if AVAILABLE_GADGETS[key]["tname"] == name:
|
||||||
|
return AVAILABLE_GADGETS[key].copy()
|
||||||
|
print ("Unknown gadget name: '%s'" % name)
|
||||||
|
return None
|
||||||
|
|
||||||
def make_requested_gadget(viewpage, name, opts, dbstate, uistate):
|
def make_requested_gadget(viewpage, name, opts, dbstate, uistate):
|
||||||
if name in AVAILABLE_GADGETS:
|
if name in AVAILABLE_GADGETS:
|
||||||
gui = GuiGadget(viewpage, dbstate, uistate, **opts)
|
gui = GuiGadget(viewpage, dbstate, uistate, **opts)
|
||||||
@ -636,6 +645,7 @@ class MyGrampsView(PageView.PageView):
|
|||||||
data[opt] = cp.get(sec, opt).strip()
|
data[opt] = cp.get(sec, opt).strip()
|
||||||
if "name" not in data:
|
if "name" not in data:
|
||||||
data["name"] = "Unnamed Gadget"
|
data["name"] = "Unnamed Gadget"
|
||||||
|
data["tname"]= _("Unnamed Gadget")
|
||||||
retval.append((data["name"], data)) # name, opts
|
retval.append((data["name"], data)) # name, opts
|
||||||
else:
|
else:
|
||||||
# give defaults as currently known
|
# give defaults as currently known
|
||||||
@ -872,8 +882,9 @@ class MyGrampsView(PageView.PageView):
|
|||||||
self.drop_widget(self.widget, gadget, 0, 0, 0)
|
self.drop_widget(self.widget, gadget, 0, 0, 0)
|
||||||
|
|
||||||
def add_gadget(self, obj):
|
def add_gadget(self, obj):
|
||||||
name = obj.get_child().get_label()
|
tname = obj.get_child().get_label()
|
||||||
all_opts = get_gadget_options_by_name(name)
|
all_opts = get_gadget_options_by_tname(tname)
|
||||||
|
name = all_opts["name"]
|
||||||
if all_opts == None:
|
if all_opts == None:
|
||||||
print "Unknown gadget type: '%s'; bad gadgets.ini file?" % name
|
print "Unknown gadget type: '%s'; bad gadgets.ini file?" % name
|
||||||
return
|
return
|
||||||
@ -950,7 +961,8 @@ class MyGrampsView(PageView.PageView):
|
|||||||
qr_menu = ag_menu.get_submenu()
|
qr_menu = ag_menu.get_submenu()
|
||||||
if qr_menu == None:
|
if qr_menu == None:
|
||||||
qr_menu = gtk.Menu()
|
qr_menu = gtk.Menu()
|
||||||
names = AVAILABLE_GADGETS.keys()
|
names = [AVAILABLE_GADGETS[key]["tname"] for key
|
||||||
|
in AVAILABLE_GADGETS.keys()]
|
||||||
names.sort()
|
names.sort()
|
||||||
for name in names:
|
for name in names:
|
||||||
Utils.add_menuitem(qr_menu, name,
|
Utils.add_menuitem(qr_menu, name,
|
||||||
|
@ -516,15 +516,18 @@ class NewsGadget(Gadget):
|
|||||||
#print " after:", text
|
#print " after:", text
|
||||||
yield False, text
|
yield False, text
|
||||||
|
|
||||||
|
|
||||||
register(type="gadget",
|
register(type="gadget",
|
||||||
name= _("Top Surnames Gadget"),
|
name= "Top Surnames Gadget",
|
||||||
|
tname=_("1Top Surnames Gadget"),
|
||||||
height=230,
|
height=230,
|
||||||
content = TopSurnamesGadget,
|
content = TopSurnamesGadget,
|
||||||
title=_("Top Surnames"),
|
title=_("Top Surnames"),
|
||||||
)
|
)
|
||||||
|
|
||||||
register(type="gadget",
|
register(type="gadget",
|
||||||
name=_("Statistics Gadget"),
|
name="Statistics Gadget",
|
||||||
|
tname=_("1Statistics Gadget"),
|
||||||
height=230,
|
height=230,
|
||||||
expand=True,
|
expand=True,
|
||||||
content = StatsGadget,
|
content = StatsGadget,
|
||||||
@ -532,7 +535,8 @@ register(type="gadget",
|
|||||||
)
|
)
|
||||||
|
|
||||||
register(type="gadget",
|
register(type="gadget",
|
||||||
name=_("Session Log Gadget"),
|
name="Session Log Gadget",
|
||||||
|
tname=_("1Session Log Gadget"),
|
||||||
height=230,
|
height=230,
|
||||||
data=['no'],
|
data=['no'],
|
||||||
content = LogGadget,
|
content = LogGadget,
|
||||||
@ -540,7 +544,8 @@ register(type="gadget",
|
|||||||
)
|
)
|
||||||
|
|
||||||
register(type="gadget",
|
register(type="gadget",
|
||||||
name=_("Python Gadget"),
|
name="Python Gadget",
|
||||||
|
tname=_("1Python Gadget"),
|
||||||
height=250,
|
height=250,
|
||||||
content = PythonGadget,
|
content = PythonGadget,
|
||||||
title=_("Python Shell"),
|
title=_("Python Shell"),
|
||||||
@ -548,6 +553,7 @@ register(type="gadget",
|
|||||||
|
|
||||||
register(type="gadget",
|
register(type="gadget",
|
||||||
name=_("TODO Gadget"),
|
name=_("TODO Gadget"),
|
||||||
|
tname=_("1TODO Gadget"),
|
||||||
height=300,
|
height=300,
|
||||||
expand=True,
|
expand=True,
|
||||||
content = TODOGadget,
|
content = TODOGadget,
|
||||||
@ -555,7 +561,8 @@ register(type="gadget",
|
|||||||
)
|
)
|
||||||
|
|
||||||
register(type="gadget",
|
register(type="gadget",
|
||||||
name=_("Welcome Gadget"),
|
name="Welcome Gadget",
|
||||||
|
tname=_("1Welcome Gadget"),
|
||||||
height=300,
|
height=300,
|
||||||
expand=True,
|
expand=True,
|
||||||
content = make_welcome_content,
|
content = make_welcome_content,
|
||||||
@ -563,14 +570,16 @@ register(type="gadget",
|
|||||||
)
|
)
|
||||||
|
|
||||||
register(type="gadget",
|
register(type="gadget",
|
||||||
name=_("Calendar Gadget"),
|
name="Calendar Gadget",
|
||||||
|
tname=_("1Calendar Gadget"),
|
||||||
height=200,
|
height=200,
|
||||||
content = CalendarGadget,
|
content = CalendarGadget,
|
||||||
title=_("Calendar"),
|
title=_("Calendar"),
|
||||||
)
|
)
|
||||||
|
|
||||||
register(type="gadget",
|
register(type="gadget",
|
||||||
name=_("News Gadget"),
|
name="News Gadget",
|
||||||
|
tname=_("1News Gadget"),
|
||||||
height=300,
|
height=300,
|
||||||
expand=True,
|
expand=True,
|
||||||
content = NewsGadget,
|
content = NewsGadget,
|
||||||
|
Loading…
Reference in New Issue
Block a user