A twin-panel file manager based on Python 3/GTK3

Double Flower

© Photo by marty brixen on unsplash

© Photo by marty brixen on unsplash

Article from Issue 243/2021
Author(s):

Following in the footsteps of Norton Commander and its clones, the Sunflower twin-panel file manager takes a giant leap forward with a switch to Python 3 and GTK3.

Some programs, such as Netscape, Adobe Photoshop, and Microsoft Office, set the benchmark for future products. For file managers, the discontinued Norton Commander paved the way to easier copying, moving, and editing files at the MS-DOS command line. Norton Commander's view, which was divided into two halves (hence the umbrella term "twin-pane file manager") let users select files from a directory list in one pane by pressing Insert and then transfer them to the directory opened in the other pane by pressing F8.

Norton Commander quickly spawned numerous clones, including Total Commander [1], Midnight Commander [2], Gnome Commander [3], PCManFM [4], and Krusader [5], as well as several other candidates. One of the classics, the graphical Sunflower [6] file manager, has been under continuous development for many years. With version 0.4, the project has switched to Python 3 and GTK3, a radical change that cost the project a great deal of time, which explains the four years between versions. Sunflower 0.4 offers an easy-to-use, highly customizable twin-pane file manager that integrates seamlessly with (but is not limited to) the Gnome desktop.

Installation

Sunflower is not available in the package sources of most popular distributions. But Arch Linux users will find two packages, sunflower and sunflower-git, in the Arch User Repository (AUR) organized by the community. With an AUR helper like Yay, you can install the program by typing:

yay -S sunflower

For other distributions, the Sunflower project offers deb and RPM installation packages, including ones for Debian, Ubuntu, and Fedora [7]. In testing, the installation worked without problems on Ubuntu 20.04 LTS and Fedora 32.

After launching, Sunflower offers a typical twin-pane file manager window (Figure 1). On both sides, you will find your home directory's contents. With a mouse click, you can navigate through the folder structure, or you can open files in the associated applications by double clicking. To launch a selected file with a different program, right-click to open the context menu and select Open with. In the menu, you will also find the usual functions for creating folders or files, functions for file operations, and options for changing the file permissions or associations (via Properties).

Figure 1: Sunflower 0.4 uses modern components like Python 3 and GTK3, while retaining the classic structure of two panels, tabs, and a toolbar at the bottom.

Operations

In the file list, you can use the mouse or the keyboard to navigate. Use the Up and Down Arrow keys to select an entry. In the usual style for Commander clones, you can reverse the selection of a file or folder by pressing Insert. Alternatively, hold down the Shift key and use the Up and Down Arrow keys to highlight a selection.

The Right Arrow key expands the folders' contents in a tree view, while the Left Arrow key collapses the tree. Clicking on Mounts takes you directly to your home directory or to mounted external drives like USB memory sticks or Android smartphones.

Choosing Selection from the hamburger menu in the window's upper right corner gives you further possibilities for selecting files or folders, including selecting or deselecting files according to a pattern or their file extension. Compare Directories in the same menu is also practical if you want to synchronize a backup directory. This option selects the files that do not exist in the other opened subwindow, but it ignores files that have just changed.

Use Ctrl+Right Arrow to expand the selected folder on the left in the right pane, while Ctrl+Left Arrow collapses the selected folder. Press Ctrl+T to open the current folder in a new tab, while Ctrl+Shift+T opens the selected folder in a new tab (see Table 1 for additional shortcuts).

Table 1

Sunflower Shortcuts

Abbreviation

Function

File operations

F2

Rename selection

F3

View selected element

F4

Edit selected element

F5

Copy selection

F6

Move selection

F7

Create new directory

Del or F8

Move selection to trash

Actions in file list

Insert

Invert selection

Shift+Up Arrow

Select top element

Shift+Down Arrow

Select bottom element

Ctrl+Right Arrow

Expand selected folder

Ctrl+Left Arrow

Collapse selected folder

Tabs

Ctrl+T

Open current folder in new tab

Ctrl+Shift+T

Open selected folder in new tab

Ctrl+Tab

Move to the next tab

Ctrl+Shift+Tab

Switch to previous tab

Ctrl+W

Close current tab

Terminal

Ctrl+Z

Open current folder in terminal

Ctrl+Shift+C

Copy selection in terminal to clipboard

Ctrl+Shift+V

Paste content from clipboard to terminal

The Display menu lets you customize the application window. The Horizontal Split option divides the file manager into two areas arranged one above the other. Dark theme lets you enable your desktop environment's default theme for multimedia applications (Figure 2).

Figure 2: Sunflower can be extensively customized in the settings: A mouse click lets you arrange the panels horizontally or activate a dark theme.

One of Sunflower's strengths lies in the terminal integrated directly in the interface. You can access it by clicking on the terminal icon in the buttonbar above the two panes or with the keyboard shortcut Ctrl+Z (Figure 3). By default, Sunflower uses the VTE terminal library, upon which other terminal applications, such as the Gnome terminal or Terminator, are also based. To adjust the font size and other details, go to Preferences | Terminal in the hamburger menu. Optionally, Sunflower will also launch an external terminal program, but it does not offer a context menu. For example, to insert pathnames, you have to click on the terminal icon and select Insert.

Figure 3: Use Ctrl+Z to display a terminal window in the currently active file manager pane.

Sunflower offers an integrated preview function for text and source code files (Figure 4). To view a file, select the file in question and click on Preview in the lower menubar or press F3. The preview automatically highlights variables and instructions in the source code. You can also disable this highlighting by clicking on Text in the preview window's header.

Figure 4: Sunflower opens files with text or source code in a preview. The preview function automatically highlights variables or commands.

To modify a file, select Edit or press F4. Sunflower then opens the selected file in the desktop environment's standard editor. You can optionally choose a different editor in the settings in View & Edit or enter an external command.

Conclusions and Outlook

The switch to Python 3 and GTK3 sets Sunflower on course for the future. With version 0.4, it is now far easier to develop the application and expand the range of functions. In testing version 0.4, I found a few areas still under construction. For example, selecting plugins for finding or renaming files results in an error message that tells you to enable a plugin – but a plugin with the stated name does not exist.

Sunflower still needs to do a bit of catching up in terms of network support. While other file managers, such as Gnome Files (formerly Nautilus) or KDE's Dolphin mount network shares directly via a URL such as smb://<User>@<Server> or ssh://<User>@<Server>, Sunflower completely lacks this function. Network drives can only be accessed if they have previously been permanently mounted in the folder structure or integrated into Nautilus. Afterwards, the contents can be viewed via the corresponding mount point or, in the case of Gnome's GVfs virtual filesystem, in /run/user/<UID>/gvfs.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Sunflower File Manager

    Sunflower is a highly configurable graphical file manager with two windows that implement an unusual concept by trying to integrate the command line with the file manager.

  • File Managers

    Working with files and folders is a typical daily task on any computer. We tested four lesser known file managers that significantly simplify handling content on mass storage media.

  • Workspace – Android Productivity Apps

    Transform your Android device into a lean, mean productivity machine with open source apps.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News