style
[psensor.git] / src / ui_pref.c
index 1f480b8..b84cf73 100644 (file)
@@ -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-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
+ */
 #include <stdlib.h>
 #include <string.h>
 
@@ -52,7 +51,8 @@ void ui_pref_dialog_run(struct ui_psensor *ui)
                *w_s_update_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;
 
        cfg = ui->config;
 
@@ -64,8 +64,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 ;
        }
 
@@ -103,34 +103,39 @@ 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_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);
+
        result = gtk_dialog_run(diag);
 
        if (result == GTK_RESPONSE_ACCEPT) {
@@ -191,6 +196,12 @@ 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);
+
                config_save(cfg);
 
                g_mutex_unlock(ui->sensors_mutex);