Commit 24ea3db8 authored by VIGNET Pierre's avatar VIGNET Pierre

Add accelerators on most of buttons in the interface: Menu/Nodes types: F1 -> F7

parent c610835d
......@@ -111,6 +111,11 @@ class Charter(object):
color = color_parse(Charter.BG_COLOR)
self.main_window.modify_bg(gtk.STATE_NORMAL, color)
self.constraint_window = None
# Accelerators
self.my_accelerators = gtk.AccelGroup()
self.main_window.add_accel_group(self.my_accelerators)
# menu bar
menu_bar = self.wtree.get_widget("menubar1")
menu_bar.modify_bg(gtk.STATE_NORMAL, color)
......@@ -122,16 +127,20 @@ class Charter(object):
menu_item = self.wtree.get_widget("legend_menu")
menu_item.connect("activate", self.show_legend)
menu_item = self.wtree.get_widget("New_model")
self.add_accelerator(menu_item, "<Control>n")
menu_item.connect("activate", self.new_charts)
menu_item = self.wtree.get_widget("Import_cadbiom")
self.add_accelerator(menu_item, "<Control>o")
menu_item.connect("activate", self.choose_xml_file)
menu_item = self.wtree.get_widget("Import_BioPAX")
self.add_accelerator(menu_item, "<Control>b")
menu_item.connect("activate", self.choose_BioPAX_file)
menu_item = self.wtree.get_widget("Import_PID")
menu_item.connect("activate", self.choose_pid_file)
menu_item = self.wtree.get_widget("Import_CadLang")
menu_item.connect("activate", self.choose_cadlang_file)
menu_item = self.wtree.get_widget("Export_cadbiom")
self.add_accelerator(menu_item, "<Control>s")
menu_item.connect("activate", self.export_to_xml)
menu_item = self.wtree.get_widget("Export_cadlang")
menu_item.connect("activate", self.export_to_lang)
......@@ -209,30 +218,37 @@ class Charter(object):
self.button_handlers["Select"] = (but, -1)
but = gtk.Button(label = "InputNode")
self.add_accelerator(but, "F1")
c_box.add(but)
self.button_handlers["InputNode"] = (but, -1)
but = gtk.Button(label = "SimpleNode")
self.add_accelerator(but, "F2")
c_box.add(but)
self.button_handlers["SimpleNode"] = (but, -1)
but = gtk.Button(label = "PermNode")
self.add_accelerator(but, "F3")
c_box.add(but)
self.button_handlers["PermNode"] = (but, -1)
but = gtk.Button(label = "StartNode")
self.add_accelerator(but, "F4")
c_box.add(but)
self.button_handlers["StartNode"] = (but, -1)
but = gtk.Button(label = "TrapNode")
self.add_accelerator(but, "F5")
c_box.add(but)
self.button_handlers["TrapNode"] = (but, -1)
but = gtk.Button(label = "Transition")
self.add_accelerator(but, "F6")
c_box.add(but)
self.button_handlers["Transition"] = (but, -1)
but = gtk.Button(label = "Constraints")
self.add_accelerator(but, "F7")
c_box.add(but)
self.button_handlers["Constraints"] = (but, -1)
......@@ -296,6 +312,20 @@ class Charter(object):
bhan = but.connect("clicked", self.current_edit_mvc.zoom_minus)
self.button_handlers["zoom_m"] = (but, bhan)
def add_accelerator(self, widget, accelerator, signal="activate"):
"""Adds a keyboard shortcut"""
if accelerator is not None:
#if DEBUG:
#print accelerator, widget.get_tooltip_text()
key, mod = gtk.accelerator_parse(accelerator)
# VISIBLE: if set, the accelerator is visible in a label
widget.add_accelerator(signal,
self.my_accelerators,
key, mod,
gtk.ACCEL_VISIBLE,
)
# print "The accelerator is well added with the signal " + signal
def drawing_button_disconnect(self):
"""
Disconnect graphic editor buttons
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment