Exemple #1
0
    def __init__(self):
        self.open_panels = {}

        # No need to also bind to "save as" because it closes and opens the
        # database anyway, thus also closing the property tab if open
        core_api.bind_to_save_database(self._handle_save_database)
        core_api.bind_to_history_insert(self._handle_items_number)
        core_api.bind_to_history_remove(self._handle_items_number)
        core_api.bind_to_insert_item(self._handle_items_number)
        core_api.bind_to_deleted_item(self._handle_items_number)
        # No need to bind to pasting items

        databases.close_database_event.bind(self._handle_close_database)
Exemple #2
0
    def __init__(self):
        self.open_panels = {}

        # No need to also bind to "save as" because it closes and opens the
        # database anyway, thus also closing the property tab if open
        core_api.bind_to_save_database(self._handle_save_database)
        core_api.bind_to_history_insert(self._handle_items_number)
        core_api.bind_to_history_remove(self._handle_items_number)
        core_api.bind_to_insert_item(self._handle_items_number)
        core_api.bind_to_deleted_item(self._handle_items_number)
        # No need to bind to pasting items

        databases.close_database_event.bind(self._handle_close_database)
Exemple #3
0
    def _post_init(self):
        # The native GTK widget used by DataViewCtrl would have an internal
        # "live" search feature which steals some keyboard shortcuts: Ctrl+n,
        # Ctrl+p, Ctrl+f, Ctrl+a, Ctrl+Shift+a
        # https://groups.google.com/d/msg/wxpython-users/1sUPp766uXU/0J22mUrkzoAJ
        # Ctrl+f can be recovered with by not overriding the Model's
        # GetColumnType method
        # See also bug #349
        # See bug #260 for generic issues about DataViewCtrl
        self.treec = dv.DataViewCtrl(self, style=dv.DV_MULTIPLE |
                                                            dv.DV_NO_HEADER)

        self.cmenu = ContextMenu(self)
        self.ctabmenu = TabContextMenu(self.filename)

        self.logspanel = logs.LogsPanel(self, self.filename)
        self.dbhistory = logs.DatabaseHistory(self, self.logspanel,
                                    self.logspanel.get_panel(), self.filename,
                                    self.treec.GetBackgroundColour())

        self.properties = Properties(self.treec)
        self.base_properties = DBProperties(self.properties)

        self.accelerators = {}

        creating_tree_event.signal(filename=self.filename)

        # Initialize the icons only *after* the various plugins have added
        # their properties
        self.properties.post_init()

        # Initialize the tree only *after* instantiating the class (and
        # initilizing the icons), because actions like the creation of item
        # images rely on the filename to be in the dictionary
        for row in core_api.get_all_items(self.filename):
            self._init_item_data(row["I_id"], row["I_text"])

        self.dvmodel = Model(self.data, self.filename)
        self.treec.AssociateModel(self.dvmodel)
        # According to DataViewModel's documentation (as of September 2014)
        # its reference count must be decreased explicitly to avoid memory
        # leaks; the wxPython demo, however, doesn't do it, and if done here,
        # the application crashes with a segfault when closing all databases
        # See also bug #104
        #self.dvmodel.DecRef()

        dvrenderer = Renderer(self, self.treec)
        dvcolumn = dv.DataViewColumn("Item", dvrenderer, 0,
                                                        align=wx.ALIGN_LEFT)
        self.treec.AppendColumn(dvcolumn)

        self._init_accelerators()

        self.Initialize(self.treec)

        # Initialize the logs panel *after* signalling creating_tree_event,
        # which is used to add plugin logs
        self.logspanel.initialize()

        nb_left = wx.GetApp().nb_left
        nb_left.add_page(self, os.path.basename(self.filename), select=True)

        # The logs panel must be shown only *after* adding the page to the
        # notebook, otherwise *for*some*reason* the databases opened
        # automatically by the sessions manager (those opened manually aren't
        # affected) will have the sash of the SplitterWindow not correctly
        # positioned (only if using SetSashGravity)
        if wx.GetApp().logs_configuration.is_shown():
            self.show_logs()

        self.history_item_update_requests = []
        self.history_tree_reset_request = False

        # Explicitly set focus on the tree, otherwise after opening a database
        # no window has focus, and this e.g. prevents F10 from showing the menu
        # if set on autohide, until a window is manually focused (note that
        # this would happen only when opening a database manually, it wouldn't
        # happen when a database is opened automatically by the session
        # manager)
        self.treec.SetFocus()

        self.treec.Bind(dv.EVT_DATAVIEW_ITEM_CONTEXT_MENU,
                                                        self._popup_item_menu)

        core_api.bind_to_insert_item(self._handle_insert_item)
        core_api.bind_to_update_item_text(self._handle_update_item_text)
        core_api.bind_to_deleting_item(self._handle_deleting_item)
        core_api.bind_to_deleted_item_2(self._handle_deleted_item)
        core_api.bind_to_history_insert(self._handle_history_insert)
        core_api.bind_to_history_update_simple(
                                            self._handle_history_update_simple)
        core_api.bind_to_history_update_deep(self._handle_history_update_deep)
        core_api.bind_to_history_update_text(self._handle_history_update_text)
        core_api.bind_to_history_remove(self._handle_history_remove)
        core_api.bind_to_history(self._handle_history)
Exemple #4
0
    def _post_init(self):
        # The native GTK widget used by DataViewCtrl would have an internal
        # "live" search feature which steals some keyboard shortcuts: Ctrl+n,
        # Ctrl+p, Ctrl+f, Ctrl+a, Ctrl+Shift+a
        # https://groups.google.com/d/msg/wxpython-users/1sUPp766uXU/0J22mUrkzoAJ
        # Ctrl+f can be recovered with by not overriding the Model's
        # GetColumnType method
        # See also bug #349
        # See bug #260 for generic issues about DataViewCtrl
        self.treec = dv.DataViewCtrl(self, style=dv.DV_MULTIPLE |
                                                            dv.DV_NO_HEADER)

        self.cmenu = ContextMenu(self)
        self.ctabmenu = TabContextMenu(self.filename)

        self.logspanel = logs.LogsPanel(self, self.filename)
        self.dbhistory = logs.DatabaseHistory(self, self.logspanel,
                                    self.logspanel.get_panel(), self.filename,
                                    self.treec.GetBackgroundColour())

        self.properties = Properties(self.treec)
        self.base_properties = DBProperties(self.properties)

        self.accelerators = {}

        creating_tree_event.signal(filename=self.filename)

        # Initialize the icons only *after* the various plugins have added
        # their properties
        self.properties.post_init()

        # Initialize the tree only *after* instantiating the class (and
        # initilizing the icons), because actions like the creation of item
        # images rely on the filename to be in the dictionary
        for row in core_api.get_all_items(self.filename):
            self._init_item_data(row["I_id"], row["I_text"])

        self.dvmodel = Model(self.data, self.filename)
        self.treec.AssociateModel(self.dvmodel)
        # According to DataViewModel's documentation (as of September 2014)
        # its reference count must be decreased explicitly to avoid memory
        # leaks; the wxPython demo, however, doesn't do it, and if done here,
        # the application crashes with a segfault when closing all databases
        # See also bug #104
        #self.dvmodel.DecRef()

        dvrenderer = Renderer(self, self.treec)
        dvcolumn = dv.DataViewColumn("Item", dvrenderer, 0,
                                                        align=wx.ALIGN_LEFT)
        self.treec.AppendColumn(dvcolumn)

        self._init_accelerators()

        self.Initialize(self.treec)

        # Initialize the logs panel *after* signalling creating_tree_event,
        # which is used to add plugin logs
        self.logspanel.initialize()

        nb_left = wx.GetApp().nb_left
        nb_left.add_page(self, os.path.basename(self.filename), select=True)

        # The logs panel must be shown only *after* adding the page to the
        # notebook, otherwise *for*some*reason* the databases opened
        # automatically by the sessions manager (those opened manually aren't
        # affected) will have the sash of the SplitterWindow not correctly
        # positioned (only if using SetSashGravity)
        if wx.GetApp().logs_configuration.is_shown():
            self.show_logs()

        self.history_item_update_requests = []
        self.history_tree_reset_request = False

        # Explicitly set focus on the tree, otherwise after opening a database
        # no window has focus, and this e.g. prevents F10 from showing the menu
        # if set on autohide, until a window is manually focused (note that
        # this would happen only when opening a database manually, it wouldn't
        # happen when a database is opened automatically by the session
        # manager)
        self.treec.SetFocus()

        self.treec.Bind(dv.EVT_DATAVIEW_ITEM_CONTEXT_MENU,
                                                        self._popup_item_menu)

        core_api.bind_to_insert_item(self._handle_insert_item)
        core_api.bind_to_update_item_text(self._handle_update_item_text)
        core_api.bind_to_deleting_item(self._handle_deleting_item)
        core_api.bind_to_deleted_item_2(self._handle_deleted_item)
        core_api.bind_to_history_insert(self._handle_history_insert)
        core_api.bind_to_history_update_simple(
                                            self._handle_history_update_simple)
        core_api.bind_to_history_update_deep(self._handle_history_update_deep)
        core_api.bind_to_history_update_text(self._handle_history_update_text)
        core_api.bind_to_history_remove(self._handle_history_remove)
        core_api.bind_to_history(self._handle_history)