set_bool(KEY_ALPHA_CHANNEL_ENABLED, b);
}
-static enum sensorlist_position get_sensorlist_position(void)
+enum sensorlist_position config_get_sensorlist_position(void)
{
return get_int(KEY_INTERFACE_SENSORLIST_POSITION);
}
-static void set_sensorlist_position(enum sensorlist_position pos)
+void config_set_sensorlist_position(enum sensorlist_position pos)
{
set_int(KEY_INTERFACE_SENSORLIST_POSITION, pos);
}
c->graph_fgcolor = get_foreground_color();
c->graph_bg_alpha = get_graph_background_alpha();
c->alpha_channel_enabled = is_alpha_channel_enabled();
- c->sensorlist_position = get_sensorlist_position();
c->slog_enabled = is_slog_enabled();
c->slog_interval = config_get_slog_interval();
if (c->graph_monitoring_duration < 1)
c->graph_monitoring_duration = 10;
- c->unity_launcher_count_disabled
- = get_bool(KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED);
-
- c->hide_on_startup = get_bool(KEY_INTERFACE_HIDE_ON_STARTUP);
-
c->window_restore_enabled
= get_bool(KEY_INTERFACE_WINDOW_RESTORE_ENABLED);
set_background_color(c->graph_bgcolor);
set_foreground_color(c->graph_fgcolor);
set_graph_background_alpha(c->graph_bg_alpha);
- set_sensorlist_position(c->sensorlist_position);
set_slog_enabled(c->slog_enabled);
set_slog_interval(c->slog_interval);
set_int(KEY_SENSOR_UPDATE_INTERVAL, c->sensor_update_interval);
- set_bool(KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED,
- c->unity_launcher_count_disabled);
-
set_bool(KEY_INTERFACE_HIDE_ON_STARTUP, c->hide_on_startup);
set_bool(KEY_INTERFACE_WINDOW_RESTORE_ENABLED,
#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());
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_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();
}
log_debug("Window size: %d %d", cfg->window_w, cfg->window_h);
cfg->window_divider_pos
- = gtk_paned_get_position(GTK_PANED(ui->sensor_box));
+ = gtk_paned_get_position(GTK_PANED(w_sensor_box));
config_save(cfg);
}
set_keep_below(GTK_WINDOW(window));
menu_bar = GTK_WIDGET(gtk_builder_get_object(builder, "menu_bar"));
- ui->main_box = GTK_WIDGET(gtk_builder_get_object(builder, "main_box"));
+ w_main_box = GTK_CONTAINER(gtk_builder_get_object(builder, "main_box"));
ui->popup_menu = GTK_WIDGET(gtk_builder_get_object(builder,
"popup_menu"));
g_object_ref(G_OBJECT(ui->popup_menu));
ui->main_window = window;
- ui->w_graph = GTK_WIDGET(gtk_builder_get_object(builder, "graph"));
+ w_graph = GTK_WIDGET(gtk_builder_get_object(builder, "graph"));
ui_graph_create(ui);
- ui->sensor_box = GTK_PANED(gtk_builder_get_object(builder,
- "sensor_box"));
+ w_sensor_box = GTK_PANED(gtk_builder_get_object(builder,
+ "sensor_box"));
ui->sensors_store = GTK_LIST_STORE(gtk_builder_get_object
(builder, "sensors_store"));
ui->sensors_tree = GTK_TREE_VIEW(gtk_builder_get_object
(builder, "sensors_tree"));
- ui->sensors_scrolled_tree
+ w_sensors_scrolled_tree
= GTK_SCROLLED_WINDOW(gtk_builder_get_object
(builder, "sensors_scrolled_tree"));
connect_cbks(GTK_WINDOW(window), menu_bar);
log_debug("ui_window_create(): show_all");
- gtk_widget_show_all(ui->main_box);
+ update_layout();
+ gtk_widget_show_all(GTK_WIDGET(w_main_box));
set_menu_bar_enabled(menu_bar);
g_object_unref(G_OBJECT(builder));
void ui_window_update(struct ui_psensor *ui)
{
struct config *cfg;
+ enum sensorlist_position sensorlist_pos;
log_debug("ui_window_update()");
cfg = ui->config;
- g_object_ref(GTK_WIDGET(ui->sensors_scrolled_tree));
- g_object_ref(GTK_WIDGET(ui->w_graph));
-
- gtk_container_remove(GTK_CONTAINER(ui->sensor_box),
- GTK_WIDGET(ui->sensors_scrolled_tree));
-
- gtk_container_remove(GTK_CONTAINER(ui->sensor_box), ui->w_graph);
-
- gtk_container_remove(GTK_CONTAINER(ui->main_box),
- GTK_WIDGET(ui->sensor_box));
-
- if (cfg->sensorlist_position == SENSORLIST_POSITION_RIGHT
- || cfg->sensorlist_position == SENSORLIST_POSITION_LEFT)
- ui->sensor_box
- = GTK_PANED(gtk_paned_new(GTK_ORIENTATION_HORIZONTAL));
- else
- ui->sensor_box
- = GTK_PANED(gtk_paned_new(GTK_ORIENTATION_VERTICAL));
-
- gtk_box_pack_end(GTK_BOX(ui->main_box),
- GTK_WIDGET(ui->sensor_box), TRUE, TRUE, 2);
-
- if (cfg->sensorlist_position == SENSORLIST_POSITION_RIGHT
- || cfg->sensorlist_position == SENSORLIST_POSITION_BOTTOM) {
- gtk_paned_pack1(ui->sensor_box,
- GTK_WIDGET(ui->w_graph), TRUE, TRUE);
- gtk_paned_pack2(ui->sensor_box,
- GTK_WIDGET(ui->sensors_scrolled_tree),
- FALSE, TRUE);
- } else {
- gtk_paned_pack1(ui->sensor_box,
- GTK_WIDGET(ui->sensors_scrolled_tree),
- FALSE, TRUE);
- gtk_paned_pack2(ui->sensor_box,
- GTK_WIDGET(ui->w_graph), TRUE, TRUE);
- }
-
if (cfg->window_restore_enabled)
- gtk_paned_set_position(ui->sensor_box, cfg->window_divider_pos);
-
- g_object_unref(GTK_WIDGET(ui->sensors_scrolled_tree));
- g_object_unref(GTK_WIDGET(ui->w_graph));
+ gtk_paned_set_position(w_sensor_box, cfg->window_divider_pos);
- gtk_widget_show_all(GTK_WIDGET(ui->sensor_box));
}
void ui_window_show(struct ui_psensor *ui)
return result;
}
+
+GtkWidget *ui_get_graph(void)
+{
+ return w_graph;
+}
config_set_count_visible(gtk_toggle_button_get_active(btn));
}
+void ui_pref_sensorlist_position_changed_cbk(GtkComboBox *combo, gpointer data)
+{
+ config_set_sensorlist_position(gtk_combo_box_get_active(combo));
+}
+
GdkRGBA color_to_GdkRGBA(struct color *color)
{
GdkRGBA c;
w_sensorlist_pos = GTK_COMBO_BOX
(gtk_builder_get_object(builder, "sensors_list_position"));
- gtk_combo_box_set_active(w_sensorlist_pos, cfg->sensorlist_position);
+ gtk_combo_box_set_active(w_sensorlist_pos,
+ config_get_sensorlist_position());
w_autostart = GTK_TOGGLE_BUTTON
(gtk_builder_get_object(builder, "autostart"));
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);
+ !config_is_count_visible());
if (ui_unity_is_supported()) {
gtk_widget_set_has_tooltip
else
cfg->alpha_channel_enabled = 1;
- cfg->sensorlist_position
- = gtk_combo_box_get_active(w_sensorlist_pos);
-
- cfg->unity_launcher_count_disabled
- = !gtk_toggle_button_get_active
- (w_enable_launcher_counter);
-
cfg->sensor_update_interval
= gtk_spin_button_get_value_as_int(w_s_update_interval);