X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_pref.c;h=9112dd5acd553d9bd45b5743ef984d160bac0223;hb=7fdddf9fea2abfa0ef22822937de81d289558a14;hp=32cc35ff554189542cdbcd7d492068168bc6a50d;hpb=d92bb15bcf27f77b27cea7554686fce24f86e042;p=psensor.git diff --git a/src/ui_pref.c b/src/ui_pref.c index 32cc35f..9112dd5 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-2013 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 @@ -47,12 +46,14 @@ 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_menu, *w_enable_launcher_counter, *w_hide_on_startup, + *w_win_restore, *w_slog_enabled; + GtkComboBoxText *w_temp_unit; cfg = ui->config; @@ -64,8 +65,8 @@ void ui_pref_dialog_run(struct ui_psensor *ui) &error); if (!ok) { - g_warning("%s", error->message); - g_free(error); + log_printf(LOG_ERR, error->message); + g_error_free(error); return ; } @@ -81,8 +82,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,28 +104,52 @@ 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_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_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); @@ -132,7 +157,7 @@ void ui_pref_dialog_run(struct ui_psensor *ui) double value; GdkColor color; - g_mutex_lock(ui->sensors_mutex); + pthread_mutex_lock(&ui->sensors_mutex); gtk_color_button_get_color(w_color_fg, &color); color_set(cfg->graph_fgcolor, @@ -162,6 +187,10 @@ void ui_pref_dialog_run(struct ui_psensor *ui) cfg->menu_bar_disabled = !gtk_toggle_button_get_active(w_enable_menu); + cfg->unity_launcher_count_disabled + = !gtk_toggle_button_get_active + (w_enable_launcher_counter); + gtk_window_set_decorated(GTK_WINDOW(ui->main_window), cfg->window_decoration_enabled); @@ -182,9 +211,24 @@ 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); + pthread_mutex_unlock(&ui->sensors_mutex); ui_window_update(ui); }