Ejemplo n.º 1
0
    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        ShortkeyMixin.__init__(self)

        self.set_title('zfm')
        self.set_default_size(360, 460)
        self.connect('delete_event', self.delete_event)

        #-- main widgets
        self.filelists = [FileList(), FileList()]
        self.fviews = [FileViewPane(flist) for flist in self.filelists]
        self.fviews[0].getView().setOther(self.fviews[1].getView())
        self.fviews[1].getView().setOther(self.fviews[0].getView())

        #-- layout
        mainbox = gtk.HBox()
        mainbox.set_property('homogeneous', True)
        for fview in self.fviews:
            mainbox.pack_start(fview, expand=True, padding=0)

        self.add(mainbox)

        #-- hotkeys
        self.bind_shortkey(conf['k-quit'], self.onQuit)

        #-- set up fileviews
        for i, fview in enumerate(self.fviews):
            if conf['remember-paths'] and len(conf['saved-paths']) >= i + 1:
                self.filelists[i].setCwd(conf['saved-paths'][i])
            else:
                self.filelists[i].setCwdHome()
            fview.fileview.connect('focus-in-event', self.onFviewFocusIn)
        self.fviews[0].setActive(True)

        #-- restore geom
        if conf['remember-wingeom'] and conf['wingeom'] is not None:
            geom = conf['wingeom']
            self.move(geom[0], geom[1])
            self.resize(geom[2], geom[3])

        #--
        self.show_all()
Ejemplo n.º 2
0
    def __init__(self, flist, parent_pane):
        gtk.TreeView.__init__(self, flist)
        ShortkeyMixin.__init__(self)

        self.parent_pane = parent_pane

        self.flist = flist
        self.flist.fname_markup_fun = fname_markup
        self.firstCwdDone = False
        
        self.set_headers_visible(False)
        self.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_NONE)

        fname_renderer = gtk.CellRendererText()
        fname_renderer.set_property('editable', True)
        fname_renderer.connect('edited', self.onRenameCommit)
        mark_renderer = gtk.CellRendererText()

        self.col_fname = gtk.TreeViewColumn('Name', fname_renderer, markup=2)
        self.col_mark = gtk.TreeViewColumn('Xxx', mark_renderer, background=3)

        self.col_fname.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
        self.col_fname.set_expand(True)
        # self.col_mark.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
        self.col_mark.set_expand(False)
        self.col_mark.set_property('min-width', 9)
        self.col_mark.set_property('max-width', 9)

        self.append_column(self.col_mark)
        self.append_column(self.col_fname)

        gtk.rc_parse_string( """
        style "filelist-style-active"{
            GtkTreeView::odd-row-color = "#eee"
            GtkTreeView::even-row-color = "#eee"
            GtkTreeView::allow-rules = 1
        }
        style "filelist-style-inactive"{
            GtkTreeView::odd-row-color = "#ddd"
            GtkTreeView::even-row-color = "#ddd"
            GtkTreeView::allow-rules = 1
        }
        widget "*filelist_view_active*" style "filelist-style-active"
        widget "*filelist_view_inactive*" style "filelist-style-inactive"
    """)
        self.set_name('filelist_view_inactive')
        self.set_rules_hint(True)
        self.modify_base(gtk.STATE_SELECTED, gtk.gdk.color_parse('#efefef'))
        self.modify_base(gtk.STATE_ACTIVE, gtk.gdk.color_parse('#efefef'))

        # self.flist.marked_names = {}
        self.alternating_mark_state = True
        
        self.get_selection().set_mode(gtk.SELECTION_MULTIPLE)

        #-- hotkeys
        self.bind_shortkey(conf['k-nav-up'], self.onNavUp)
        self.bind_shortkey(conf['k-nav-home'], self.onNavHome)
        self.bind_shortkey(conf['k-reload'], self.onNavReload)
        self.bind_shortkey(conf['k-toggle-hidden'], self.onToggleHidden)
        self.bind_shortkey(conf['k-file-rename'], self.onBeginRename)
        self.bind_shortkey('Return', self.onItemEnter)
        self.bind_shortkey(conf['k-file-delete'], self.onDoDelete)
        self.bind_shortkey(conf['k-new-file'], self.onDoNewFile)
        self.bind_shortkey(conf['k-mark'], self.onToggleMark)
        self.bind_shortkey(conf['k-mark-all'], self.onToggleMarkAll)
        self.bind_shortkey(conf['k-mark-section'], self.onMarkSection)
        self.bind_shortkey(conf['k-mark-inverse'], self.onMarkInverse)

        #-- model init
        self.flist.connect('cwd-changed', self.onCwdChanged)
        self.flist.connect('cwd-up', self.onCwdUp)
        self.flist.connect('file-deleted', self.onFileDeleted)