X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_pref.c;h=4dd4bf8309f855a602c1046190cd03e6a178b492;hb=829e06d4a516b4fe0ae21c6b23b2ff088ca8cb68;hp=0470116520f32e025ca0f6b8ccb2fc19d9d72ece;hpb=76a6adb05fd59bec20251c8d7eee958bc9f285bc;p=psensor.git diff --git a/src/ui_pref.c b/src/ui_pref.c index 0470116..4dd4bf8 100644 --- a/src/ui_pref.c +++ b/src/ui_pref.c @@ -1,22 +1,21 @@ /* - Copyright (C) 2010-2011 jeanfi@gmail.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA -*/ - + * Copyright (C) 2010-2014 jeanfi@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ #include #include @@ -24,7 +23,7 @@ #include "cfg.h" #include "ui_pref.h" #include "ui_color.h" -#include "compat.h" +#include GdkColor *color_to_gdkcolor(struct color *color) { @@ -47,12 +46,16 @@ void ui_pref_dialog_run(struct ui_psensor *ui) GError *error = NULL; GdkColor *color_fg, *color_bg; GtkColorButton *w_color_fg, *w_color_bg; - GtkHScale *w_bg_opacity; + GtkScale *w_bg_opacity; GtkSpinButton *w_update_interval, *w_monitoring_duration, - *w_s_update_interval; + *w_s_update_interval, *w_slog_interval; GtkComboBox *w_sensorlist_pos; GtkToggleButton *w_hide_window_decoration, *w_keep_window_below, - *w_enable_menu, *w_enable_launcher_counter; + *w_enable_menu, *w_enable_launcher_counter, *w_hide_on_startup, + *w_win_restore, *w_slog_enabled, *w_autostart; + GtkComboBoxText *w_temp_unit; + GtkEntry *w_notif_script; + char *notif_script; cfg = ui->config; @@ -64,13 +67,21 @@ void ui_pref_dialog_run(struct ui_psensor *ui) &error); if (!ok) { - g_warning("%s", error->message); + log_printf(LOG_ERR, error->message); g_error_free(error); return ; } diag = GTK_DIALOG(gtk_builder_get_object(builder, "dialog1")); + w_notif_script = GTK_ENTRY(gtk_builder_get_object(builder, + "notif_script")); + notif_script = config_get_notif_script(); + if (notif_script) { + gtk_entry_set_text(GTK_ENTRY(w_notif_script), notif_script); + free(notif_script); + } + color_fg = color_to_gdkcolor(cfg->graph_fgcolor); w_color_fg = GTK_COLOR_BUTTON(gtk_builder_get_object(builder, "color_fg")); @@ -81,8 +92,8 @@ void ui_pref_dialog_run(struct ui_psensor *ui) "color_bg")); gtk_color_button_set_color(w_color_bg, color_bg); - w_bg_opacity = GTK_HSCALE(gtk_builder_get_object(builder, - "bg_opacity")); + w_bg_opacity = GTK_SCALE(gtk_builder_get_object(builder, + "bg_opacity")); gtk_range_set_value(GTK_RANGE(w_bg_opacity), cfg->graph_bg_alpha); w_update_interval = GTK_SPIN_BUTTON(gtk_builder_get_object @@ -103,41 +114,67 @@ void ui_pref_dialog_run(struct ui_psensor *ui) cfg->graph_monitoring_duration); w_sensorlist_pos = GTK_COMBO_BOX - (gtk_builder_get_object(builder, - "sensors_list_position")); + (gtk_builder_get_object(builder, "sensors_list_position")); gtk_combo_box_set_active(w_sensorlist_pos, cfg->sensorlist_position); w_hide_window_decoration = GTK_TOGGLE_BUTTON - (gtk_builder_get_object(builder, - "hide_window_decoration")); + (gtk_builder_get_object(builder, "hide_window_decoration")); gtk_toggle_button_set_active(w_hide_window_decoration, !cfg->window_decoration_enabled); w_keep_window_below = GTK_TOGGLE_BUTTON - (gtk_builder_get_object(builder, - "keep_window_below")); + (gtk_builder_get_object(builder, "keep_window_below")); gtk_toggle_button_set_active(w_keep_window_below, cfg->window_keep_below_enabled); + w_autostart = GTK_TOGGLE_BUTTON + (gtk_builder_get_object(builder, "autostart")); + gtk_toggle_button_set_active(w_autostart, pxdg_is_autostarted()); + w_enable_menu = GTK_TOGGLE_BUTTON - (gtk_builder_get_object(builder, - "enable_menu")); - gtk_toggle_button_set_active(w_enable_menu, - !cfg->menu_bar_disabled); + (gtk_builder_get_object(builder, "enable_menu")); + gtk_toggle_button_set_active(w_enable_menu, !cfg->menu_bar_disabled); w_enable_launcher_counter = GTK_TOGGLE_BUTTON - (gtk_builder_get_object(builder, - "enable_launcher_counter")); + (gtk_builder_get_object(builder, "enable_launcher_counter")); gtk_toggle_button_set_active(w_enable_launcher_counter, !cfg->unity_launcher_count_disabled); + w_slog_enabled = GTK_TOGGLE_BUTTON + (gtk_builder_get_object(builder, "enable_slog")); + gtk_toggle_button_set_active(w_slog_enabled, cfg->slog_enabled); + + w_slog_interval = GTK_SPIN_BUTTON + (gtk_builder_get_object(builder, "slog_interval")); + gtk_spin_button_set_value(w_slog_interval, cfg->slog_interval); + + w_hide_on_startup + = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, + "hide_on_startup")); + gtk_toggle_button_set_active(w_hide_on_startup, cfg->hide_on_startup); + + w_win_restore + = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, + "restore_window")); + gtk_toggle_button_set_active(w_win_restore, + cfg->window_restore_enabled); + + w_temp_unit + = GTK_COMBO_BOX_TEXT(gtk_builder_get_object + (builder, "temperature_unit")); + gtk_combo_box_set_active(GTK_COMBO_BOX(w_temp_unit), + cfg->temperature_unit); + result = gtk_dialog_run(diag); if (result == GTK_RESPONSE_ACCEPT) { double value; GdkColor color; - g_mutex_lock(ui->sensors_mutex); + pthread_mutex_lock(&ui->sensors_mutex); + + config_set_notif_script + (gtk_entry_get_text(GTK_ENTRY(w_notif_script))); gtk_color_button_get_color(w_color_fg, &color); color_set(cfg->graph_fgcolor, @@ -191,9 +228,26 @@ void ui_pref_dialog_run(struct ui_psensor *ui) = (cfg->graph_monitoring_duration * 60) / cfg->sensor_update_interval; + cfg->hide_on_startup + = gtk_toggle_button_get_active(w_hide_on_startup); + + cfg->window_restore_enabled + = gtk_toggle_button_get_active(w_win_restore); + + cfg->slog_enabled + = gtk_toggle_button_get_active(w_slog_enabled); + + cfg->slog_interval + = gtk_spin_button_get_value_as_int(w_slog_interval); + + cfg->temperature_unit + = gtk_combo_box_get_active(GTK_COMBO_BOX(w_temp_unit)); + config_save(cfg); - g_mutex_unlock(ui->sensors_mutex); + pxdg_set_autostart(gtk_toggle_button_get_active(w_autostart)); + + pthread_mutex_unlock(&ui->sensors_mutex); ui_window_update(ui); }