From ae573ea0c5328662e711d7717edc835d1a313d58 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Tue, 11 Nov 2014 10:45:38 +0100 Subject: [PATCH] window decoration changes applied immediately --- src/cfg.c | 6 ++-- src/cfg.h | 4 ++- src/glade/psensor-pref.glade | 84 ++------------------------------------------ src/ui.c | 28 +++++++++++++-- src/ui_pref.c | 16 +++++---- src/ui_pref.h | 2 ++ 6 files changed, 44 insertions(+), 96 deletions(-) diff --git a/src/cfg.c b/src/cfg.c index 37048c9..13ea515 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -328,7 +328,7 @@ static void set_slog_interval(int interval) set_int(KEY_SLOG_INTERVAL, interval); } -static bool is_window_decoration_enabled(void) +bool config_is_window_decoration_enabled(void) { return !get_bool(KEY_INTERFACE_WINDOW_DECORATION_DISABLED); } @@ -338,7 +338,7 @@ static bool is_window_keep_below_enabled(void) return get_bool(KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED); } -static void set_window_decoration_enabled(bool enabled) +void config_set_window_decoration_enabled(bool enabled) { set_bool(KEY_INTERFACE_WINDOW_DECORATION_DISABLED, !enabled); } @@ -419,7 +419,6 @@ struct config *config_load(void) c->graph_bg_alpha = get_graph_background_alpha(); c->alpha_channel_enabled = is_alpha_channel_enabled(); c->sensorlist_position = get_sensorlist_position(); - c->window_decoration_enabled = is_window_decoration_enabled(); c->window_keep_below_enabled = is_window_keep_below_enabled(); c->slog_enabled = is_slog_enabled(); c->slog_interval = config_get_slog_interval(); @@ -474,7 +473,6 @@ void config_save(const struct config *c) set_foreground_color(c->graph_fgcolor); set_graph_background_alpha(c->graph_bg_alpha); set_sensorlist_position(c->sensorlist_position); - set_window_decoration_enabled(c->window_decoration_enabled); set_window_keep_below_enabled(c->window_keep_below_enabled); set_slog_enabled(c->slog_enabled); set_slog_interval(c->slog_interval); diff --git a/src/cfg.h b/src/cfg.h index bbdfd77..1d6e777 100644 --- a/src/cfg.h +++ b/src/cfg.h @@ -47,7 +47,6 @@ struct config { /* Position of the sensors list table */ enum sensorlist_position sensorlist_position; - bool window_decoration_enabled; bool window_keep_below_enabled; bool window_restore_enabled; /* Last saved position of the window. */ @@ -150,6 +149,9 @@ int config_get_sensor_unit(void); double config_get_default_high_threshold_temperature(void); +bool config_is_window_decoration_enabled(void); +void config_set_window_decoration_enabled(bool); + /* * Returns the user directory containing psensor data (configuration * and log). diff --git a/src/glade/psensor-pref.glade b/src/glade/psensor-pref.glade index 868c682..4cc27d9 100644 --- a/src/glade/psensor-pref.glade +++ b/src/glade/psensor-pref.glade @@ -1,5 +1,5 @@ - + @@ -133,12 +133,12 @@ 4 0 True + 0 0 2 - 1 @@ -158,7 +158,6 @@ 0 1 2 - 1 @@ -178,7 +177,6 @@ 0 2 2 - 1 @@ -199,7 +197,6 @@ 0 3 2 - 1 @@ -219,8 +216,6 @@ 1 4 - 1 - 1 @@ -244,8 +239,6 @@ 1 5 - 1 - 1 @@ -263,7 +256,6 @@ 0 4 2 - 1 @@ -280,8 +272,6 @@ 0 5 - 1 - 1 @@ -325,8 +315,6 @@ 0 0 - 1 - 1 @@ -345,8 +333,6 @@ 0 1 - 1 - 1 @@ -365,8 +351,6 @@ 0 2 - 1 - 1 @@ -413,8 +397,6 @@ 1 3 - 1 - 1 @@ -431,8 +413,6 @@ 0 3 - 1 - 1 @@ -449,8 +429,6 @@ 0 4 - 1 - 1 @@ -467,8 +445,6 @@ 1 4 - 1 - 1 @@ -485,8 +461,6 @@ 0 5 - 1 - 1 @@ -507,7 +481,6 @@ 0 2 2 - 1 @@ -524,8 +497,6 @@ 0 7 - 1 - 1 @@ -542,8 +513,6 @@ 0 8 - 1 - 1 @@ -564,7 +533,6 @@ 0 6 2 - 1 @@ -622,8 +590,6 @@ 1 5 - 1 - 1 @@ -674,8 +640,6 @@ 1 8 - 1 - 1 @@ -726,8 +690,6 @@ 1 7 - 1 - 1 @@ -747,7 +709,6 @@ 0 1 2 - 1 @@ -769,7 +730,6 @@ 0 0 2 - 1 @@ -817,8 +777,6 @@ 0 0 - 1 - 1 @@ -837,8 +795,6 @@ 1 0 - 1 - 1 @@ -854,8 +810,6 @@ 2 0 - 1 - 1 @@ -876,7 +830,6 @@ 0 1 3 - 1 @@ -894,8 +847,6 @@ 1 2 - 1 - 1 @@ -912,8 +863,6 @@ 0 2 - 1 - 1 @@ -929,8 +878,6 @@ 2 2 - 1 - 1 @@ -946,8 +893,6 @@ 0 3 - 1 - 1 @@ -965,7 +910,6 @@ 1 3 2 - 1 @@ -1014,8 +958,6 @@ 0 1 - 1 - 1 @@ -1035,8 +977,6 @@ 0 3 - 1 - 1 @@ -1056,8 +996,6 @@ 0 4 - 1 - 1 @@ -1077,8 +1015,6 @@ 0 6 - 1 - 1 @@ -1097,8 +1033,6 @@ 0 8 - 1 - 1 @@ -1118,8 +1052,6 @@ 0 9 - 1 - 1 @@ -1139,8 +1071,6 @@ 0 10 - 1 - 1 @@ -1160,8 +1090,6 @@ 0 11 - 1 - 1 @@ -1183,8 +1111,6 @@ 0 7 - 1 - 1 @@ -1206,8 +1132,6 @@ 0 5 - 1 - 1 @@ -1229,8 +1153,6 @@ 0 2 - 1 - 1 @@ -1252,8 +1174,6 @@ 0 0 - 1 - 1 diff --git a/src/ui.c b/src/ui.c index fc5f5c3..e81e841 100644 --- a/src/ui.c +++ b/src/ui.c @@ -28,6 +28,29 @@ #include "ui_status.h" #include "ui_appindicator.h" +static void set_decoration(GtkWindow *win) +{ + gtk_window_set_decorated(win, config_is_window_decoration_enabled()); +} + +static void +decoration_changed_cbk(GSettings *settings, gchar *key, gpointer data) +{ + set_decoration((GtkWindow *)data); +} + +static void connect_cbks(GtkWindow *win) +{ + log_fct_enter(); + + g_signal_connect_after(config_get_GSettings(), + "changed::interface-window-decoration-disabled", + G_CALLBACK(decoration_changed_cbk), + win); + + log_fct_exit(); +} + static void save_window_pos(struct ui_psensor *ui) { gboolean visible; @@ -225,8 +248,7 @@ void ui_window_create(struct ui_psensor *ui) g_signal_connect(window, "delete_event", G_CALLBACK(on_delete_event_cb), ui); - gtk_window_set_decorated(GTK_WINDOW(window), - cfg->window_decoration_enabled); + set_decoration(GTK_WINDOW(window)); gtk_window_set_keep_below(GTK_WINDOW(window), cfg->window_keep_below_enabled); @@ -253,6 +275,8 @@ void ui_window_create(struct ui_psensor *ui) ui_sensorlist_create(ui); + connect_cbks(GTK_WINDOW(window)); + log_debug("ui_window_create(): show_all"); gtk_widget_show_all(ui->main_box); diff --git a/src/ui_pref.c b/src/ui_pref.c index 4594a97..27201ad 100644 --- a/src/ui_pref.c +++ b/src/ui_pref.c @@ -33,6 +33,12 @@ #include #include +void ui_pref_decoration_toggled_cbk(GtkToggleButton *btn, gpointer data) +{ + config_set_window_decoration_enabled + (!config_is_window_decoration_enabled()); +} + GdkRGBA color_to_GdkRGBA(struct color *color) { GdkRGBA c; @@ -131,7 +137,7 @@ void ui_pref_dialog_run(struct ui_psensor *ui) w_hide_window_decoration = GTK_TOGGLE_BUTTON (gtk_builder_get_object(builder, "hide_window_decoration")); gtk_toggle_button_set_active(w_hide_window_decoration, - !cfg->window_decoration_enabled); + !config_is_window_decoration_enabled()); w_keep_window_below = GTK_TOGGLE_BUTTON (gtk_builder_get_object(builder, "keep_window_below")); @@ -276,6 +282,8 @@ void ui_pref_dialog_run(struct ui_psensor *ui) gtk_toggle_button_set_active(w_udisks2, config_is_udisks2_enabled()); + gtk_builder_connect_signals(builder, NULL); + result = gtk_dialog_run(diag); if (result == GTK_RESPONSE_ACCEPT) { @@ -310,9 +318,6 @@ void ui_pref_dialog_run(struct ui_psensor *ui) cfg->sensorlist_position = gtk_combo_box_get_active(w_sensorlist_pos); - cfg->window_decoration_enabled = - !gtk_toggle_button_get_active(w_hide_window_decoration); - cfg->window_keep_below_enabled = gtk_toggle_button_get_active(w_keep_window_below); @@ -323,9 +328,6 @@ void ui_pref_dialog_run(struct ui_psensor *ui) = !gtk_toggle_button_get_active (w_enable_launcher_counter); - gtk_window_set_decorated(GTK_WINDOW(ui->main_window), - cfg->window_decoration_enabled); - gtk_window_set_keep_below(GTK_WINDOW(ui->main_window), cfg->window_keep_below_enabled); diff --git a/src/ui_pref.h b/src/ui_pref.h index 2e669c5..219545a 100644 --- a/src/ui_pref.h +++ b/src/ui_pref.h @@ -24,4 +24,6 @@ void ui_pref_dialog_run(struct ui_psensor *); GdkRGBA color_to_GdkRGBA(struct color *color); +void ui_pref_decoration_toggled_cbk(GtkToggleButton *, gpointer); + #endif -- 2.7.4