diff options
| author | Paul Buetow <paul@buetow.org> | 2026-07-12 17:30:26 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-07-12 17:30:26 +0300 |
| commit | 547b810eea19b0c72731e30ca3e2e339593c1833 (patch) | |
| tree | e19fc9308d2f93ffd1d558ec705effc6d9ffb752 /src/app.c | |
| parent | 1770b12d5d95476310c27ccf39a91b5ba4a3f119 (diff) | |
skeleton: GtkApplication, window, GSettings schema, desktop, tests (ft0)
M0 (task ft0): the app shell — no feature views yet (those are M1 large, M7
grid).
- src/main.c: g_application_run + --version via handle-local-options (--help
is GApplication's own); exits before activate so --version works headless.
- src/app.{c,h}: GgazeApp : AdwApplication : GtkApplication (libadwaita
styling, decision #29), single-instance (decision #32),
G_APPLICATION_HANDLES_OPEN; activate + open reuse the active window
(replace-on-new-open); ggaze_window_open remembers the GFile.
- src/window.{c,h}: GgazeWindow : GtkApplicationWindow with AdwHeaderBar and a
GtkStack (children 'grid'/'large', default 'grid'); dispose clears the file.
- data/org.buetow.ggaze.desktop (image/* MIME, validated) and
data/org.buetow.ggaze.gschema.xml (all keys + defaults, --strict clean).
- meson: libggaze static lib shared by the executable and tests; install to
bindir/applications/glib-2.0 schemas; gnome.post_install compiles schemas +
updates desktop db.
- tests: unit test_app (--version/--help/unknown via subprocess), integration
test_window (offscreen stack checks + open-titles), bootstrap. 3/3 green.
- docs/tech-stack.md: window-geometry shape corrected to (width,height,
fullscreen,maximized) to match the schema.
Diffstat (limited to 'src/app.c')
| -rw-r--r-- | src/app.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/app.c b/src/app.c new file mode 100644 index 0000000..587feb7 --- /dev/null +++ b/src/app.c @@ -0,0 +1,74 @@ +/*:* + * ggaze — application object + * + * Implements GgazeApp (GgazeApp : AdwApplication : GtkApplication). Wires the + * GApplication `open` signal (file or folder) and the default `activate` + * (no-arg) path to a GgazeWindow, reusing the active window for the + * single-instance "replace on new open" behaviour (decision #32). Real + * file-vs-folder resolution is the navigator's job in M2; M0 just remembers + * the path and titles the window. See docs/architecture.md. + * + * Copyright (c) 2026 ggaze contributors + * SPDX-License-Identifier: GPL-3.0-or-later + *:*/ + +#include "app.h" +#include "window.h" +#include "ggaze-config.h" + +#include <glib.h> + +struct _GgazeApp { + AdwApplication parent_instance; +}; + +G_DEFINE_TYPE(GgazeApp, ggaze_app, ADW_TYPE_APPLICATION) + +static GgazeWindow * +_ensure_window(GgazeApp *p_app) { + GtkWindow *p_active = + gtk_application_get_active_window(GTK_APPLICATION(p_app)); + if (p_active != NULL && GGAZE_IS_WINDOW(p_active)) { + return (GgazeWindow *)p_active; + } + return (ggaze_window_new(p_app)); +} + +static void +ggaze_app_activate(GApplication *p_app) { + GgazeWindow *p_win = _ensure_window(GGAZE_APP(p_app)); + gtk_window_present(GTK_WINDOW(p_win)); +} + +static void +ggaze_app_open(GApplication *p_app, GFile **p_files, gint n_files, + const gchar *c_hint) { + (void)c_hint; + GgazeApp *p_app_self = GGAZE_APP(p_app); + GgazeWindow *p_win = _ensure_window(p_app_self); + /* open-question Z / decision #27: one file opens it; many files open the + * first file's folder with the first current (navigator wiring in M2). */ + if (n_files > 0 && p_files != NULL) { + ggaze_window_open(p_win, p_files[0]); + } + gtk_window_present(GTK_WINDOW(p_win)); +} + +static void +ggaze_app_init(GgazeApp *p_app) { + (void)p_app; +} + +static void +ggaze_app_class_init(GgazeAppClass *p_klass) { + GApplicationClass *p_app_class = G_APPLICATION_CLASS(p_klass); + p_app_class->activate = ggaze_app_activate; + p_app_class->open = ggaze_app_open; +} + +GgazeApp * +ggaze_app_new(void) { + return ( + GGAZE_APP(g_object_new(GGAZE_TYPE_APP, "application-id", GGAZE_APP_ID, + "flags", G_APPLICATION_HANDLES_OPEN, NULL))); +}
\ No newline at end of file |
