def do_get_filters(self):
        """
        Adds filters
        """
        filters = Unity.FilterSet.new()
        filter_icon = Gio.ThemedIcon.new(SVG_DIR+'group-recent.svg')

        tags_filter = Unity.CheckOptionFilter.new('tags', _('Tags'), filter_icon, True)
        for tag_struct in everpad_provider.list_tags():
            tag = Tag.from_tuple(tag_struct)
            tags_filter.add_option(str(tag.id), tag.name, filter_icon)
        filters.add(tags_filter)

        notebooks_filter = Unity.RadioOptionFilter.new('notebooks', _('Notebooks'), filter_icon, True)
        for notebook_struct in everpad_provider.list_notebooks():
            notebook = Notebook.from_tuple(notebook_struct)
            notebooks_filter.add_option(str(notebook.id), notebook.name, filter_icon)
        filters.add(notebooks_filter)

        places_filter = Unity.RadioOptionFilter.new('places', _('Places'), filter_icon, True)
        for place_struct in everpad_provider.list_places():
            place = Place.from_tuple(place_struct)
            places_filter.add_option(str(place.id), place.name, filter_icon)
        filters.add(places_filter)
        return filters
예제 #2
0
 def test_notes_with_notebook_and_places(self):
     """Test notes with notebook and places"""
     notebook = Notebook.from_tuple(
         self.service.create_notebook('test', None),
     )
     notes = []
     get_place = lambda num: '123' if num < 50 else '456'
     for i in range(100):
         notes.append(Note.from_tuple(self.service.create_note(Note(
             id=NONE_ID,
             title='New note',
             content="New note content",
             tags=['123', '345'],
             notebook=notebook.id,
             created=NONE_VAL,
             updated=NONE_VAL,
             place=get_place(i),
         ).struct)))
     filtered = []
     for num, note in enumerate(notes):
         if not num % 2:
             self.service.update_note(note.struct)  # mark note exist
             filtered.append(note)
     notes = filtered  # notes.remove(note) not work, wtf
     self.assertEqual(
         self._to_ids(notes), self._to_ids(map(
             Note.from_tuple, self.service.find_notes(
                 '', dbus.Array([], signature='i'),
                 dbus.Array([], signature='i'), 0,
                 100, Note.ORDER_UPDATED_DESC, -1,
             ),
         )),
     )
     filtered = []
     for num, note in enumerate(notes):
         note.title += '*'
         if num % 2:
             self.service.delete_note(note.id)
             with self.assertRaises(DBusException):
                 self.service.update_note(note.struct)
         else:
             updated = Note.from_tuple(
                 self.service.update_note(note.struct),
             )
             self.assertEqual(note.title, updated.title)
             filtered.append(updated)
     self.assertEqual(len(filtered),
         self.service.get_notebook_notes_count(notebook.id),
     )
     self.assertEqual(set(['123', '456']), set(map(
         lambda place: Place.from_tuple(place).name,
         self.service.list_places(),
     )))
예제 #3
0
파일: lens.py 프로젝트: altawu/everpad
 def update_props(self):
     icon = Gio.ThemedIcon.new("/usr/share/icons/unity-icon-theme/places/svg/group-recent.svg")
     tags = Unity.CheckOptionFilter.new('tags', _('Tags'), icon, True)
     for tag_struct in provider.list_tags():
         tag = Tag.from_tuple(tag_struct)
         tags.add_option(str(tag.id), tag.name, icon)
     notebooks = Unity.RadioOptionFilter.new('notebooks', _('Notebooks'), icon, True)
     for notebook_struct in provider.list_notebooks():
         notebook = Notebook.from_tuple(notebook_struct)
         notebooks.add_option(str(notebook.id), notebook.name, icon)
     places = Unity.RadioOptionFilter.new('places', _('Places'), icon, True)
     for place_struct in provider.list_places():
         place = Place.from_tuple(place_struct)
         places.add_option(str(place.id), place.name, icon)
     self._lens.props.filters = [notebooks, tags, places]
예제 #4
0
파일: lens.py 프로젝트: AnderSilva/everpad
 def update_props(self):
     icon = Gio.ThemedIcon.new(resource_filename("share/icons/unity-icon-theme/places/svg/group-recent.svg"))
     tags = Unity.CheckOptionFilter.new('tags', _('Tags'), icon, True)
     for tag_struct in provider.list_tags():
         tag = Tag.from_tuple(tag_struct)
         tags.add_option(str(tag.id), tag.name, icon)
     notebooks = Unity.RadioOptionFilter.new('notebooks', _('Notebooks'), icon, True)
     for notebook_struct in provider.list_notebooks():
         notebook = Notebook.from_tuple(notebook_struct)
         notebooks.add_option(str(notebook.id), notebook.name, icon)
     places = Unity.RadioOptionFilter.new('places', _('Places'), icon, True)
     for place_struct in provider.list_places():
         place = Place.from_tuple(place_struct)
         places.add_option(str(place.id), place.name, icon)
     self._lens.props.filters = [notebooks, tags, places]
     self._lens.props.search_in_global = bool(int(provider.get_settings_value('search-on-home') or 1))
예제 #5
0
파일: lens.py 프로젝트: guofengstc/everpad
 def update_props(self):
     icon = Gio.ThemedIcon.new(
         "/usr/share/icons/unity-icon-theme/places/svg/group-recent.svg")
     tags = Unity.CheckOptionFilter.new('tags', _('Tags'), icon, True)
     for tag_struct in provider.list_tags():
         tag = Tag.from_tuple(tag_struct)
         tags.add_option(str(tag.id), tag.name, icon)
     notebooks = Unity.RadioOptionFilter.new('notebooks', _('Notebooks'),
                                             icon, True)
     for notebook_struct in provider.list_notebooks():
         notebook = Notebook.from_tuple(notebook_struct)
         notebooks.add_option(str(notebook.id), notebook.name, icon)
     places = Unity.RadioOptionFilter.new('places', _('Places'), icon, True)
     for place_struct in provider.list_places():
         place = Place.from_tuple(place_struct)
         places.add_option(str(place.id), place.name, icon)
     self._lens.props.filters = [notebooks, tags, places]
예제 #6
0
파일: lens.py 프로젝트: cas--/everpad
 def update_props(self):
     icon = Gio.ThemedIcon.new(
         resource_filename(
             "share/icons/unity-icon-theme/places/svg/group-recent.svg"))
     tags = Unity.CheckOptionFilter.new('tags', _('Tags'), icon, True)
     for tag_struct in provider.list_tags():
         tag = Tag.from_tuple(tag_struct)
         tags.add_option(str(tag.id), tag.name, icon)
     notebooks = Unity.RadioOptionFilter.new('notebooks', _('Notebooks'),
                                             icon, True)
     for notebook_struct in provider.list_notebooks():
         notebook = Notebook.from_tuple(notebook_struct)
         notebooks.add_option(str(notebook.id), notebook.name, icon)
     places = Unity.RadioOptionFilter.new('places', _('Places'), icon, True)
     for place_struct in provider.list_places():
         place = Place.from_tuple(place_struct)
         places.add_option(str(place.id), place.name, icon)
     self._lens.props.filters = [notebooks, tags, places]
     self._lens.props.search_in_global = bool(
         int(provider.get_settings_value('search-on-home') or 1))
예제 #7
0
파일: service.py 프로젝트: cas--/everpad
 def test_notes_with_notebook_and_places(self):
     """Test notes with notebook and places"""
     notebook = Notebook.from_tuple(
         self.service.create_notebook('test', None), )
     notes = []
     get_place = lambda num: '123' if num < 50 else '456'
     for i in range(100):
         notes.append(
             Note.from_tuple(
                 self.service.create_note(
                     Note(
                         id=NONE_ID,
                         title='New note',
                         content="New note content",
                         tags=['123', '345'],
                         notebook=notebook.id,
                         created=NONE_VAL,
                         updated=NONE_VAL,
                         place=get_place(i),
                     ).struct)))
     filtered = []
     for num, note in enumerate(notes):
         if not num % 2:
             self.service.update_note(note.struct)  # mark note exist
             filtered.append(note)
     notes = filtered  # notes.remove(note) not work, wtf
     self.assertEqual(
         self._to_ids(notes),
         self._to_ids(
             map(
                 Note.from_tuple,
                 self.service.find_notes(
                     '',
                     dbus.Array([], signature='i'),
                     dbus.Array([], signature='i'),
                     0,
                     100,
                     Note.ORDER_UPDATED_DESC,
                     -1,
                 ),
             )),
     )
     filtered = []
     for num, note in enumerate(notes):
         note.title += '*'
         if num % 2:
             self.service.delete_note(note.id)
             with self.assertRaises(DBusException):
                 self.service.update_note(note.struct)
         else:
             updated = Note.from_tuple(
                 self.service.update_note(note.struct), )
             self.assertEqual(note.title, updated.title)
             filtered.append(updated)
     self.assertEqual(
         len(filtered),
         self.service.get_notebook_notes_count(notebook.id),
     )
     self.assertEqual(
         set(['123', '456']),
         set(
             map(
                 lambda place: Place.from_tuple(place).name,
                 self.service.list_places(),
             )))