def __init__(self, main_window): Gtk.Dialog.__init__(self, _("Block Manager"), main_window, 0, ()) self.main_window = main_window self.main_control = self self.set_default_size(400, 300) box = self.get_content_area() vbox = Gtk.VBox() box.pack_start(vbox, True, True, 0) # Block List self.block_notebook = BlockNotebook(self) # Button bar button_bar = Gtk.HBox() button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_NEW) button.connect("clicked", self.__new, None) button_bar.pack_start(button, False, False, 0) button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_EDIT) button.connect("clicked", self.__edit, None) button_bar.pack_start(button, False, False, 0) button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_DELETE) button.connect("clicked", self.__delete, None) button_bar.pack_start(button, False, False, 0) vbox.pack_start(self.block_notebook, True, True, 0) vbox.pack_start(button_bar, False, False, 0) self.show_all() self.show()
class TestBlockNotebook(TestBase): def setUp(self): self.block_notebook = BlockNotebook(self.create_main_window()) def test_update_blocks(self): blocks = System.get_blocks() self.assertIsNone(self.block_notebook.update_blocks(blocks), "Failed to update blocks") def test_search(self): query = "Add Float" self.assertIsNone(self.block_notebook.search(query)) def test_get_selected_block(self): self.assertIsNone(self.block_notebook.get_selected_block())
class TestBlockNotebook(TestCase): def setUp(self): """Do the test basic setup.""" win = MainWindow() self.blocknotebook = BlockNotebook(win) # ---------------------------------------------------------------------- def test_update(self): self.assertIsNone(self.blocknotebook.update()) # ---------------------------------------------------------------------- def test_search(self): query = "Testando" self.assertIsNone(self.blocknotebook.search(query)) query = None self.assertIsNone(self.blocknotebook.search(query)) # ---------------------------------------------------------------------- def test_get_selected_block(self): self.assertIsNone(self.blocknotebook.get_selected_block())
def __init__(self, main_window): Gtk.Dialog.__init__(self, title=_("Block Manager"), transient_for=main_window) self.main_window = main_window self.main_control = self self.set_default_size(400, 300) box = self.get_content_area() vbox = Gtk.VBox() box.pack_start(vbox, True, True, 0) # Block List self.block_notebook = BlockNotebook(self) self.update() vbox.pack_start(self.block_notebook, True, True, 0) # Button bar button_bar = ButtonBar() button_bar.add_button({ "icone": Gtk.STOCK_NEW, "action": self.__new, "data": None }) button_bar.add_button({ "icone": Gtk.STOCK_EDIT, "action": self.__edit, "data": None }) button_bar.add_button({ "icone": Gtk.STOCK_DELETE, "action": self.__delete, "data": None }) vbox.pack_start(button_bar, False, False, 0) self.show_all() self.show()
def setUp(self): self.block_notebook = BlockNotebook(self.create_main_window())
def setUp(self): """Do the test basic setup.""" win = MainWindow() self.blocknotebook = BlockNotebook(win)
class BlockManager(Gtk.Dialog): """ This class contains methods related the BlockManager class """ # ---------------------------------------------------------------------- def __init__(self, main_window): Gtk.Dialog.__init__(self, _("Block Manager"), main_window, 0, ()) self.main_window = main_window self.main_control = self self.set_default_size(400, 300) box = self.get_content_area() vbox = Gtk.VBox() box.pack_start(vbox, True, True, 0) # Block List self.block_notebook = BlockNotebook(self) self.update() vbox.pack_start(self.block_notebook, True, True, 0) # Button bar button_bar = ButtonBar() button_bar.add_button({ "icone": Gtk.STOCK_NEW, "action": self.__new, "data": None }) button_bar.add_button({ "icone": Gtk.STOCK_EDIT, "action": self.__edit, "data": None }) button_bar.add_button({ "icone": Gtk.STOCK_DELETE, "action": self.__delete, "data": None }) vbox.pack_start(button_bar, False, False, 0) self.show_all() self.show() # ---------------------------------------------------------------------- def __new(self, widget=None, data=None): BlockEditor(self, BlockModel()) # ---------------------------------------------------------------------- def __edit(self, widget=None, data=None): block = self.block_notebook.get_selected_block() if block is None: return BlockEditor(self, block) # ---------------------------------------------------------------------- def __delete(self, widget=None, data=None): block = self.block_notebook.get_selected_block() if block is None: return dialog = Dialog().confirm_dialog(_("Are you sure?"), self) result = dialog.run() dialog.destroy() if result == Gtk.ResponseType.OK: self.main_window.main_control.delete_block(block) self.update() # ---------------------------------------------------------------------- def set_block(self, block): """ This method is called when a block is selected. Nothing to do here. Parameters: block Returns: None. """ pass # ---------------------------------------------------------------------- def add_block(self, block): """ This method is called when a block is double clicked. Parameters: * **block** (:class:`<>`) """ BlockEditor(self, self.block_notebook.get_selected_block()) # ---------------------------------------------------------------------- def add_new_block(self, block): self.main_window.main_control.add_new_block(block) # ---------------------------------------------------------------------- def update(self): System() self.block_notebook.update_blocks(System.get_blocks())
def __init__(self): """ This method is constructor. """ System() Gtk.Window.__init__(self, title="Mosaicode") self.resize(System.get_preferences().width, System.get_preferences().height) self.main_control = MainControl(self) # GUI components self.menu = Menu(self) self.toolbar = Toolbar(self) self.search = SearchBar(self) self.block_notebook = BlockNotebook(self) self.property_box = PropertyBox(self) self.work_area = WorkArea(self) self.status = Status(self) self.diagram_menu = DiagramMenu() self.menu.add_help() self.block_menu = BlockMenu() System.set_log(self.status) # vbox main # ----------------------------------------------------- # | Menu # ----------------------------------------------------- # | Toolbar # ----------------------------------------------------- # | V Paned bottom # ----------------------------------------------------- # First Vertical Box vbox_main = Gtk.VBox() self.add(vbox_main) vbox_main.pack_start(self.menu, False, True, 0) vbox_main.pack_start(self.toolbar, False, False, 0) self.vpaned_bottom = Gtk.Paned.new(Gtk.Orientation.VERTICAL) vbox_main.add(self.vpaned_bottom) # vpaned_bottom # ----------------------------------------------------- # | hpaned_work_area # ===================================================== # | status # ----------------------------------------------------- self.hpaned_work_area = Gtk.HPaned() self.hpaned_work_area.connect("accept-position", self.__resize) self.hpaned_work_area.set_position( System.get_preferences().hpaned_work_area) self.vpaned_bottom.add1(self.hpaned_work_area) self.vpaned_bottom.add2(self.__create_frame(self.status)) self.vpaned_bottom.set_position(System.get_preferences().vpaned_bottom) self.vpaned_bottom.set_size_request(50, 50) # hpaned_work_area # ----------------------------------------------------- # | vbox_left || work_area # ----------------------------------------------------- vbox_left = Gtk.VBox(homogeneous=False, spacing=0) self.hpaned_work_area.add1(vbox_left) self.hpaned_work_area.add2(self.work_area) # vbox_left # ----------------------------------------------------- # |search # ----------------------------------------------------- # |vpaned_left # ----------------------------------------------------- vbox_left.pack_start(self.search, False, False, 0) self.vpaned_left = Gtk.VPaned() vbox_left.pack_start(self.vpaned_left, True, True, 0) # vpaned_left # ----------------------------------------------------- # |blocks_tree_view # ===================================================== # |property_box # ----------------------------------------------------- self.vpaned_left.add1(self.__create_frame(self.block_notebook)) self.vpaned_left.add2(self.__create_frame(self.property_box)) self.vpaned_left.set_position(System.get_preferences().vpaned_left) self.connect("key-press-event", self.__on_key_press) self.connect("check-resize", self.__resize) self.connect("delete-event", self.main_control.exit) self.main_control.init() # Load the plugin from mosaicode.plugins.extensionsmanager.extensionsmanager \ import ExtensionsManager as em em().load(self)
class TestBlockNotebook(TestBase): def setUp(self): self.block_notebook = BlockNotebook(self.create_main_window()) self.block_notebook.update_blocks() def test_update_blocks(self): self.assertIsNone(self.block_notebook.update_blocks(), "Failed to update blocks") self.assertIsNone(self.block_notebook.update_blocks(), "Failed to update blocks") def test_search(self): query = "Add Float" self.assertIsNone(self.block_notebook.search(query)) def test_get_selected_block(self): self.block_notebook.get_selected_block() self.block_notebook.set_current_page(0) while self.block_notebook.get_n_pages() > 0: self.block_notebook.remove_page(0) self.block_notebook.tabs.pop() self.block_notebook.get_selected_block()
def setUp(self): self.block_notebook = BlockNotebook(self.create_main_window()) blocks = System.get_blocks() self.block_notebook.update_blocks(blocks)
class BlockManager(Gtk.Dialog): """ This class contains methods related the BlockManager class """ # ---------------------------------------------------------------------- def __init__(self, main_window): Gtk.Dialog.__init__(self, title=_("Block Manager"), transient_for=main_window) self.main_window = main_window self.main_control = self self.set_default_size(400, 300) box = self.get_content_area() vbox = Gtk.VBox() box.pack_start(vbox, True, True, 0) # Block List self.block_notebook = BlockNotebook(self) self.update() vbox.pack_start(self.block_notebook, True, True, 0) # Button bar button_bar = ButtonBar() button_bar.add_button({ "icone": Gtk.STOCK_NEW, "action": self.__new, "data": None }) button_bar.add_button({ "icone": Gtk.STOCK_EDIT, "action": self.__edit, "data": None }) button_bar.add_button({ "icone": Gtk.STOCK_DELETE, "action": self.__delete, "data": None }) vbox.pack_start(button_bar, False, False, 0) self.show_all() self.show() # ---------------------------------------------------------------------- def __new(self, widget=None, data=None): BlockEditor(self, BlockModel()).run() # ---------------------------------------------------------------------- def __edit(self, widget=None, data=None): block = self.block_notebook.get_selected_block() if block is None: return BlockEditor(self, block).run() # ---------------------------------------------------------------------- def __delete(self, widget=None, data=None): block = self.block_notebook.get_selected_block() if block is None: return result = ConfirmDialog(_("Are you sure?"), self).run() if result == Gtk.ResponseType.OK: self.main_window.main_control.delete_block(block) self.update() # ---------------------------------------------------------------------- def add_new_block(self, block): self.main_window.main_control.add_new_block(block) # ---------------------------------------------------------------------- def update(self): System() self.block_notebook.update_blocks(System.get_blocks())
class PluginManager(Gtk.Dialog): """ This class contains methods related the PluginManager class """ # ---------------------------------------------------------------------- def __init__(self, main_window): Gtk.Dialog.__init__(self, _("Plugin Manager"), main_window, 0, ()) self.main_window = main_window self.plugin = Plugin() self.main_control = self self.set_default_size(400, 300) box = self.get_content_area() vbox = Gtk.VBox() box.pack_start(vbox, True, True, 0) # Plugin List self.block_notebook = BlockNotebook(self) # Button bar button_bar = Gtk.HBox() button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_NEW) button.connect("clicked", self.__new, None) button_bar.pack_start(button, False, False, 0) button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_EDIT) button.connect("clicked", self.__edit, None) button_bar.pack_start(button, False, False, 0) button = Gtk.ToolButton.new_from_stock(Gtk.STOCK_DELETE) button.connect("clicked", self.__delete, None) button_bar.pack_start(button, False, False, 0) vbox.pack_start(self.block_notebook, True, True, 0) vbox.pack_start(button_bar, False, False, 0) self.show_all() self.show() # ---------------------------------------------------------------------- def __new(self, widget=None, data=None): PluginEditor(self, Plugin()) # ---------------------------------------------------------------------- def __edit(self, widget=None, data=None): plugin = self.block_notebook.get_selected_block() if plugin is None: return PluginEditor(self, plugin) # ---------------------------------------------------------------------- def __delete(self, widget=None, data=None): plugin = self.block_notebook.get_selected_block() if plugin is None: return dialog = Dialog().confirm_dialog(_("Are you sure?"), self) result = dialog.run() dialog.destroy() if result == Gtk.ResponseType.OK: self.main_window.main_control.delete_plugin(plugin) self.update() # ---------------------------------------------------------------------- def set_block(self, plugin): """ This method is called when a block is selected. Nothing to do here. Parameters: plugin Returns: None. """ pass # ---------------------------------------------------------------------- def add_block(self, plugin): """ This method is called when a block is double clicked. Parameters: * **plugin** (:class:`<>`) """ PluginEditor(self, self.block_notebook.get_selected_block()) # ---------------------------------------------------------------------- def add_plugin(self, plugin): self.main_window.main_control.add_plugin(plugin) # ---------------------------------------------------------------------- def update(self): self.block_notebook.update()