mirror of
https://github.com/artizirk/wdisplays.git
synced 2026-10-03 12:55:42 +03:00
Automatically load and save application preferences found in hamburger menu
This commit is contained in:
@@ -48,3 +48,11 @@ install_data(
|
||||
output: '@0@.desktop'.format(meson.project_name()),
|
||||
configuration: conf),
|
||||
install_dir: get_option('datadir') / 'applications')
|
||||
|
||||
settings_schemas = [ 'wdisplays.gschema.xml' ]
|
||||
gschema_dir = get_option('prefix') / get_option('datadir') / 'glib-2.0' / 'schemas'
|
||||
install_data(settings_schemas, install_dir: gschema_dir)
|
||||
|
||||
gnome.post_install(
|
||||
glib_compile_schemas: true
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<gresource prefix="@resource_prefix@">
|
||||
<file compressed="true" preprocess="xml-stripblanks">wdisplays.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">head.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">wdisplays.gschema.xml</file>
|
||||
<file compressed="true">style.css</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<schemalist>
|
||||
<schema id="com.github.artizirk.wdisplays" path="/com/github/artizirk/wdisplays/">
|
||||
<key name="auto-apply" type="b">
|
||||
<default>false</default>
|
||||
</key>
|
||||
<key name="capture-screens" type="b">
|
||||
<default>true</default>
|
||||
</key>
|
||||
<key name="show-overlay" type="b">
|
||||
<default>true</default>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
||||
+17
@@ -858,6 +858,10 @@ static void info_bar_animation_done(GObject *object, GParamSpec *pspec, gpointer
|
||||
|
||||
static void auto_apply_selected(GSimpleAction *action, GVariant *param, gpointer data) {
|
||||
struct wd_state *state = data;
|
||||
|
||||
GSettings *settings = g_settings_new("com.github.artizirk.wdisplays");
|
||||
g_settings_set_boolean(settings, "auto-apply", g_variant_get_boolean(param));
|
||||
|
||||
state->autoapply = g_variant_get_boolean(param);
|
||||
g_simple_action_set_state(action, param);
|
||||
}
|
||||
@@ -874,6 +878,10 @@ static gboolean redraw_canvas(GtkWidget *widget, GdkFrameClock *frame_clock, gpo
|
||||
|
||||
static void capture_selected(GSimpleAction *action, GVariant *param, gpointer data) {
|
||||
struct wd_state *state = data;
|
||||
|
||||
GSettings *settings = g_settings_new("com.github.artizirk.wdisplays");
|
||||
g_settings_set_boolean(settings, "capture-screens", g_variant_get_boolean(param));
|
||||
|
||||
state->capture = g_variant_get_boolean(param);
|
||||
g_simple_action_set_state(action, param);
|
||||
update_tick_callback(state);
|
||||
@@ -881,6 +889,10 @@ static void capture_selected(GSimpleAction *action, GVariant *param, gpointer da
|
||||
|
||||
static void overlay_selected(GSimpleAction *action, GVariant *param, gpointer data) {
|
||||
struct wd_state *state = data;
|
||||
|
||||
GSettings *settings = g_settings_new("com.github.artizirk.wdisplays");
|
||||
g_settings_set_boolean(settings, "show-overlay", g_variant_get_boolean(param));
|
||||
|
||||
state->show_overlay = g_variant_get_boolean(param);
|
||||
g_simple_action_set_state(action, param);
|
||||
|
||||
@@ -1019,6 +1031,11 @@ static void activate(GtkApplication* app, gpointer user_data) {
|
||||
g_signal_connect(action, "activate", G_CALLBACK(zoom_in), state);
|
||||
g_action_map_add_action(G_ACTION_MAP(main_actions), G_ACTION(action));
|
||||
|
||||
GSettings *settings = g_settings_new("com.github.artizirk.wdisplays");
|
||||
state->autoapply = g_settings_get_boolean(settings, "auto-apply");
|
||||
state->capture = g_settings_get_boolean(settings, "capture-screens");
|
||||
state->show_overlay = g_settings_get_boolean(settings, "show-overlay");
|
||||
|
||||
action = g_simple_action_new_stateful("auto-apply", NULL,
|
||||
g_variant_new_boolean(state->autoapply));
|
||||
g_signal_connect(action, "change-state", G_CALLBACK(auto_apply_selected), state);
|
||||
|
||||
Reference in New Issue
Block a user