diff --git a/data/gtk/prefs.blp b/data/gtk/prefs.blp index 50be7f1dbabf73447c25ca919cb82b70bf60cfa5..abf38e3318bf9532f6b6c265c5f7592da5d3308d 100644 --- a/data/gtk/prefs.blp +++ b/data/gtk/prefs.blp @@ -1,15 +1,12 @@ -// SPDX-FileCopyrightText: 2022-2023 Bruce Cowan <bruce@bcowan.me.uk> +// SPDX-FileCopyrightText: 2022-2024 Bruce Cowan <bruce@bcowan.me.uk> // // SPDX-License-Identifier: GPL-3.0-or-later using Gtk 4.0; using Adw 1; -template $RugbyPrefWindow : Adw.PreferencesWindow { - default-width: -1; - default-height: -1; +template $RugbyPrefDialog : Adw.PreferencesDialog { title: "Preferences"; - modal: true; search-enabled: false; Adw.PreferencesPage { diff --git a/src/main.c b/src/main.c index bc9e344298ab8644aeb325bb1c3628fdd89b4573..a6acc9acc406b857e8b3a3839050a3506e87b876 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ #include <config.h> #include "rugby-app-window.h" -#include "rugby-pref-window.h" +#include "rugby-pref-dialog.h" static void on_activate ( GApplication *app, @@ -48,8 +48,8 @@ preferences_activated (G_GNUC_UNUSED GSimpleAction *simple, GtkApplication *app = GTK_APPLICATION (user_data); GtkWindow *window = gtk_application_get_active_window (app); - RugbyPrefWindow *pref_window = rugby_pref_window_new (RUGBY_APP_WINDOW (window)); - gtk_window_present (GTK_WINDOW (pref_window)); + RugbyPrefDialog *pref_window = rugby_pref_dialog_new (); + adw_dialog_present (ADW_DIALOG (pref_window), GTK_WIDGET (window)); } static void diff --git a/src/meson.build b/src/meson.build index c49d2bdae602e282f501f082bffea17d11177418..2f7f618e7c0d6a4cc2ba8609eb3416a3aa636aac 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2016-2023 Bruce Cowan <bruce@bcowan.me.uk> +# SPDX-FileCopyrightText: 2016-2024 Bruce Cowan <bruce@bcowan.me.uk> # # SPDX-License-Identifier: GPL-3.0-or-later sources = [ @@ -7,7 +7,7 @@ sources = [ 'rugby-list-store.c', 'rugby-possibility.c', 'rugby-possibility-widget.c', - 'rugby-pref-window.c', + 'rugby-pref-dialog.c', ] config_h = vcs_tag( diff --git a/src/rugby-pref-window.c b/src/rugby-pref-dialog.c similarity index 56% rename from src/rugby-pref-window.c rename to src/rugby-pref-dialog.c index a4c3c3cf17c7634c953a6828311809e11f3ced07..dcd30f42de76651cd9eff861f427fff219a2870d 100644 --- a/src/rugby-pref-window.c +++ b/src/rugby-pref-dialog.c @@ -4,11 +4,11 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -#include "rugby-pref-window.h" +#include "rugby-pref-dialog.h" -struct _RugbyPrefWindow +struct _RugbyPrefDialog { - AdwPreferencesWindow parent_instance; + AdwPreferencesDialog parent_instance; GtkWidget *try_spin; GtkWidget *utry_spin; @@ -17,38 +17,37 @@ struct _RugbyPrefWindow GSettings *settings; }; -G_DEFINE_TYPE (RugbyPrefWindow, rugby_pref_window, ADW_TYPE_PREFERENCES_WINDOW) +G_DEFINE_TYPE (RugbyPrefDialog, rugby_pref_dialog, ADW_TYPE_PREFERENCES_DIALOG) static void -rugby_pref_window_dispose (GObject *object) +rugby_pref_dialog_dispose (GObject *object) { - RugbyPrefWindow *self = RUGBY_PREF_WINDOW (object); + RugbyPrefDialog *self = RUGBY_PREF_DIALOG (object); g_clear_object (&self->settings); - gtk_widget_dispose_template (GTK_WIDGET (object), RUGBY_TYPE_PREF_WINDOW); + gtk_widget_dispose_template (GTK_WIDGET (object), RUGBY_TYPE_PREF_DIALOG); - G_OBJECT_CLASS (rugby_pref_window_parent_class)->dispose (object); + G_OBJECT_CLASS (rugby_pref_dialog_parent_class)->dispose (object); } static void -rugby_pref_window_class_init (RugbyPrefWindowClass *klass) +rugby_pref_dialog_class_init (RugbyPrefDialogClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - object_class->dispose = rugby_pref_window_dispose; + object_class->dispose = rugby_pref_dialog_dispose; gtk_widget_class_set_template_from_resource (widget_class, "/uk/me/bcowan/Rugby/gtk/prefs.ui"); - gtk_widget_class_bind_template_child (widget_class, RugbyPrefWindow, try_spin); - gtk_widget_class_bind_template_child (widget_class, RugbyPrefWindow, utry_spin); - gtk_widget_class_bind_template_child (widget_class, RugbyPrefWindow, kick_spin); - + gtk_widget_class_bind_template_child (widget_class, RugbyPrefDialog, try_spin); + gtk_widget_class_bind_template_child (widget_class, RugbyPrefDialog, utry_spin); + gtk_widget_class_bind_template_child (widget_class, RugbyPrefDialog, kick_spin); } static void -rugby_pref_window_init (RugbyPrefWindow *self) +rugby_pref_dialog_init (RugbyPrefDialog *self) { gtk_widget_init_template (GTK_WIDGET (self)); @@ -65,10 +64,9 @@ rugby_pref_window_init (RugbyPrefWindow *self) G_SETTINGS_BIND_DEFAULT); } -RugbyPrefWindow * -rugby_pref_window_new (RugbyAppWindow *window) +RugbyPrefDialog * +rugby_pref_dialog_new (void) { - return g_object_new (RUGBY_TYPE_PREF_WINDOW, - "transient-for", window, + return g_object_new (RUGBY_TYPE_PREF_DIALOG, NULL); } diff --git a/src/rugby-pref-dialog.h b/src/rugby-pref-dialog.h new file mode 100644 index 0000000000000000000000000000000000000000..d3e2a7e62d9969e4a69695da5c82e9d72becc0a7 --- /dev/null +++ b/src/rugby-pref-dialog.h @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2020-2024 Bruce Cowan <bruce@bcowan.me.uk> + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include "rugby-app-window.h" + +#include <adwaita.h> + +G_BEGIN_DECLS + +#define RUGBY_TYPE_PREF_DIALOG (rugby_pref_dialog_get_type()) + +G_DECLARE_FINAL_TYPE (RugbyPrefDialog, rugby_pref_dialog, RUGBY, PREF_DIALOG, AdwPreferencesDialog) + +RugbyPrefDialog *rugby_pref_dialog_new (void); + +G_END_DECLS diff --git a/src/rugby-pref-window.h b/src/rugby-pref-window.h deleted file mode 100644 index 555b890ad0bb2ea67a8370c2cae3ad81aad1f4c5..0000000000000000000000000000000000000000 --- a/src/rugby-pref-window.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020-2022 Bruce Cowan <bruce@bcowan.me.uk> - * - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -#pragma once - -#include "rugby-app-window.h" - -#include <adwaita.h> - -G_BEGIN_DECLS - -#define RUGBY_TYPE_PREF_WINDOW (rugby_pref_window_get_type()) - -G_DECLARE_FINAL_TYPE (RugbyPrefWindow, rugby_pref_window, RUGBY, PREF_WINDOW, AdwPreferencesWindow) - -RugbyPrefWindow *rugby_pref_window_new (RugbyAppWindow *window); - -G_END_DECLS