Beispiel #1
0
    def __init__(self, app, main_window, viewerid=None,
                 default_viewer=ThreePaneViewer):
        Viewer.__init__(self, app, main_window, viewerid, 
                        viewer_name="tabbed_viewer")
        self._default_viewer = default_viewer
        self._current_viewer = None
        self._callbacks = {}
        self._ui_ready = False
        self._null_viewer = Viewer(app, main_window)
        self._tab_names = {}

        # TODO: move to the app?
        # viewer registry
        self._viewer_lookup = TwoWayDict()
        self._viewer_lookup.add(ThreePaneViewer(app, main_window).get_name(), 
                                ThreePaneViewer)
        
        # layout
        self._tabs = gtk.Notebook()
        self._tabs.show()
        self._tabs.set_property("show-border", False)
        self._tabs.set_property("homogeneous", True)
        self._tabs.set_property("scrollable", True)
        self._tabs.connect("switch-page", self._on_switch_tab)
        self._tabs.connect("page-added", self._on_tab_added)
        self._tabs.connect("page-removed", self._on_tab_removed)
        self._tabs.connect("button-press-event", self._on_button_press)
        self.pack_start(self._tabs, True, True, 0)

        # initialize with a single tab
        self.new_tab()
    def __init__(self, app, main_window, viewerid=None,
                 default_viewer=ThreePaneViewer):
        Viewer.__init__(self, app, main_window, viewerid, 
                        viewer_name="tabbed_viewer")
        self._default_viewer = default_viewer
        self._current_viewer = None
        self._callbacks = {}
        self._ui_ready = False
        self._null_viewer = Viewer(app, main_window)
        self._tab_names = {}

        # TODO: move to the app?
        # viewer registry
        self._viewer_lookup = TwoWayDict()
        self._viewer_lookup.add(ThreePaneViewer(app, main_window).get_name(), 
                                ThreePaneViewer)
        
        # layout
        self._tabs = gtk.Notebook()
        self._tabs.show()
        self._tabs.set_property("show-border", False)
        self._tabs.set_property("homogeneous", True)
        self._tabs.set_property("scrollable", True)
        self._tabs.connect("switch-page", self._on_switch_tab)
        self._tabs.connect("page-added", self._on_tab_added)
        self._tabs.connect("page-removed", self._on_tab_removed)
        self._tabs.connect("button-press-event", self._on_button_press)
        self.pack_start(self._tabs, True, True, 0)

        # initialize with a single tab
        self.new_tab()
    def new_node(self, kind, pos, parent=None):
        """Add a new node to the notebook"""
        
        # TODO: think about where this goes

        if self._notebook is None:
            return

        self.treeview.cancel_editing()
        self.listview.cancel_editing()
        
        if parent is None:
            nodes = self.get_selected_nodes()
            if len(nodes) == 1:
                parent = nodes[0]
            else:
                parent = self._notebook
        
        node = Viewer.new_node(self, kind, pos, parent)

        self._view_new_node(node)
Beispiel #4
0
    def new_node(self, kind, pos, parent=None):
        """Add a new node to the notebook"""
        
        # TODO: think about where this goes

        if self._notebook is None:
            return

        self.treeview.cancel_editing()
        self.listview.cancel_editing()
        
        if parent is None:
            nodes = self.get_selected_nodes()
            if len(nodes) == 1:
                parent = nodes[0]
            else:
                parent = self._notebook
        
        node = Viewer.new_node(self, kind, pos, parent)

        self._view_new_node(node)
    def __init__(self, app, main_window, viewerid=None):
        Viewer.__init__(self, app, main_window, viewerid,
                        viewer_name="three_pane_viewer")
        self._ui_ready = False

        # node selections        
        self._current_page = None     # current page in editor
        self._treeview_sel_nodes = [] # current selected nodes in treeview
        self._queue_list_select = []  # nodes to select in listview after treeview change
        self._new_page_occurred = False
        self.back_button = None
        self._view_mode = DEFAULT_VIEW_MODE

        self.connect("history-changed", self._on_history_changed)

        #=========================================
        # widgets


        # treeview
        self.treeview = KeepNoteTreeView()
        self.treeview.set_get_node(self._app.get_node)
        self.treeview.connect("select-nodes", self._on_tree_select)
        self.treeview.connect("delete-node", self.on_delete_node)
        self.treeview.connect("error", lambda w,t,e: self.emit("error", t, e))
        self.treeview.connect("edit-node", self._on_edit_node)
        self.treeview.connect("goto-node", self.on_goto_node)
        self.treeview.connect("activate-node", self.on_activate_node)
        self.treeview.connect("drop-file", self._on_attach_file)
        
        # listview
        self.listview = KeepNoteListView()
        self.listview.set_get_node(self._app.get_node)
        self.listview.connect("select-nodes", self._on_list_select)
        self.listview.connect("delete-node", self.on_delete_node)
        self.listview.connect("goto-node", self.on_goto_node)
        self.listview.connect("activate-node", self.on_activate_node)
        self.listview.connect("goto-parent-node",
                              lambda w: self.on_goto_parent_node())
        self.listview.connect("error", lambda w,t,e: self.emit("error", t, e))
        self.listview.connect("edit-node", self._on_edit_node)
        self.listview.connect("drop-file", self._on_attach_file)
        self.listview.on_status = self.set_status  # TODO: clean up
        
        # editor
        #self.editor = KeepNoteEditor(self._app)
        #self.editor = RichTextEditor(self._app)
        self.editor = ContentEditor(self._app)
        rich_editor = RichTextEditor(self._app)
        self.editor.add_editor("text/xhtml+xml", rich_editor)
        self.editor.add_editor("text", TextEditor(self._app))
        self.editor.set_default_editor(rich_editor)

        self.editor.connect("view-node", self._on_editor_view_node)
        self.editor.connect("child-activated", self._on_child_activated)
        self.editor.connect("visit-node", lambda w, n: self.goto_node(n, False))
        self.editor.connect("error", lambda w,t,e: self.emit("error", t, e))
        self.editor.connect("window-request", lambda w,t: 
                            self.emit("window-request", t))
        self.editor.view_nodes([])
        
        self.editor_pane = gtk.VBox(False, 5)
        self.editor_pane.pack_start(self.editor, True, True, 0)


        #=====================================
        # layout

        # TODO: make sure to add underscore for these variables

        # create a horizontal paned widget
        self.hpaned = gtk.HPaned()
        self.pack_start(self.hpaned, True, True, 0)
        self.hpaned.set_position(DEFAULT_HSASH_POS)

                
        # layout major widgets
        self.paned2 = gtk.VPaned()
        self.hpaned.add2(self.paned2)
        self.paned2.set_position(DEFAULT_VSASH_POS)
        
        # treeview and scrollbars
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.add(self.treeview)
        self.hpaned.add1(sw)
        
        # listview with scrollbars
        self.listview_sw = gtk.ScrolledWindow()
        self.listview_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.listview_sw.set_shadow_type(gtk.SHADOW_IN)
        self.listview_sw.add(self.listview)
        self.paned2.add1(self.listview_sw)
        #self.paned2.child_set_property(self.listview_sw, "shrink", True)
        
        # layout editor
        self.paned2.add2(self.editor_pane)
        
        self.treeview.grab_focus()
Beispiel #6
0
    def __init__(self, app, main_window, viewerid=None):
        Viewer.__init__(self, app, main_window, viewerid,
                        viewer_name="three_pane_viewer")
        self._ui_ready = False

        # node selections        
        self._current_page = None     # current page in editor
        self._treeview_sel_nodes = [] # current selected nodes in treeview
        self._queue_list_select = []  # nodes to select in listview after treeview change
        self._new_page_occurred = False
        self.back_button = None
        self._view_mode = DEFAULT_VIEW_MODE

        self.connect("history-changed", self._on_history_changed)

        #=========================================
        # widgets


        # treeview
        self.treeview = KeepNoteTreeView()
        self.treeview.set_get_node(self._app.get_node)
        self.treeview.connect("select-nodes", self._on_tree_select)
        self.treeview.connect("delete-node", self.on_delete_node)
        self.treeview.connect("error", lambda w,t,e: self.emit("error", t, e))
        self.treeview.connect("edit-node", self._on_edit_node)
        self.treeview.connect("goto-node", self.on_goto_node)
        self.treeview.connect("activate-node", self.on_activate_node)
        self.treeview.connect("drop-file", self._on_attach_file)
        
        # listview
        self.listview = KeepNoteListView()
        self.listview.set_get_node(self._app.get_node)
        self.listview.connect("select-nodes", self._on_list_select)
        self.listview.connect("delete-node", self.on_delete_node)
        self.listview.connect("goto-node", self.on_goto_node)
        self.listview.connect("activate-node", self.on_activate_node)
        self.listview.connect("goto-parent-node",
                              lambda w: self.on_goto_parent_node())
        self.listview.connect("error", lambda w,t,e: self.emit("error", t, e))
        self.listview.connect("edit-node", self._on_edit_node)
        self.listview.connect("drop-file", self._on_attach_file)
        self.listview.on_status = self.set_status  # TODO: clean up
        
        # editor
        #self.editor = KeepNoteEditor(self._app)
        #self.editor = RichTextEditor(self._app)
        self.editor = ContentEditor(self._app)
        rich_editor = RichTextEditor(self._app)
        self.editor.add_editor("text/xhtml+xml", rich_editor)
        self.editor.add_editor("text", TextEditor(self._app))
        self.editor.set_default_editor(rich_editor)

        self.editor.connect("view-node", self._on_editor_view_node)
        self.editor.connect("child-activated", self._on_child_activated)
        self.editor.connect("visit-node", lambda w, n: self.goto_node(n, False))
        self.editor.connect("error", lambda w,t,e: self.emit("error", t, e))
        self.editor.connect("window-request", lambda w,t: 
                            self.emit("window-request", t))
        self.editor.view_nodes([])
        
        self.editor_pane = gtk.VBox(False, 5)
        self.editor_pane.pack_start(self.editor, True, True, 0)


        #=====================================
        # layout

        # TODO: make sure to add underscore for these variables

        # create a horizontal paned widget
        self.hpaned = gtk.HPaned()
        self.pack_start(self.hpaned, True, True, 0)
        self.hpaned.set_position(DEFAULT_HSASH_POS)

                
        # layout major widgets
        self.paned2 = gtk.VPaned()
        self.hpaned.add2(self.paned2)
        self.paned2.set_position(DEFAULT_VSASH_POS)
        
        # treeview and scrollbars
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.add(self.treeview)
        self.hpaned.add1(sw)
        
        # listview with scrollbars
        self.listview_sw = gtk.ScrolledWindow()
        self.listview_sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.listview_sw.set_shadow_type(gtk.SHADOW_IN)
        self.listview_sw.add(self.listview)
        self.paned2.add1(self.listview_sw)
        #self.paned2.child_set_property(self.listview_sw, "shrink", True)
        
        # layout editor
        self.paned2.add2(self.editor_pane)
        
        self.treeview.grab_focus()