コード例 #1
0
def save(sibling_node_id, name_edit, url_edit, update_interval_edit,
         mark_as_read_checkbox, button):
    url = url_edit.get_edit_text()
    feed_type = sourceservice.detect_feed_type(url)
    link = sourceservice.get_link(url, feed_type)

    config_adapter = ConfigAdapter()
    db = DatabaseAdapter()

    sibling_node = next(db.get_node(sibling_node_id))
    config_node = config_adapter.get_source(sibling_node_id)
    new_node_id = sourceservice.generate_node_id()
    parent_node_id = sibling_node['parent_id']

    new_node = db.add_source(new_node_id, parent_node_id,
                             name_edit.get_edit_text(), feed_type, url,
                             update_interval_edit.get_edit_text())
    db.close_connection()

    config_adapter.add_source(sibling_node_id, new_node_id,
                              name_edit.get_edit_text(), feed_type, url, link,
                              update_interval_edit.get_edit_text(),
                              mark_as_read_checkbox.get_state())
    state.sources = config_adapter.get_sources()

    main.set_focused_item()
    rows = db.get_source_items(state.selected_node_id, state.node_id_unreads,
                               state.selected_filter)
    main.display(state.loop, rows)
コード例 #2
0
    def show_unread(node_id):
        db = DatabaseAdapter()

        state.selected_filter = 'unread'
        state.selected_node_id = node_id

        main.set_focused_item()

        rows = db.get_source_items(node_id, state.node_id_unreads,
                                   state.selected_filter)

        main.display(state.loop, rows)
コード例 #3
0
    def mark_as_read(item_id):
        db = DatabaseAdapter()

        main.set_focused_item()

        db.set_item_read(item_id)

        rows = db.get_source_items(state.selected_node_id,
                                   state.node_id_unreads,
                                   state.selected_filter)

        main.display(state.loop, rows)
コード例 #4
0
    def select(row):
        db = DatabaseAdapter()

        main.set_focused_item()

        db.set_item_read(row['item_id'])

        rows = db.get_source_items(state.selected_node_id,
                                   state.node_id_unreads,
                                   state.selected_filter)

        main.display(state.loop, rows)

        webbrowser.open_new_tab(row['url'])
コード例 #5
0
    def mark_as_read(node_id):
        main.set_focused_item()

        db = DatabaseAdapter()

        if node_id == state.node_id_unreads:
            db.set_unreads_read()
        else:
            db.set_source_read(node_id)

        db.close_connection()

        rows = db.get_source_items(state.selected_node_id,
                                   state.node_id_unreads,
                                   state.selected_filter)

        main.display(state.loop, rows)
コード例 #6
0
ファイル: delete.py プロジェクト: mylk/termrea
def delete(node, button):
    config_adapter = ConfigAdapter()
    db = DatabaseAdapter()

    node_ids = []
    if node['type'] == 'folder':
        folder_nodes = db.get_nodes_by_parent(node['node_id'])
        for folder_node in folder_nodes:
            node_ids.append(folder_node['node_id'])
    node_ids.append(node['node_id'])

    for node_id in node_ids:
        db.delete_node(node_id)
        config_adapter.delete_source(node_id)

    db.close_connection()

    state.sources = config_adapter.get_sources()
    main.set_focused_item()
    rows = db.get_source_items(state.selected_node_id, state.node_id_unreads,
                               state.selected_filter)
    main.display(state.loop, rows)