Commit Graph

360 Commits

Author SHA1 Message Date
Andreas Kling
d754ac5bcb LibGUI+VisualBuilder: Add move-to-front/back to GCommonActions
Also give them nice little icons. :^)
2019-09-14 22:42:39 +02:00
Andreas Kling
b41b5433f4 LibGUI: Add Undo/Redo to GCommonActions 2019-09-14 22:23:49 +02:00
Andreas Kling
e83390387c LibGUI: Simplify GCommonActions a bit
Use the same callback signature as GAction so we can just forward it
to GAction instead of chaining callbacks.
2019-09-14 22:10:44 +02:00
Mauri de Souza Nunes
2d24b12a34 LibC: Implement mkdtemp library function 2019-09-14 12:05:50 +02:00
Andreas Kling
161cb89e87 LibC: Make gettid() cache the thread ID in thread-local-storage
This makes gettid() very cheap, compared to the cost of having to do
a syscall every time.
2019-09-14 11:37:58 +02:00
Andreas Kling
ec5091fa7d GraphicsBitmap: Allow constructing a wrapper bitmap around 8-bit pixels
This will be very useful for optimizing games like DOOM. :^)
2019-09-14 11:20:07 +02:00
Andreas Kling
c543ee5c5b WindowServer+LibGUI: Store a "data type" with the clipboard content
This will allow us to distinguish between different types of data
stored on the clipboard.
2019-09-14 09:19:05 +02:00
Andreas Kling
11f2e7cd5c GMenu: Update apps now that you can create a nameless GMenu
We had many context menus with names, simply because you were forced
to give them names.
2019-09-13 22:14:07 +02:00
Andreas Kling
f360858836 LibGUI: Tweak selection modification behavior on context menu event
Before bringing up the context menu, clicking...

- ...on an already selected item leaves selection alone
- ...on an unselected item makes it the only selected item
- ...outside any item clears the selection
2019-09-13 21:58:30 +02:00
Andreas Kling
f1c4b65089 GDirectoryModel: Add on_path_change hook 2019-09-13 21:43:23 +02:00
Andreas Kling
bf23f1e8bc GItemView: Add context menu support
Also, use the model_column() internally for selection as well as for
painting to keep things consistent.

Note that we always fire the on_context_menu_request hook, even if you
didn't click on an item. In those cases, you get a GModelIndex().
2019-09-13 21:42:26 +02:00
Andreas Kling
69365ccdd0 GMenu: Allow constructing without a name
We'll just default to "", which works fine for context menus.
2019-09-13 21:29:47 +02:00
Mauri de Souza Nunes
7d85fc00e4 Kernel: Implement fchdir syscall
The fchdir() function is equivalent to chdir() except that the
directory that is to be the new current working directory is
specified by a file descriptor.
2019-09-13 14:04:38 +02:00
Mauri de Souza Nunes
6d7c928359 LibC: Add MAXPATHLEN to limits.h
MAXPATHLEN defines the longest permissable path length after expanding
symbolic links. It is used to allocate a temporary buffer from the buffer
pool in which to do the name expansion, hence should be a power of two.

On UNIX MAXPATHLEN has the same size as PATH_MAX.
2019-09-13 09:21:41 +02:00
Andreas Kling
c74e4d0c80 LibC: Pass the environment as third argument to main()
After some very confused debugging, I discovered that GNU make has a
main() function with this signature:

    int main(int argc, char** argv, char** envp)

Apparently this is a non-standard but widely supported thing, so let's
do the same in Serenity so make works as expected.

This fixes an issue where you had to do "make PATH=..." instead of make
just picking up PATH from the environment. :^)
2019-09-12 21:43:32 +02:00
Andreas Kling
13ca1ee8dc GDirectoryModel: Allow retrieving an item's full path via Role::Custom 2019-09-12 18:58:52 +02:00
Andreas Kling
1cb661ae69 GModelSelection: Add size() and a const overload of for_each_index() 2019-09-12 18:42:15 +02:00
Andreas Kling
566eb58170 GDirectoryModel: Include directories in total byte count
I don't know what's really right or wrong here. It seems fine to also
include the directories in the total byte count, and it makes it a bit
easier to stay consistent when adding up size numbers elsewhere.
2019-09-12 18:41:28 +02:00
Andreas Kling
aeba1128e3 LibC: Add some missing errno codes 2019-09-12 18:26:19 +02:00
Andreas Kling
8b0d530584 LibC: fgets() shouldn't stop on '\0' 2019-09-11 23:01:55 +02:00
Andreas Kling
f89944e804 Inspector+LibCore+rpcdump: Rework the RPC stuff to be request/response
RPC clients now send JSON-encoded requests to the RPC server.
The connection also stays alive instead of disconnecting automatically
after the initial CObject graph dump.

JSON payloads are preceded by a single host-order encoded 32-bit int
containing the length of the payload.

So far, we have three RPC commands:

    - Identify
    - GetAllObjects
    - Disconnect

We'll be adding more of these as we go along. :^)
2019-09-11 21:19:23 +02:00
Andreas Kling
38b75d2a97 CIODevice: read(u8*, int) overload should return 0 on EOF 2019-09-11 21:13:14 +02:00
Andreas Kling
99970d7d4b CSocket: Share code between connect() overloads
Both overloads should know how to set up a notifier callback in case
we get EINPROGRESS from connect().

It might be even better to merge the connect() overloads into a single
function..
2019-09-11 19:44:15 +02:00
Andreas Kling
b305a51c90 CIODevice: read_all() should return a null ByteBuffer when nothing read
We were returning a zero-length ByteBuffer in some cases. We should be
consistent about this and always return a null ByteBuffer if nothing
was read at all.
2019-09-11 19:33:51 +02:00
Andreas Kling
ada1f504fd LibC: Make sure perror() is consistent about the errno it prints 2019-09-10 19:35:51 +02:00
Andreas Kling
31ba7ba2cc LibC: #define errno errno
This makes the binutils port build again, after the TLS changes.
2019-09-08 14:20:13 +02:00
Andreas Kling
64b1e9deec GTreeView: Make double-clicking toggle openable items 2019-09-07 21:45:06 +02:00
Andreas Kling
2f5b2685af GModel: Remove selected_index() and set_selected_index()
This breaks GSortingProxyModel selection preservation across resorts.
I'm not yet sure how we're going to solve that, but it's going to have
to work a bit differently than before, since the model itself no longer
knows what's selected.

Selection is now managed by GModelSelection which allows us to select
any arbitrary number of items, and to have different selections in
different views onto the same model. Pretty sweet. :^)
2019-09-07 21:39:44 +02:00
Andreas Kling
6dec328af7 LibGUI+FileManager: Add GAbstractView::on_selection_change hook
This hook will be called whenever the view's selection changes somehow.
Use this in the FileManager to keep the left and right views in sync.
2019-09-07 21:35:04 +02:00
Andreas Kling
fb18613e8a LibGUI: Convert various little things to GModelSelection
All the little things that were using the per-model seletion are now
moving over to GModelSelection.
2019-09-07 20:35:31 +02:00
Andreas Kling
d2d1a30d61 GListView: Switch to using GModelSelection to support multi-select 2019-09-07 20:31:11 +02:00
Andreas Kling
56c360591c GTreeView: Switch to using GModelSelection
We don't support multi-select in GTreeView yet. Some day though :^)
2019-09-07 20:15:33 +02:00
Andreas Kling
55bae788f0 GDirectoryModel: No need to clear the selected index in open()
Now that the view manages selection instead of the model, it's not
something GDirectoryModel needs to worry about anymore.
2019-09-07 20:01:18 +02:00
Andreas Kling
98a68c82bc GItemView: Make Ctrl+click toggle item selection on/off 2019-09-07 19:38:08 +02:00
Andreas Kling
a5e0242992 GTableView: Switch to using GModelSelection to support multi-select 2019-09-07 19:35:45 +02:00
Andreas Kling
b0f42ee672 GModelSelection: Add contains_row(int) and toggle(GModelIndex) 2019-09-07 19:33:58 +02:00
Andreas Kling
94b599e344 GItemView: Switch to using GModelSelection to support multi-select
This is really quite straightforward. Instead of using the GModel's
selected_index(), we now query/update the view's own GModelSelection.
2019-09-07 19:21:07 +02:00
Andreas Kling
82559e211d LibGUI: Add GModelSelection to help implementing multiple-select views
Each GAbstractView now has a GModelSelection backed by a simple
HashTable<GModelIndex>. When the selection changes somehow, the view
gets notified via the notify_selection_changed() callback.

In the future it will probably make sense to move to using some kind of
ranges as the internal representation instead.
2019-09-07 19:21:07 +02:00
Andreas Kling
19b69741ed GModelIndex: Add hash traits so we can make a HashTable<GModelIndex> 2019-09-07 19:21:07 +02:00
Andreas Kling
60cd3c093a LibDraw: Make sure we install libdraw.a so ports can link with -ldraw 2019-09-07 18:19:02 +02:00
Andreas Kling
29f58aef21 LibC: Add some missing pieces in inttypes.h 2019-09-07 18:18:43 +02:00
Andreas Kling
a635619cc0 GTabWidget: Rename get_active_tab() => active_tab_index() 2019-09-07 16:57:26 +02:00
Jesse Buhagiar
3f05799e41 LibGUI: GTabWidget can now return active tab index
`GTabWidget` now allows the user/caller to get the currently active
tab widget, meaning that actions that are applied globally (such as
an 'Apply' or 'OK' button) can now react to specific tabs etc.
2019-09-07 16:51:15 +02:00
Jesse Buhagiar
ecbc0322c1 Applications: Create a display properties manager
An interactive application to modify the current display settings, such as
the current wallpaper as well as the screen resolution. Currently we're
adding the resolutions ourselves, because there's currently no way to
detect was resolutions the current display adapter supports (or at least
I can't see one... Maybe VBE does and I'm stupid). It even comes with
a very nice template'd `ItemList` that can support a vector of any type,
which makes life much simpler.
2019-09-07 16:51:15 +02:00
Andreas Kling
af14b8dc59 LibC: Make "errno" thread-specific
Now that the kernel supports thread-local storage, we can declare errno
with the __thread keyword, which causes it to be per-thread.

This should fix all the stupid issues that happen when many threads use
the same errno. :^)
2019-09-07 15:57:02 +02:00
Andreas Kling
56e0e6be56 LibC: Borrow a slightly more functional getopt()
We were already borrowing a getopt() from the BSD family until the day
we write our own. This patch borrows a slightly more modern one so we
also get getopt_long().

Fixes #190.

See also #91 for the desire to eventually NIH our own getopt()..
2019-09-06 20:03:16 +02:00
Andreas Kling
6ab498edf7 GTextEditor: Paint line numbers with TopRight text alignment
This makes sure they line up with the first visual line for wrapped
lines that span multiple visual lines.
2019-09-06 19:24:16 +02:00
Andreas Kling
a791b86afa LibDraw: Add TextAlignment::TopRight
Also tidy up the alignment code to use switch statements.
2019-09-06 19:23:54 +02:00
Andreas Kling
73fdbba59c AK: Rename <AK/AKString.h> to <AK/String.h>
This was a workaround to be able to build on case-insensitive file
systems where it might get confused about <string.h> vs <String.h>.

Let's just not support building that way, so String.h can have an
objectively nicer name. :^)
2019-09-06 15:36:54 +02:00
Andreas Kling
b4a2bb9383 GScrollBar: Scrolling with the mouse wheel should use step increments 2019-09-06 15:01:08 +02:00