Example #1
0
def __getNewFileChoice():
    dialog = gtk.FileChooserDialog("New file...", None,
                                   gtk.FILE_CHOOSER_ACTION_SAVE,
                                   (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                    gtk.STOCK_OPEN, gtk.RESPONSE_OK))
    filter = gtk.FileFilter()
    filter.set_name("All files")
    filter.add_pattern("*")
    dialog.add_filter(filter)
    # Does the user have a folder selected that we should instead load on
    # newFile?
    from leftpanel import leftview
    model, iter = leftview.get_selection().get_selected()
    from datastore import F_REF
    try:
        object = model.get_value(iter, F_REF)
        if isinstance(object, PackageFileObj):  # A file
            folder = object.parent
        elif isinstance(object, FolderObj):  # A folder
            folder = object
        if folder == None:
            folderPath = get_config_path()
        else:
            folderPath = folder.path  # Get the path to the folder object
    except TypeError, e:
        print >> stderr, "__getNewFileChoice:", e
        #Nothing selected, select default
        folderPath = get_config_path()
Example #2
0
def __getNewFileChoice():
    dialog = gtk.FileChooserDialog("New file...", None,
            gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL,
                gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
    filter = gtk.FileFilter()
    filter.set_name("All files")
    filter.add_pattern("*")
    dialog.add_filter(filter)
    # Does the user have a folder selected that we should instead load on
    # newFile?
    from leftpanel import leftview
    model, iter = leftview.get_selection().get_selected()
    from datastore import F_REF
    try:
        object = model.get_value(iter, F_REF)
        if isinstance(object, PackageFileObj): # A file
            folder = object.parent
        elif isinstance(object, FolderObj): # A folder 
            folder = object
        if folder == None:
            folderPath = get_config_path()
        else:
            folderPath = folder.path # Get the path to the folder object
    except TypeError,e:
        print >>stderr, "__getNewFileChoice:",e
        #Nothing selected, select default
        folderPath = get_config_path()
Example #3
0
def drag_begin_signal(treeview, dragcontext, *args):
    """ Grab model and data begin dragged """
    #global bmodel
    global data
    global lselection
    global lselected
    from leftpanel import leftview
    lselection = leftview.get_selection()
    lselected = lselection.get_selected()
    data = [] #master container
    #get the selected rows
    model = treeview.get_model()
    rows = treeview.get_selection().get_selected_rows()[1]
    for path in rows: #each line is a path to the row
        print "DRAG_BEGIN_SIGNAL_PATHS:"; print path
        cdata = [] #current data
        iter = model.get_iter(path)
        cdata.append(model.get_value(iter, E_NAME))
        cdata.append(model.get_value(iter, E_DATA))
        cdata.append(model.get_value(iter, E_EDITABLE))
        cdata.append(model.get_value(iter, E_PARENT))
        cdata.append(model.get_value(iter,E_MODIFIED))
        cdata.append(gtk.TreeRowReference(model, path))
        data.append(cdata)
    print "MASTER DATA CONTAINER:"
    print data
Example #4
0
def getCurrentFile():
    """ Return  [PackageFileObj, model] when it cannot be retrieved by others means """
    from leftpanel import leftview
    from datastore import F_REF
    model, iter = leftview.get_selection().get_selected()
    try:
        PackageFile = model.get_value(iter, F_REF)
    except: #Nothing selected
        PackageFile = None
    return [PackageFile, model]
Example #5
0
def switchListView(widget, drag_context, x, y, timestamp, *args):
    """ Hilights leftview drop target during drag operation """
    from leftpanel import leftview
    import rightpanel
    model = leftview.get_model()
    path = leftview.get_dest_row_at_pos(x, y)
    leftview.expand_row(path[0], True)
    #iter = model.get_iter(path[0])
    treeselection = leftview.get_selection()
    treeselection.select_path(path[0])
Example #6
0
def deleteFile(*args):
    """ Deletes the currently selected file """
    if ensureNotModified(msg):

        # What exactly is currently selected?
        from leftpanel import leftview
        model, iter = leftview.get_selection().get_selected()
        from datastore import F_REF
        try:
            object = model.get_value(iter, F_REF)
            if isinstance(object, PackageFileObj):  # A file
                file = object
                dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,\
                        "This operation is irreversible, are you sure you want to delete " + str(file) + "?")
                dialog.set_default_response(gtk.RESPONSE_NO)
                dialog.set_title("File removal...")
                response = dialog.run()
                if response == gtk.RESPONSE_YES:
                    print "Test delete file: " + file.path
                    __removeFile(file.path)
                    dialog.destroy()
                    reinitializeDatabase()
                    if file.parent != None:
                        __reselectAfterDelete(file.parent.path)
                else:
                    dialog.destroy()
            elif isinstance(object, FolderObj):  # A folder
                folder = object
                dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,\
                        "This operation is irreversible, are you sure you want to delete directory " + \
                                str(folder) + " and its contents?")
                dialog.set_default_response(gtk.RESPONSE_NO)
                dialog.set_title("Directory removal...")
                response = dialog.run()
                if response == gtk.RESPONSE_YES:
                    print "Test delete dir: " + folder.path
                    __removeDirectory(folder.path)
                    dialog.destroy()
                    reinitializeDatabase()
                    if folder.parentState:
                        __reselectAfterDelete(folder.parent.path)
                else:
                    dialog.destroy()
        except TypeError, e:
            print >> stderr, "deleteFile: ", e
Example #7
0
def deleteFile(*args):
    """ Deletes the currently selected file """
    if ensureNotModified(msg):

        # What exactly is currently selected?
        from leftpanel import leftview
        model, iter = leftview.get_selection().get_selected()
        from datastore import F_REF
        try:
            object = model.get_value(iter, F_REF)
            if isinstance(object, PackageFileObj): # A file
                file = object
                dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,\
                        "This operation is irreversible, are you sure you want to delete " + str(file) + "?")
                dialog.set_default_response(gtk.RESPONSE_NO)
                dialog.set_title("File removal...")
                response = dialog.run()
                if response == gtk.RESPONSE_YES:
                    print "Test delete file: " + file.path
                    __removeFile(file.path)
                    dialog.destroy()
                    reinitializeDatabase()
                    if file.parent != None:
                        __reselectAfterDelete(file.parent.path)
                else:
                    dialog.destroy()
            elif isinstance(object, FolderObj): # A folder 
                folder = object
                dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,\
                        "This operation is irreversible, are you sure you want to delete directory " + \
                                str(folder) + " and its contents?")
                dialog.set_default_response(gtk.RESPONSE_NO)
                dialog.set_title("Directory removal...")
                response = dialog.run()
                if response == gtk.RESPONSE_YES:
                    print "Test delete dir: " + folder.path
                    __removeDirectory(folder.path)
                    dialog.destroy()
                    reinitializeDatabase()
                    if folder.parentState:
                        __reselectAfterDelete(folder.parent.path)
                else:
                    dialog.destroy()
        except TypeError,e:
            print >>stderr, "deleteFile: ",e
Example #8
0
def renameFile(*args):
    """ Renames the currently selected file """
    from leftpanel import leftview
    model, iter = leftview.get_selection().get_selected()
    from datastore import F_REF
    try:
        object = model.get_value(iter, F_REF)
        if isinstance(object, PackageFileObj):  # A file
            type = "File"
            if object.parent == None:
                setFolder = get_config_path()
            else:
                setFolder = object.parent.path
        elif isinstance(object, FolderObj):  # A folder
            type = "Directory"
            setFolder = object.parent.path
        if ensureNotModified(msg):
            __createRenameDialog(object, type, setFolder)
    except TypeError, e:
        print >> stderr, "__renameFile:", e
Example #9
0
def renameFile(*args):
    """ Renames the currently selected file """
    from leftpanel import leftview

    model, iter = leftview.get_selection().get_selected()
    from datastore import F_REF

    try:
        object = model.get_value(iter, F_REF)
        if isinstance(object, PackageFileObj):  # A file
            type = "File"
            if object.parent == None:
                setFolder = get_config_path()
            else:
                setFolder = object.parent.path
        elif isinstance(object, FolderObj):  # A folder
            type = "Directory"
            setFolder = object.parent.path
        if ensureNotModified(msg):
            __createRenameDialog(object, type, setFolder)
    except TypeError, e:
        print >> stderr, "__renameFile:", e