def refresh(self):
     '''
     Populates the combo box with the available backends
     '''
     self.liststore.clear()
     backend_types = BackendFactory().get_all_backends()
     for name, module in backend_types.iteritems():
         pixbuf = self.dialog.get_pixbuf_from_icon_name(name, 16, 16)
         self.liststore.append((name, \
                                module.Backend.get_human_default_name(), \
                                pixbuf))
     if backend_types:
         #triggers a "changed" signal, which is used in the AddPanel to
         #refresh the backend description and icon
         self.set_active(0)
Exemplo n.º 2
0
    def do_startup(self):
        """Callback when primary instance should initialize"""
        Gtk.Application.do_startup(self)

        # Register backends
        datastore = DataStore()

        for backend_dic in BackendFactory().get_saved_backends_list():
            datastore.register_backend(backend_dic)

        # Save the backends directly to be sure projects.xml is written
        datastore.save(quit=False)

        self.req = datastore.get_requester()

        self.config = self.req.get_config("browser")
        self.config_plugins = self.req.get_config("plugins")

        self.clipboard = clipboard.TaskClipboard(self.req)

        self.timer = Timer(self.config)
        self.timer.connect('refresh', self.autoclean)

        self.preferences_dialog = Preferences(self.req, self)
        self.plugins_dialog = PluginsDialog(self.req)

        if self.config.get('dark_mode'):
            self.toggle_darkmode()

        self.init_style()
Exemplo n.º 3
0
    def __init__(self, app_id):
        """Setup Application."""

        super().__init__(application_id=app_id,
                         flags=Gio.ApplicationFlags.HANDLES_OPEN)

        # Register backends
        datastore = DataStore()

        [
            datastore.register_backend(backend_dic)
            for backend_dic in BackendFactory().get_saved_backends_list()
        ]

        # Save the backends directly to be sure projects.xml is written
        datastore.save(quit=False)

        self.req = datastore.get_requester()

        self.config = self.req.get_config("browser")
        self.config_plugins = self.req.get_config("plugins")

        self.clipboard = clipboard.TaskClipboard(self.req)

        self.timer = Timer(self.config)
        self.timer.connect('refresh', self.autoclean)

        self.preferences_dialog = Preferences(self.req, self)
        self.plugins_dialog = PluginsDialog(self.req)

        if self.config.get('dark_mode'):
            self.toggle_darkmode()

        self.init_style()
Exemplo n.º 4
0
 def setUp(self):
     thread_tomboy = threading.Thread(target=self.spawn_fake_tomboy_server)
     thread_tomboy.start()
     thread_tomboy.join()
     # only the test process should go further, the dbus server one should
     # stop here
     if not PID_TOMBOY:
         return
     # we create a custom dictionary listening to the server, and register
     # it in GTG.
     additional_dic = {}
     additional_dic["use this fake connection instead"] = (
         FakeTomboy.BUS_NAME, FakeTomboy.BUS_PATH, FakeTomboy.BUS_INTERFACE)
     additional_dic[GenericBackend.KEY_ATTACHED_TAGS] = \
         [GenericBackend.ALLTASKS_TAG]
     additional_dic[GenericBackend.KEY_DEFAULT_BACKEND] = True
     dic = BackendFactory().get_new_backend_dict('backend_tomboy',
                                                 additional_dic)
     self.datastore = DataStore()
     self.backend = self.datastore.register_backend(dic)
     # waiting for the "start_get_tasks" to settle
     time.sleep(1)
     # we create a dbus session to speak with the server
     self.bus = dbus.SessionBus()
     obj = self.bus.get_object(FakeTomboy.BUS_NAME, FakeTomboy.BUS_PATH)
     self.tomboy = dbus.Interface(obj, FakeTomboy.BUS_INTERFACE)
Exemplo n.º 5
0
def core_main_init(options=None, args=None):
    '''
    Part of the main function prior to the UI initialization.
    '''
    # Debugging subsystem initialization
    if options.debug:
        Log.setLevel(logging.DEBUG)
        Log.debug("Debug output enabled.")
    else:
        Log.setLevel(logging.INFO)
    Log.set_debugging_mode(options.debug)
    config = CoreConfig()
    check_instance(config.get_data_dir(), args)
    backends_list = BackendFactory().get_saved_backends_list()
    # Load data store
    ds = DataStore(config)
    # Register backends
    for backend_dic in backends_list:
        ds.register_backend(backend_dic)
    # save the backends directly to be sure projects.xml is written
    ds.save(quit=False)

    # Launch task browser
    req = ds.get_requester()
    return ds, req
Exemplo n.º 6
0
    def __init__(self, app_id, debug):
        """Setup Application."""

        super().__init__(application_id=app_id)

        if debug:
            log.setLevel(logging.DEBUG)
            log.debug("Debug output enabled.")
        else:
            log.setLevel(logging.INFO)

        # Register backends
        datastore = DataStore()

        [datastore.register_backend(backend_dic)
         for backend_dic in BackendFactory().get_saved_backends_list()]

        # Save the backends directly to be sure projects.xml is written
        datastore.save(quit=False)

        self.req = datastore.get_requester()

        self.config = self.req.get_config("browser")
        self.config_plugins = self.req.get_config("plugins")

        self.clipboard = clipboard.TaskClipboard(self.req)

        self.timer = Timer(self.config)
        self.timer.connect('refresh', self.autoclean)

        self.preferences_dialog = Preferences(self.req, self)
        self.plugins_dialog = PluginsDialog(self.req)

        self.init_style()
Exemplo n.º 7
0
    def on_combo_changed(self, widget=None):
        """
        Updates the backend description and icon.

        @param widget: just to make this function usable as a signal callback.
                       Not used.
        """
        backend_name = self.combo_types.get_selected()
        if backend_name is None:
            return
        backend = BackendFactory().get_backend(backend_name)
        self.label_description.set_markup(backend.Backend.get_description())

        markup = '<big><big><big><b>%s</b></big></big></big>' % \
            backend.Backend.get_human_default_name()
        self.label_name.set_markup(markup)
        authors = backend.Backend.get_authors()
        author_txt = '<b>%s</b>:\n   - %s' % \
            (ngettext("Author", "Authors", len(authors)),
             reduce(lambda a, b: a + "\n" + "   - " + b, authors))
        self.label_author.set_markup(author_txt)
        pixbuf = self.dialog.get_pixbuf_from_icon_name(
            backend.Backend.get_icon(), 128)
        self.image_icon.set_from_pixbuf(pixbuf)
        self.show_all()
Exemplo n.º 8
0
 def refresh(self):
     """
     Populates the combo box with the available backends
     """
     self.liststore.clear()
     backend_types = BackendFactory().get_all_backends()
     for name, module in backend_types.iteritems():
         # FIXME: Disable adding another localfile backend.
         # It just produce many warnings, provides no use case
         # See LP bug #940917 (Izidor)
         if name == "backend_localfile":
             continue
         pixbuf = self.dialog.get_pixbuf_from_icon_name(name, 16)
         self.liststore.append((name, module.Backend.get_human_default_name(), pixbuf))
     if backend_types:
         # triggers a "changed" signal, which is used in the AddPanel to
         # refresh the backend description and icon
         self.set_active(0)
Exemplo n.º 9
0
 def refresh(self):
     '''
     Populates the combo box with the available backends
     '''
     self.liststore.clear()
     backend_types = BackendFactory().get_all_backends()
     for name, module in backend_types.iteritems():
         # FIXME: Disable adding another localfile backend.
         # It just produce many warnings, provides no use case
         # See LP bug #940917 (Izidor)
         if name == "backend_localfile":
             continue
         pixbuf = self.dialog.get_pixbuf_from_icon_name(name, 16)
         self.liststore.append(
             (name, module.Backend.get_human_default_name(), pixbuf))
     if backend_types:
         # triggers a "changed" signal, which is used in the AddPanel to
         # refresh the backend description and icon
         self.set_active(0)
Exemplo n.º 10
0
    def on_backend_added(self, backend_name):
        """
        When a backend is added, it is created and registered in the Datastore.
        Also, the configuration panel is shown.

        @param backend_name: the name of the type of the backend to add
                             (identified as BACKEND_NAME in the Backend class)
        """
        # Create Backend
        backend_dic = BackendFactory().get_new_backend_dict(backend_name)
        if backend_dic:
            backend_dic[GenericBackend.KEY_ENABLED] = False
            self.req.register_backend(backend_dic)
        # Restore UI
        self._show_panel("configuration")
Exemplo n.º 11
0
    def do_startup(self):
        """Callback when primary instance should initialize"""
        try:
            Gtk.Application.do_startup(self)
            Gtk.Window.set_default_icon_name(self.props.application_id)

            # Load default file
            data_file = os.path.join(DATA_DIR, 'gtg_data.xml')
            self.ds.find_and_load_file(data_file)

            # TODO: Remove this once the new core is stable
            self.ds.data_path = os.path.join(DATA_DIR, 'gtg_data2.xml')

            # Register backends
            datastore = DataStore()

            for backend_dic in BackendFactory().get_saved_backends_list():
                datastore.register_backend(backend_dic)

            # Save the backends directly to be sure projects.xml is written
            datastore.save(quit=False)

            self.req = datastore.get_requester()

            self.config = self.req.get_config("browser")
            self.config_plugins = self.req.get_config("plugins")

            self.clipboard = clipboard.TaskClipboard(self.req)

            self.timer = Timer(self.config)
            self.timer.connect('refresh', self.autoclean)

            self.preferences_dialog = Preferences(self.req, self)
            self.plugins_dialog = PluginsDialog(self.req)

            if self.config.get('dark_mode'):
                self.toggle_darkmode()

            self.init_style()
        except Exception as e:
            self._exception = e
            log.exception("Exception during startup")
            self._exception_dialog_timeout_id = GLib.timeout_add(
                # priority is a kwarg for some reason not reflected in the docs
                5000, self._startup_exception_timeout, None)