def do_init(self): editor = moo.Editor.instance() xml = editor.get_ui_xml() if xml is None: # standalone python module, not in medit return False self.ui_merge_id = xml.new_merge_id() if have_pyconsole: moo.window_class_add_action(moo.EditWindow, "PythonConsole", display_name=_("Python Console"), label=_("Python Console"), callback=self.show_console) xml.add_item(self.ui_merge_id, "ToolsMenu", "PythonConsole", "PythonConsole", -1) """ Run file """ moo.window_class_add_action(moo.EditWindow, "RunFile", display_name=_("Run File"), label=_("Run File"), stock_id=moo.STOCK_EXECUTE, default_accel="<shift>F9", callback=self.run_file) moo.edit_window_set_action_filter("RunFile", moo.ACTION_CHECK_SENSITIVE, "langs:python") xml.add_item(self.ui_merge_id, "ToolsMenu", "RunFile", "RunFile", -1) return True
def init(self, project): editor = moo.Editor.instance() editor.set_property("allow-empty-window", True) editor.set_property("single-window", True) moo.window_class_add_action(moo.EditWindow, "NewProject", display_name=_("New Project"), label=_("New Project..."), stock_id=moo.STOCK_NEW_PROJECT, callback=self.new_project_cb) moo.window_class_add_action(moo.EditWindow, "OpenProject", display_name=_("Open Project"), label=_("Open Project"), stock_id=moo.STOCK_OPEN_PROJECT, callback=self.open_project_cb) moo.window_class_add_action(moo.EditWindow, "ProjectOptions", display_name=_("Project _Options"), label=_("Project Options"), stock_id=moo.STOCK_PROJECT_OPTIONS, callback=self.project_options_cb) moo.window_class_add_action(moo.EditWindow, "CloseProject", display_name=_("Close Project"), label=_("Close Project"), stock_id=moo.STOCK_CLOSE_PROJECT, callback=self.close_project_cb) self.__init_project_types() self.project_to_open = project self.project = None self.window = None self.recent_list = moo.HistoryList("ProjectManager") self.recent_list.connect("activate_item", self.recent_item_activated) moo.window_class_add_action(moo.EditWindow, "OpenRecentProject", factory=_OpenRecent(self)) xml = editor.get_ui_xml() self.merge_id = xml.new_merge_id() xml.insert_markup_after( self.merge_id, "Editor/Menubar", "View", """ <item name="Project" _label="%s"> <item action="NewProject"/> <item action="OpenProject"/> <item action="OpenRecentProject"/> <separator/> <item action="ProjectOptions"/> <separator/> <item action="CloseProject"/> <separator/> </item> """ % (N_("_Project"), ))
def init(self, project): editor = moo.Editor.instance() editor.set_property("allow-empty-window", True) editor.set_property("single-window", True) moo.window_class_add_action(moo.EditWindow, "NewProject", display_name=_("New Project"), label=_("New Project..."), stock_id=moo.STOCK_NEW_PROJECT, callback=self.new_project_cb) moo.window_class_add_action(moo.EditWindow, "OpenProject", display_name=_("Open Project"), label=_("Open Project"), stock_id=moo.STOCK_OPEN_PROJECT, callback=self.open_project_cb) moo.window_class_add_action(moo.EditWindow, "ProjectOptions", display_name=_("Project _Options"), label=_("Project Options"), stock_id=moo.STOCK_PROJECT_OPTIONS, callback=self.project_options_cb) moo.window_class_add_action(moo.EditWindow, "CloseProject", display_name=_("Close Project"), label=_("Close Project"), stock_id=moo.STOCK_CLOSE_PROJECT, callback=self.close_project_cb) self.__init_project_types() self.project_to_open = project self.project = None self.window = None self.recent_list = moo.HistoryList("ProjectManager") self.recent_list.connect("activate_item", self.recent_item_activated) moo.window_class_add_action(moo.EditWindow, "OpenRecentProject", factory=_OpenRecent(self)) xml = editor.get_ui_xml() self.merge_id = xml.new_merge_id() xml.insert_markup_after(self.merge_id, "Editor/Menubar", "View", """ <item name="Project" _label="%s"> <item action="NewProject"/> <item action="OpenProject"/> <item action="OpenRecentProject"/> <separator/> <item action="ProjectOptions"/> <separator/> <item action="CloseProject"/> <separator/> </item> """ % (N_("_Project"),))
def do_init(self): editor = moo.Editor.instance() xml = editor.get_ui_xml() self.ui_merge_id = xml.new_merge_id() # Create a new action associated with editor windows moo.window_class_add_action( moo.EditWindow, "AnAction", # unique action id display_name="Do Something", # what user sees in Configure Shortcuts dialog label="Do Something", # menu item label stock_id=gtk.STOCK_APPLY, # stock icon callback=self.do_stuff, # the action callback ) # and add it into the xml, so it's actually persent in menu xml.add_item(self.ui_merge_id, "Editor/Menubar/Tools", name="AnAction", action="AnAction", position=-1) return True
def do_init(self): editor = moo.Editor.instance() xml = editor.get_ui_xml() self.ui_merge_id = xml.new_merge_id() # Create a new action associated with editor windows moo.window_class_add_action( moo.EditWindow, "AnAction", # unique action id display_name= "Do Something", # what user sees in Configure Shortcuts dialog label="Do Something", # menu item label stock_id=gtk.STOCK_APPLY, # stock icon callback=self.do_stuff # the action callback ) # and add it into the xml, so it's actually persent in menu xml.add_item(self.ui_merge_id, "Editor/Menubar/Tools", name="AnAction", action="AnAction", position=-1) return True
def add_action(self, id, **kwargs): moo.window_class_add_action(moo.EditWindow, id, **kwargs) self.actions.append(id)