Commit Graph

151 Commits

Author SHA1 Message Date
networkException
938051feb8 Everywhere: Use Core::ConfigFile::AllowWriting::Yes to allow writing 2021-08-22 01:32:25 +02:00
Andreas Kling
7d904eed12 FileManager: Reorder main toolbar actions a little bit
Put the "Open in terminal" action next to the other navigation actions.
And separate the "New File" and "New Directory" actions from the actions
that operate on existing items.
2021-08-18 13:00:20 +02:00
sin-ack
e11d177618 Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:

- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
  and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
  the top margin, the second argument to the left and right margins,
  and the third argument to the bottom margin.
2021-08-18 10:30:50 +02:00
sin-ack
9c9a5c55cb Userland+LibGUI: Make Margins arguments match CSS ordering
Previously the argument order for Margins was (left, top, right,
bottom). To make it more familiar and closer to how CSS does it, the
argument order is now (top, right, bottom, left).
2021-08-18 10:30:50 +02:00
sin-ack
ca2c81251a Everywhere: Replace Model::update() with Model::invalidate()
Most of the models were just calling did_update anyway, which is
pointless since it can be unified to the base Model class. Instead, code
calling update() will now call invalidate(), which functions identically
and is more obvious in what it does.

Additionally, a default implementation is provided, which removes the
need to add empty implementations of update() for each model subclass.

Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2021-08-06 19:14:31 +02:00
Karol Kosek
4988540cb1 FileManager: Use the current directory as one of the initial locations
This change makes `cd /bin; FileManager` open the app in /bin.
2021-08-03 09:12:33 +02:00
Karol Kosek
35cc5b9873 FileManager: Set chdir to the current path when opening applications 2021-08-03 09:12:33 +02:00
LuK1337
a91848c148 FileManager: Refresh DirectoryView after applying changes
Fixes: #9136
2021-08-01 12:30:24 +02:00
Karol Kosek
92fd86901d FileManager: Enable/Disable mkdir and touch actions on path change
This change disables the icons in read-only directories.
2021-08-01 12:12:59 +02:00
Karol Kosek
755fe2b0ca FileManager: Remove the rename action from the tree view context menu
The action never worked properly here.  It used the selection
from the directory view, instead of the tree view.
Furthermore, the tree view isn't even editable.

Just making tree view editable wouldn't fix it -- it'd probably
need something like creating an on_stop_editing() function
in the AbstractView to change the path after the rename.

For now, I'll remove the action from the menu as a "temporary fix".
2021-08-01 12:12:59 +02:00
Karol Kosek
c1dc9e6de2 FileManager: Add the rename action to the toolbar
When I was adding the action in #8713, the action did not have an icon
yet.  Now, since it has an icon now, we can add it to the toolbar!
2021-08-01 12:12:59 +02:00
Brian Gianforcaro
a51e6547aa Applications: Remove unused header includes 2021-08-01 08:10:16 +02:00
FrHun
0dd4e2d21b FileManager: Fix properties button margins 2021-07-27 22:17:23 +02:00
Andreas Kling
49b9683381 FileManager: Make "show dotfiles" affect the tree view as well
Previously this only affected the main directory view.
2021-07-27 18:27:49 +02:00
Karol Kosek
a1d0ad61a6 FileManager: Show an open icon for selected folder in tree view again
The original work was done in #2752
(deceb91c48 to be precise),
but unfortunately 2c772d1848 replaced
on_selection with on_selection_change, which caused the function
to never be executed, as it was reassigned a few lines below.
2021-07-24 21:13:22 +02:00
Sam Atkins
9ac757647f FileManager: Switch FileOperationProgressWidget::did_error() to SV& 2021-07-22 12:48:44 +02:00
Sam Atkins
469bca9d3a FileManager: Show progress dialog for file deletions
Progress dialogs are nice! :^)

Showing a proper file-deletion animation would be nice, but that is
outside the scope of my abilities.
2021-07-22 12:48:44 +02:00
Sam Atkins
dd833dc220 FileManager: Rename FileOperation::Cut to FileOperation::Move 2021-07-22 12:48:44 +02:00
Sam Atkins
5090b1bdba FileManager: Set file op progress window's text based on the operation 2021-07-22 12:48:44 +02:00
Sam Atkins
0a62d517fd FileManager+FileOperation: Implement (and use) 'Move' command
`FileOperation Move ...` is now used for cut-and-paste in the
FileManager.
2021-07-22 12:48:44 +02:00
Sam Atkins
516764ef17 FileManager: Show progress dialog for pasted files
For now, this is a slight step backwards, as Cut does not remove the
source files. This will be rectified next.
2021-07-22 12:48:44 +02:00
Sam Atkins
d8fb8b9583 FileManager: Move mass-copy code from DirectoryView to FileUtils
This is preparation for calling it from FileManager/main.cpp

Also made file_operation_windows take NonnullRefPtrs.
2021-07-22 12:48:44 +02:00
Sam Atkins
9060310840 FileManager: Combine drag&drop file copies into one progress window
This fixes #6902.

Previously, dragging and dropping multiple files would create a window
for each file or directory that was selected. Now, we combine them and
show one progress window for the whole batch. :^)
2021-07-22 12:48:44 +02:00
Sam Atkins
ca039e6ba1 FileManager+FileOperation: Switch to east const
(And some adjustments based on MaxWipfli's feedback)
2021-07-22 12:48:44 +02:00
Andreas Kling
687a12d7fb Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
2021-07-21 21:24:26 +02:00
Andreas Kling
c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Andreas Kling
d0fb511d75 FileManager: Set main window size before showing the window
This prevents sometimes seeing a smaller FileManager window on startup
before it resizes to the proper size.
2021-07-20 18:05:05 +02:00
ls
fe7bacc2df File Manager: Differentiate between navigation and rename errors
Adds a new on_rename_error handler and renames the old on_error handler
to on_directory_change_error in FileSystemModel. The on_rename_error
handler creates a MessageDialog with the error message.
2021-07-19 18:20:34 +02:00
Karol Kosek
399be9bcc3 FileManager+Spreadsheet: Unify cut-copy-paste order
File Manager and Spreadsheet had an inconsistent order relative
to other apps (they had a copy-cut-paste order, where every other app
had a cut-copy-paste order).
2021-07-17 18:30:37 +04:30
Karol Kosek
d34ef6d997 FileManager: Add Rename action to context and application menu
Prior to this change, the only way to rename a file was to press F2
on keyboard.
2021-07-13 17:54:37 +02:00
luk1337
0b48e12dd7
FileManager: Convert properties window UI to GML (#8705) 2021-07-13 12:57:10 +02:00
pancake
86a4d0694f FileManager: Add Open in Terminal on folder context menu 2021-07-08 16:15:55 +04:30
Andreas Kling
fda22c6889 FileManager: Fix Desktop rubber-banding getting clipped at the edge
The issue was that the desktop IconView has Gfx::FrameShape::NoFrame as
its frame shape, but with a non-zero frame_thickness().

This caused us to not render a frame, but to include one in the
selection boundary calculations.

Fix this by setting the desktop icon view's frame thickness to 0.

Fixes #8525.
2021-07-07 18:10:19 +02:00
Daniel Bertalan
6c0b9919ce FileManager: Remove explicit T to Optional<T> conversion 2021-07-04 07:24:41 +04:30
Sam Atkins
f5e63f785a FileManager: Remove clicked breadcrumbs for non-existing directories
This fixes #8204.

In the case that we just navigated up from a directory because it was
deleted, we can detect that easily by checking if the child directory
exists, and then remove the relevant breadcrumbs immediately.

However, it's harder to notice if a child directory for a breadcrumb
is deleted at another time. Previously, clicking that breadcrumb would
crash, but now we check to see if the directory it points to actually
exists. If it doesn't, we pop that breadcrumb and any after it, off
of the breadcrumbbar.

This may not be the ideal solution - maybe it should detect that the
directory is gone automatically - but it works and doesn't involve
managing additional directory watchers.
2021-07-01 17:15:26 +04:30
Max Wipfli
fc6d051dfd AK+Everywhere: Add and use static APIs for LexicalPath
The LexicalPath instance methods dirname(), basename(), title() and
extension() will be changed to return StringView const& in a further
commit. Due to this, users creating temporary LexicalPath objects just
to call one of those getters will recieve a StringView const& pointing
to a possible freed buffer.

To avoid this, static methods for those APIs have been added, which will
return a String by value to avoid those problems. All cases where
temporary LexicalPath objects have been used as described above haven
been changed to use the static APIs.
2021-06-30 11:13:54 +02:00
Max Wipfli
9b8f35259c AK: Remove the LexicalPath::is_valid() API
Since this is always set to true on the non-default constructor and
subsequently never modified, it is somewhat pointless. Furthermore,
there are arguably no invalid relative paths.
2021-06-30 11:13:54 +02:00
Andreas Kling
67d1b28b97 FileManager: Pass launch origin rects to spawned programs
This makes GUI applications animate their initial window showing up
on screen. :^)
2021-06-27 19:38:11 +02:00
Sam Atkins
8e9fb3766d FileManager: Add "Open in New Window" context menu action 2021-06-25 19:19:57 +02:00
Gunnar Beutner
631d36fd98 Everywhere: Add component declarations
This adds component declarations so that users can select to not build
certain parts of the OS.
2021-06-17 11:03:51 +02:00
Jelle Raaijmakers
c247d7a662 Utilities: Change unzip -o option to -d
Other `unzip` implementations universally use `-d` to indicate the
output directory, so let's follow this convention.
2021-06-13 17:05:48 +01:00
Marcus Nilsson
d5fa0ea60f FileManager: Save maximized window state on exit
When exiting FileManager in maximized state, save it and start in
maximized state on next launch.
2021-06-09 22:58:10 +02:00
Ali Mohammad Pur
51c2c69357 AK+Everywhere: Disallow constructing Functions from incompatible types
Previously, AK::Function would accept _any_ callable type, and try to
call it when called, first with the given set of arguments, then with
zero arguments, and if all of those failed, it would simply not call the
function and **return a value-constructed Out type**.
This lead to many, many, many hard to debug situations when someone
forgot a `const` in their lambda argument types, and many cases of
people taking zero arguments in their lambdas to ignore them.
This commit reworks the Function interface to not include any such
surprising behaviour, if your function instance is not callable with
the declared argument set of the Function, it can simply not be
assigned to that Function instance, end of story.
2021-06-06 00:27:30 +04:30
Jelle Raaijmakers
2c772d1848 LibGUI/AbstractView: Remove on_selection
Since the introduction of multi-select, we have had both `on_selection`
and `on_selection_change`, the latter of which was only invoked when a
change in selection came in through the model.

This removes `AbstractView::on_selection` and replaces it usage with
the more explicit `on_selection_change` everywhere.
2021-05-26 17:39:13 +04:30
Max Wipfli
229414b002 Applications: Use titlecase and distinct underlined characters in menus
This changes (context) menus across the system to conform to titlecase
capitalization and to not underline the same character twice (for
accessing actions with Alt).
2021-05-21 18:41:28 +01:00
Linus Groh
95a11d5737 FileManager: Change shortcut of Display Settings desktop option
'D' is already used by 'New Directory', let's use 'S'.

Fixes #7350.
2021-05-21 17:56:10 +01:00
Andreas Kling
31d4bcf5bf Userland: Tighten a *lot* of pledges! :^)
Since applications using Core::EventLoop no longer need to create a
socket in /tmp/rpc/, and also don't need to listen for incoming
connections on this socket, we can remove a whole bunch of pledges!
2021-05-13 23:28:40 +02:00
Jelle Raaijmakers
55c3a5969c FileManager: Set minimum folder pane width 2021-05-13 00:43:41 +01:00
Andreas Kling
a6a57830d0 FileManager: Reorganize main toolbar a little bit
Re-group things so they match the menus better.
2021-05-12 21:37:37 +02:00
Andreas Kling
bed2356b11 FileManager: Reorganize menus a little bit
Move the common editing actions (cut/copy/paste/select-all) into a new
"Edit" menu. And move the "Open Terminal Here" action to the "Go" menu.
2021-05-12 21:32:54 +02:00
Ali Mohammad Pur
a91a49337c LibCore+Everywhere: Move OpenMode out of IODevice
...and make it an enum class so people don't omit "OpenMode".
2021-05-12 11:00:45 +01:00
Andreas Kling
4b0098e52f Everywhere: Rename app_menu to file_menu or game_menu 2021-05-01 17:40:54 +02:00
Andreas Kling
3d4afe7614 Everywhere: "indexes" => "indices"
I've wasted a silly amount of time in the past fretting over which
of these words to use. Let's just choose one and use it everywhere. :^)
2021-04-29 22:23:52 +02:00
Andreas Kling
7ae7170d61 Everywhere: "file name" => "filename" 2021-04-29 22:16:18 +02:00
TheGeopard
2b78d90d04 FileManager: Unzip from context Menu
This adds a new context menu entry allowing you to extract ZIP archives
by invoking /bin/unzip
2021-04-25 18:40:42 +02:00
Andreas Kling
b91c49364d AK: Rename adopt() to adopt_ref()
This makes it more symmetrical with adopt_own() (which is used to
create a NonnullOwnPtr from the result of a naked new.)
2021-04-23 16:46:57 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Tobias Christiansen
a8915ecd61 FileManager+FileOperation: Report Errors when doing an file operation
Report back errors from the FileOperation to the FileManager and
display them in the MessageBox
2021-04-20 12:02:01 +02:00
Tobias Christiansen
7d60164d93 FileManager: Don't crash on error in FileOperation
did_error() caused the program to crash since the DialogBox tried to
run its own Notifier with the same - now invalid because closed - fd.

In addition to setting the member that is the Notifier to nullptr we
also tell the Notifier that it is not enabled anymore.
2021-04-20 12:02:01 +02:00
Andreas Kling
e98091ad15 FileManager: Show action status tips in the status bar :^) 2021-04-18 16:44:00 +02:00
Linus Groh
0d4912826b FileManager: Pluralize empty selection statusbar message properly
"item(s)" is silly, we can be more specific. :^)
2021-04-18 00:48:07 +02:00
Leandro Pereira
602f98fe67 FileManager: Estimate transfer time
Use the total bytes transferred count to estimate the time left
for the copy operation to finish.  With the estimate label, the
two progress bars were deemed superfluous, so the only remaining
progress bar is the overall copy progress, that is updated more
frequently.  (The same progress is also shown in the task bar,
so you can minimize the window and still be informed of the
progress.)
2021-04-17 09:41:35 +02:00
Leandro Pereira
8d25290198 FileManager: Show file copying animation
Bring some mid-90s charm and show a file flying animation while copying
files.  Icons for both source and destination directories are currently
the default icons, but in the future they could be the respective icons
for the destination directory.
2021-04-17 09:41:35 +02:00
Andreas Kling
0528dc9b87 FileManager: Make DirectoryView API's take String instead of StringView 2021-04-17 01:27:30 +02:00
Andreas Kling
a2baab38fd Everywhere: It's now "Foobar", not "FooBar", and not "foo bar"
I hereby declare these to be full nouns that we don't split,
neither by space, nor by underscore:

- Breadcrumbbar
- Coolbar
- Menubar
- Progressbar
- Scrollbar
- Statusbar
- Taskbar
- Toolbar

This patch makes everything consistent by replacing every other variant
of these with the proper one. :^)
2021-04-13 16:58:15 +02:00
Andreas Kling
bf1ef6533c FileManager+FileOperation: Show byte progress of current file
What I meant for the GUI progress bars to show:

- Bytes copied of the current file
- Files copied of the total set

What it actually showed:

- Bytes copied of the total bytes
- Files copied of the total set

This patch fixes it by showing byte progress of the current file
instead of byte progress of total bytes.
2021-04-13 10:12:50 +02:00
Andreas Kling
a5420ee3d0 FileManager: Use a Core::File for the FileOperation pipes
Instead of popen()/pclose(), we now open the pipes manually and wrap
them in a friendly Core::File object.
2021-04-13 10:12:50 +02:00
Andreas Kling
f54e290548 FileManager: Use FileOperation to perform drag&drop copy out-of-process
And display the progress of the copy operation in a separate window. :^)

Note that this patch only updates the drag&drop code path to use the new
mechanism. We still have to go through FileManager and make use of this
everywhere.

We also need to support additional operations, like Move, Delete, etc.

Still, this is quite cool! :^)
2021-04-13 10:12:50 +02:00
Gunnar Beutner
8ca5b8c065 LibC: Move S_* defines into <fcntl.h>
According to the Single UNIX Specification, Version 2 that's where
those macros should be defined. This fixes the libiconv port.

This also fixes some (but not all) build errors for the diffutils and nano ports.
2021-04-11 09:51:20 +02:00
Andreas Kling
c6c0ec9403 FileManager: Add Alt shortcuts to menu actions 2021-04-09 17:08:49 +02:00
Andreas Kling
ec1a72b759 FileManager: Set the default menu item in desktop context menus
This makes the "Run TextEditor" action show up in bold text as expected
when opening the context menu for TextEditor on the desktop. :^)
2021-04-06 17:55:47 +02:00
Andreas Kling
0652c2e4cc FileManager: Add Alt shortcuts for top-level menus 2021-04-05 23:15:43 +02:00
Andreas Kling
52de9b1753 LibGUI: Do AbstractView::set_column_hidden() => set_column_visible()
This API felt backwards, so let's change it.
2021-04-05 11:57:47 +02:00
Andreas Kling
eff7ea5b84 LibGUI: Add GUI::CommonActions::make_properties_action()
Many apps want a "Properties" action with the same icon and shortcut.
2021-04-04 22:43:43 +02:00
Federico Guerinoni
49a062f81d LibGUI: Show human readable size in filemanager
The size is visible only in TableView mode of the filemanager.
2021-03-26 22:59:09 +01:00
Andreas Kling
78b12e1521 Userland: Turn all application menus into window menus :^) 2021-03-25 22:14:09 +01:00
David Isaksson
3f9ac88c6e PropertiesWindow: Show the file size in a human readable format 2021-03-25 10:59:11 +01:00
Vyacheslav Pukhanov
4b99dbe644 FileManager: Accept TreeView drop event 2021-03-11 18:54:52 +01:00
Linus Groh
a0362d827c FileManager: Disable view change actions when directory is unreadable
Closes #3556.
2021-03-07 16:19:36 +01:00
speles
0071742a5a FileManager: Use ArgsParser, handle more options
This adds 2 more flags, that help with the "select on start" invocation.
-s - makes us open the parent directory of the entry, and select it.
-r - makes FileManager to skip real path resolution for cases when we
     want to select the symlink in parent directory.

Also, if the file path is passed as argument, not it will open parent
with the file selected.
2021-03-07 11:00:36 +01:00
speles
6e16a5cdfa Applications: Open folder with pre-selected file where appropriate :^) 2021-03-07 11:00:36 +01:00
Zac
6d68ae45b4 FileManager: Add launch handler actions to desktop context menu
Extracted a method from the code in the File Manager application which
added actions for activating launch handlers found for the selected
file from the context menu. Applied this method to desktop files
and shortcuts.

Note: made some launch handler related methods in the DirectoryView
static or const which allows passing const DirectoryView& to certain
methods.
2021-03-03 21:53:01 +01:00
speles
0b5ca28475 FileManager: Focus on file when opening file's location from Properties 2021-03-01 11:16:18 +01:00
speles
e964d238b8 FileManager+LaunchServer: Add launching FileManager with focus on file 2021-03-01 11:16:18 +01:00
Linus Groh
e265054c12 Everywhere: Remove a bunch of redundant 'AK::' namespace prefixes
This is basically just for consistency, it's quite strange to see
multiple AK container types next to each other, some with and some
without the namespace prefix - we're 'using AK::Foo;' a lot and should
leverage that. :^)
2021-02-26 16:59:56 +01:00
Morc - Richard Gráčik
edf9d07d3f FileManager: change icon for Show in File Manager
A small detail to match with the new File Manager icon in context menu. :^)
2021-02-25 08:50:25 +01:00
thankyouverycool
42717b5b79 Base: Add new icons for fonts and File Manager 2021-02-25 08:08:26 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Mițca Dumitru
255da9b02b FileManager: Use newly introduced LibCore file management helpers
Most of the functions under FileUtils were removed, except those which
dealt with file deletion, as they spawned MessageBoxes for errors, as
such, those functions were written in terms of Core::File::remove.
2021-02-21 18:14:29 +01:00
Andreas Kling
adb6db9774 FileManager: Set tooltips on the path breadcrumb bar
Each segment of the breadcrumb bar now shows the path it represents.
2021-02-20 14:23:41 +01:00
Linus Groh
3583b62ad3 LibGUI: Swap order of InputBox value and parent window args
This is now consistent with the other dialog classes.
2021-02-20 12:19:46 +01:00
Andreas Kling
4f0be55770 LibGUI: Remove GUI::FilePicker::file_exists()
I have no idea why this existed but everyone should just use
Core::File::exists() instead. :^)
2021-02-19 23:46:54 +01:00
thankyouverycool
94e494d6d2 FileManager: Add layout options to View menu
File Manager's toolbar, location bar, status bar and folder pane
can now be toggled on/off
2021-02-13 11:01:59 +01:00
thankyouverycool
cb42ba0ab1 FileManager: Save 'Show dotfiles' setting in FileManager.ini 2021-02-13 11:01:59 +01:00
Linus Groh
6b7c96589b Everywhere: Add missing parent window to about dialogs
Partially addresses #5177.
2021-01-30 13:42:39 +01:00
DragonAlex98
509e39ac00 FileManager: Make DirectoryView open links in their real directory
Previously it was possible to open a link like /home/anon/Desktop/Home,
leading to a folder with the same name. Now it correctly opens its real
path, which is /home/anon

FileManager: Use Core::File::real_path_for to get real path of links
2021-01-24 19:21:54 +01:00
Andreas Kling
d312011708 Everywhere: Drop "shared_buffer" in most GUI programs, pledge "recvfd"
Now that WindowServer broadcasts the system theme using an anonymous
file, we need clients to pledge "recvfd" so they can receive it.

Some programs keep the "shared_buffer" pledge since it's still used for
a handful of things.
2021-01-16 19:30:32 +01:00
Andreas Kling
c71807a3fc Everywhere: Convert a handful of String::format() => formatted() 2021-01-16 14:52:04 +01:00
Cypher87
0f7efd5bf1
FileManager: Added label "Location" to BreadcrumbBar (#4924) 2021-01-15 19:37:27 +01:00
Andreas Kling
20915795a8 Everywhere: Pledge "sendfd" in WindowServer client programs
This is needed for the new way we transfer window backing stores.
2021-01-15 14:10:32 +01:00