Commit graph

167 commits

Author SHA1 Message Date
Sergey Bugaev
4139838a93 Userland et al: Pledge sigaction when needed
* In some cases, we can first call sigaction()/signal(), then *not* pledge
  sigaction.
* In other cases, we pledge sigaction at first, call sigaction()/signal()
  second, then pledge again, this time without sigaction.
* In yet other cases, we keep the sigaction pledge. I suppose these could all be
  migrated to drop it or not pledge it at all, if somebody is interested in
  doing that.
2020-05-26 14:35:10 +02:00
Linus Groh
0edfd45451 FileManager: Remove empty public access modifier from DesktopWidget 2020-05-19 19:25:41 +02:00
Andreas Kling
3d5233ae40 FileManager: Make the location box 2px taller 2020-05-18 17:51:09 +02:00
Sergey Bugaev
acc107a44f FileManager+LibGUI+Userland: Switch clipboard to MIME types
We will now actually use MIME types for clipboard. The default type is now
"text/plain" (instead of just "text").

This also fixes some issues in copy(1) and paste(1).
2020-05-16 09:11:46 +02:00
Andreas Kling
244efe050a Clipboard: Move the system clipboard to a dedicated service process :^)
This commit moves the clipboard from WindowServer into a new Clipboard
service program. Clipboard runs as the unprivileged "clipboard" user
and with a much tighter pledge than WindowServer.

To keep things working as before, all GUI::Application users now make
a connection to Clipboard after making the connection to WindowServer.
It could be interesting to connect to Clipboard on demand, but right
now that would necessitate expanding every GUI app's pledge to include
"unix" and also unveiling the clipboard portal, which I prefer not to.
2020-05-14 22:53:58 +02:00
Nicholas Hollett
b7810a31c3 LibDesktop: Switch to LaunchServer for DesktopServices::open
Moves DirectoryServices out of LibCore (because we need to link with
LibIPC), renames it Desktop::Launcher (because Desktop::DesktopServices
doesn't scan right) and ports it to use the LaunchServer which is now
responsible for starting programs for a file.
2020-05-09 15:13:32 +02:00
Ben Wiederhake
ef433cb367 LibGUI: The UI calls it 'Icon view', fix the name in the code 2020-05-02 14:12:36 +02:00
Andreas Kling
06c478852a FileManager: Realize the initial path when opened from the command line 2020-04-30 22:38:28 +02:00
Andreas Kling
51df4bdbfc DisplaySettings: Rename from DisplayProperties 2020-04-29 15:53:51 +02:00
Andres Vieira
cb118111b6 FileManager: Deny rename in PropertiesDialog if user can't write in path
The FileManager PropertiesDialog always let the user change the name of
files and folders to then be prompted with  write permissions error.

Now it checks for write permissions on the containing folder so it can
"disable" the TextBox input. We can't really disable TextBox right now,
hence the quotes.
2020-04-28 10:00:12 +02:00
Andres Vieira
1d874c03af FileManager: Disable delete action if user can't write in current path
Before this the delete action would be enabled in whenever was the case
in which the user had some selection made. This patch forces a check
to access() with the current folder path to see if the user actually can
delete nodes in it.
2020-04-28 10:00:12 +02:00
Andres Vieira
42f493ec9d FileManager: Add folder-specific paste action
This action is a bit different to the regular paste action because it
takes into account the folder in which the context menu was opened,
so it can be enabled/disabled whether that folder is writable or not for
the current user.

Both paste action use the same logic, now moved to the function
do_action(const GUI::Action&), but in the case of the folder being
right clicked, it pastes inside of it.
2020-04-28 10:00:12 +02:00
Andres Vieira
1f007181be FileManager: Disable paste action for non-writable directories 2020-04-28 10:00:12 +02:00
Andres Vieira
a1bcd9ca8a FileManager: Disables mkdir action if permissions don't allow it
Now the "New directory..." contextual menu is disabled if the current
user doesn't have enough permissions to create a node in the current
path.

This prevents the user going to the "New Directory" InputBox, writing
an appropriate name and accepting just to find they can't even do it :)
2020-04-28 10:00:12 +02:00
Andres Vieira
bf9926743a FileManager: Add paste action to DirectoryView's context menu 2020-04-27 11:21:24 +02:00
Andres Vieira
ef963dae7e FileManager: Paste inside folder if done through its context menu
Now FileManager will paste the clipboard contents inside a folder if the
paste action was clicked through a folder context menu, being the target
directory the selected folder.

This mimicks most of the behaviours that the different file managers
have.
2020-04-27 11:21:24 +02:00
Andres Vieira
91b70d34e7 FileManager: Copy and Delete selected file(s), not current folder
FileManager had this weird behaviour in which it would ignore the
current selection and try to copy and delete the current folder.
2020-04-27 11:21:24 +02:00
Andres Vieira
1617be1e6f FileManager: Disable open_parent_directory_action if the new path is "/" 2020-04-26 15:26:01 +02:00
Andreas Kling
ab336e895f LibGUI: Add a ToolBarContainer widget and put most ToolBars in one
This mimics the Explorer toolbar container from Windows 2000 and looks
pretty neat! :^)
2020-04-23 17:44:49 +02:00
Jonathan Archer
0efb5b3a11 Desktop: Context menu option to open FileManager 2020-04-23 11:22:32 +02:00
Jonathan Archer
3bbd7d9425 Desktop: Show DisplayProperties in context menu 2020-04-23 11:22:32 +02:00
Jonathan Archer
5457020d4e Desktop: File creation from the context menu
Kinda hackish, but it does work.
2020-04-23 11:22:32 +02:00
Jonathan Archer
d02c02cebe Desktop: Add context menu for directory view
Only has the option to create a folder, but hey ;^)
2020-04-23 11:22:32 +02:00
Andreas Kling
09138d542d FileManager: Fix build 2020-04-22 12:38:33 +02:00
angel
0d47ad7efe FileManager: Exit the application cleanly when failing to open initial directory
Co-Authored-By: Andreas Kling <kling@serenityos.org>
2020-04-22 12:12:32 +02:00
angel
cc424b7b0f FileManager: Graceful handling of access errors
A neat error message is displayed when failing to open a directory!
2020-04-22 12:12:32 +02:00
Andreas Kling
705cee528a LibGUI: Make it easier to create checkable GUI::Actions
This patch adds GUI::Action::create_checkable() helpers that work just
like the existing create() helpers, but the actions become checkable(!)

Clients are no longer required to manage the checked state of their
actions manually, but instead they will be checked/unchecked as needed
by GUI::Action itself before the activation hook is fired.
2020-04-21 17:21:28 +02:00
Andreas Kling
52a250cb61 LibGUI: Make MenuBar a Core::Object
This makes it show up in Inspector with all the menus inside it. :^)
2020-04-21 16:19:18 +02:00
angel
e0a16f8752 FileManager+LibGUI: Allow drop on entire DirectoryView
Previously, drag and drop would only work when dragging between node
items on a DirectoryView. This commit makes it possible to drag files to
the empty area of the DirectoryView and copy files more easily between
windows.
2020-04-20 12:15:26 +02:00
Andreas Kling
c45e16f605 LibCore: Add StandardPaths thing to retrieve various standard locations
Fixes #1853.
2020-04-19 19:57:05 +02:00
angel
11054fc9f9 FileManager: Fix recursive copy on drag
When a drag operation is accepted, we don't check whether the source
nodes contain the destination directory. This could trigger an unwanted
recursive copy.
2020-04-19 17:16:08 +02:00
angel
0ec37c0d64 FileManager: Ignore empty selections on tree view
If the selection is empty, the model index will be invalid and the file
system model will return the root directory path by default. This causes
the file manager to jump to the root directory when the currently
selected item on the tree view is deselected.
2020-04-19 15:23:16 +02:00
Sergey Bugaev
f8b2a7b4a7 LibCore+LibGUI: Move DesktopServices to LibCore 2020-04-19 11:14:26 +02:00
Andreas Kling
7dbb8b6f09 FileManager: Allow running in desktop mode
FileManager can now be started with the --desktop argument. When it's
started in this mode, it will run as a WindowType::Desktop window and
not create any of its regular UI.

The desktop version of the file manager is currently pretty bare-bones
but we can improve it over time and share more code with the regular
file manager windows.

I think this is pretty cool! :^)
2020-04-18 22:04:41 +02:00
Oriko
2c5faa8ff3 FileManager: Add properties action to directory context menu 2020-04-05 16:02:07 +02:00
Andreas Kling
26eeaef0a8 LibGUI: Add MenuBar::add_menu(name)
This allows us to construct menus in a more natural way:

    auto& file_menu = menubar->add_menu("File");
    file_menu.add_action(...);

Instead of the old way:

    auto file_menu = GUI::Menu::construct();
    file_menu->add_action(...);
    menubar->add_menu(file_menu);
2020-04-04 12:58:05 +02:00
Itamar
a4497ce375 FileManager: chdir to appropriate directory before starting Terminal 2020-03-18 08:23:31 +01:00
Itamar
45d7ea1b63 FileManager: Add "Open Terminal here" action 2020-03-15 19:09:24 +01:00
Tibor Nagy
f347dd5c5e Applications: Use "Document - AppName" window title format
Fixes #1444
2020-03-13 23:30:12 +01:00
Andreas Kling
37fc6c117c Userspace: Add missing #includes now that AK/StdLibExtras.h is smaller 2020-03-08 13:06:51 +01:00
Andreas Kling
b29ff7b821 LibGUI: Don't use Core::Object::add() to instantiate dialogs
Now that add() returns a WidgetType&, we can't rely on the parent of a
GUI::Dialog to still keep it alive after exec() returns. This happens
because exec() will call remove_from_parent() on itself before
returning.

And so we go back to the old idiom for creating a GUI::Dialog centered
above a specific window. Just call GUI::Dialog::construct(), passing
the "parent" window as the last parameter.
2020-03-04 21:04:06 +01:00
Andreas Kling
028c011760 LibCore: Make Core::Object::add<ChildType> return a ChildType&
Since the returned object is now owned by the callee object, we can
simply vend a ChildType&. This allows us to use "." instead of "->"
at the call site, which is quite nice. :^)
2020-03-04 21:04:06 +01:00
Andreas Kling
03e0ddce52 LibGUI: Some more convenience functions for constructing widgets
This patch adds two new API's:

- WidgetType& GUI::Window::set_main_widget<WidgetType>();

  This creates a new main widget for a window, assigns it, and returns
  it to you as a WidgetType&.

- LayoutType& GUI::Widget::set_layout<LayoutType>();

  Same basic idea, creates a new layout, assigns it, and returns it to
  you as a LayoutType&.
2020-03-03 22:37:48 +01:00
Andreas Kling
3d20da9ee4 Userspace: Use Core::Object::add() when building interfaces 2020-02-23 11:10:52 +01:00
Andreas Kling
b011ea9962 LibGUI: Reduce menu-related header dependencies 2020-02-15 01:56:30 +01:00
Andreas Kling
814d59f462 LibGUI: Port the drag&drop code to Core::MimeData 2020-02-14 13:18:59 +01:00
Andreas Kling
4dc15fc063 FileManager: Copy item(s) when dragging and dropping them :^)
This patch implements basic drag & drop file management in a narrow set
of cases. You can now drag & drop a file onto a folder in the same
directory, and the dropped file will be copied into the directory.

We'll need to support a lot more variations of this, but this is nice!
2020-02-13 21:57:02 +01:00
Andreas Kling
95fe78667f FileManager: Run clang-format on main.cpp 2020-02-13 21:54:27 +01:00
Andreas Kling
6a9cc66b97 LibGUI: Remove leading G from filenames 2020-02-06 20:33:02 +01:00
Andreas Kling
d17e23bd27 LibCore: Remove leading C from filenames 2020-02-06 15:04:03 +01:00