X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_pref.c;h=cc4be17034aaeecf3f67398420f288cf1d2c767d;hb=e57d7f801ae20f02e0cb28107a89b31fa51de1c1;hp=809ee205232d5529fa63062bc183644ff7159bb1;hpb=609664bb77874990e10f8073e54bb7f1645c8d72;p=psensor.git diff --git a/src/ui_pref.c b/src/ui_pref.c index 809ee20..cc4be17 100644 --- a/src/ui_pref.c +++ b/src/ui_pref.c @@ -1,22 +1,21 @@ /* - Copyright (C) 2010-2011 wpitchoune@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-2012 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,11 +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; GtkComboBox *w_sensorlist_pos; - GtkToggleButton *w_hide_window_decoration, *w_keep_window_below; + GtkToggleButton *w_hide_window_decoration, *w_keep_window_below, + *w_enable_menu, *w_enable_launcher_counter, *w_hide_on_startup, + *w_win_restore; + GtkComboBoxText *w_temp_unit; cfg = ui->config; @@ -63,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 ; } @@ -80,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 @@ -102,22 +104,46 @@ 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); + + 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_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) { @@ -151,6 +177,13 @@ void ui_pref_dialog_run(struct ui_psensor *ui) cfg->window_keep_below_enabled = gtk_toggle_button_get_active(w_keep_window_below); + 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); @@ -171,11 +204,20 @@ 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->temperature_unit + = gtk_combo_box_get_active(GTK_COMBO_BOX(w_temp_unit)); + config_save(cfg); g_mutex_unlock(ui->sensors_mutex); - ui_main_box_create(ui); + ui_window_update(ui); } g_object_unref(G_OBJECT(builder)); gtk_widget_destroy(GTK_WIDGET(diag));