Skip to content
Snippets Groups Projects
Verified Commit 0af66478 authored by Bruce Cowan's avatar Bruce Cowan :airplane:
Browse files

Migrate to AdwPreferencesDialog

parent 5ca05e9b
No related branches found
No related tags found
No related merge requests found
// 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 {
......
......@@ -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
......
# 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(
......
......@@ -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);
}
/*
* SPDX-FileCopyrightText: 2020-2022 Bruce Cowan <bruce@bcowan.me.uk>
* SPDX-FileCopyrightText: 2020-2024 Bruce Cowan <bruce@bcowan.me.uk>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
......@@ -12,10 +12,10 @@
G_BEGIN_DECLS
#define RUGBY_TYPE_PREF_WINDOW (rugby_pref_window_get_type())
#define RUGBY_TYPE_PREF_DIALOG (rugby_pref_dialog_get_type())
G_DECLARE_FINAL_TYPE (RugbyPrefWindow, rugby_pref_window, RUGBY, PREF_WINDOW, AdwPreferencesWindow)
G_DECLARE_FINAL_TYPE (RugbyPrefDialog, rugby_pref_dialog, RUGBY, PREF_DIALOG, AdwPreferencesDialog)
RugbyPrefWindow *rugby_pref_window_new (RugbyAppWindow *window);
RugbyPrefDialog *rugby_pref_dialog_new (void);
G_END_DECLS
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment