- 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 "cfg.h"
-#include "ui.h"
-#include "ui_graph.h"
-#include "ui_pref.h"
-#include "ui_sensorpref.h"
-#include "ui_sensorlist.h"
-#include "ui_appindicator.h"
+ * 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 <stdlib.h>
+
+#include <cfg.h>
+#include <slog.h>
+#include <ui.h>
+#include <ui_appindicator.h>
+#include <ui_graph.h>
+#include <ui_pref.h>
+#include <ui_sensorlist.h>
+#include <ui_sensorpref.h>
+#include <ui_status.h>
+
+static GtkWidget *w_sensors_scrolled_tree;
+static GtkWidget *w_graph;
+static GtkContainer *w_sensor_box;
+static GtkContainer *w_main_box;
+
+static void update_layout(void)
+{
+ enum sensorlist_position sensorlist_pos;
+
+ g_object_ref(w_sensors_scrolled_tree);
+ g_object_ref(w_graph);
+
+ gtk_container_remove(w_sensor_box,
+ w_sensors_scrolled_tree);
+
+ gtk_container_remove(w_sensor_box, w_graph);
+
+ gtk_container_remove(w_main_box, GTK_WIDGET(w_sensor_box));
+
+ sensorlist_pos = config_get_sensorlist_position();
+ if (sensorlist_pos == SENSORLIST_POSITION_RIGHT
+ || sensorlist_pos == SENSORLIST_POSITION_LEFT)
+ w_sensor_box
+ = GTK_PANED(gtk_paned_new(GTK_ORIENTATION_HORIZONTAL));
+ else
+ w_sensor_box
+ = GTK_PANED(gtk_paned_new(GTK_ORIENTATION_VERTICAL));
+
+ gtk_box_pack_end(GTK_BOX(w_main_box),
+ GTK_WIDGET(w_sensor_box), TRUE, TRUE, 2);
+
+ if (sensorlist_pos == SENSORLIST_POSITION_RIGHT
+ || sensorlist_pos == SENSORLIST_POSITION_BOTTOM) {
+ gtk_paned_pack1(w_sensor_box, w_graph, TRUE, TRUE);
+ gtk_paned_pack2(w_sensor_box,
+ w_sensors_scrolled_tree,
+ FALSE,
+ TRUE);
+ } else {
+ gtk_paned_pack1(w_sensor_box,
+ w_sensors_scrolled_tree,
+ FALSE,
+ TRUE);
+ gtk_paned_pack2(w_sensor_box, w_graph, TRUE, TRUE);
+ }
+
+ g_object_unref(w_sensors_scrolled_tree);
+ g_object_unref(w_graph);
+
+ gtk_widget_show_all(GTK_WIDGET(w_sensor_box));
+}
+
+static void set_decoration(GtkWindow *win)
+{
+ gtk_window_set_decorated(win, config_is_window_decoration_enabled());
+}
+
+static void set_keep_below(GtkWindow *win)
+{
+ gtk_window_set_keep_below(win, config_is_window_keep_below_enabled());
+}
+
+static void set_menu_bar_enabled(GtkWidget *bar)
+{
+ if (config_is_menu_bar_enabled())
+ gtk_widget_show(bar);
+ else
+ gtk_widget_hide(bar);
+}
+
+static void
+decoration_changed_cbk(GSettings *settings, gchar *key, gpointer data)
+{
+ set_decoration(GTK_WINDOW(data));
+}
+
+static void
+keep_below_changed_cbk(GSettings *settings, gchar *key, gpointer data)
+{
+ set_keep_below(GTK_WINDOW(data));
+}
+
+static void
+menu_bar_changed_cbk(GSettings *settings, gchar *key, gpointer data)
+{
+ set_menu_bar_enabled(GTK_WIDGET(data));
+}
+
+static void
+sensorlist_position_changed_cbk(GSettings *settings, gchar *key, gpointer data)
+{
+ update_layout();
+}
+
+static void connect_cbks(GtkWindow *win, GtkWidget *menu_bar)
+{
+ log_fct_enter();
+
+ g_signal_connect_after(config_get_GSettings(),
+ "changed::interface-window-decoration-disabled",
+ G_CALLBACK(decoration_changed_cbk),
+ win);
+
+ g_signal_connect_after(config_get_GSettings(),
+ "changed::interface-window-keep-below-enabled",
+ G_CALLBACK(keep_below_changed_cbk),
+ win);
+
+ g_signal_connect_after(config_get_GSettings(),
+ "changed::interface-menu-bar-disabled",
+ G_CALLBACK(menu_bar_changed_cbk),
+ menu_bar);
+
+ g_signal_connect_after(config_get_GSettings(),
+ "changed::interface-sensorlist-position",
+ G_CALLBACK(sensorlist_position_changed_cbk),
+ menu_bar);
+
+
+ log_fct_exit();
+}