Commit Graph

777 Commits

Author SHA1 Message Date
Andreas Kling
dbab20782e LibGUI: Make FilteringProxyModel factory function return ErrorOr 2021-11-24 13:52:01 +01:00
Andreas Kling
51c4de8774 LibGUI: Add GUI::Menu::try_add_action() and try_add_separator()
These are fallible variants that return ErrorOr. :^)
2021-11-24 13:52:01 +01:00
Andreas Kling
9b07e13fb6 LibGUI: Add GUI::Toolbar::try_add_action()
This is a fallible variant of add_action() that returns ErrorOr.
It's careful to not fail with a partially added action.
2021-11-24 13:52:01 +01:00
Andreas Kling
47b6339025 LibGUI: Add GUI::TabWidget::try_add_tab<T>(...)
This is a fallible variant of add_tab<T>(...) that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Andreas Kling
dc47fce2d9 LibGUI: Add GUI::Window::try_set_main_widget<T>(...)
This is a fallible variant of set_main_widget<T>() that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Andreas Kling
bde9c2bc65 LibGUI: Add GUI::Window::try_add_menu()
This is a fallible variant of add_menu() that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Andreas Kling
6b79745aa4 LibGUI: Add GUI::Widget::try_set_layout<T>(...)
This is a fallible variant of set_layout<T>(...) that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Andreas Kling
bc79be362d LibGUI: Add GUI::Menubar::try_add_menu()
This is a fallible variant of Menubar::add_menu() that returns ErrorOr.
2021-11-24 13:52:01 +01:00
Vyacheslav Pukhanov
2189cc6bf1 LibGUI: Reverse FilteringProxyModel update propagation flow
FilteringProxyModel is a narrowing projection of its parent model with
a filter applied. That means that updates of FilteringProxyModel should
not propagate to its parent model, but the opposite - updates happening
in the parent model should "trickle down" and trigger an update of the
filtering model.
2021-11-24 13:46:09 +01:00
Federico Guerinoni
221a32577e LibGUI: Support applying AutocompleteBox suggestions with mouse
Fixes: #8004
2021-11-23 13:43:11 +00:00
Andreas Kling
58fb3ebf66 LibCore+AK: Move MappedFile from AK to LibCore
MappedFile is strictly a userspace thing, so it doesn't belong in AK
(which is supposed to be user/kernel agnostic.)
2021-11-23 11:33:36 +01:00
Mustafa Quraish
a0ef655451 LibGUI: Let Application constructor accept in Main::Arguments
Instead of manually passing in `arguments.argc` and `arguments.argv`,
we can now just pass in the arguments directly.
2021-11-22 21:13:42 -08:00
Andreas Kling
8e4eebe9b1 LibGUI: Use ErrorOr<T> in the file system thumbnail generator 2021-11-21 20:22:48 +01:00
Andreas Kling
5a79c69b02 LibGfx: Make ImageDecoderPlugin::frame() return ErrorOr<>
This is a first step towards better error propagation from image codecs.
2021-11-21 20:22:48 +01:00
Ben Wiederhake
768915bbcd LibGUI: Make clipboard bitmap parsing more robust
In particular, malicious programs used to be able to set arbitrary
values as "format", which could cause UB (most likely a crash).

Furthermore, we do not transmit palette data, so an application sending
an indexed bitmap cannot possibly expect the other side to receive a
useful image. Therefore, we refuse to build a bitmap.
2021-11-21 11:49:06 +00:00
Ben Wiederhake
f22c0ffe0c LibGUI+Everywhere: Make sync requests to Clipboard server more obvious 2021-11-21 11:49:06 +00:00
Ben Wiederhake
06f140a025 LibGUI: Avoid access to Clipboard server, clipboard text is never empty
The clipboard cannot reasonably contain the empty string. The clipboard
can be empty (i.e. cleared), sure, but that this check was about whether
the clipboard contained the empty string.

This cannot easily happen for two reasons:
- TextEditor GUI elements disable their copy actions when the selection
  is empty.
- Clipboard::set_data, through which all text-copying operates,
  implicitly forbids empty strings, because Process::sys$anon_create
  forbids empty anonymous files.
- Even if it were sent (e.g. by creating a non-empty anonymous file and
  sending it manually to the Clipboard server), it would not be
  received, because decode(Decoder&, Core::AnonymousBuffer&) goes
  through mmap() with a size of 0, which also is forbidden by the
  Kernel.

In other words, if the clipboard is never the empty text, therefore
checking this condition is pointless, and we can save a roundtrip to the
Clipboard server.
2021-11-21 11:49:06 +00:00
Ben Wiederhake
c80dcc4671 LibGUI: Make paste access to Clipboard atomic
This avoids data race issues and saves a synchronous request to the
ClipboardServer.
2021-11-21 11:49:06 +00:00
Ben Wiederhake
b6419f2cf2 LibGUI: Make clipboard-as-bitmap parsing less data-race-y
This encourages the caller to first fetch data and type atomically, and
then parse that, instead of potentially making multiple requests.
2021-11-21 11:49:06 +00:00
Sam Atkins
23341f35cb LibGUI: Add SettingsWindow class
The FooSettings apps have quite a lot of boilerplate just around
creating a tabbed window with the same styling and the same row of
buttons along the bottom. So, let's extract that out into a class we can
reuse! :^)

You create a SettingsWindow instead of a regular Window, passing a title
and a flag to determine if a "Defaults" button is shown. Then call
add_tab() to add tabs to it. Tabs are widgets extending
SettingsWindow::Tab, which has methods for saving and resetting the
values.
2021-11-20 21:05:20 +00:00
Andreas Kling
2b866e3c9b LibGfx: Remove ImageDecoderPlugin::bitmap() in favor of frame(index)
To encourage proper support for multi-frame images throughout the
system, get rid of the single-frame convenience bitmap() API.
2021-11-18 21:11:30 +01:00
Andreas Kling
216e21a1fa AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk.
The end goal here is to propagate buffer allocation failures to the
caller, and allow the use of TRY() with formatting functions.
2021-11-17 00:21:13 +01:00
Andreas Kling
587f9af960 AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string
literal with returned errors.

This will allow us to use TRY() when working with JSON data.
2021-11-17 00:21:10 +01:00
Andrew January
c0d6e37ab3 LibGUI: Add support for Ctrl+Delete in TextEditor
Allow deleting the word after the cursor using Ctrl+Delete in a similar
manner to how Ctrl+Backspace deletes the word before the cursor.
2021-11-13 12:53:29 +01:00
Andrew January
22e80bae29 LibGUI: Change delete key handling from action to keydown_event
Having the delete key handling be done via an action limits our ability
to support key modifiers (e.g. ctrl+delete deleting the word in front of
the cursor).

The fact that it was an action _did_ allow us to have a delete button in
the TextEditor UI. However, this is an odd choice in the first place
that isn't common in other text editors, so I just removed it.
2021-11-13 12:53:29 +01:00
Andreas Kling
d21dc1f451 Everywhere: Replace "virtual desktop" => "workspace" 2021-11-13 12:48:43 +01:00
Andreas Kling
62ce7653cb LibGUI: Use PNGImageDecoderPlugin for ELF icon extraction
Getting rid of all the remaining calls to load_png_from_memory() and the
related wrappers for each decoder.
2021-11-13 00:55:07 +01:00
Andreas Kling
80d4e830a0 Everywhere: Pass AK::ReadonlyBytes by value 2021-11-11 01:27:46 +01:00
Andreas Kling
8b1108e485 Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Andreas Kling
a7f1f1c34b LibCore: Use ErrorOr<T> for Core::File::open() 2021-11-08 00:35:27 +01:00
Andreas Kling
6e255b262f LibGfx: Use ErrorOr<T> for try_create_from_serialized_byte_buffer() 2021-11-08 00:35:27 +01:00
Andreas Kling
0de33b3d6c LibGfx: Use ErrorOr<T> for Bitmap::try_create()
Another one that was used in a fajillion places.
2021-11-08 00:35:27 +01:00
Andreas Kling
235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
Andreas Kling
2da4cfcc80 LibGfx: Use ErrorOr<T> for Bitmap::clone() 2021-11-08 00:35:27 +01:00
Andreas Kling
83d1460ee8 LibGfx: Use ErrorOr<T> for Bitmap::try_create_wrapper() 2021-11-08 00:35:27 +01:00
Andreas Kling
f23f99d51b LibGfx: Use ErrorOr<T> for Bitmap::try_create_with_anonymous_buffer() 2021-11-08 00:35:27 +01:00
Andreas Kling
e2eabb4132 LibCore: Use ErrorOr<T> in Core::AnonymousBuffer 2021-11-08 00:35:27 +01:00
Sam Atkins
f22043a225 LibGfx: Add FlagRole to GUI::Variant 2021-11-05 23:34:22 +01:00
Andreas Kling
c098a6495b LibGUI: Use default Button and TextBox heights in InputBox 2021-11-05 01:37:00 +01:00
Andreas Kling
60a245b065 LibGUI: Don't ask WindowServer to destroy windows during app teardown
This makes teardown faster since we don't have to wait for responses to
each destroy_window request. It also avoids doing IPC during teardown,
which is a general source of problems.
2021-11-03 19:56:47 +01:00
Andreas Kling
24ea6a8ce7 LibGUI: Add GUI::Application::in_teardown()
This will return true after ~GUI::Application() has been entered.
2021-11-03 19:56:47 +01:00
FrHun
82d7934959 LibGUI: ScrollableContainerWidget GML autocomplete 2021-11-03 16:13:19 +01:00
FrHun
54f459e020 LibGUI: AbstractScrollableWidget GML/JSON 2021-11-03 16:13:19 +01:00
FrHun
7110afe9bf LibGUI: ScrollableContainerWidget respect size 2021-11-03 16:13:19 +01:00
FrHun
a59e9a7a81 LibGUI: ScrollableContainerWidget consider frame
Do not consider the space that is taken up by the frame, as useable
size.
2021-11-03 16:13:19 +01:00
FrHun
dab7ec190e LibGUI: Margins for AbstractScrollableWidget
Implement, and use internally, content_margins() from Widget.
Since AbstractScrollableWidget already has a method called content_size,
the convenience method, with the same name, in Widget has to be
explicitly called.
2021-11-03 16:13:19 +01:00
frhun
a4eeb6f9eb LibGUI: ToolbarContainer account for frame width
Because Frame now has content_margins, and the layouts now respect
them, this extra margin setting is no longer needed.
2021-11-03 16:13:19 +01:00
FrHun
6964c2a2db LibGUI: Implement content margins for Frame 2021-11-03 16:13:19 +01:00
FrHun
a21ea5f10f LibGUI: Invalidate GroupBox layout on font change 2021-11-03 16:13:19 +01:00
FrHun
70e5a77794 LibGUI: Consider content_margins for BoxLayout 2021-11-03 16:13:19 +01:00