summaryrefslogtreecommitdiff
path: root/sensors-applet
diff options
context:
space:
mode:
Diffstat (limited to 'sensors-applet')
-rw-r--r--sensors-applet/prefs-dialog.c1407
-rw-r--r--sensors-applet/prefs-dialog.h62
-rw-r--r--sensors-applet/sensor-config-dialog.c1244
3 files changed, 1315 insertions, 1398 deletions
diff --git a/sensors-applet/prefs-dialog.c b/sensors-applet/prefs-dialog.c
index 6bd5df9..f7d11ff 100644
--- a/sensors-applet/prefs-dialog.c
+++ b/sensors-applet/prefs-dialog.c
@@ -29,23 +29,24 @@
#define OLD_TEMP_SCALE 0
#define NEW_TEMP_SCALE 1
+
/* when a user closes the prefs-dialog we assume that applet is now
setup, so store all values in gsettings */
void prefs_dialog_close(SensorsApplet *sensors_applet) {
- if (sensors_applet->sensors != NULL) {
- sensors_applet_settings_save_sensors(sensors_applet);
- }
- if (sensors_applet->prefs_dialog) {
- gtk_widget_destroy(GTK_WIDGET(sensors_applet->prefs_dialog->dialog));
- g_free(sensors_applet->prefs_dialog);
- sensors_applet->prefs_dialog = NULL;
+ if (sensors_applet->sensors != NULL) {
+ sensors_applet_settings_save_sensors(sensors_applet);
+ }
- }
- if (sensors_applet->timeout_id == 0) {
- sensors_applet->timeout_id = g_timeout_add_seconds(g_settings_get_int (sensors_applet->settings, TIMEOUT) / 1000, (GSourceFunc)sensors_applet_update_active_sensors, sensors_applet);
- }
+ if (sensors_applet->prefs_dialog) {
+ gtk_widget_destroy(GTK_WIDGET(sensors_applet->prefs_dialog->dialog));
+ g_free(sensors_applet->prefs_dialog);
+ sensors_applet->prefs_dialog = NULL;
+ }
+ if (sensors_applet->timeout_id == 0) {
+ sensors_applet->timeout_id = g_timeout_add_seconds(g_settings_get_int (sensors_applet->settings, TIMEOUT) / 1000, (GSourceFunc)sensors_applet_update_active_sensors, sensors_applet);
+ }
}
@@ -53,39 +54,39 @@ void prefs_dialog_response(GtkDialog *prefs_dialog,
gint response,
gpointer data) {
- SensorsApplet *sensors_applet;
- GError *error = NULL;
- gint current_page;
- gchar *uri;
+ SensorsApplet *sensors_applet;
+ GError *error = NULL;
+ gint current_page;
+ gchar *uri;
- sensors_applet = (SensorsApplet *)data;
+ sensors_applet = (SensorsApplet *)data;
- switch (response) {
+ switch (response) {
case GTK_RESPONSE_HELP:
- g_debug("loading help in prefs");
- current_page = gtk_notebook_get_current_page(sensors_applet->prefs_dialog->notebook);
- uri = g_strdup_printf("help:mate-sensors-applet/%s",
- ((current_page == 0) ?
- "sensors-applet-general-options" :
- ((current_page == 1) ?
- "sensors-applet-sensors" :
- NULL)));
+ g_debug("loading help in prefs");
+ current_page = gtk_notebook_get_current_page(sensors_applet->prefs_dialog->notebook);
+ uri = g_strdup_printf("help:mate-sensors-applet/%s",
+ ((current_page == 0) ?
+ "sensors-applet-general-options" :
+ ((current_page == 1) ?
+ "sensors-applet-sensors" :
+ NULL)));
#if GTK_CHECK_VERSION (3, 22, 0)
- gtk_show_uri_on_window(NULL, uri, gtk_get_current_event_time(), &error);
+ gtk_show_uri_on_window(NULL, uri, gtk_get_current_event_time(), &error);
#else
- gtk_show_uri(NULL, uri, gtk_get_current_event_time(), &error);
+ gtk_show_uri(NULL, uri, gtk_get_current_event_time(), &error);
#endif
- g_free(uri);
+ g_free(uri);
- if (error) {
- g_debug("Could not open help document: %s ",error->message);
- g_error_free (error);
- }
- break;
+ if (error) {
+ g_debug("Could not open help document: %s ",error->message);
+ g_error_free (error);
+ }
+ break;
default:
- g_debug("closing prefs dialog");
- prefs_dialog_close(sensors_applet);
- }
+ g_debug("closing prefs dialog");
+ prefs_dialog_close(sensors_applet);
+ }
}
@@ -93,116 +94,118 @@ static gboolean prefs_dialog_convert_low_and_high_values(GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
TemperatureScale scales[2]) {
- SensorType sensor_type;
- gdouble low_value, high_value;
- gtk_tree_model_get(model,
- iter,
- SENSOR_TYPE_COLUMN, &sensor_type,
- LOW_VALUE_COLUMN, &low_value,
- HIGH_VALUE_COLUMN, &high_value,
- -1);
+ SensorType sensor_type;
+ gdouble low_value, high_value;
- if (sensor_type == TEMP_SENSOR)
- {
- low_value = sensors_applet_convert_temperature(low_value,
- scales[OLD_TEMP_SCALE],
- scales[NEW_TEMP_SCALE]);
+ gtk_tree_model_get(model,
+ iter,
+ SENSOR_TYPE_COLUMN, &sensor_type,
+ LOW_VALUE_COLUMN, &low_value,
+ HIGH_VALUE_COLUMN, &high_value,
+ -1);
- high_value = sensors_applet_convert_temperature(high_value,
- scales[OLD_TEMP_SCALE],
- scales[NEW_TEMP_SCALE]);
+ if (sensor_type == TEMP_SENSOR) {
+ low_value = sensors_applet_convert_temperature(low_value,
+ scales[OLD_TEMP_SCALE],
+ scales[NEW_TEMP_SCALE]);
+ high_value = sensors_applet_convert_temperature(high_value,
+ scales[OLD_TEMP_SCALE],
+ scales[NEW_TEMP_SCALE]);
- gtk_tree_store_set(GTK_TREE_STORE(model),
- iter,
- LOW_VALUE_COLUMN, low_value,
- HIGH_VALUE_COLUMN, high_value,
- -1);
- }
- return FALSE;
+
+ gtk_tree_store_set(GTK_TREE_STORE(model),
+ iter,
+ LOW_VALUE_COLUMN, low_value,
+ HIGH_VALUE_COLUMN, high_value,
+ -1);
+ }
+ return FALSE;
}
static void prefs_dialog_timeout_changed(GtkSpinButton *button,
PrefsDialog *prefs_dialog) {
- gint value;
- value = (gint)(gtk_spin_button_get_value(button) * 1000);
- g_settings_set_int (prefs_dialog->sensors_applet->settings, TIMEOUT, value);
+
+ gint value;
+ value = (gint)(gtk_spin_button_get_value(button) * 1000);
+ g_settings_set_int (prefs_dialog->sensors_applet->settings, TIMEOUT, value);
}
static void prefs_dialog_display_mode_changed(GtkComboBox *display_mode_combo_box,
PrefsDialog *prefs_dialog) {
- int display_mode;
- display_mode = gtk_combo_box_get_active(display_mode_combo_box);
+ int display_mode;
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_label),
- (display_mode != DISPLAY_ICON) &&
- (display_mode != DISPLAY_VALUE) &&
- (display_mode != DISPLAY_GRAPH));
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_combo_box),
- (display_mode != DISPLAY_ICON) &&
- (display_mode != DISPLAY_VALUE) &&
- (display_mode != DISPLAY_GRAPH));
+ display_mode = gtk_combo_box_get_active(display_mode_combo_box);
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_label),
- (display_mode == DISPLAY_GRAPH));
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_spinbutton),
- (display_mode == DISPLAY_GRAPH));
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_label),
+ (display_mode != DISPLAY_ICON) &&
+ (display_mode != DISPLAY_VALUE) &&
+ (display_mode != DISPLAY_GRAPH));
- g_settings_set_int (prefs_dialog->sensors_applet->settings,
- DISPLAY_MODE,
- gtk_combo_box_get_active(display_mode_combo_box));
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_combo_box),
+ (display_mode != DISPLAY_ICON) &&
+ (display_mode != DISPLAY_VALUE) &&
+ (display_mode != DISPLAY_GRAPH));
- sensors_applet_display_layout_changed(prefs_dialog->sensors_applet);
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_label),
+ (display_mode == DISPLAY_GRAPH));
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_spinbutton),
+ (display_mode == DISPLAY_GRAPH));
+
+ g_settings_set_int (prefs_dialog->sensors_applet->settings,
+ DISPLAY_MODE,
+ gtk_combo_box_get_active(display_mode_combo_box));
+
+ sensors_applet_display_layout_changed(prefs_dialog->sensors_applet);
}
static void prefs_dialog_layout_mode_changed(GtkComboBox *layout_mode_combo_box,
PrefsDialog *prefs_dialog) {
- g_settings_set_int (prefs_dialog->sensors_applet->settings,
- LAYOUT_MODE,
- gtk_combo_box_get_active(layout_mode_combo_box));
+ g_settings_set_int (prefs_dialog->sensors_applet->settings,
+ LAYOUT_MODE,
+ gtk_combo_box_get_active(layout_mode_combo_box));
- sensors_applet_display_layout_changed(prefs_dialog->sensors_applet);
+ sensors_applet_display_layout_changed(prefs_dialog->sensors_applet);
}
-
static void prefs_dialog_temperature_scale_changed(GtkComboBox *temperature_scale_combo_box,
PrefsDialog *prefs_dialog) {
- /* get old temp scale value */
- TemperatureScale scales[2];
- GtkTreeModel *model;
- scales[OLD_TEMP_SCALE] = (TemperatureScale) g_settings_get_int (prefs_dialog->sensors_applet->settings,
- TEMPERATURE_SCALE);
+ /* get old temp scale value */
+ TemperatureScale scales[2];
+ GtkTreeModel *model;
- scales[NEW_TEMP_SCALE] = (TemperatureScale)gtk_combo_box_get_active(temperature_scale_combo_box);
+ scales[OLD_TEMP_SCALE] = (TemperatureScale) g_settings_get_int (prefs_dialog->sensors_applet->settings, TEMPERATURE_SCALE);
- g_settings_set_int (prefs_dialog->sensors_applet->settings,
- TEMPERATURE_SCALE,
- scales[NEW_TEMP_SCALE]);
+ scales[NEW_TEMP_SCALE] = (TemperatureScale)gtk_combo_box_get_active(temperature_scale_combo_box);
- /* now go thru and convert all low and high sensor values in
- * the tree to either celcius or Fahrenheit */
- model = gtk_tree_view_get_model(prefs_dialog->view);
- gtk_tree_model_foreach(model,
- (GtkTreeModelForeachFunc)prefs_dialog_convert_low_and_high_values,
- scales);
+ g_settings_set_int (prefs_dialog->sensors_applet->settings,
+ TEMPERATURE_SCALE,
+ scales[NEW_TEMP_SCALE]);
- /* finally update display of active sensors */
- sensors_applet_update_active_sensors(prefs_dialog->sensors_applet);
+ /* now go thru and convert all low and high sensor values in
+ * the tree to either celcius or Fahrenheit */
+ model = gtk_tree_view_get_model(prefs_dialog->view);
+ gtk_tree_model_foreach(model,
+ (GtkTreeModelForeachFunc)prefs_dialog_convert_low_and_high_values,
+ scales);
+
+ /* finally update display of active sensors */
+ sensors_applet_update_active_sensors(prefs_dialog->sensors_applet);
}
// hide/show units
static void prefs_dialog_show_units_toggled (GtkCheckButton *show_units, PrefsDialog *prefs_dialog) {
- gboolean state;
+ gboolean state;
- state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_units));
- g_settings_set_boolean (prefs_dialog->sensors_applet->settings, HIDE_UNITS, !state);
- sensors_applet_update_active_sensors (prefs_dialog->sensors_applet);
+ state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_units));
+ g_settings_set_boolean (prefs_dialog->sensors_applet->settings, HIDE_UNITS, !state);
+ sensors_applet_update_active_sensors (prefs_dialog->sensors_applet);
}
@@ -210,757 +213,715 @@ static void prefs_dialog_show_units_toggled (GtkCheckButton *show_units, PrefsDi
static void prefs_dialog_display_notifications_toggled(GtkCheckButton *display_notifications,
PrefsDialog *prefs_dialog) {
- gboolean notify;
+ gboolean notify;
- notify = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(display_notifications));
- g_settings_set_boolean(prefs_dialog->sensors_applet->settings,
- DISPLAY_NOTIFICATIONS,
- notify);
+ notify = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(display_notifications));
+ g_settings_set_boolean(prefs_dialog->sensors_applet->settings,
+ DISPLAY_NOTIFICATIONS,
+ notify);
- if (notify) {
- sensors_applet_update_active_sensors(prefs_dialog->sensors_applet);
- } else {
- sensors_applet_notify_end_all(prefs_dialog->sensors_applet);
- }
+ if (notify) {
+ sensors_applet_update_active_sensors(prefs_dialog->sensors_applet);
+ } else {
+ sensors_applet_notify_end_all(prefs_dialog->sensors_applet);
+ }
}
#endif
+
static void prefs_dialog_graph_size_changed(GtkSpinButton *button,
PrefsDialog *prefs_dialog) {
- gint value;
- value = (gint)(gtk_spin_button_get_value(button));
- g_settings_set_int(prefs_dialog->sensors_applet->settings, GRAPH_SIZE, value);
- /* notify change of number of samples */
- sensors_applet_graph_size_changed(prefs_dialog->sensors_applet);
+ gint value;
+ value = (gint)(gtk_spin_button_get_value(button));
+ g_settings_set_int(prefs_dialog->sensors_applet->settings, GRAPH_SIZE, value);
+
+ /* notify change of number of samples */
+ sensors_applet_graph_size_changed(prefs_dialog->sensors_applet);
}
/* callbacks for the tree of sensors */
static void prefs_dialog_sensor_toggled(GtkCellRenderer *renderer, gchar *path_str, PrefsDialog *prefs_dialog) {
- GtkTreeIter iter;
- GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkTreePath *path;
- gboolean old_value;
+ gboolean old_value;
- path = gtk_tree_path_new_from_string(path_str);
+ path = gtk_tree_path_new_from_string(path_str);
- gtk_tree_model_get_iter(GTK_TREE_MODEL(prefs_dialog->sensors_applet->sensors), &iter, path);
- gtk_tree_model_get(GTK_TREE_MODEL(prefs_dialog->sensors_applet->sensors),
- &iter,
- ENABLE_COLUMN, &old_value,
- -1);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(prefs_dialog->sensors_applet->sensors), &iter, path);
+ gtk_tree_model_get(GTK_TREE_MODEL(prefs_dialog->sensors_applet->sensors),
+ &iter,
+ ENABLE_COLUMN, &old_value,
+ -1);
- if (old_value) {
- sensors_applet_sensor_disabled(prefs_dialog->sensors_applet,
- path);
- } else {
- sensors_applet_sensor_enabled(prefs_dialog->sensors_applet,
- path);
- }
+ if (old_value) {
+ sensors_applet_sensor_disabled(prefs_dialog->sensors_applet, path);
+ } else {
+ sensors_applet_sensor_enabled(prefs_dialog->sensors_applet, path);
+ }
- gtk_tree_store_set(prefs_dialog->sensors_applet->sensors, &iter,
- ENABLE_COLUMN, !old_value,
- -1);
+ gtk_tree_store_set(prefs_dialog->sensors_applet->sensors, &iter,
+ ENABLE_COLUMN, !old_value,
+ -1);
- gtk_tree_path_free(path);
+ gtk_tree_path_free(path);
}
static void prefs_dialog_sensor_name_changed(GtkCellRenderer *renderer, gchar *path_str, gchar *new_text, PrefsDialog *prefs_dialog) {
- GtkTreeIter iter;
- GtkTreePath *path = gtk_tree_path_new_from_string(path_str);
+ GtkTreeIter iter;
+ GtkTreePath *path = gtk_tree_path_new_from_string(path_str);
- gtk_tree_model_get_iter(GTK_TREE_MODEL(prefs_dialog->sensors_applet->sensors), &iter, path);
+ gtk_tree_model_get_iter(GTK_TREE_MODEL(prefs_dialog->sensors_applet->sensors), &iter, path);
- gtk_tree_store_set(prefs_dialog->sensors_applet->sensors, &iter, LABEL_COLUMN, new_text, -1);
+ gtk_tree_store_set(prefs_dialog->sensors_applet->sensors, &iter, LABEL_COLUMN, new_text, -1);
- sensors_applet_update_sensor(prefs_dialog->sensors_applet, path);
- gtk_tree_path_free(path);
+ sensors_applet_update_sensor(prefs_dialog->sensors_applet, path);
+ gtk_tree_path_free(path);
}
static void prefs_dialog_row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, PrefsDialog *prefs_dialog) {
- /* only bring up dialog this if is a sensor - ie has no
- * children */
- GtkTreeIter iter;
- GtkTreeModel *model;
-
- model = gtk_tree_view_get_model(view);
- /* make sure can set iter first */
- if (gtk_tree_model_get_iter(model, &iter, path) && !gtk_tree_model_iter_has_child(model, &iter)) {
- sensor_config_dialog_create(prefs_dialog->sensors_applet);
- }
+ /* only bring up dialog this if is a sensor - ie has no
+ * children */
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+
+ model = gtk_tree_view_get_model(view);
+ /* make sure can set iter first */
+ if (gtk_tree_model_get_iter(model, &iter, path) && !gtk_tree_model_iter_has_child(model, &iter)) {
+ sensor_config_dialog_create(prefs_dialog->sensors_applet);
+ }
}
-
static void prefs_dialog_sensor_up_button_clicked(GtkButton *button, PrefsDialog *prefs_dialog) {
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreePath *path;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ if (gtk_tree_selection_get_selected(prefs_dialog->sensors_applet->selection, &model, &iter)) {
+ /* if has no prev node set up button insentive */
+ path = gtk_tree_model_get_path(model, &iter);
+ if (gtk_tree_path_prev(path)) {
+
+ GtkTreeIter prev_iter;
+ /* check is a valid node in out model */
+ if (gtk_tree_model_get_iter(model, &prev_iter, path)) {
+
+ gtk_tree_store_move_before(GTK_TREE_STORE(model),
+ &iter,
+ &prev_iter);
+ g_signal_emit_by_name(prefs_dialog->sensors_applet->selection, "changed");
+ sensors_applet_reorder_sensors(prefs_dialog->sensors_applet);
+
+ }
+ }
- if (gtk_tree_selection_get_selected(prefs_dialog->sensors_applet->selection, &model, &iter)) {
- /* if has no prev node set up button insentive */
- path = gtk_tree_model_get_path(model, &iter);
- if (gtk_tree_path_prev(path)) {
- GtkTreeIter prev_iter;
- /* check is a valid node in out model */
- if (gtk_tree_model_get_iter(model, &prev_iter, path)) {
- gtk_tree_store_move_before(GTK_TREE_STORE(model),
- &iter,
- &prev_iter);
- g_signal_emit_by_name(prefs_dialog->sensors_applet->selection,
- "changed");
+ gtk_tree_path_free(path);
- sensors_applet_reorder_sensors(prefs_dialog->sensors_applet);
+ }
+}
+static void prefs_dialog_sensor_down_button_clicked(GtkButton *button, PrefsDialog *prefs_dialog) {
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreeIter iter_next;
- }
- }
+ if (gtk_tree_selection_get_selected(prefs_dialog->sensors_applet->selection, &model, &iter)) {
+ iter_next = iter;
+ /* if has no next node set down button insentive */
+ if (gtk_tree_model_iter_next(model, &iter_next)) {
- gtk_tree_path_free(path);
+ gtk_tree_store_move_after(GTK_TREE_STORE(model),
+ &iter,
+ &iter_next);
+ g_signal_emit_by_name(prefs_dialog->sensors_applet->selection, "changed");
+ sensors_applet_reorder_sensors(prefs_dialog->sensors_applet);
}
+ }
}
-static void prefs_dialog_sensor_down_button_clicked(GtkButton *button, PrefsDialog *prefs_dialog) {
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeIter iter_next;
-
- if (gtk_tree_selection_get_selected(prefs_dialog->sensors_applet->selection, &model, &iter)) {
- iter_next = iter;
- /* if has no next node set down button insentive */
- if (gtk_tree_model_iter_next(model, &iter_next)) {
- gtk_tree_store_move_after(GTK_TREE_STORE(model),
- &iter,
- &iter_next);
- g_signal_emit_by_name(prefs_dialog->sensors_applet->selection,
- "changed");
- sensors_applet_reorder_sensors(prefs_dialog->sensors_applet);
-
- }
- }
-}
-
-
-
static void prefs_dialog_sensor_config_button_clicked(GtkButton *button, PrefsDialog *prefs_dialog) {
- sensor_config_dialog_create(prefs_dialog->sensors_applet);
+ sensor_config_dialog_create(prefs_dialog->sensors_applet);
}
-
/* if a sensor is selected, make config sure button is able to be
* clicked and also set the sensitivities properly for the up and down
* buttons */
static void prefs_dialog_selection_changed(GtkTreeSelection *selection,
PrefsDialog *prefs_dialog) {
- GtkTreeIter iter;
- GtkTreePath *path;
- GtkTreeModel *model;
- /* if there is a selection with no children make config button
- * sensitive */
- if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
- if (!gtk_tree_model_iter_has_child(model, &iter)) {
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_config_button), TRUE);
- } else {
- /* otherwise make insensitive */
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_config_button), FALSE);
- }
-
- /* if has no prev node set up button insentive */
- path = gtk_tree_model_get_path(model, &iter);
- if (gtk_tree_path_prev(path)) {
- GtkTreeIter prev_iter;
- /* check is a valid node in out model */
- if (gtk_tree_model_get_iter(model, &prev_iter, path)) {
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), TRUE);
- } else {
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
- }
- } else {
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
- }
-
- gtk_tree_path_free(path);
-
- /* if has no next node set down button insentive */
- if (gtk_tree_model_iter_next(model, &iter)) {
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), TRUE);
- } else {
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE);
- }
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GtkTreeModel *model;
+ /* if there is a selection with no children make config button sensitive */
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+ if (!gtk_tree_model_iter_has_child(model, &iter)) {
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_config_button), TRUE);
} else {
- /* otherwise make all insensitive */
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_config_button), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE);
-
+ /* otherwise make insensitive */
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_config_button), FALSE);
}
-}
-void prefs_dialog_open(SensorsApplet *sensors_applet) {
- gchar *header_text;
- PrefsDialog *prefs_dialog;
- DisplayMode display_mode;
- GtkWidget *content_area;
+ /* if has no prev node set up button insentive */
+ path = gtk_tree_model_get_path(model, &iter);
+ if (gtk_tree_path_prev(path)) {
+ GtkTreeIter prev_iter;
+ /* check is a valid node in out model */
+ if (gtk_tree_model_get_iter(model, &prev_iter, path)) {
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), TRUE);
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
+ }
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
+ }
- g_assert(sensors_applet->prefs_dialog == NULL);
+ gtk_tree_path_free(path);
- /* while prefs dialog is open, stop the updating of sensors so
- * we don't get any race conditions due to concurrent updates
- * of the labels, values and icons linked lists etc. */
- if (sensors_applet->timeout_id != 0) {
- if (g_source_remove(sensors_applet->timeout_id)) {
- sensors_applet->timeout_id = 0;
- }
+ /* if has no next node set down button insentive */
+ if (gtk_tree_model_iter_next(model, &iter)) {
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), TRUE);
+ } else {
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE);
}
- sensors_applet->prefs_dialog = g_new0(PrefsDialog, 1);
- prefs_dialog = sensors_applet->prefs_dialog;
+ } else {
+ /* otherwise make all insensitive */
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_config_button), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE);
- prefs_dialog->sensors_applet = sensors_applet;
+ }
+}
- prefs_dialog->dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("Sensors Applet Preferences"),
- NULL,
- 0,
- GTK_STOCK_HELP,
- GTK_RESPONSE_HELP,
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- NULL));
- gtk_window_set_icon_name(GTK_WINDOW(prefs_dialog->dialog),
- "mate-sensors-applet");
+void prefs_dialog_open(SensorsApplet *sensors_applet) {
+ gchar *header_text;
+ PrefsDialog *prefs_dialog;
+ DisplayMode display_mode;
+ GtkWidget *content_area;
+
+ g_assert(sensors_applet->prefs_dialog == NULL);
+
+ /* while prefs dialog is open, stop the updating of sensors so
+ * we don't get any race conditions due to concurrent updates
+ * of the labels, values and icons linked lists etc. */
+ if (sensors_applet->timeout_id != 0) {
+ if (g_source_remove(sensors_applet->timeout_id)) {
+ sensors_applet->timeout_id = 0;
+ }
+ }
- g_object_set(prefs_dialog->dialog,
- "border-width", 12,
- "default-width", 480,
- "default-height", 350,
- NULL);
+ sensors_applet->prefs_dialog = g_new0(PrefsDialog, 1);
+ prefs_dialog = sensors_applet->prefs_dialog;
- content_area = gtk_dialog_get_content_area (prefs_dialog->dialog);
- gtk_box_set_homogeneous(GTK_BOX(content_area), FALSE);
+ prefs_dialog->sensors_applet = sensors_applet;
- gtk_box_set_spacing(GTK_BOX(content_area), 5);
+ prefs_dialog->dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("Sensors Applet Preferences"),
+ NULL,
+ 0,
+ GTK_STOCK_HELP,
+ GTK_RESPONSE_HELP,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ NULL));
+ gtk_window_set_icon_name(GTK_WINDOW(prefs_dialog->dialog), "mate-sensors-applet");
- g_signal_connect(prefs_dialog->dialog,
- "response", G_CALLBACK(prefs_dialog_response),
- sensors_applet);
+ g_object_set(prefs_dialog->dialog,
+ "border-width", 12,
+ "default-width", 480,
+ "default-height", 350,
+ NULL);
- g_signal_connect_swapped(prefs_dialog->dialog,
- "delete-event", G_CALLBACK(prefs_dialog_close),
- sensors_applet);
+ content_area = gtk_dialog_get_content_area (prefs_dialog->dialog);
+ gtk_box_set_homogeneous(GTK_BOX(content_area), FALSE);
- g_signal_connect_swapped(prefs_dialog->dialog,
- "destroy", G_CALLBACK(prefs_dialog_close),
- sensors_applet);
+ gtk_box_set_spacing(GTK_BOX(content_area), 5);
- /* if no SensorsList's have been created, this is because
- we haven't been able to access any sensors */
- if (sensors_applet->sensors == NULL) {
- GtkWidget *label;
- GtkWidget *content_area;
- label = gtk_label_new(_("No sensors found!"));
- content_area = gtk_dialog_get_content_area (prefs_dialog->dialog);
- gtk_box_pack_start (GTK_BOX(content_area), label, FALSE, FALSE, 0);
- return;
- }
+ g_signal_connect(prefs_dialog->dialog,
+ "response", G_CALLBACK(prefs_dialog_response),
+ sensors_applet);
+ g_signal_connect_swapped(prefs_dialog->dialog,
+ "delete-event", G_CALLBACK(prefs_dialog_close),
+ sensors_applet);
- header_text = g_markup_printf_escaped("<b>%s</b>", _("Display"));
- prefs_dialog->display_header = g_object_new(GTK_TYPE_LABEL,
- "use-markup", TRUE,
- "label", header_text,
+ g_signal_connect_swapped(prefs_dialog->dialog,
+ "destroy", G_CALLBACK(prefs_dialog_close),
+ sensors_applet);
+ /* if no SensorsList's have been created, this is because
+ we haven't been able to access any sensors */
+ if (sensors_applet->sensors == NULL) {
+ GtkWidget *label;
+ GtkWidget *content_area;
+ label = gtk_label_new(_("No sensors found!"));
+ content_area = gtk_dialog_get_content_area (prefs_dialog->dialog);
+ gtk_box_pack_start (GTK_BOX(content_area), label, FALSE, FALSE, 0);
+ return;
+ }
+
+ header_text = g_markup_printf_escaped("<b>%s</b>", _("Display"));
+ prefs_dialog->display_header = g_object_new(GTK_TYPE_LABEL,
+ "use-markup", TRUE,
+ "label", header_text,
+ "xalign", 0.0,
+ NULL);
+ g_free(header_text);
+
+ prefs_dialog->display_mode_combo_box = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
+
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("label with value"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("icon with value"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("value only"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("icon only"));
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("graph only"));
+
+ display_mode = g_settings_get_int(sensors_applet->settings, DISPLAY_MODE);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_dialog->display_mode_combo_box), display_mode);
+
+ g_signal_connect(prefs_dialog->display_mode_combo_box,
+ "changed",
+ G_CALLBACK(prefs_dialog_display_mode_changed),
+ prefs_dialog);
+
+ /* use spaces in label to indent */
+ prefs_dialog->display_mode_label = g_object_new(GTK_TYPE_LABEL,
+ "use-underline", TRUE,
+ "label", _("_Display sensors in panel as"),
+ "mnemonic-widget", prefs_dialog->display_mode_combo_box,
"xalign", 0.0,
NULL);
- g_free(header_text);
-
- prefs_dialog->display_mode_combo_box = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
-
-
- gtk_combo_box_text_append_text(
- GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("label with value"));
- gtk_combo_box_text_append_text(
- GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("icon with value"));
- gtk_combo_box_text_append_text(
- GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("value only"));
- gtk_combo_box_text_append_text(
- GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("icon only"));
- gtk_combo_box_text_append_text(
- GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("graph only"));
-
-
- display_mode = g_settings_get_int(sensors_applet->settings, DISPLAY_MODE);
- gtk_combo_box_set_active(
- GTK_COMBO_BOX(prefs_dialog->display_mode_combo_box), display_mode);
-
- g_signal_connect(prefs_dialog->display_mode_combo_box,
- "changed",
- G_CALLBACK(prefs_dialog_display_mode_changed),
- prefs_dialog);
-
+ prefs_dialog->layout_mode_combo_box = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
- /* use spaces in label to indent */
- prefs_dialog->display_mode_label = g_object_new(GTK_TYPE_LABEL,
- "use-underline", TRUE,
- "label", _("_Display sensors in panel as"),
- "mnemonic-widget", prefs_dialog->display_mode_combo_box,
- "xalign", 0.0,
- NULL);
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_combo_box),
+ (display_mode != DISPLAY_ICON) &&
+ (display_mode != DISPLAY_VALUE) &&
+ (display_mode != DISPLAY_GRAPH));
+ gtk_combo_box_text_append_text(prefs_dialog->layout_mode_combo_box, _("beside labels / icons"));
+ gtk_combo_box_text_append_text(prefs_dialog->layout_mode_combo_box, _("below labels / icons"));
+ gtk_combo_box_set_active(
+ GTK_COMBO_BOX(prefs_dialog->layout_mode_combo_box),
+ g_settings_get_int(sensors_applet->settings, LAYOUT_MODE));
+ g_signal_connect(prefs_dialog->layout_mode_combo_box,
+ "changed",
+ G_CALLBACK(prefs_dialog_layout_mode_changed),
+ prefs_dialog);
- prefs_dialog->layout_mode_combo_box = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
-
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_combo_box),
- (display_mode != DISPLAY_ICON) &&
- (display_mode != DISPLAY_VALUE) &&
- (display_mode != DISPLAY_GRAPH));
-
- gtk_combo_box_text_append_text(prefs_dialog->layout_mode_combo_box, _("beside labels / icons"));
- gtk_combo_box_text_append_text(prefs_dialog->layout_mode_combo_box, _("below labels / icons"));
-
- gtk_combo_box_set_active(
- GTK_COMBO_BOX(prefs_dialog->layout_mode_combo_box),
- g_settings_get_int(sensors_applet->settings, LAYOUT_MODE));
+ prefs_dialog->layout_mode_label = g_object_new(GTK_TYPE_LABEL,
+ "use-underline", TRUE,
+ "label", _("Preferred _position of sensor values"),
+ "mnemonic-widget", prefs_dialog->layout_mode_combo_box,
+ "xalign", 0.0,
+ NULL);
- g_signal_connect(prefs_dialog->layout_mode_combo_box,
- "changed",
- G_CALLBACK(prefs_dialog_layout_mode_changed),
- prefs_dialog);
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_label),
+ (display_mode != DISPLAY_ICON) &&
+ (display_mode != DISPLAY_VALUE) &&
+ (display_mode != DISPLAY_GRAPH));
+
+ prefs_dialog->temperature_scale_combo_box = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
+
+ gtk_combo_box_text_append_text(prefs_dialog->temperature_scale_combo_box, _("Kelvin"));
+ gtk_combo_box_text_append_text(prefs_dialog->temperature_scale_combo_box, _("Celsius"));
+ gtk_combo_box_text_append_text(prefs_dialog->temperature_scale_combo_box, _("Fahrenheit"));
+
+ gtk_combo_box_set_active(
+ GTK_COMBO_BOX(prefs_dialog->temperature_scale_combo_box),
+ g_settings_get_int(sensors_applet->settings, TEMPERATURE_SCALE));
+
+ g_signal_connect(prefs_dialog->temperature_scale_combo_box,
+ "changed",
+ G_CALLBACK(prefs_dialog_temperature_scale_changed),
+ prefs_dialog);
+
+ prefs_dialog->temperature_scale_label = g_object_new(GTK_TYPE_LABEL,
+ "use-underline", TRUE,
+ "label", _("_Temperature scale"),
+ "mnemonic-widget", prefs_dialog->temperature_scale_combo_box,
+ "xalign", 0.0,
+ NULL);
+
+ prefs_dialog->graph_size_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+ "value", (gdouble)g_settings_get_int(sensors_applet->settings, GRAPH_SIZE),
+ "lower", 1.0,
+ "upper", 100.0,
+ "step-increment", 1.0,
+ "page-increment", 10.0,
+ "page-size", 0.0,
+ NULL);
- prefs_dialog->layout_mode_label = g_object_new(GTK_TYPE_LABEL,
- "use-underline", TRUE,
- "label", _("Preferred _position of sensor values"),
- "mnemonic-widget", prefs_dialog->layout_mode_combo_box,
- "xalign", 0.0,
+ prefs_dialog->graph_size_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+ "adjustment", prefs_dialog->graph_size_adjust,
+ "climb-rate", 1.0,
+ "digits", 0,
+ "value", (gdouble)g_settings_get_int(sensors_applet->settings, GRAPH_SIZE),
+ "width-chars", 4,
NULL);
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_label),
- (display_mode != DISPLAY_ICON) &&
- (display_mode != DISPLAY_VALUE) &&
- (display_mode != DISPLAY_GRAPH));
-
- prefs_dialog->temperature_scale_combo_box = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
-
- gtk_combo_box_text_append_text(prefs_dialog->temperature_scale_combo_box, _("Kelvin"));
- gtk_combo_box_text_append_text(prefs_dialog->temperature_scale_combo_box, _("Celsius"));
- gtk_combo_box_text_append_text(prefs_dialog->temperature_scale_combo_box, _("Fahrenheit"));
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_spinbutton), (display_mode == DISPLAY_GRAPH));
- gtk_combo_box_set_active(
- GTK_COMBO_BOX(prefs_dialog->temperature_scale_combo_box),
- g_settings_get_int(sensors_applet->settings, TEMPERATURE_SCALE));
+ prefs_dialog->graph_size_label = g_object_new(GTK_TYPE_LABEL,
+ "use-underline", TRUE,
+ "label", _("Graph _size (pixels)"),
+ "mnemonic-widget", prefs_dialog->graph_size_spinbutton,
+ "xalign", 0.0,
+ NULL);
- g_signal_connect(prefs_dialog->temperature_scale_combo_box,
- "changed",
- G_CALLBACK(prefs_dialog_temperature_scale_changed),
- prefs_dialog);
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_label), (display_mode == DISPLAY_GRAPH));
+
+ g_signal_connect(prefs_dialog->graph_size_spinbutton, "value-changed",
+ G_CALLBACK(prefs_dialog_graph_size_changed),
+ prefs_dialog);
+
+ // hide/show units
+ prefs_dialog->show_units = gtk_check_button_new_with_label (_("Show _units"));
+ gtk_button_set_use_underline (GTK_BUTTON (prefs_dialog->show_units), TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs_dialog->show_units),
+ !g_settings_get_boolean (sensors_applet->settings, HIDE_UNITS));
+ g_signal_connect (prefs_dialog->show_units, "toggled",
+ G_CALLBACK (prefs_dialog_show_units_toggled),
+ prefs_dialog);
+
+ header_text = g_markup_printf_escaped("<b>%s</b>", _("Update"));
+ prefs_dialog->update_header = g_object_new(GTK_TYPE_LABEL,
+ "use-markup", TRUE,
+ "label", header_text,
+ "xalign", 0.0,
+ NULL);
+ g_free(header_text);
+
+ prefs_dialog->timeout_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+ "value", 2.0,
+ "lower", 1.5,
+ "upper", 10.0,
+ "step-increment", 0.5,
+ "page-increment", 1.0,
+ "page-size", 0.0,
+ NULL);
+
+ prefs_dialog->timeout_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+ "adjustment", prefs_dialog->timeout_adjust,
+ "climb-rate", 0.5,
+ "digits", 1,
+ "value", (gdouble) g_settings_get_int(sensors_applet->settings, TIMEOUT) / 1000.0,
+ "width-chars", 4,
+ NULL);
- prefs_dialog->temperature_scale_label = g_object_new(GTK_TYPE_LABEL,
- "use-underline", TRUE,
- "label", _("_Temperature scale"),
- "mnemonic-widget", prefs_dialog->temperature_scale_combo_box,
- "xalign", 0.0,
- NULL);
+ prefs_dialog->timeout_label = g_object_new(GTK_TYPE_LABEL,
+ "use-underline", TRUE,
+ "label", _("Update _interval (secs)"),
+ "mnemonic-widget", prefs_dialog->timeout_spinbutton,
+ "xalign", 0.0,
+ NULL);
- prefs_dialog->graph_size_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
- "value", (gdouble)g_settings_get_int(sensors_applet->settings, GRAPH_SIZE),
- "lower", 1.0,
- "upper", 100.0,
- "step-increment", 1.0,
- "page-increment", 10.0,
- "page-size", 0.0,
- NULL);
+ g_signal_connect(prefs_dialog->timeout_spinbutton, "value-changed",
+ G_CALLBACK(prefs_dialog_timeout_changed),
+ prefs_dialog);
- prefs_dialog->graph_size_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
- "adjustment", prefs_dialog->graph_size_adjust,
- "climb-rate", 1.0,
- "digits", 0,
- "value", (gdouble)g_settings_get_int(sensors_applet->settings, GRAPH_SIZE),
- "width-chars", 4,
- NULL);
-
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_spinbutton),
- (display_mode == DISPLAY_GRAPH));
-
- prefs_dialog->graph_size_label = g_object_new(GTK_TYPE_LABEL,
- "use-underline", TRUE,
- "label", _("Graph _size (pixels)"),
- "mnemonic-widget", prefs_dialog->graph_size_spinbutton,
+#ifdef HAVE_LIBNOTIFY
+ header_text = g_markup_printf_escaped("<b>%s</b>", _("Notifications"));
+ prefs_dialog->notifications_header = g_object_new(GTK_TYPE_LABEL,
+ "use-markup", TRUE,
+ "label", header_text,
"xalign", 0.0,
NULL);
+ g_free(header_text);
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_label),
- (display_mode == DISPLAY_GRAPH));
-
- g_signal_connect(prefs_dialog->graph_size_spinbutton, "value-changed",
- G_CALLBACK(prefs_dialog_graph_size_changed),
- prefs_dialog);
-
-
- // hide/show units
- prefs_dialog->show_units = gtk_check_button_new_with_label (_("Show _units"));
- gtk_button_set_use_underline (GTK_BUTTON (prefs_dialog->show_units), TRUE);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs_dialog->show_units),
- !g_settings_get_boolean (sensors_applet->settings, HIDE_UNITS));
- g_signal_connect (prefs_dialog->show_units, "toggled",
- G_CALLBACK (prefs_dialog_show_units_toggled), prefs_dialog);
-
-
- header_text = g_markup_printf_escaped("<b>%s</b>", _("Update"));
- prefs_dialog->update_header = g_object_new(GTK_TYPE_LABEL,
- "use-markup", TRUE,
- "label", header_text,
-
- "xalign", 0.0,
- NULL);
- g_free(header_text);
-
-
- prefs_dialog->timeout_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
- "value", 2.0,
- "lower", 1.5,
- "upper", 10.0,
- "step-increment", 0.5,
- "page-increment", 1.0,
- "page-size", 0.0,
- NULL);
-
- prefs_dialog->timeout_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
- "adjustment", prefs_dialog->timeout_adjust,
- "climb-rate", 0.5,
- "digits", 1,
- "value", (gdouble) g_settings_get_int(sensors_applet->settings, TIMEOUT) / 1000.0,
- "width-chars", 4,
- NULL);
+ prefs_dialog->display_notifications = g_object_new(GTK_TYPE_CHECK_BUTTON,
+ "use-underline", TRUE,
+ "label", _("Display _notifications"),
+ NULL);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_dialog->display_notifications),
+ g_settings_get_boolean(sensors_applet->settings,
+ DISPLAY_NOTIFICATIONS));
+ g_signal_connect(prefs_dialog->display_notifications,
+ "toggled",
+ G_CALLBACK(prefs_dialog_display_notifications_toggled),
+ prefs_dialog);
+#endif
+ /* SIZE AND LAYOUT */
+ /* keep all widgets same size */
+ prefs_dialog->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
- prefs_dialog->timeout_label = g_object_new(GTK_TYPE_LABEL,
- "use-underline", TRUE,
- "label", _("Update _interval (secs)"),
- "mnemonic-widget", prefs_dialog->timeout_spinbutton,
- "xalign", 0.0,
- NULL);
+ gtk_size_group_add_widget(prefs_dialog->size_group,
+ GTK_WIDGET(prefs_dialog->display_mode_combo_box));
- g_signal_connect(prefs_dialog->timeout_spinbutton, "value-changed",
- G_CALLBACK(prefs_dialog_timeout_changed),
- prefs_dialog);
+ gtk_size_group_add_widget(prefs_dialog->size_group,
+ GTK_WIDGET(prefs_dialog->layout_mode_combo_box));
-#ifdef HAVE_LIBNOTIFY
- header_text = g_markup_printf_escaped("<b>%s</b>", _("Notifications"));
- prefs_dialog->notifications_header = g_object_new(GTK_TYPE_LABEL,
- "use-markup", TRUE,
- "label", header_text,
-
- "xalign", 0.0,
- NULL);
- g_free(header_text);
-
- prefs_dialog->display_notifications = g_object_new(GTK_TYPE_CHECK_BUTTON,
- "use-underline", TRUE,
- "label", _("Display _notifications"),
- NULL);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_dialog->display_notifications),
- g_settings_get_boolean(sensors_applet->settings,
- DISPLAY_NOTIFICATIONS));
- g_signal_connect(prefs_dialog->display_notifications,
- "toggled",
- G_CALLBACK(prefs_dialog_display_notifications_toggled),
- prefs_dialog);
-#endif
+ gtk_size_group_add_widget(prefs_dialog->size_group,
+ GTK_WIDGET(prefs_dialog->temperature_scale_combo_box));
- /* SIZE AND LAYOUT */
- /* keep all widgets same size */
- prefs_dialog->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+ gtk_size_group_add_widget(prefs_dialog->size_group,
+ GTK_WIDGET(prefs_dialog->timeout_spinbutton));
- gtk_size_group_add_widget(prefs_dialog->size_group,
- GTK_WIDGET(prefs_dialog->display_mode_combo_box));
+ g_object_unref(prefs_dialog->size_group);
- gtk_size_group_add_widget(prefs_dialog->size_group,
- GTK_WIDGET(prefs_dialog->layout_mode_combo_box));
+ prefs_dialog->globals_grid = g_object_new(GTK_TYPE_GRID,
+ "row-homogeneous", FALSE,
+ "column-homogeneous", FALSE,
+ "row-spacing", 6,
+ "column-spacing", 12,
+ NULL);
- gtk_size_group_add_widget(prefs_dialog->size_group,
- GTK_WIDGET(prefs_dialog->temperature_scale_combo_box));
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->display_header),
+ 0, 0, 2, 1);
- gtk_size_group_add_widget(prefs_dialog->size_group,
- GTK_WIDGET(prefs_dialog->timeout_spinbutton));
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->display_mode_label),
+ 1, 1, 1, 1);
- g_object_unref(prefs_dialog->size_group);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->display_mode_combo_box),
+ 2, 1, 1, 1);
- prefs_dialog->globals_grid = g_object_new(GTK_TYPE_GRID,
- "row-homogeneous", FALSE,
- "column-homogeneous", FALSE,
- "row-spacing", 6,
- "column-spacing", 12,
- NULL);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->layout_mode_label),
+ 1, 2, 1, 1);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->layout_mode_combo_box),
+ 2, 2, 1, 1);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->display_header),
- 0, 0, 2, 1);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->graph_size_label),
+ 1, 3, 1, 1);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->display_mode_label),
- 1, 1, 1, 1);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->graph_size_spinbutton),
+ 2, 3, 1, 1);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->display_mode_combo_box),
- 2, 1, 1, 1);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->temperature_scale_label),
+ 1, 4, 1, 1);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->layout_mode_label),
- 1, 2, 1, 1);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->temperature_scale_combo_box),
+ 2, 4, 1, 1);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->layout_mode_combo_box),
- 2, 2, 1, 1);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->show_units),
+ 1, 5, 1, 1);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->graph_size_label),
- 1, 3, 1, 1);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->update_header),
+ 0, 6, 2, 1);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->graph_size_spinbutton),
- 2, 3, 1, 1);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->timeout_label),
+ 1, 7, 1, 1);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->temperature_scale_label),
- 1, 4, 1, 1);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->timeout_spinbutton),
+ 2, 7, 1, 1);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->temperature_scale_combo_box),
- 2, 4, 1, 1);
+#ifdef HAVE_LIBNOTIFY
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->notifications_header),
+ 0, 8, 2, 1);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->show_units),
- 1, 5, 1, 1);
+ gtk_grid_attach(prefs_dialog->globals_grid,
+ GTK_WIDGET(prefs_dialog->display_notifications),
+ 1, 9, 1, 1);
+#endif
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->update_header),
- 0, 6, 2, 1);
+ gtk_widget_set_valign(GTK_WIDGET(prefs_dialog->globals_grid), GTK_ALIGN_START);
+ gtk_widget_set_margin_start(GTK_WIDGET(prefs_dialog->globals_grid), 12);
+ gtk_widget_set_margin_end(GTK_WIDGET(prefs_dialog->globals_grid), 12);
+ gtk_widget_set_margin_top(GTK_WIDGET(prefs_dialog->globals_grid), 12);
+ gtk_widget_set_margin_bottom(GTK_WIDGET(prefs_dialog->globals_grid), 12);
+
+ prefs_dialog->view = g_object_new(GTK_TYPE_TREE_VIEW,
+ "model", GTK_TREE_MODEL(sensors_applet->sensors),
+ "rules-hint", TRUE,
+ "reorderable", FALSE,
+ "enable-search", TRUE,
+ "search-column", LABEL_COLUMN,
+ NULL);
+
+ /* get double clicks on rows - do same as configure sensor
+ * button clicks */
+ g_signal_connect(prefs_dialog->view, "row-activated",
+ G_CALLBACK(prefs_dialog_row_activated),
+ prefs_dialog);
+
+ prefs_dialog->id_renderer = gtk_cell_renderer_text_new();
+ prefs_dialog->label_renderer = gtk_cell_renderer_text_new();
+ g_object_set(prefs_dialog->label_renderer,
+ "editable", TRUE,
+ NULL);
+
+ g_signal_connect(prefs_dialog->label_renderer, "edited",
+ G_CALLBACK(prefs_dialog_sensor_name_changed),
+ prefs_dialog);
+
+ prefs_dialog->enable_renderer = gtk_cell_renderer_toggle_new();
+ g_signal_connect(prefs_dialog->enable_renderer, "toggled",
+ G_CALLBACK(prefs_dialog_sensor_toggled),
+ prefs_dialog);
+ prefs_dialog->icon_renderer = gtk_cell_renderer_pixbuf_new();
+
+ prefs_dialog->id_column = gtk_tree_view_column_new_with_attributes(_("Sensor"),
+ prefs_dialog->id_renderer,
+ "text", ID_COLUMN,
+ NULL);
+
+ gtk_tree_view_column_set_min_width(prefs_dialog->id_column, 90);
+
+ prefs_dialog->label_column = gtk_tree_view_column_new_with_attributes(_("Label"),
+ prefs_dialog->label_renderer,
+ "text", LABEL_COLUMN,
+ "visible", VISIBLE_COLUMN,
+ NULL);
+
+ gtk_tree_view_column_set_min_width(prefs_dialog->label_column, 100);
+
+ /* create the tooltip */
+ gtk_widget_set_tooltip_text(GTK_WIDGET(prefs_dialog->view),
+ _("Labels can be edited directly by clicking on them."));
+ prefs_dialog->enable_column = gtk_tree_view_column_new_with_attributes(_("Enabled"),
+ prefs_dialog->enable_renderer,
+ "active", ENABLE_COLUMN,
+ "visible", VISIBLE_COLUMN,
+ NULL);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->timeout_label),
- 1, 7, 1, 1);
+ prefs_dialog->icon_column = gtk_tree_view_column_new_with_attributes(_("Icon"),
+ prefs_dialog->icon_renderer,
+ "pixbuf", ICON_PIXBUF_COLUMN,
+ "visible", VISIBLE_COLUMN,
+ NULL);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->timeout_spinbutton),
- 2, 7, 1, 1);
+ gtk_tree_view_append_column(prefs_dialog->view, prefs_dialog->id_column);
+ gtk_tree_view_append_column(prefs_dialog->view, prefs_dialog->icon_column);
+ gtk_tree_view_append_column(prefs_dialog->view, prefs_dialog->label_column);
+ gtk_tree_view_append_column(prefs_dialog->view, prefs_dialog->enable_column);
+ gtk_tree_view_columns_autosize(prefs_dialog->view);
-#ifdef HAVE_LIBNOTIFY
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->notifications_header),
- 0, 8, 2, 1);
+ prefs_dialog->scrolled_window = g_object_new(GTK_TYPE_SCROLLED_WINDOW,
+ "hadjustment", NULL,
+ "height-request", 200,
+ "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
+ "vadjustment",NULL,
+ "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
+ NULL);
- gtk_grid_attach(prefs_dialog->globals_grid,
- GTK_WIDGET(prefs_dialog->display_notifications),
- 1, 9, 1, 1);
-#endif
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(prefs_dialog->scrolled_window), GTK_SHADOW_IN);
- gtk_widget_set_valign(GTK_WIDGET(prefs_dialog->globals_grid), GTK_ALIGN_START);
- gtk_widget_set_margin_start(GTK_WIDGET(prefs_dialog->globals_grid), 12);
- gtk_widget_set_margin_end(GTK_WIDGET(prefs_dialog->globals_grid), 12);
- gtk_widget_set_margin_top(GTK_WIDGET(prefs_dialog->globals_grid), 12);
- gtk_widget_set_margin_bottom(GTK_WIDGET(prefs_dialog->globals_grid), 12);
-
- prefs_dialog->view = g_object_new(GTK_TYPE_TREE_VIEW,
- "model", GTK_TREE_MODEL(sensors_applet->sensors),
- "rules-hint", TRUE,
- "reorderable", FALSE,
- "enable-search", TRUE,
- "search-column", LABEL_COLUMN,
- NULL);
-
- /* get double clicks on rows - do same as configure sensor
- * button clicks */
- g_signal_connect(prefs_dialog->view, "row-activated",
- G_CALLBACK(prefs_dialog_row_activated),
- prefs_dialog);
-
- prefs_dialog->id_renderer = gtk_cell_renderer_text_new();
- prefs_dialog->label_renderer = gtk_cell_renderer_text_new();
- g_object_set(prefs_dialog->label_renderer,
- "editable", TRUE,
- NULL);
-
- g_signal_connect(prefs_dialog->label_renderer, "edited",
- G_CALLBACK(prefs_dialog_sensor_name_changed),
- prefs_dialog);
-
- prefs_dialog->enable_renderer = gtk_cell_renderer_toggle_new();
- g_signal_connect(prefs_dialog->enable_renderer, "toggled",
- G_CALLBACK(prefs_dialog_sensor_toggled),
- prefs_dialog);
- prefs_dialog->icon_renderer = gtk_cell_renderer_pixbuf_new();
-
- prefs_dialog->id_column = gtk_tree_view_column_new_with_attributes(_("Sensor"),
- prefs_dialog->id_renderer,
- "text", ID_COLUMN,
- NULL);
+ gtk_container_add(GTK_CONTAINER(prefs_dialog->scrolled_window), GTK_WIDGET(prefs_dialog->view));
- gtk_tree_view_column_set_min_width(prefs_dialog->id_column, 90);
-
- prefs_dialog->label_column = gtk_tree_view_column_new_with_attributes(_("Label"),
- prefs_dialog->label_renderer,
- "text", LABEL_COLUMN,
- "visible", VISIBLE_COLUMN,
- NULL);
-
- gtk_tree_view_column_set_min_width(prefs_dialog->label_column, 100);
-
- /* create the tooltip */
- gtk_widget_set_tooltip_text(GTK_WIDGET(prefs_dialog->view),
- _("Labels can be edited directly by clicking on them."));
- prefs_dialog->enable_column = gtk_tree_view_column_new_with_attributes(_("Enabled"),
- prefs_dialog->enable_renderer,
- "active", ENABLE_COLUMN,
- "visible", VISIBLE_COLUMN,
- NULL);
-
- prefs_dialog->icon_column = gtk_tree_view_column_new_with_attributes(_("Icon"),
- prefs_dialog->icon_renderer,
- "pixbuf", ICON_PIXBUF_COLUMN,
- "visible", VISIBLE_COLUMN,
- NULL);
- gtk_tree_view_append_column(prefs_dialog->view,
- prefs_dialog->id_column);
- gtk_tree_view_append_column(prefs_dialog->view,
- prefs_dialog->icon_column);
- gtk_tree_view_append_column(prefs_dialog->view,
- prefs_dialog->label_column);
- gtk_tree_view_append_column(prefs_dialog->view,
- prefs_dialog->enable_column);
-
- gtk_tree_view_columns_autosize(prefs_dialog->view);
-
- prefs_dialog->scrolled_window = g_object_new(GTK_TYPE_SCROLLED_WINDOW,
- "hadjustment", NULL,
- "height-request", 200,
- "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
- "vadjustment",NULL,
- "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
- NULL);
-
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(prefs_dialog->scrolled_window),
- GTK_SHADOW_IN);
-
- gtk_container_add(GTK_CONTAINER(prefs_dialog->scrolled_window), GTK_WIDGET(prefs_dialog->view));
-
- /* GtkTree Selection */
- sensors_applet->selection = gtk_tree_view_get_selection(prefs_dialog->view);
- /* allow user to only select one row at a time at most */
- gtk_tree_selection_set_mode(sensors_applet->selection, GTK_SELECTION_SINGLE);
- /* when selection is changed, make sure sensor_config button is
- activated */
-
- /* Create buttons for user to interact with sensors tree */
- prefs_dialog->sensor_up_button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_GO_UP));
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
+ /* GtkTree Selection */
+ sensors_applet->selection = gtk_tree_view_get_selection(prefs_dialog->view);
+ /* allow user to only select one row at a time at most */
+ gtk_tree_selection_set_mode(sensors_applet->selection, GTK_SELECTION_SINGLE);
+ /* when selection is changed, make sure sensor_config button is activated */
- g_signal_connect(prefs_dialog->sensor_up_button, "clicked",
- G_CALLBACK(prefs_dialog_sensor_up_button_clicked),
- prefs_dialog);
+ /* Create buttons for user to interact with sensors tree */
+ prefs_dialog->sensor_up_button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_GO_UP));
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
- prefs_dialog->sensor_down_button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_GO_DOWN));
- gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE);
+ g_signal_connect(prefs_dialog->sensor_up_button, "clicked",
+ G_CALLBACK(prefs_dialog_sensor_up_button_clicked),
+ prefs_dialog);
- g_signal_connect(prefs_dialog->sensor_down_button, "clicked",
- G_CALLBACK(prefs_dialog_sensor_down_button_clicked),
- prefs_dialog);
+ prefs_dialog->sensor_down_button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_GO_DOWN));
+ gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE);
+ g_signal_connect(prefs_dialog->sensor_down_button, "clicked",
+ G_CALLBACK(prefs_dialog_sensor_down_button_clicked),
+ prefs_dialog);
- prefs_dialog->buttons_box = GTK_BUTTON_BOX(gtk_button_box_new(GTK_ORIENTATION_VERTICAL));
+ prefs_dialog->buttons_box = GTK_BUTTON_BOX(gtk_button_box_new(GTK_ORIENTATION_VERTICAL));
- gtk_button_box_set_layout(GTK_BUTTON_BOX(prefs_dialog->buttons_box),
- GTK_BUTTONBOX_SPREAD);
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(prefs_dialog->buttons_box), GTK_BUTTONBOX_SPREAD);
- gtk_box_pack_start(GTK_BOX(prefs_dialog->buttons_box), GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(prefs_dialog->buttons_box), GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(prefs_dialog->buttons_box), GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(prefs_dialog->buttons_box), GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE, FALSE, 0);
- prefs_dialog->sensors_hbox = g_object_new(GTK_TYPE_BOX,
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "border-width", 5,
- "homogeneous", FALSE,
- "spacing", 5,
- NULL);
+ prefs_dialog->sensors_hbox = g_object_new(GTK_TYPE_BOX,
+ "orientation", GTK_ORIENTATION_HORIZONTAL,
+ "border-width", 5,
+ "homogeneous", FALSE,
+ "spacing", 5,
+ NULL);
- gtk_box_pack_start(prefs_dialog->sensors_hbox,
- GTK_WIDGET(prefs_dialog->scrolled_window),
- TRUE, TRUE, 0); /* make sure window takes
- * up most of room */
-
- gtk_box_pack_start(prefs_dialog->sensors_hbox,
- GTK_WIDGET(prefs_dialog->buttons_box),
- FALSE, FALSE, 0);
-
-
- /* Sensor Config button */
- /* initially make button insensitive until user selects a row
- from the sensors tree */
- prefs_dialog->sensor_config_button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_PROPERTIES));
- g_object_set(prefs_dialog->sensor_config_button,
- "sensitive", FALSE,
- NULL);
-
-
- g_signal_connect(sensors_applet->selection,
- "changed",
- G_CALLBACK(prefs_dialog_selection_changed),
- prefs_dialog);
-
- /* pass selection to signal handler so we can give user a
- sensors_applet->prefs_dialog with the selected rows alarm
- value and enable */
- g_signal_connect(prefs_dialog->sensor_config_button, "clicked",
- G_CALLBACK(prefs_dialog_sensor_config_button_clicked),
- prefs_dialog);
-
- prefs_dialog->sensor_config_hbox = g_object_new(GTK_TYPE_BOX,
- "orientation", GTK_ORIENTATION_HORIZONTAL,
- "border-width", 5,
- "homogeneous", FALSE,
- "spacing", 0,
- NULL);
- gtk_box_pack_end(prefs_dialog->sensor_config_hbox,
- GTK_WIDGET(prefs_dialog->sensor_config_button),
- FALSE, FALSE, 0);
-
- /* pack sensors_vbox */
- prefs_dialog->sensors_vbox = g_object_new(GTK_TYPE_BOX,
- "orientation", GTK_ORIENTATION_VERTICAL,
- "border-width", 5,
- "homogeneous", FALSE,
- "spacing", 0,
- NULL);
+ gtk_box_pack_start(prefs_dialog->sensors_hbox,
+ GTK_WIDGET(prefs_dialog->scrolled_window),
+ TRUE, TRUE, 0); /* make sure window takes up most of room */
+
+ gtk_box_pack_start(prefs_dialog->sensors_hbox,
+ GTK_WIDGET(prefs_dialog->buttons_box),
+ FALSE, FALSE, 0);
+
+ /* Sensor Config button */
+ /* initially make button insensitive until user selects a row
+ from the sensors tree */
+ prefs_dialog->sensor_config_button = GTK_BUTTON(gtk_button_new_from_stock(GTK_STOCK_PROPERTIES));
+ g_object_set(prefs_dialog->sensor_config_button,
+ "sensitive", FALSE,
+ NULL);
+
+ g_signal_connect(sensors_applet->selection,
+ "changed",
+ G_CALLBACK(prefs_dialog_selection_changed),
+ prefs_dialog);
+
+ /* pass selection to signal handler so we can give user a
+ sensors_applet->prefs_dialog with the selected rows alarm
+ value and enable */
+ g_signal_connect(prefs_dialog->sensor_config_button, "clicked",
+ G_CALLBACK(prefs_dialog_sensor_config_button_clicked),
+ prefs_dialog);
+
+ prefs_dialog->sensor_config_hbox = g_object_new(GTK_TYPE_BOX,
+ "orientation", GTK_ORIENTATION_HORIZONTAL,
+ "border-width", 5,
+ "homogeneous", FALSE,
+ "spacing", 0,
+ NULL);
+ gtk_box_pack_end(prefs_dialog->sensor_config_hbox,
+ GTK_WIDGET(prefs_dialog->sensor_config_button),
+ FALSE, FALSE, 0);
+
+ /* pack sensors_vbox */
+ prefs_dialog->sensors_vbox = g_object_new(GTK_TYPE_BOX,
+ "orientation", GTK_ORIENTATION_VERTICAL,
+ "border-width", 5,
+ "homogeneous", FALSE,
+ "spacing", 0,
+ NULL);
- gtk_box_pack_start(prefs_dialog->sensors_vbox,
- GTK_WIDGET(prefs_dialog->sensors_hbox),
- TRUE, TRUE, 0);
- gtk_box_pack_start(prefs_dialog->sensors_vbox,
- GTK_WIDGET(prefs_dialog->sensor_config_hbox),
- FALSE, FALSE, 0);
+ gtk_box_pack_start(prefs_dialog->sensors_vbox,
+ GTK_WIDGET(prefs_dialog->sensors_hbox),
+ TRUE, TRUE, 0);
+ gtk_box_pack_start(prefs_dialog->sensors_vbox,
+ GTK_WIDGET(prefs_dialog->sensor_config_hbox),
+ FALSE, FALSE, 0);
- prefs_dialog->notebook = g_object_new(GTK_TYPE_NOTEBOOK,
- NULL);
+ prefs_dialog->notebook = g_object_new(GTK_TYPE_NOTEBOOK, NULL);
- gtk_notebook_append_page(prefs_dialog->notebook,
- GTK_WIDGET(prefs_dialog->globals_grid),
- gtk_label_new(_("General Options")));
+ gtk_notebook_append_page(prefs_dialog->notebook,
+ GTK_WIDGET(prefs_dialog->globals_grid),
+ gtk_label_new(_("General Options")));
- gtk_notebook_append_page(prefs_dialog->notebook,
- GTK_WIDGET(prefs_dialog->sensors_vbox),
- gtk_label_new(_("Sensors")));
+ gtk_notebook_append_page(prefs_dialog->notebook,
+ GTK_WIDGET(prefs_dialog->sensors_vbox),
+ gtk_label_new(_("Sensors")));
- /* pack notebook into prefs_dialog */
- content_area = gtk_dialog_get_content_area (prefs_dialog->dialog);
- gtk_box_pack_start (GTK_BOX(content_area),
- GTK_WIDGET(prefs_dialog->notebook), TRUE, TRUE, 0);
+ /* pack notebook into prefs_dialog */
+ content_area = gtk_dialog_get_content_area (prefs_dialog->dialog);
+ gtk_box_pack_start (GTK_BOX(content_area), GTK_WIDGET(prefs_dialog->notebook), TRUE, TRUE, 0);
- gtk_widget_show_all(GTK_WIDGET(prefs_dialog->dialog));
+ gtk_widget_show_all(GTK_WIDGET(prefs_dialog->dialog));
}
diff --git a/sensors-applet/prefs-dialog.h b/sensors-applet/prefs-dialog.h
index 331850b..14c3a1e 100644
--- a/sensors-applet/prefs-dialog.h
+++ b/sensors-applet/prefs-dialog.h
@@ -26,41 +26,39 @@
#include "sensors-applet.h"
typedef struct {
- SensorsApplet *sensors_applet;
- GtkDialog *dialog;
- GtkNotebook *notebook;
-
- /* widgets for global prefs */
- GtkSpinButton *timeout_spinbutton, *graph_size_spinbutton;
- GtkGrid *globals_grid;
- GtkHSeparator *globals_separator;
- GtkComboBoxText *display_mode_combo_box, *layout_mode_combo_box, *temperature_scale_combo_box;
- GtkLabel *timeout_label, *display_mode_label, *layout_mode_label, *temperature_scale_label, *graph_size_label, *update_header, *display_header;
- GtkAdjustment *timeout_adjust, *graph_size_adjust;
- GtkWidget *show_units;
+ SensorsApplet *sensors_applet;
+ GtkDialog *dialog;
+ GtkNotebook *notebook;
+
+ /* widgets for global prefs */
+ GtkSpinButton *timeout_spinbutton, *graph_size_spinbutton;
+ GtkGrid *globals_grid;
+ GtkHSeparator *globals_separator;
+ GtkComboBoxText *display_mode_combo_box, *layout_mode_combo_box, *temperature_scale_combo_box;
+ GtkLabel *timeout_label, *display_mode_label, *layout_mode_label, *temperature_scale_label, *graph_size_label, *update_header, *display_header;
+ GtkAdjustment *timeout_adjust, *graph_size_adjust;
+ GtkWidget *show_units;
#ifdef HAVE_LIBNOTIFY
- GtkCheckButton *display_notifications;
- GtkLabel *notifications_header;
+ GtkCheckButton *display_notifications;
+ GtkLabel *notifications_header;
#endif
-
- /* widgets for sensors tree */
- GtkTreeView *view;
- GtkTreeViewColumn *id_column, *label_column, *enable_column, *icon_column;
- GtkCellRenderer *id_renderer, *label_renderer, *enable_renderer, *icon_renderer;
- GtkScrolledWindow *scrolled_window;
-
- GtkButtonBox *buttons_box; /* holds sensor reorder buttons */
- GtkBox *sensors_hbox; /* holds scrolled window and
- * buttons_vbox */
- GtkBox *sensors_vbox; /* holds sensors_hbox and sensor_config_hbox */
- GtkBox *sensor_config_hbox; /* holds config button */
- GtkSizeGroup *size_group; /* so comboboxes all
- * request the same size */
-
- GtkButton *sensor_up_button;
- GtkButton *sensor_down_button;
- GtkButton *sensor_config_button;
+
+ /* widgets for sensors tree */
+ GtkTreeView *view;
+ GtkTreeViewColumn *id_column, *label_column, *enable_column, *icon_column;
+ GtkCellRenderer *id_renderer, *label_renderer, *enable_renderer, *icon_renderer;
+ GtkScrolledWindow *scrolled_window;
+
+ GtkButtonBox *buttons_box; /* holds sensor reorder buttons */
+ GtkBox *sensors_hbox; /* holds scrolled window and buttons_vbox */
+ GtkBox *sensors_vbox; /* holds sensors_hbox and sensor_config_hbox */
+ GtkBox *sensor_config_hbox; /* holds config button */
+ GtkSizeGroup *size_group; /* so comboboxes all request the same size */
+
+ GtkButton *sensor_up_button;
+ GtkButton *sensor_down_button;
+ GtkButton *sensor_config_button;
} PrefsDialog;
/* function prototypes */
diff --git a/sensors-applet/sensor-config-dialog.c b/sensors-applet/sensor-config-dialog.c
index 901324f..16583f9 100644
--- a/sensors-applet/sensor-config-dialog.c
+++ b/sensors-applet/sensor-config-dialog.c
@@ -28,749 +28,707 @@
#define VALUE_DECIMAL_PLACES 3
typedef struct {
- SensorsApplet *sensors_applet;
-
- GtkWidget *dialog;
- /* icon widgets */
- GtkLabel *icon_header, *icon_type_label;
- GtkComboBox *icon_type_combo_box;
- GtkAlignment *icon_type_combo_box_aligner;
- GtkCellRenderer *icon_renderer;
-
- /* Graph Color chooser */
- GtkColorButton *graph_color_button;
- GtkAlignment *graph_color_button_aligner;
- GtkLabel *graph_color_label, *graph_header;
-
- /* multiplier and offset widgets */
- GtkLabel *scale_header, *multiplier_label, *offset_label;
- GtkAlignment *multiplier_spinbutton_aligner, *offset_spinbutton_aligner;
- GtkAdjustment *multiplier_adjust, *offset_adjust;
- GtkSpinButton *multiplier_spinbutton, *offset_spinbutton;
-
- GtkLabel *limits_header;
- GtkLabel *low_value_label, *high_value_label;
- GtkAlignment *low_value_spinbutton_aligner, *high_value_spinbutton_aligner;
- GtkAdjustment *low_value_adjust, *high_value_adjust;
- GtkSpinButton *low_value_spinbutton, *high_value_spinbutton;
-
- /* alarm widgets */
- GtkLabel *alarm_header;
- GtkLabel *low_alarm_command_label, *high_alarm_command_label, *alarm_timeout_label;
- GtkAlignment *alarm_timeout_spinbutton_aligner;
- GtkAdjustment *alarm_timeout_adjust;
- GtkSpinButton *alarm_timeout_spinbutton;
- GtkGrid *grid;
- GtkAlignment *alarm_enable_aligner;
- GtkCheckButton *alarm_enable_checkbutton;
- GtkEntry *low_alarm_command_entry, *high_alarm_command_entry;
-
- GtkSizeGroup *size_group;
+ SensorsApplet *sensors_applet;
+
+ GtkWidget *dialog;
+ /* icon widgets */
+ GtkLabel *icon_header, *icon_type_label;
+ GtkComboBox *icon_type_combo_box;
+ GtkAlignment *icon_type_combo_box_aligner;
+ GtkCellRenderer *icon_renderer;
+
+ /* Graph Color chooser */
+ GtkColorButton *graph_color_button;
+ GtkAlignment *graph_color_button_aligner;
+ GtkLabel *graph_color_label, *graph_header;
+
+ /* multiplier and offset widgets */
+ GtkLabel *scale_header, *multiplier_label, *offset_label;
+ GtkAlignment *multiplier_spinbutton_aligner, *offset_spinbutton_aligner;
+ GtkAdjustment *multiplier_adjust, *offset_adjust;
+ GtkSpinButton *multiplier_spinbutton, *offset_spinbutton;
+
+ GtkLabel *limits_header;
+ GtkLabel *low_value_label, *high_value_label;
+ GtkAlignment *low_value_spinbutton_aligner, *high_value_spinbutton_aligner;
+ GtkAdjustment *low_value_adjust, *high_value_adjust;
+ GtkSpinButton *low_value_spinbutton, *high_value_spinbutton;
+
+ /* alarm widgets */
+ GtkLabel *alarm_header;
+ GtkLabel *low_alarm_command_label, *high_alarm_command_label, *alarm_timeout_label;
+ GtkAlignment *alarm_timeout_spinbutton_aligner;
+ GtkAdjustment *alarm_timeout_adjust;
+ GtkSpinButton *alarm_timeout_spinbutton;
+ GtkGrid *grid;
+ GtkAlignment *alarm_enable_aligner;
+ GtkCheckButton *alarm_enable_checkbutton;
+ GtkEntry *low_alarm_command_entry, *high_alarm_command_entry;
+
+ GtkSizeGroup *size_group;
} SensorConfigDialog;
+
static void sensor_config_dialog_response(GtkDialog *dialog,
gint response,
gpointer data) {
- SensorConfigDialog *config_dialog;
- GError *error = NULL;
- config_dialog = (SensorConfigDialog *)data;
+ SensorConfigDialog *config_dialog;
+ GError *error = NULL;
+
+ config_dialog = (SensorConfigDialog *)data;
- switch (response) {
+ switch (response) {
case GTK_RESPONSE_HELP:
- g_debug("loading help in config dialog");
+ g_debug("loading help in config dialog");
#if GTK_CHECK_VERSION (3, 22, 0)
- gtk_show_uri_on_window(NULL,
+ gtk_show_uri_on_window(NULL,
#else
- gtk_show_uri(NULL,
+ gtk_show_uri(NULL,
#endif
- "help:mate-sensors-applet/sensors-applet-sensors#sensors-applet-sensor-config-dialog",
- gtk_get_current_event_time(),
- &error);
-
- if (error) {
- g_debug("Could not open help document: %s ",error->message);
- g_error_free (error);
- }
- break;
+ "help:mate-sensors-applet/sensors-applet-sensors#sensors-applet-sensor-config-dialog",
+ gtk_get_current_event_time(),
+ &error);
+
+ if (error) {
+ g_debug("Could not open help document: %s ",error->message);
+ g_error_free (error);
+ }
+ break;
+
default:
- g_debug("destroying config dialog");
- gtk_widget_destroy(GTK_WIDGET(dialog));
- }
+ g_debug("destroying config dialog");
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+ }
}
static void sensor_config_dialog_multiplier_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- gdouble value;
-
- value = gtk_spin_button_get_value(spinbutton);
-
- gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
- &model,
- &iter);
-
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors),
- &iter);
- gtk_tree_store_set(config_dialog->sensors_applet->sensors,
- &iter,
- MULTIPLIER_COLUMN, value,
- -1);
-
- sensors_applet_update_sensor(config_dialog->sensors_applet, path);
- gtk_tree_path_free(path);
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gdouble value;
+
+ value = gtk_spin_button_get_value(spinbutton);
+
+ gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+ &model,
+ &iter);
+
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+ gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+ &iter,
+ MULTIPLIER_COLUMN, value,
+ -1);
+
+ sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+ gtk_tree_path_free(path);
}
static void sensor_config_dialog_offset_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- gdouble value;
-
- value = gtk_spin_button_get_value(spinbutton);
-
- gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
- &model,
- &iter);
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors),
- &iter);
- gtk_tree_store_set(config_dialog->sensors_applet->sensors,
- &iter,
- OFFSET_COLUMN, value,
- -1);
-
- sensors_applet_update_sensor(config_dialog->sensors_applet, path);
- gtk_tree_path_free(path);
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gdouble value;
+
+ value = gtk_spin_button_get_value(spinbutton);
+
+ gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+ &model,
+ &iter);
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+ gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+ &iter,
+ OFFSET_COLUMN, value,
+ -1);
+
+ sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+ gtk_tree_path_free(path);
}
static void sensor_config_dialog_low_value_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- gdouble value;
-
- value = gtk_spin_button_get_value(spinbutton);
-
- gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
- &model,
- &iter);
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors),
- &iter);
-
- gtk_tree_store_set(config_dialog->sensors_applet->sensors,
- &iter,
- LOW_VALUE_COLUMN, value,
- -1);
-
- sensors_applet_update_sensor(config_dialog->sensors_applet, path);
- gtk_tree_path_free(path);
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gdouble value;
+
+ value = gtk_spin_button_get_value(spinbutton);
+
+ gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+ &model,
+ &iter);
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+ gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+ &iter,
+ LOW_VALUE_COLUMN, value,
+ -1);
+
+ sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+ gtk_tree_path_free(path);
}
static void sensor_config_dialog_high_value_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- gdouble value;
-
- value = gtk_spin_button_get_value(spinbutton);
-
- gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
- &model,
- &iter);
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors),
- &iter);
-
- gtk_tree_store_set(config_dialog->sensors_applet->sensors,
- &iter,
- HIGH_VALUE_COLUMN, value,
- -1);
-
- sensors_applet_update_sensor(config_dialog->sensors_applet, path);
- gtk_tree_path_free(path);
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gdouble value;
+
+ value = gtk_spin_button_get_value(spinbutton);
+
+ gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+ &model,
+ &iter);
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+ gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+ &iter,
+ HIGH_VALUE_COLUMN, value,
+ -1);
+
+ sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+ gtk_tree_path_free(path);
}
static void sensor_config_dialog_alarm_toggled(GtkToggleButton *button, SensorConfigDialog *config_dialog) {
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
-
- gboolean value;
- value = gtk_toggle_button_get_active(button);
-
- /* update state of alarm widgets */
- gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->alarm_timeout_label), value);
- gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), value);
- gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->low_alarm_command_label), value);
- gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->low_alarm_command_entry), value);
- gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->high_alarm_command_label), value);
- gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->high_alarm_command_entry), value);
-
- gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
- &model,
- &iter);
-
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors),
- &iter);
-
- gtk_tree_store_set(config_dialog->sensors_applet->sensors,
- &iter,
- ALARM_ENABLE_COLUMN, value,
- -1);
-
- sensors_applet_update_sensor(config_dialog->sensors_applet, path);
- gtk_tree_path_free(path);
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ gboolean value;
+ value = gtk_toggle_button_get_active(button);
+
+ /* update state of alarm widgets */
+ gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->alarm_timeout_label), value);
+ gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), value);
+ gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->low_alarm_command_label), value);
+ gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->low_alarm_command_entry), value);
+ gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->high_alarm_command_label), value);
+ gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->high_alarm_command_entry), value);
+
+ gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+ &model,
+ &iter);
+
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+ gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+ &iter,
+ ALARM_ENABLE_COLUMN, value,
+ -1);
+
+ sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+ gtk_tree_path_free(path);
}
static void sensor_config_dialog_alarm_timeout_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- gint value;
-
- value = gtk_spin_button_get_value_as_int(spinbutton);
-
- gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
- &model,
- &iter);
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors),
- &iter);
-
- sensors_applet_all_alarms_off(config_dialog->sensors_applet, path);
- gtk_tree_store_set(config_dialog->sensors_applet->sensors,
- &iter,
- ALARM_TIMEOUT_COLUMN, value,
- -1);
-
- sensors_applet_update_sensor(config_dialog->sensors_applet, path);
- gtk_tree_path_free(path);
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ gint value;
+
+ value = gtk_spin_button_get_value_as_int(spinbutton);
+
+ gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+ &model,
+ &iter);
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+ sensors_applet_all_alarms_off(config_dialog->sensors_applet, path);
+ gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+ &iter,
+ ALARM_TIMEOUT_COLUMN, value,
+ -1);
+
+ sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+ gtk_tree_path_free(path);
}
static void sensor_config_dialog_alarm_command_edited(GtkEntry *command_entry, SensorConfigDialog *config_dialog, NotifType notif_type) {
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
-
- gchar *value;
- g_object_get(command_entry, "text", &value, NULL);
-
- gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
- &model,
- &iter);
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors),
- &iter);
-
- sensors_applet_alarm_off(config_dialog->sensors_applet, path, notif_type);
-
- gtk_tree_store_set(config_dialog->sensors_applet->sensors,
- &iter,
- (notif_type == LOW_ALARM ?
- LOW_ALARM_COMMAND_COLUMN : HIGH_ALARM_COMMAND_COLUMN),
- value,
- -1);
- g_free(value);
- sensors_applet_update_sensor(config_dialog->sensors_applet, path);
- gtk_tree_path_free(path);
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ gchar *value;
+ g_object_get(command_entry, "text", &value, NULL);
+
+ gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+ &model,
+ &iter);
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+ sensors_applet_alarm_off(config_dialog->sensors_applet, path, notif_type);
+
+ gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+ &iter,
+ (notif_type == LOW_ALARM ? LOW_ALARM_COMMAND_COLUMN : HIGH_ALARM_COMMAND_COLUMN),
+ value,
+ -1);
+ g_free(value);
+ sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+ gtk_tree_path_free(path);
}
static void sensor_config_dialog_low_alarm_command_edited(GtkEntry *command_entry, SensorConfigDialog *config_dialog) {
- sensor_config_dialog_alarm_command_edited(command_entry,
- config_dialog,
- LOW_ALARM);
+ sensor_config_dialog_alarm_command_edited(command_entry,
+ config_dialog,
+ LOW_ALARM);
}
static void sensor_config_dialog_high_alarm_command_edited(GtkEntry *command_entry, SensorConfigDialog *config_dialog) {
- sensor_config_dialog_alarm_command_edited(command_entry,
- config_dialog,
- HIGH_ALARM);
+ sensor_config_dialog_alarm_command_edited(command_entry,
+ config_dialog,
+ HIGH_ALARM);
}
-static void sensor_config_dialog_icon_type_changed(GtkComboBox *icon_type_combo_box,
+static void sensor_config_dialog_icon_type_changed(GtkComboBox *icon_type_combo_box,
SensorConfigDialog *config_dialog) {
- GtkTreeModel *icons_model;
- GtkTreeIter icons_iter;
-
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreePath *path;
-
- GdkPixbuf *new_icon;
- IconType icon_type;
-
- icons_model = gtk_combo_box_get_model(icon_type_combo_box);
- if (gtk_combo_box_get_active_iter(icon_type_combo_box,
- &icons_iter)) {
-
- gtk_tree_model_get(icons_model, &icons_iter,
- 0, &new_icon,
- -1);
-
- icon_type = gtk_combo_box_get_active(icon_type_combo_box);
- gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
- &model,
- &iter);
-
- path = gtk_tree_model_get_path(model, &iter);
- gtk_tree_store_set(config_dialog->sensors_applet->sensors,
- &iter,
- ICON_TYPE_COLUMN, icon_type,
- ICON_PIXBUF_COLUMN, new_icon,
- -1);
- g_object_unref(new_icon);
- sensors_applet_icon_changed(config_dialog->sensors_applet, path);
- gtk_tree_path_free(path);
- }
+ GtkTreeModel *icons_model;
+ GtkTreeIter icons_iter;
+
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ GdkPixbuf *new_icon;
+ IconType icon_type;
+
+ icons_model = gtk_combo_box_get_model(icon_type_combo_box);
+ if (gtk_combo_box_get_active_iter(icon_type_combo_box, &icons_iter)) {
+
+ gtk_tree_model_get(icons_model, &icons_iter,
+ 0, &new_icon,
+ -1);
+
+ icon_type = gtk_combo_box_get_active(icon_type_combo_box);
+ gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+ &model,
+ &iter);
+
+ path = gtk_tree_model_get_path(model, &iter);
+ gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+ &iter,
+ ICON_TYPE_COLUMN, icon_type,
+ ICON_PIXBUF_COLUMN, new_icon,
+ -1);
+ g_object_unref(new_icon);
+ sensors_applet_icon_changed(config_dialog->sensors_applet, path);
+ gtk_tree_path_free(path);
+ }
}
static void sensor_config_dialog_graph_color_set(GtkColorChooser *color_chooser,
SensorConfigDialog *config_dialog) {
- GtkTreeModel *model;
- GtkTreePath *path;
- GtkTreeIter iter;
- GtkWidget *content_area;
- gchar *color_string;
- GdkRGBA color;
+ GtkTreeModel *model;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+ GtkWidget *content_area;
+ gchar *color_string;
+ GdkRGBA color;
- gtk_color_chooser_get_rgba(color_chooser,
- &color);
+ gtk_color_chooser_get_rgba(color_chooser, &color);
- color_string = g_strdup_printf ("#%02X%02X%02X", (int)(0.5 + CLAMP (color.red, 0., 1.) * 255.),
- (int)(0.5 + CLAMP (color.green, 0., 1.) * 255.),
- (int)(0.5 + CLAMP (color.blue, 0., 1.) * 255.));
+ color_string = g_strdup_printf ("#%02X%02X%02X", (int)(0.5 + CLAMP (color.red, 0., 1.) * 255.),
+ (int)(0.5 + CLAMP (color.green, 0., 1.) * 255.),
+ (int)(0.5 + CLAMP (color.blue, 0., 1.) * 255.));
- gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
- &model,
- &iter);
+ gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+ &model,
+ &iter);
- gtk_tree_store_set(config_dialog->sensors_applet->sensors,
- &iter,
- GRAPH_COLOR_COLUMN, color_string,
- -1);
+ gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+ &iter,
+ GRAPH_COLOR_COLUMN, color_string,
+ -1);
- g_free(color_string);
+ g_free(color_string);
- path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors),
- &iter);
- sensors_applet_update_sensor(config_dialog->sensors_applet, path);
- gtk_tree_path_free(path);
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+ sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+ gtk_tree_path_free(path);
}
void sensor_config_dialog_create(SensorsApplet *sensors_applet) {
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkWidget *content_area;
-
- SensorConfigDialog *config_dialog;
-
- GtkListStore *icon_store;
- IconType count;
- GdkPixbuf *pixbuf;
- GdkRGBA graph_color;
- gchar *sensor_label;
- gchar *header_text;
-
- /* instance variables for data */
- gdouble low_value, high_value, multiplier, offset;
- gboolean alarm_enable;
- gchar *low_alarm_command, *high_alarm_command;
- gint alarm_timeout;
- IconType icon_type;
- gchar *graph_color_string;
-
- config_dialog = g_new0(SensorConfigDialog, 1);
- config_dialog->sensors_applet = sensors_applet;
-
- gtk_tree_selection_get_selected(sensors_applet->selection,
- &model,
- &iter);
- /* get current values of alarm and its enable */
- gtk_tree_model_get(model, &iter,
- LOW_VALUE_COLUMN, &low_value,
- HIGH_VALUE_COLUMN, &high_value,
- ALARM_ENABLE_COLUMN, &alarm_enable,
- LOW_ALARM_COMMAND_COLUMN, &low_alarm_command,
- HIGH_ALARM_COMMAND_COLUMN, &high_alarm_command,
- ALARM_TIMEOUT_COLUMN, &alarm_timeout,
- MULTIPLIER_COLUMN, &multiplier,
- OFFSET_COLUMN, &offset,
- ICON_TYPE_COLUMN, &icon_type,
- GRAPH_COLOR_COLUMN, &graph_color_string,
- LABEL_COLUMN, &sensor_label,
- -1);
- header_text = g_strdup_printf("%s - %s", _("Sensor Properties"), sensor_label);
-
- config_dialog->dialog = gtk_dialog_new_with_buttons(header_text,
- GTK_WINDOW(sensors_applet->prefs_dialog->dialog),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_HELP,
- GTK_RESPONSE_HELP,
- GTK_STOCK_CLOSE,
- GTK_RESPONSE_CLOSE,
- NULL);
- gtk_window_set_icon_name(GTK_WINDOW(config_dialog->dialog),
- "sensors-applet");
-
- g_free(header_text);
- g_free(sensor_label);
-
- g_object_set(config_dialog->dialog,
- "border-width", 12,
- NULL);
-
- g_signal_connect(config_dialog->dialog,
- "response",
- G_CALLBACK(sensor_config_dialog_response),
- config_dialog);
-
-
- /* graph stuff */
- header_text = g_markup_printf_escaped("<b>%s</b>", _("Graph"));
- config_dialog->graph_header = g_object_new(GTK_TYPE_LABEL,
- "use-markup", TRUE,
- "label", header_text,
- "xalign", 0.0,
- NULL);
- g_free(header_text);
-
-
- gdk_rgba_parse(&graph_color, graph_color_string);
- config_dialog->graph_color_button = GTK_COLOR_BUTTON(gtk_color_button_new_with_rgba(&graph_color));
- gtk_widget_set_halign (GTK_WIDGET(config_dialog->graph_color_button), GTK_ALIGN_START);
- gtk_widget_set_valign (GTK_WIDGET(config_dialog->graph_color_button), GTK_ALIGN_START);
-
- gtk_color_button_set_title(config_dialog->graph_color_button, _("Graph Color"));
-
- config_dialog->graph_color_label = g_object_new(GTK_TYPE_LABEL,
- "label", _("Graph _color"),
- "mnemonic-widget", config_dialog->graph_color_button,
- "use-underline", TRUE,
- "xalign", 0.0,
- NULL);
-
- g_signal_connect(config_dialog->graph_color_button, "color-set",
- G_CALLBACK(sensor_config_dialog_graph_color_set),
- config_dialog);
-
- /* icon stuff */
- header_text = g_markup_printf_escaped("<b>%s</b>", _("Icon"));
- config_dialog->icon_header = g_object_new(GTK_TYPE_LABEL,
- "use-markup", TRUE,
- "label", header_text,
- "xalign", 0.0,
- NULL);
- g_free(header_text);
-
- /* icon type */
- icon_store = gtk_list_store_new(1, GDK_TYPE_PIXBUF);
-
- /* populate list with icons */
- for (count = CPU_ICON; count < NUM_ICONS; count++) {
- pixbuf = sensors_applet_load_icon(count);
- if (pixbuf) {
- gtk_list_store_insert(icon_store, &iter, count);
- gtk_list_store_set(icon_store, &iter,
- 0, pixbuf,
- -1);
- /* let list hold icons */
- g_object_unref(pixbuf);
- }
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GtkWidget *content_area;
+
+ SensorConfigDialog *config_dialog;
+
+ GtkListStore *icon_store;
+ IconType count;
+ GdkPixbuf *pixbuf;
+ GdkRGBA graph_color;
+ gchar *sensor_label;
+ gchar *header_text;
+
+ /* instance variables for data */
+ gdouble low_value, high_value, multiplier, offset;
+ gboolean alarm_enable;
+ gchar *low_alarm_command, *high_alarm_command;
+ gint alarm_timeout;
+ IconType icon_type;
+ gchar *graph_color_string;
+
+ config_dialog = g_new0(SensorConfigDialog, 1);
+ config_dialog->sensors_applet = sensors_applet;
+
+ gtk_tree_selection_get_selected(sensors_applet->selection,
+ &model,
+ &iter);
+ /* get current values of alarm and its enable */
+ gtk_tree_model_get(model, &iter,
+ LOW_VALUE_COLUMN, &low_value,
+ HIGH_VALUE_COLUMN, &high_value,
+ ALARM_ENABLE_COLUMN, &alarm_enable,
+ LOW_ALARM_COMMAND_COLUMN, &low_alarm_command,
+ HIGH_ALARM_COMMAND_COLUMN, &high_alarm_command,
+ ALARM_TIMEOUT_COLUMN, &alarm_timeout,
+ MULTIPLIER_COLUMN, &multiplier,
+ OFFSET_COLUMN, &offset,
+ ICON_TYPE_COLUMN, &icon_type,
+ GRAPH_COLOR_COLUMN, &graph_color_string,
+ LABEL_COLUMN, &sensor_label,
+ -1);
+ header_text = g_strdup_printf("%s - %s", _("Sensor Properties"), sensor_label);
+
+ config_dialog->dialog = gtk_dialog_new_with_buttons(header_text,
+ GTK_WINDOW(sensors_applet->prefs_dialog->dialog),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_HELP,
+ GTK_RESPONSE_HELP,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ NULL);
+ gtk_window_set_icon_name(GTK_WINDOW(config_dialog->dialog), "sensors-applet");
+
+ g_free(header_text);
+ g_free(sensor_label);
+
+ g_object_set(config_dialog->dialog,
+ "border-width", 12,
+ NULL);
+
+ g_signal_connect(config_dialog->dialog,
+ "response",
+ G_CALLBACK(sensor_config_dialog_response),
+ config_dialog);
+
+ /* graph stuff */
+ header_text = g_markup_printf_escaped("<b>%s</b>", _("Graph"));
+ config_dialog->graph_header = g_object_new(GTK_TYPE_LABEL,
+ "use-markup", TRUE,
+ "label", header_text,
+ "xalign", 0.0,
+ NULL);
+ g_free(header_text);
+
+ gdk_rgba_parse(&graph_color, graph_color_string);
+ config_dialog->graph_color_button = GTK_COLOR_BUTTON(gtk_color_button_new_with_rgba(&graph_color));
+ gtk_widget_set_halign (GTK_WIDGET(config_dialog->graph_color_button), GTK_ALIGN_START);
+ gtk_widget_set_valign (GTK_WIDGET(config_dialog->graph_color_button), GTK_ALIGN_START);
+
+ gtk_color_button_set_title(config_dialog->graph_color_button, _("Graph Color"));
+
+ config_dialog->graph_color_label = g_object_new(GTK_TYPE_LABEL,
+ "label", _("Graph _color"),
+ "mnemonic-widget", config_dialog->graph_color_button,
+ "use-underline", TRUE,
+ "xalign", 0.0,
+ NULL);
+
+ g_signal_connect(config_dialog->graph_color_button, "color-set",
+ G_CALLBACK(sensor_config_dialog_graph_color_set),
+ config_dialog);
+
+ /* icon stuff */
+ header_text = g_markup_printf_escaped("<b>%s</b>", _("Icon"));
+ config_dialog->icon_header = g_object_new(GTK_TYPE_LABEL,
+ "use-markup", TRUE,
+ "label", header_text,
+ "xalign", 0.0,
+ NULL);
+ g_free(header_text);
+
+ /* icon type */
+ icon_store = gtk_list_store_new(1, GDK_TYPE_PIXBUF);
+
+ /* populate list with icons */
+ for (count = CPU_ICON; count < NUM_ICONS; count++) {
+ pixbuf = sensors_applet_load_icon(count);
+ if (pixbuf) {
+ gtk_list_store_insert(icon_store, &iter, count);
+ gtk_list_store_set(icon_store, &iter, 0, pixbuf, -1);
+ /* let list hold icons */
+ g_object_unref(pixbuf);
}
-
- config_dialog->icon_type_combo_box = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(icon_store)));
+ }
+
+ config_dialog->icon_type_combo_box = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(icon_store)));
gtk_widget_set_halign (GTK_WIDGET(config_dialog->icon_type_combo_box), GTK_ALIGN_START);
gtk_widget_set_valign (GTK_WIDGET(config_dialog->icon_type_combo_box), GTK_ALIGN_START);
- config_dialog->icon_renderer = gtk_cell_renderer_pixbuf_new();
- gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box),
- GTK_CELL_RENDERER(config_dialog->icon_renderer),
- FALSE);
-
- gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box),
- GTK_CELL_RENDERER(config_dialog->icon_renderer),
- "pixbuf", 0);
-
- gtk_combo_box_set_active(config_dialog->icon_type_combo_box,
- icon_type);
-
- g_signal_connect(config_dialog->icon_type_combo_box, "changed",
- G_CALLBACK(sensor_config_dialog_icon_type_changed),
- config_dialog);
-
-
-
- config_dialog->icon_type_label = g_object_new(GTK_TYPE_LABEL,
- "label", _("Sensor _icon"),
- "mnemonic-widget", config_dialog->icon_type_combo_box,
- "use-underline", TRUE,
- "xalign", 0.0,
- NULL);
-
- header_text = g_markup_printf_escaped("<b>%s</b>", _("Scaling Parameters"));
- config_dialog->scale_header = g_object_new(GTK_TYPE_LABEL,
- "use-markup", TRUE,
- "label", header_text,
- "xalign", 0.0,
- NULL);
- g_free(header_text);
-
- /* do multiplier and offset widgets */
- config_dialog->multiplier_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
- "value", 1.0,
- "lower", 0.001,
- "upper", 1000.0,
- "step-increment", 0.1,
- "page-increment", 1.0,
- "page-size", 1.0,
- NULL);
-
-
- config_dialog->multiplier_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
- "adjustment", config_dialog->multiplier_adjust,
- "digits", VALUE_DECIMAL_PLACES,
- "value", multiplier,
- "width-chars", SPINBUTTON_WIDTH_CHARS,
- NULL);
+ config_dialog->icon_renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box),
+ GTK_CELL_RENDERER(config_dialog->icon_renderer),
+ FALSE);
+
+ gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box),
+ GTK_CELL_RENDERER(config_dialog->icon_renderer),
+ "pixbuf", 0);
+
+ gtk_combo_box_set_active(config_dialog->icon_type_combo_box, icon_type);
+
+ g_signal_connect(config_dialog->icon_type_combo_box, "changed",
+ G_CALLBACK(sensor_config_dialog_icon_type_changed),
+ config_dialog);
+
+ config_dialog->icon_type_label = g_object_new(GTK_TYPE_LABEL,
+ "label", _("Sensor _icon"),
+ "mnemonic-widget", config_dialog->icon_type_combo_box,
+ "use-underline", TRUE,
+ "xalign", 0.0,
+ NULL);
+
+ header_text = g_markup_printf_escaped("<b>%s</b>", _("Scaling Parameters"));
+ config_dialog->scale_header = g_object_new(GTK_TYPE_LABEL,
+ "use-markup", TRUE,
+ "label", header_text,
+ "xalign", 0.0,
+ NULL);
+ g_free(header_text);
+
+ /* do multiplier and offset widgets */
+ config_dialog->multiplier_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+ "value", 1.0,
+ "lower", 0.001,
+ "upper", 1000.0,
+ "step-increment", 0.1,
+ "page-increment", 1.0,
+ "page-size", 1.0,
+ NULL);
+
+ config_dialog->multiplier_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+ "adjustment", config_dialog->multiplier_adjust,
+ "digits", VALUE_DECIMAL_PLACES,
+ "value", multiplier,
+ "width-chars", SPINBUTTON_WIDTH_CHARS,
+ NULL);
gtk_widget_set_halign (GTK_WIDGET(config_dialog->multiplier_spinbutton), GTK_ALIGN_START);
gtk_widget_set_valign (GTK_WIDGET(config_dialog->multiplier_spinbutton), GTK_ALIGN_START);
- config_dialog->multiplier_label = g_object_new(GTK_TYPE_LABEL,
- "label", _("Sensor value _multiplier"),
- "mnemonic-widget", config_dialog->multiplier_spinbutton,
- "use-underline", TRUE,
- "xalign", 0.0,
- NULL);
-
-
- g_signal_connect(config_dialog->multiplier_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_multiplier_changed), config_dialog);
-
-
- config_dialog->offset_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
- "value", 0.0,
- "lower", -1000.000,
- "upper", 1000.000,
- "step-increment", 0.01,
- "page-increment", 1.0,
- "page-size", 1.0,
- NULL);
-
- config_dialog->offset_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
- "adjustment", config_dialog->offset_adjust,
- "digits", VALUE_DECIMAL_PLACES,
- "value", (gdouble)offset,
- "width-chars", SPINBUTTON_WIDTH_CHARS,
- NULL);
-
+ config_dialog->multiplier_label = g_object_new(GTK_TYPE_LABEL,
+ "label", _("Sensor value _multiplier"),
+ "mnemonic-widget", config_dialog->multiplier_spinbutton,
+ "use-underline", TRUE,
+ "xalign", 0.0,
+ NULL);
+
+ g_signal_connect(config_dialog->multiplier_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_multiplier_changed), config_dialog);
+
+ config_dialog->offset_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+ "value", 0.0,
+ "lower", -1000.000,
+ "upper", 1000.000,
+ "step-increment", 0.01,
+ "page-increment", 1.0,
+ "page-size", 1.0,
+ NULL);
+
+ config_dialog->offset_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+ "adjustment", config_dialog->offset_adjust,
+ "digits", VALUE_DECIMAL_PLACES,
+ "value", (gdouble)offset,
+ "width-chars", SPINBUTTON_WIDTH_CHARS,
+ NULL);
+
gtk_widget_set_halign (GTK_WIDGET(config_dialog->offset_spinbutton), GTK_ALIGN_START);
gtk_widget_set_valign (GTK_WIDGET(config_dialog->offset_spinbutton), GTK_ALIGN_START);
- config_dialog->offset_label = g_object_new(GTK_TYPE_LABEL,
- "label", _("Sensor value _offset"),
- "mnemonic-widget", config_dialog->offset_spinbutton,
- "use-underline", TRUE,
- "xalign", 0.0,
- NULL);
+ config_dialog->offset_label = g_object_new(GTK_TYPE_LABEL,
+ "label", _("Sensor value _offset"),
+ "mnemonic-widget", config_dialog->offset_spinbutton,
+ "use-underline", TRUE,
+ "xalign", 0.0,
+ NULL);
+
+ g_signal_connect(config_dialog->offset_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_offset_changed), config_dialog);
+
+ /* now do alarm widgets */
+ header_text = g_markup_printf_escaped("<b>%s</b>", _("Sensor Limits"));
+ config_dialog->limits_header = g_object_new(GTK_TYPE_LABEL,
+ "use-markup", TRUE,
+ "label", header_text,
+ "xalign", 0.0,
+ NULL);
+ g_free(header_text);
+
+ config_dialog->low_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+ "value", 0.0,
+ "lower", -100000.0,
+ "upper", 100000.0,
+ "step-increment", 1.0,
+ "page-increment", 10.0,
+ "page-size", 100.0,
+ NULL);
+
+ config_dialog->low_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+ "adjustment", config_dialog->low_value_adjust,
+ "digits", VALUE_DECIMAL_PLACES,
+ "value", low_value,
+ "width-chars", SPINBUTTON_WIDTH_CHARS,
+ NULL);
+
+ gtk_widget_set_halign (GTK_WIDGET(config_dialog->low_value_spinbutton), GTK_ALIGN_START);
+ gtk_widget_set_valign (GTK_WIDGET(config_dialog->low_value_spinbutton), GTK_ALIGN_START);
+
+ config_dialog->low_value_label = g_object_new(GTK_TYPE_LABEL,
+ "label", _("Sensor _low value"),
+ "mnemonic-widget", config_dialog->low_value_spinbutton,
+ "use-underline", TRUE,
+ "xalign", 0.0,
+ NULL);
+
+ g_signal_connect(config_dialog->low_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_low_value_changed), config_dialog);
+
+ config_dialog->high_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+ "value", 0.0,
+ "lower", -100000.0,
+ "upper", 100000.0,
+ "step-increment", 1.0,
+ "page-increment", 10.0,
+ "page-size", 100.0,
+ NULL);
+
+ config_dialog->high_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+ "adjustment", config_dialog->high_value_adjust,
+ "digits", VALUE_DECIMAL_PLACES,
+ "value", high_value,
+ "width-chars", SPINBUTTON_WIDTH_CHARS,
+ NULL);
+
+ gtk_widget_set_halign (GTK_WIDGET(config_dialog->high_value_spinbutton), GTK_ALIGN_START);
+ gtk_widget_set_valign (GTK_WIDGET(config_dialog->high_value_spinbutton), GTK_ALIGN_START);
- g_signal_connect(config_dialog->offset_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_offset_changed), config_dialog);
+ config_dialog->high_value_label = g_object_new(GTK_TYPE_LABEL,
+ "label", _("Sensor _high value"),
+ "mnemonic-widget", config_dialog->high_value_spinbutton,
+ "use-underline", TRUE,
+ "xalign", 0.0,
+ NULL);
+ g_signal_connect(config_dialog->high_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_high_value_changed), config_dialog);
- /* now do alarm widgets */
- header_text = g_markup_printf_escaped("<b>%s</b>", _("Sensor Limits"));
- config_dialog->limits_header = g_object_new(GTK_TYPE_LABEL,
- "use-markup", TRUE,
- "label", header_text,
- "xalign", 0.0,
- NULL);
- g_free(header_text);
+ header_text = g_markup_printf_escaped("<b>%s</b>", _("Alarm"));
+ config_dialog->alarm_header = g_object_new(GTK_TYPE_LABEL,
+ "use-markup", TRUE,
+ "label", header_text,
+ "xalign", 0.0,
+ NULL);
+ g_free(header_text);
- config_dialog->low_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+ config_dialog->alarm_timeout_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
"value", 0.0,
- "lower", -100000.0,
- "upper", 100000.0,
+ "lower", 0.0,
+ "upper", 10000.0,
"step-increment", 1.0,
"page-increment", 10.0,
"page-size", 100.0,
NULL);
-
- config_dialog->low_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
- "adjustment", config_dialog->low_value_adjust,
- "digits", VALUE_DECIMAL_PLACES,
- "value", low_value,
+ config_dialog->alarm_timeout_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+ "adjustment", config_dialog->alarm_timeout_adjust,
+ "digits", 0,
+ "value", (gdouble)alarm_timeout,
"width-chars", SPINBUTTON_WIDTH_CHARS,
+ "sensitive", alarm_enable,
+ NULL);
- NULL);
-
- gtk_widget_set_halign (GTK_WIDGET(config_dialog->low_value_spinbutton), GTK_ALIGN_START);
- gtk_widget_set_valign (GTK_WIDGET(config_dialog->low_value_spinbutton), GTK_ALIGN_START);
+ gtk_widget_set_halign (GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), GTK_ALIGN_START);
+ gtk_widget_set_valign (GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), GTK_ALIGN_START);
- config_dialog->low_value_label = g_object_new(GTK_TYPE_LABEL,
- "label", _("Sensor _low value"),
- "mnemonic-widget", config_dialog->low_value_spinbutton,
+ config_dialog->alarm_timeout_label = g_object_new(GTK_TYPE_LABEL,
+ "label", _("Alarm _repeat interval (secs)"),
+ "mnemonic-widget", config_dialog->alarm_timeout_spinbutton,
"use-underline", TRUE,
"xalign", 0.0,
+ "sensitive", alarm_enable,
+ NULL);
- NULL);
-
-
- g_signal_connect(config_dialog->low_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_low_value_changed), config_dialog);
-
- config_dialog->high_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
- "value", 0.0,
- "lower", -100000.0,
- "upper", 100000.0,
- "step-increment", 1.0,
- "page-increment", 10.0,
- "page-size", 100.0,
- NULL);
-
-
- config_dialog->high_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
- "adjustment", config_dialog->high_value_adjust,
- "digits", VALUE_DECIMAL_PLACES,
- "value", high_value,
- "width-chars", SPINBUTTON_WIDTH_CHARS,
-
- NULL);
-
- gtk_widget_set_halign (GTK_WIDGET(config_dialog->high_value_spinbutton), GTK_ALIGN_START);
- gtk_widget_set_valign (GTK_WIDGET(config_dialog->high_value_spinbutton), GTK_ALIGN_START);
-
- config_dialog->high_value_label = g_object_new(GTK_TYPE_LABEL,
- "label", _("Sensor _high value"),
- "mnemonic-widget", config_dialog->high_value_spinbutton,
- "use-underline", TRUE,
- "xalign", 0.0,
+ g_signal_connect(config_dialog->alarm_timeout_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_alarm_timeout_changed), config_dialog);
- NULL);
-
-
- g_signal_connect(config_dialog->high_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_high_value_changed), config_dialog);
-
-
- header_text = g_markup_printf_escaped("<b>%s</b>", _("Alarm"));
- config_dialog->alarm_header = g_object_new(GTK_TYPE_LABEL,
- "use-markup", TRUE,
- "label", header_text,
- "xalign", 0.0,
- NULL);
- g_free(header_text);
-
- config_dialog->alarm_timeout_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
- "value", 0.0,
- "lower", 0.0,
- "upper", 10000.0,
- "step-increment", 1.0,
- "page-increment", 10.0,
- "page-size", 100.0,
- NULL);
-
- config_dialog->alarm_timeout_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
- "adjustment", config_dialog->alarm_timeout_adjust,
- "digits", 0,
- "value", (gdouble)alarm_timeout,
- "width-chars", SPINBUTTON_WIDTH_CHARS,
- "sensitive", alarm_enable,
-
- NULL);
-
- gtk_widget_set_halign (GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), GTK_ALIGN_START);
- gtk_widget_set_valign (GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), GTK_ALIGN_START);
-
- config_dialog->alarm_timeout_label = g_object_new(GTK_TYPE_LABEL,
- "label", _("Alarm _repeat interval (secs)"),
- "mnemonic-widget", config_dialog->alarm_timeout_spinbutton,
-
- "use-underline", TRUE,
- "xalign", 0.0,
+ config_dialog->low_alarm_command_entry = g_object_new(GTK_TYPE_ENTRY,
+ "text", low_alarm_command,
+ "width-chars", 25,
"sensitive", alarm_enable,
NULL);
- g_signal_connect(config_dialog->alarm_timeout_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_alarm_timeout_changed), config_dialog);
+ g_free(low_alarm_command);
- config_dialog->low_alarm_command_entry = g_object_new(GTK_TYPE_ENTRY,
- "text", low_alarm_command,
- "width-chars", 25,
- "sensitive", alarm_enable,
- NULL);
+ config_dialog->low_alarm_command_label = g_object_new(GTK_TYPE_LABEL,
+ "use-underline", TRUE,
+ "label", _("Lo_w alarm command"),
+ "mnemonic-widget", config_dialog->low_alarm_command_entry,
+ "xalign", 0.0,
+ "sensitive", alarm_enable,
+ NULL);
- g_free(low_alarm_command);
+ g_signal_connect(config_dialog->low_alarm_command_entry,
+ "changed",
+ G_CALLBACK(sensor_config_dialog_low_alarm_command_edited),
+ config_dialog);
- config_dialog->low_alarm_command_label = g_object_new(GTK_TYPE_LABEL,
- "use-underline", TRUE,
- "label", _("Lo_w alarm command"),
- "mnemonic-widget", config_dialog->low_alarm_command_entry,
- "xalign", 0.0,
+ config_dialog->high_alarm_command_entry = g_object_new(GTK_TYPE_ENTRY,
+ "text", high_alarm_command,
+ "width-chars", 25,
"sensitive", alarm_enable,
-
NULL);
- g_signal_connect(config_dialog->low_alarm_command_entry,
- "changed",
- G_CALLBACK(sensor_config_dialog_low_alarm_command_edited),
- config_dialog);
-
- config_dialog->high_alarm_command_entry = g_object_new(GTK_TYPE_ENTRY,
- "text", high_alarm_command,
- "width-chars", 25,
- "sensitive", alarm_enable,
- NULL);
+ g_free(high_alarm_command);
- g_free(high_alarm_command);
+ config_dialog->high_alarm_command_label = g_object_new(GTK_TYPE_LABEL,
+ "use-underline", TRUE,
+ "label", _("Hi_gh alarm command"),
+ "mnemonic-widget", config_dialog->high_alarm_command_entry,
+ "xalign", 0.0,
+ "sensitive", alarm_enable,
+ NULL);
- config_dialog->high_alarm_command_label = g_object_new(GTK_TYPE_LABEL,
- "use-underline", TRUE,
- "label", _("Hi_gh alarm command"),
- "mnemonic-widget", config_dialog->high_alarm_command_entry,
- "xalign", 0.0,
- "sensitive", alarm_enable,
+ g_signal_connect(config_dialog->high_alarm_command_entry,
+ "changed",
+ G_CALLBACK(sensor_config_dialog_high_alarm_command_edited),
+ config_dialog);
- NULL);
+ config_dialog->alarm_enable_checkbutton = g_object_new(GTK_TYPE_CHECK_BUTTON,
+ "use-underline", TRUE,
+ "label", _("_Enable alarm"),
+ "active", alarm_enable,
+ "xalign", 0.0,
+ NULL);
- g_signal_connect(config_dialog->high_alarm_command_entry,
- "changed",
- G_CALLBACK(sensor_config_dialog_high_alarm_command_edited),
- config_dialog);
-
- config_dialog->alarm_enable_checkbutton = g_object_new(GTK_TYPE_CHECK_BUTTON,
- "use-underline", TRUE,
- "label", _("_Enable alarm"),
- "active", alarm_enable,
- "xalign", 0.0,
- NULL);
-
gtk_widget_set_halign (GTK_WIDGET(config_dialog->alarm_enable_checkbutton), GTK_ALIGN_START);
gtk_widget_set_valign (GTK_WIDGET(config_dialog->alarm_enable_checkbutton), GTK_ALIGN_START);
- g_signal_connect(config_dialog->alarm_enable_checkbutton, "toggled", G_CALLBACK(sensor_config_dialog_alarm_toggled), config_dialog);
-
-
-
- config_dialog->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
- gtk_size_group_add_widget(config_dialog->size_group,
- GTK_WIDGET(config_dialog->multiplier_spinbutton));
- gtk_size_group_add_widget(config_dialog->size_group,
- GTK_WIDGET(config_dialog->offset_spinbutton));
- gtk_size_group_add_widget(config_dialog->size_group,
- GTK_WIDGET(config_dialog->low_value_spinbutton));
- gtk_size_group_add_widget(config_dialog->size_group,
- GTK_WIDGET(config_dialog->high_value_spinbutton));
- gtk_size_group_add_widget(config_dialog->size_group,
- GTK_WIDGET(config_dialog->alarm_timeout_spinbutton));
- gtk_size_group_add_widget(config_dialog->size_group,
- GTK_WIDGET(config_dialog->icon_type_combo_box));
- gtk_size_group_add_widget(config_dialog->size_group,
- GTK_WIDGET(config_dialog->graph_color_button));
- g_object_unref(config_dialog->size_group);
+ g_signal_connect(config_dialog->alarm_enable_checkbutton, "toggled", G_CALLBACK(sensor_config_dialog_alarm_toggled), config_dialog);
+
+ config_dialog->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+ gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->multiplier_spinbutton));
+ gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->offset_spinbutton));
+ gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->low_value_spinbutton));
+ gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->high_value_spinbutton));
+ gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->alarm_timeout_spinbutton));
+ gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->icon_type_combo_box));
+ gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->graph_color_button));
+ g_object_unref(config_dialog->size_group);
config_dialog->grid = g_object_new(GTK_TYPE_GRID,
- "column-spacing", 5,
- "row-homogeneous", FALSE,
- "column-homogeneous", FALSE,
- "row-spacing", 6,
- "column-spacing", 12,
- NULL);
+ "column-spacing", 5,
+ "row-homogeneous", FALSE,
+ "column-homogeneous", FALSE,
+ "row-spacing", 6,
+ "column-spacing", 12,
+ NULL);
gtk_grid_attach(config_dialog->grid,
GTK_WIDGET(config_dialog->scale_header),
@@ -871,6 +829,6 @@ void sensor_config_dialog_create(SensorsApplet *sensors_applet) {
content_area = gtk_dialog_get_content_area (GTK_DIALOG(config_dialog->dialog));
gtk_box_pack_start(GTK_BOX(content_area), GTK_WIDGET(config_dialog->grid), FALSE, FALSE, 0);
- gtk_widget_show_all(config_dialog->dialog);
+ gtk_widget_show_all(config_dialog->dialog);
-}
+}