add g_settings to save preferences

master
Zwarf 2022-01-13 11:12:53 +01:00
rodzic 60e4006704
commit e8f4edca3b
7 zmienionych plików z 53 dodań i 6 usunięć

Wyświetl plik

@ -26,3 +26,10 @@ subdir('src')
subdir('po')
meson.add_install_script('build-aux/meson/postinstall.py')
gnome.post_install(
gtk_update_icon_cache: true,
glib_compile_schemas: true,
update_desktop_database: true,
)

Wyświetl plik

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema path="/de/zwarf/picplanner/" id="de.zwarf.picplanner">
<key name="timezone" type="i">
<default>0</default>
<range min="-12" max="12"/>
<default>1</default>
<summary>Time-Zone</summary>
<description>The time-zone used to show times.</description>
</key>
</schema>
</schemalist>

Wyświetl plik

@ -18,11 +18,17 @@ picplanner_deps = [
gnome = import('gnome')
picplanner_sources += gnome.compile_resources('picplanner-resources',
'picplanner.gresource.xml',
'picplanner.gresource.xml', source_dir: '.',
c_name: 'picplanner'
)
executable('picplanner', picplanner_sources,
gnome.compile_schemas(build_by_default: true)
install_data('de.zwarf.picplanner.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
)
executable('picplanner',
picplanner_sources,
dependencies: picplanner_deps,
install: true,
)

Wyświetl plik

@ -25,7 +25,6 @@ struct _PicplannerWindow
/* Template widgets */
GtkHeaderBar *header_bar;
GtkLabel *label;
};
G_DEFINE_TYPE (PicplannerWindow, picplanner_window, GTK_TYPE_APPLICATION_WINDOW)
@ -37,7 +36,6 @@ picplanner_window_class_init (PicplannerWindowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/de/zwarf/picplanner/picplanner-window.ui");
gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, header_bar);
//gtk_widget_class_bind_template_child (widget_class, PicplannerWindow, label);
}
static void

Wyświetl plik

@ -27,7 +27,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (PicplannerWindow, picplanner_window, PICPLANNER, WINDOW, GtkApplicationWindow)
PicplannerWindow *picplanner_app_window_new (PicplannerApplication *app);
void picplanner_app_window_open (PicplannerWindow *win, GFile *file);
PicplannerWindow *picplanner_window_new (PicplannerApplication *app);
void picplanner_window_open (PicplannerWindow *win, GFile *file);
G_END_DECLS

Wyświetl plik

@ -6,6 +6,7 @@ struct _PicplannerPrefs
{
GtkDialog parent_instance;
GSettings *settings;
GtkWidget *timezone;
};
G_DEFINE_TYPE (PicplannerPrefs, picplanner_prefs, GTK_TYPE_DIALOG)
@ -14,6 +15,11 @@ static void
picplanner_prefs_init (PicplannerPrefs *prefs)
{
gtk_widget_init_template (GTK_WIDGET (prefs));
prefs->settings = g_settings_new ("de.zwarf.picplanner");
g_settings_bind (prefs->settings, "timezone",
prefs->timezone, "value",
G_SETTINGS_BIND_DEFAULT);
}
static void
@ -35,6 +41,7 @@ picplanner_prefs_class_init (PicplannerPrefsClass *class)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (class),
"/de/zwarf/picplanner/ui/preferences-dialog.ui");
gtk_widget_class_bind_template_child (GTK_WIDGET_CLASS (class), PicplannerPrefs, timezone);
}
PicplannerPrefs *

Wyświetl plik

@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkAdjustment" id="d_adjustment">
<property name="lower">1</property>
<property name="upper">31</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<template class="PicplannerPrefs" parent="GtkDialog">
<property name="title">Preferences</property>
<property name="resizable">0</property>
@ -11,6 +17,16 @@
<property name="label">Preferences</property>
</object>
</child>
<child>
<object class="GtkSpinButton" id="timezone">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">d_adjustment</property>
<property name="numeric">True</property>
<property name="wrap">True</property>
<property name="value">1</property>
</object>
</child>
</object>
</child>
</template>