Пример #1
0
 def __init__(self):
     self._ui = None
     self.default_store = get_default_store()
     StartApplicationEvent.connect(self._on_StartApplicationEvent)
     EditorSlaveCreateEvent.connect(self._on_EditorSlaveCreateEvent)
     add_bindings([
         ('plugin.books.search_books', '<Primary><Alt>B'),
         ('plugin.books.search_publishers', '<Primary><Alt>P'),
     ])
Пример #2
0
 def __init__(self):
     self._ui = None
     self.default_store = get_default_store()
     StartApplicationEvent.connect(self._on_StartApplicationEvent)
     StopApplicationEvent.connect(self._on_StopApplicationEvent)
     EditorSlaveCreateEvent.connect(self._on_EditorSlaveCreateEvent)
     add_bindings([
         ('plugin.optical.pre_sale', ''),
     ])
Пример #3
0
 def __init__(self):
     self._ui = None
     self.default_store = get_default_store()
     StartApplicationEvent.connect(self._on_StartApplicationEvent)
     EditorSlaveCreateEvent.connect(self._on_EditorSlaveCreateEvent)
     add_bindings([
         ('plugin.books.search_books', '<Primary><Alt>B'),
         ('plugin.books.search_publishers', '<Primary><Alt>P'),
     ])
Пример #4
0
    def __init__(self, store, model=None, visual_mode=False, edit_mode=None):
        """ A base class for editor slaves inheritance

        :param store: a store
        :param model: the object model tied with the proxy widgets
        :param visual_mode: does this slave must be opened in visual mode?
                            if so, all the proxy widgets will be disable
        :param edit_mode: indicate if the slave are being edited or its a new one
                          The editor that creates the slave should pass his
                          property edit_mode to the slaves.
                          If None self.edit_mode will be defined accordingly to
                          the model
        """
        self.store = store
        # FIXME: Need to check if we need to add edit_mode parameter for all classes
        # that inherit from BaseEditor
        if edit_mode is not None:
            self.edit_mode = edit_mode
        else:
            self.edit_mode = model is not None
        self.visual_mode = visual_mode

        if model:
            created = ""
        else:
            created = "created "
            model = self.create_model(self.store)

            if model is None:
                fmt = "%s.create_model() must return a valid model, not %r"
                raise ValueError(fmt % (self.__class__.__name__, model))

        log.info("%s editor using a %smodel %s" % (
            self.__class__.__name__, created, type(model).__name__))

        if self.model_type:
            if not isinstance(model, self.model_type):
                fmt = '%s editor requires a model of type %s, got a %r'
                raise TypeError(
                    fmt % (self.__class__.__name__,
                           self.model_type.__name__,
                           model))
        else:
            fmt = "Editor %s must define a model_type attribute"
            raise ValueError(fmt % (self.__class__.__name__, ))
        self.model = model

        GladeSlaveDelegate.__init__(self, gladefile=self.gladefile)
        if self.visual_mode:
            self._setup_visual_mode()
        self.setup_proxies()
        self.setup_slaves()

        EditorSlaveCreateEvent.emit(self, model, store, visual_mode)
Пример #5
0
    def __init__(self, store, model=None, visual_mode=False, edit_mode=None):
        """ A base class for editor slaves inheritance

        :param store: a store
        :param model: the object model tied with the proxy widgets
        :param visual_mode: does this slave must be opened in visual mode?
                            if so, all the proxy widgets will be disable
        :param edit_mode: indicate if the slave are being edited or its a new one
                          The editor that creates the slave should pass his
                          property edit_mode to the slaves.
                          If None self.edit_mode will be defined accordingly to
                          the model
        """
        self.store = store
        # FIXME: Need to check if we need to add edit_mode parameter for all classes
        # that inherit from BaseEditor
        if edit_mode is not None:
            self.edit_mode = edit_mode
        else:
            self.edit_mode = model is not None
        self.visual_mode = visual_mode

        if model:
            created = ""
        else:
            created = "created "
            model = self.create_model(self.store)

            if model is None:
                fmt = "%s.create_model() must return a valid model, not %r"
                raise ValueError(fmt % (self.__class__.__name__, model))

        log.info("%s editor using a %smodel %s" %
                 (self.__class__.__name__, created, type(model).__name__))

        if self.model_type:
            if not isinstance(model, self.model_type):
                fmt = '%s editor requires a model of type %s, got a %r'
                raise TypeError(
                    fmt %
                    (self.__class__.__name__, self.model_type.__name__, model))
        else:
            fmt = "Editor %s must define a model_type attribute"
            raise ValueError(fmt % (self.__class__.__name__, ))
        self.model = model

        GladeSlaveDelegate.__init__(self, gladefile=self.gladefile)
        if self.visual_mode:
            self._setup_visual_mode()
        self.setup_proxies()
        self.setup_slaves()

        EditorSlaveCreateEvent.emit(self, model, store, visual_mode)
Пример #6
0
    def __init__(self, store, model=None, visual_mode=False):
        """ A base class for editor slaves inheritance

        :param store: a store
        :param model: the object model tied with the proxy widgets
        :param visual_mode: does this slave must be opened in visual mode?
                            if so, all the proxy widgets will be disable
        """
        self.store = store
        self.edit_mode = model is not None
        self.visual_mode = visual_mode

        if model:
            created = ""
        else:
            created = "created "
            model = self.create_model(self.store)

            if model is None:
                raise ValueError(
                    "%s.create_model() must return a valid model, not %r" % (
                    self.__class__.__name__, model))

        log.info("%s editor using a %smodel %s" % (
            self.__class__.__name__, created, type(model).__name__))

        if self.model_type:
            if not isinstance(model, self.model_type):
                raise TypeError(
                    '%s editor requires a model of type %s, got a %r' % (
                    self.__class__.__name__, self.model_type.__name__,
                    model))
        else:
            raise ValueError("Editor %s must define a model_type "
                             "attribute" % (
                self.__class__.__name__, ))
        self.model = model

        GladeSlaveDelegate.__init__(self, gladefile=self.gladefile)
        if self.visual_mode:
            self._setup_visual_mode()
        self.setup_proxies()
        self.setup_slaves()

        EditorSlaveCreateEvent.emit(self, model, store, visual_mode)
Пример #7
0
    def __init__(self, store, model=None, visual_mode=False):
        """ A base class for editor slaves inheritance

        :param store: a store
        :param model: the object model tied with the proxy widgets
        :param visual_mode: does this slave must be opened in visual mode?
                            if so, all the proxy widgets will be disable
        """
        self.store = store
        self.edit_mode = model is not None
        self.visual_mode = visual_mode

        if model:
            created = ""
        else:
            created = "created "
            model = self.create_model(self.store)

            if model is None:
                raise ValueError(
                    "%s.create_model() must return a valid model, not %r" %
                    (self.__class__.__name__, model))

        log.info("%s editor using a %smodel %s" %
                 (self.__class__.__name__, created, type(model).__name__))

        if self.model_type:
            if not isinstance(model, self.model_type):
                raise TypeError(
                    '%s editor requires a model of type %s, got a %r' %
                    (self.__class__.__name__, self.model_type.__name__, model))
        else:
            raise ValueError("Editor %s must define a model_type "
                             "attribute" % (self.__class__.__name__, ))
        self.model = model

        GladeSlaveDelegate.__init__(self, gladefile=self.gladefile)
        if self.visual_mode:
            self._setup_visual_mode()
        self.setup_proxies()
        self.setup_slaves()

        EditorSlaveCreateEvent.emit(self, model, store, visual_mode)