#define KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED \
"/apps/psensor/interface/window_keep_below_enabled"
+#define KEY_INTERFACE_MENU_BAR_DISABLED \
+"/apps/psensor/interface/menu_bar_disabled"
+
+
GConfClient *client;
char *config_get_string(char *key, char *default_value)
if (cfg->sensor_values_max_length < 3)
cfg->sensor_values_max_length = 3;
+ cfg->menu_bar_disabled = gconf_client_get_bool
+ (client,
+ KEY_INTERFACE_MENU_BAR_DISABLED,
+ NULL);
+
return cfg;
}
KEY_SENSOR_UPDATE_INTERVAL,
cfg->sensor_update_interval, NULL);
+ gconf_client_set_bool(client,
+ KEY_INTERFACE_MENU_BAR_DISABLED,
+ cfg->menu_bar_disabled, NULL);
+
}
int sensor_values_max_length;
int sensor_update_interval;
+
+ int menu_bar_disabled;
};
/*
/* sensor list */
ui.ui_sensorlist = ui_sensorlist_create(ui.sensors);
- ui_sensor_box_create(&ui);
-
- gtk_widget_show_all(ui.main_window);
+ ui_window_update(&ui);
thread = g_thread_create((GThreadFunc) update_psensor_measures,
&ui, TRUE, &error);
psensor_list_free(ui.sensors);
- /* gdk_threads_leave(); */
-
return 0;
}
gtk_container_add(GTK_CONTAINER(window), ui->main_box);
ui->main_window = window;
+ ui->menu_bar = menubar;
+
+ gtk_widget_show_all(ui->main_window);
}
-void ui_sensor_box_create(struct ui_psensor *ui)
+static void menu_bar_show(unsigned int show, struct ui_psensor *ui)
+{
+ if (show)
+ gtk_widget_show(ui->menu_bar);
+ else
+ gtk_widget_hide(ui->menu_bar);
+}
+
+void ui_window_update(struct ui_psensor *ui)
{
struct config *cfg;
GtkWidget *w_sensorlist;
}
gtk_widget_show_all(ui->sensor_box);
+
+ if (cfg->menu_bar_disabled)
+ menu_bar_show(0, ui);
+ else
+ menu_bar_show(1, ui);
}
GtkWidget *main_window;
+ GtkWidget *menu_bar;
+
/*
The main vertical box, top contains the menubar, bottom
contains the sensor_box.
};
/*
+ Update the window according to the configuration.
+
Creates or re-creates the sensor_box according to the position of
the list of sensors in the configuration.
+
+ Show or hide the menu bar.
*/
-void ui_sensor_box_create(struct ui_psensor *);
+void ui_window_update(struct ui_psensor *);
/*
Must be called to terminate Psensor UI.
*/
void ui_window_create(struct ui_psensor *ui);
+void ui_menu_bar_show(unsigned int show, struct ui_psensor *ui);
+
#endif
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;
cfg = ui->config;
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);
+
+
result = gtk_dialog_run(diag);
if (result == GTK_RESPONSE_ACCEPT) {
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);
+
gtk_window_set_decorated(GTK_WINDOW(ui->main_window),
cfg->window_decoration_enabled);
g_mutex_unlock(ui->sensors_mutex);
- ui_sensor_box_create(ui);
+ ui_window_update(ui);
}
g_object_unref(G_OBJECT(builder));
gtk_widget_destroy(GTK_WIDGET(diag));