Ejemplo n.º 1
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()
Ejemplo n.º 2
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()
Ejemplo n.º 3
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)
Ejemplo n.º 4
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()
Ejemplo n.º 5
0
 def test_translate(self):
     datastore = DataStore()
     root_task = datastore.task_factory('root-task', newtask=True)
     root_task.add_tag('@my-tag')
     root_task.add_tag('@my-other-tag')
     root_task.set_title('my task')
     datastore.push_task(root_task)
     child_task = datastore.task_factory('child-task', newtask=True)
     child_task.set_title('my first child')
     child_task.add_tag('@my-tag')
     child_task.add_tag('@my-other-tag')
     child_task.set_text("@my-tag, @my-other-tag, \n\ntask content")
     datastore.push_task(child_task)
     root_task.add_child(child_task.get_id())
     child2_task = datastore.task_factory('done-child-task', newtask=True)
     child2_task.set_title('my done child')
     child2_task.add_tag('@my-tag')
     child2_task.add_tag('@my-other-tag')
     child2_task.set_text("@my-tag, @my-other-tag, \n\nother task txt")
     child2_task.set_status(Task.STA_DONE)
     datastore.push_task(child2_task)
     root_task.add_child(child2_task.get_id())
     root_task.set_text(f"@my-tag, @my-other-tag\n\nline\n"
                        f"{{!{child_task.get_id()}!}}\n"
                        f"{{!{child2_task.get_id()}!}}\n")
     self.assertEqual(
         [child_task.get_id(), child2_task.get_id()],
         root_task.get_children())
     self.assertEqual([root_task.get_id()], child_task.get_parents())
     self.assertEqual([], PARENT_FIELD.get_gtg(root_task, NAMESPACE))
     self.assertEqual(['child-task', 'done-child-task'],
                      CHILDREN_FIELD.get_gtg(root_task, NAMESPACE))
     self.assertEqual(['root-task'],
                      PARENT_FIELD.get_gtg(child_task, NAMESPACE))
     self.assertEqual([], CHILDREN_FIELD.get_gtg(child_task, NAMESPACE))
     root_vtodo = Translator.fill_vtodo(root_task, 'calname', NAMESPACE)
     child_vtodo = Translator.fill_vtodo(child_task, 'calname', NAMESPACE)
     child2_vtodo = Translator.fill_vtodo(child2_task, 'calname', NAMESPACE)
     self.assertEqual([], PARENT_FIELD.get_dav(vtodo=root_vtodo.vtodo))
     self.assertEqual(['child-task', 'done-child-task'],
                      CHILDREN_FIELD.get_dav(vtodo=root_vtodo.vtodo))
     self.assertEqual(['root-task'],
                      PARENT_FIELD.get_dav(vtodo=child_vtodo.vtodo))
     self.assertEqual([], CHILDREN_FIELD.get_dav(vtodo=child_vtodo.vtodo))
     self.assertTrue('\r\nRELATED-TO;RELTYPE=CHILD:child-task\r\n' in
                     root_vtodo.serialize())
     self.assertTrue('\r\nRELATED-TO;RELTYPE=PARENT:root-task\r\n' in
                     child_vtodo.serialize())
     root_contents = root_vtodo.contents['vtodo'][0].contents
     child_cnt = child_vtodo.contents['vtodo'][0].contents
     child2_cnt = child2_vtodo.contents['vtodo'][0].contents
     for cnt in root_contents, child_cnt, child2_cnt:
         self.assertEqual(['my-tag', 'my-other-tag'],
                          cnt['categories'][0].value)
     self.assertEqual('my first child', child_cnt['summary'][0].value)
     self.assertEqual('my done child', child2_cnt['summary'][0].value)
     self.assertEqual('task content', child_cnt['description'][0].value)
     self.assertEqual('other task txt', child2_cnt['description'][0].value)
     self.assertEqual('line\n[ ] my first child\n[x] my done child',
                      root_contents['description'][0].value)
Ejemplo n.º 6
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
Ejemplo n.º 7
0
 def setUp(self):
     """
     Creates the environment for the tests
     @returns: None
     """
     self.datastore = DataStore()
     self.requester = self.datastore.get_requester()
Ejemplo n.º 8
0
 def setUp(self):
     ds = DataStore()
     self.req = ds.get_requester()
     # initalize gobject signaling system
     self.gobject_signal_manager = GobjectSignalsManager()
     self.gobject_signal_manager.init_signals()
     # refresh the viewtree for tasks
     tt = self.req.get_tasks_tree()
     tt.reset_filters()
Ejemplo n.º 9
0
 def _setup_backend():
     datastore = DataStore()
     parameters = {
         'pid': 'favorite',
         'service-url': 'color',
         'username': '******',
         'password': '******',
         'period': 1
     }
     backend = Backend(parameters)
     datastore.register_backend({
         'backend': backend,
         'pid': 'backendid',
         'first_run': True
     })
     return datastore, backend
Ejemplo n.º 10
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)