Exemple #1
0
class TiseanView:

    ##
    # The Constructor
    #
    # @param self the instance pointer
    #
    def __init__(self, controller):

        # Set the Glade file
        self.gladefile = "classes/gui/glade/tiseangui.glade"

        self.controller = controller
        self.currentForm = None
        # we load the main widgets of the view
        self.mainInterface = gtk.glade.XML(self.gladefile)
        self.mainWindow = self.mainInterface.get_widget("TiseanGUI")
        self.consoleWindow = self.mainInterface.get_widget("TiseanGuiConsole")
        self.menuBar = self.mainInterface.get_widget("TiseanMenuBar")
        self.optionsCommandsHolder = self.mainInterface.get_widget("TiseanCommandOptionsHolder")
        self.consoleMenuItem = self.mainInterface.get_widget("console1")
        self.aboutUsDialog = self.mainInterface.get_widget("TiseanGuiAbout")

        self.consoleWindow.hide()
        self.aboutUsDialog.hide()

        # we set updater method that process the messages that receives the console
        self.consoleUpdater = TiseanViewUpdater(self.consoleWindow)
        # we start the updater
        self.consoleUpdater.start_updater()

        # we connect the callbacks of the view
        self.callback_connection()

        ##
        # Setup of the command menu of the main view
        #
        # @param self the instance pointer
        # @param TiseanCommandMenu command menu widget
        #

    def command_menu_setup(self, tiseanCommandMenu):
        self.menuBar.insert(tiseanCommandMenu, 2)

        ##
        # Callback to Hide the ConsoleWindow
        #
        # @param self the instance pointer
        #

    def console_hide(self, widget, event):
        self.consoleWindow.hide()
        return True

        ##
        # Callback to Show the ConsoleWindow
        #
        # @param self the instance pointer
        #

    def console_show(self, widget, event):
        self.consoleWindow.show()
        return True

        ##
        # Shows the ConsoleWindow
        #
        # @param self the instance pointer
        #

    def console_show(self):
        self.consoleWindow.show()
        return True

        ##
        # Connects all the callbacks of the main elements of the view
        #
        # @param self the instance pointer

    def callback_connection(self):

        if self.mainWindow:
            self.mainWindow.connect("destroy", self.controller.application_close)

            # we prevent the console window to be destroyed
        if self.consoleWindow:
            self.consoleWindow.connect("delete-event", self.console_hide)

            # we prevent the about us dialog to be destroyed
        if self.aboutUsDialog:
            self.aboutUsDialog.connect("delete-event", self.about_dialog_hide)
            self.aboutUsDialog.connect("close", self.about_dialog_hide)

            # menu items callbacks

            # console display
        if self.consoleMenuItem:
            self.consoleMenuItem.connect("activate", self.console_display)

            # exit from file menu
        quitMenuItem = self.mainInterface.get_widget("quit1")
        if quitMenuItem:
            quitMenuItem.connect("activate", self.controller.application_close)

            # about us display
        aboutUsMenuItem = self.mainInterface.get_widget("about1")
        if aboutUsMenuItem:
            aboutUsMenuItem.connect("activate", self.about_dialog_show)

        return True

        ##
        # Callback to show the About Dialog on the GUI
        #
        # @param self the instance pointer
        # @param menuItem widget that performs the calling
        #

    def about_dialog_show(self, menuItem):
        self.aboutUsDialog.show()
        return True

        ##
        # Callback to hide the About Dialog on the GUI
        #
        # @param self the instance pointer
        #

    def about_dialog_hide(self, widget, event):
        self.aboutUsDialog.hide()
        return True

        ##
        # Callback to show the Console Dialog on the GUI
        #
        # @param self the instance pointer
        # @param menuItem widget that performs the calling
        #

    def console_display(self, menuItem):

        if self.consoleWindow.get_property("visible"):
            self.consoleWindow.hide()
        else:
            self.consoleWindow.show()

            ##
            # Shows the main elements controlled by the view
            #
            # @param self the instance pointer

    def show(self):
        self.mainWindow.show()

        ##
        # Sets the configuration form of a command on the main gui.
        #
        # @param self the instance pointer
        # @param form TiseanCommandForm instance
        #

    def set_command_form(self, form):
        if self.currentForm:
            self.optionsCommandsHolder.remove(self.currentForm)
        self.optionsCommandsHolder.pack_end(form)
        self.optionsCommandsHolder.set_border_width(10)
        self.currentForm = form

        ##
        # Getter of the current command form
        #
        # @param self the instance pointer
        #

    def get_command_form(self):
        return self.currentForm

        ##
        # Getter of the Console updater of the View
        #
        # @param self the instance pointer
        #

    def get_console_updater(self):
        return self.consoleUpdater

        ##
        # Stops the Console updater of the view
        #
        # @param self the instance pointer
        #

    def stop_console_updater(self):
        self.consoleUpdater.stop_updater()
Exemple #2
0
class TiseanView():

    ##
    # The Constructor
    #
    # @param self the instance pointer
    #
    def __init__(self, controller):

        #Set the Glade file
        self.gladefile = "classes/gui/glade/tiseangui.glade"

        self.controller = controller
        self.currentForm = None
        # we load the main widgets of the view
        self.mainInterface = gtk.glade.XML(self.gladefile)
        self.mainWindow = self.mainInterface.get_widget("TiseanGUI")
        self.consoleWindow = self.mainInterface.get_widget("TiseanGuiConsole")
        self.menuBar = self.mainInterface.get_widget("TiseanMenuBar")
        self.optionsCommandsHolder = self.mainInterface.get_widget(
            "TiseanCommandOptionsHolder")
        self.consoleMenuItem = self.mainInterface.get_widget("console1")
        self.aboutUsDialog = self.mainInterface.get_widget('TiseanGuiAbout')

        self.consoleWindow.hide()
        self.aboutUsDialog.hide()

        # we set updater method that process the messages that receives the console
        self.consoleUpdater = TiseanViewUpdater(self.consoleWindow)
        # we start the updater
        self.consoleUpdater.start_updater()

        #we connect the callbacks of the view
        self.callback_connection()

    ##
    # Setup of the command menu of the main view
    #
    # @param self the instance pointer
    # @param TiseanCommandMenu command menu widget
    #
    def command_menu_setup(self, tiseanCommandMenu):
        self.menuBar.insert(tiseanCommandMenu, 2)

    ##
    # Callback to Hide the ConsoleWindow
    #
    # @param self the instance pointer
    #
    def console_hide(self, widget, event):
        self.consoleWindow.hide()
        return True

    ##
    # Callback to Show the ConsoleWindow
    #
    # @param self the instance pointer
    #
    def console_show(self, widget, event):
        self.consoleWindow.show()
        return True

    ##
    # Shows the ConsoleWindow
    #
    # @param self the instance pointer
    #
    def console_show(self):
        self.consoleWindow.show()
        return True

    ##
    # Connects all the callbacks of the main elements of the view
    #
    # @param self the instance pointer
    def callback_connection(self):

        if (self.mainWindow):
            self.mainWindow.connect("destroy",
                                    self.controller.application_close)

        #we prevent the console window to be destroyed
        if (self.consoleWindow):
            self.consoleWindow.connect("delete-event", self.console_hide)

        #we prevent the about us dialog to be destroyed
        if (self.aboutUsDialog):
            self.aboutUsDialog.connect("delete-event", self.about_dialog_hide)
            self.aboutUsDialog.connect("close", self.about_dialog_hide)

        #menu items callbacks

        # console display
        if (self.consoleMenuItem):
            self.consoleMenuItem.connect("activate", self.console_display)

        # exit from file menu
        quitMenuItem = self.mainInterface.get_widget("quit1")
        if (quitMenuItem):
            quitMenuItem.connect("activate", self.controller.application_close)

        #about us display
        aboutUsMenuItem = self.mainInterface.get_widget("about1")
        if (aboutUsMenuItem):
            aboutUsMenuItem.connect("activate", self.about_dialog_show)

        return True

    ##
    # Callback to show the About Dialog on the GUI
    #
    # @param self the instance pointer
    # @param menuItem widget that performs the calling
    #
    def about_dialog_show(self, menuItem):
        self.aboutUsDialog.show()
        return True

    ##
    # Callback to hide the About Dialog on the GUI
    #
    # @param self the instance pointer
    #
    def about_dialog_hide(self, widget, event):
        self.aboutUsDialog.hide()
        return True

    ##
    # Callback to show the Console Dialog on the GUI
    #
    # @param self the instance pointer
    # @param menuItem widget that performs the calling
    #
    def console_display(self, menuItem):

        if (self.consoleWindow.get_property("visible")):
            self.consoleWindow.hide()
        else:
            self.consoleWindow.show()

    ##
    # Shows the main elements controlled by the view
    #
    # @param self the instance pointer
    def show(self):
        self.mainWindow.show()

    ##
    # Sets the configuration form of a command on the main gui.
    #
    # @param self the instance pointer
    # @param form TiseanCommandForm instance
    #
    def set_command_form(self, form):
        if (self.currentForm):
            self.optionsCommandsHolder.remove(self.currentForm)
        self.optionsCommandsHolder.pack_end(form)
        self.optionsCommandsHolder.set_border_width(10)
        self.currentForm = form

    ##
    # Getter of the current command form
    #
    # @param self the instance pointer
    #
    def get_command_form(self):
        return self.currentForm

    ##
    # Getter of the Console updater of the View
    #
    # @param self the instance pointer
    #
    def get_console_updater(self):
        return self.consoleUpdater

    ##
    # Stops the Console updater of the view
    #
    # @param self the instance pointer
    #
    def stop_console_updater(self):
        self.consoleUpdater.stop_updater()