2 Copyright (C) 2010-2011 wpitchoune@gmail.com
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #include "ui_sensorpref.h"
28 GtkWidget *ui_sensorpref_add_entry(GtkWidget * table,
30 const char *text, guint row)
32 GtkWidget *alig, *entry;
34 ui_pref_add_label(table, label, 0, row);
36 alig = gtk_alignment_new(0, 0.5, 0, 0);
37 gtk_alignment_set_padding(GTK_ALIGNMENT(alig), 4, 4, 4, 4);
38 entry = gtk_entry_new();
39 gtk_entry_set_text(GTK_ENTRY(entry), text);
41 gtk_container_add(GTK_CONTAINER(alig), entry);
43 gtk_table_attach(GTK_TABLE(table),
47 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
53 struct ui_sensorpref *ui_sensorpref_create(struct ui_sensorlist *ui_sensorlist,
54 struct psensor *sensor)
56 struct ui_sensorpref *pref;
58 GtkSpinButton *spin_button;
59 GtkWidget *alig, *table, *w_alarm_enabled;
61 pref = malloc(sizeof(struct ui_sensorpref));
63 table = gtk_table_new(10, 2, FALSE);
64 gtk_table_set_col_spacing(GTK_TABLE(table), 0, 0);
66 /* Section Sensor Information */
67 ui_pref_add_section_title(table, _("Sensor Information"), 0);
69 ui_pref_add_label(table, _("Id:"), 0, 1);
70 ui_pref_add_label(table, sensor->id, 1, 1);
72 stype = psensor_type_to_str(sensor->type);
73 ui_pref_add_label(table, _("Type:"), 0, 2);
74 ui_pref_add_label(table, stype, 1, 2);
76 pref->w_name = ui_sensorpref_add_entry(table,
77 _("Name:"), sensor->name, 3);
80 ui_pref_add_section_title(table, _("Graph"), 4);
82 pref->w_enabled = ui_pref_add_check_button
83 (table, _("Draw sensor curve"), sensor->enabled, 5);
85 pref->w_color = ui_pref_add_color_button
86 (table, _("Color:"), sensor->color, 6);
89 ui_pref_add_section_title(table, _("Alarm"), 7);
91 w_alarm_enabled = ui_pref_add_check_button
93 _("Activate desktop notifications"), sensor->alarm_enabled,
95 if (!is_temp_type(sensor->type))
96 gtk_widget_set_sensitive(w_alarm_enabled, FALSE);
98 ui_pref_add_label(table, _("Temperature limit:"), 0, 9);
101 = GTK_SPIN_BUTTON(gtk_spin_button_new_with_range(0, 255, 1));
102 if (!is_temp_type(sensor->type))
103 gtk_widget_set_sensitive(GTK_WIDGET(spin_button), FALSE);
104 gtk_spin_button_set_value(spin_button, sensor->alarm_limit);
105 alig = gtk_alignment_new(0, 0.5, 0, 0);
106 gtk_alignment_set_padding(GTK_ALIGNMENT(alig), 4, 4, 4, 4);
107 gtk_container_add(GTK_CONTAINER(alig), GTK_WIDGET(spin_button));
108 gtk_table_attach(GTK_TABLE(table),
112 GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
114 pref->widget = table;
115 pref->w_alarm_limit = GTK_WIDGET(spin_button);
116 pref->w_alarm_enabled = w_alarm_enabled;
117 pref->ui_sensorlist = ui_sensorlist;