13 #include <sys/types.h>
15 #include "variables.h"
17 #include "mainwindow.h"
37 gtk_clist_clear(GTK_CLIST(alarmlist
));
39 gtk_clist_freeze(GTK_CLIST(alarmlist
));
41 text_line
[0] = alrm
->on
? "ON" : "OFF";
42 text_line
[1] = alrm
->time
? alrm
->time
: "ERROR";
43 text_line
[2] = alrm
->date
? alrm
->date
: "ALL";
44 text_line
[3] = alrm
->msg
? alrm
->msg
: "";
45 row
= gtk_clist_append(GTK_CLIST(alarmlist
), text_line
);
46 gtk_clist_set_row_data(GTK_CLIST(alarmlist
), row
, (gpointer
)alrm
);
50 gtk_clist_thaw(GTK_CLIST(alarmlist
));
51 list_unsel_cb(GTK_CLIST(alarmlist
), 0, 0, NULL
, NULL
);
55 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid_backlight
), backlight
);
56 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid_blink
),
58 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid_h12
), h12
);
60 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid_itm
), 1);
61 else if (time_mode
== 2)
62 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid_bin
), 1);
64 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid_clk
), 1);
65 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid_locale
), use_locale
);
66 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid_showcal
), showcal
);
67 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wid_calalrms
), calalrms
);
68 if (light_color
) gtk_entry_set_text(GTK_ENTRY(wid_color
), light_color
);
69 if (command
) gtk_entry_set_text(GTK_ENTRY(wid_command
), command
);
70 if (msgcmd
) gtk_entry_set_text(GTK_ENTRY(wid_msgcmd
), msgcmd
);
71 if (style_name
) gtk_entry_set_text(GTK_ENTRY(wid_stylename
), style_name
);
72 if (style_dir
) gtk_entry_set_text(GTK_ENTRY(wid_styledir
), style_dir
);
79 style_dir
= gtk_entry_get_text(GTK_ENTRY(wid_styledir
));
80 style_name
= gtk_entry_get_text(GTK_ENTRY(wid_stylename
));
81 light_color
= gtk_entry_get_text(GTK_ENTRY(wid_color
));
82 command
= gtk_entry_get_text(GTK_ENTRY(wid_command
));
83 msgcmd
= gtk_entry_get_text(GTK_ENTRY(wid_msgcmd
));
84 backlight
= GTK_TOGGLE_BUTTON(wid_backlight
)->active
;
85 switch_authorized
= GTK_TOGGLE_BUTTON(wid_blink
)->active
;
86 h12
= GTK_TOGGLE_BUTTON(wid_h12
)->active
;
87 if (GTK_TOGGLE_BUTTON(wid_itm
)->active
)
89 if (GTK_TOGGLE_BUTTON(wid_bin
)->active
)
93 use_locale
= GTK_TOGGLE_BUTTON(wid_locale
)->active
;
94 showcal
= GTK_TOGGLE_BUTTON(wid_showcal
)->active
;
95 calalrms
= GTK_TOGGLE_BUTTON(wid_calalrms
)->active
;
101 void do_add(GtkWidget
*widget
, void *data
) {
102 alrm_add(&alarms
, newalarm
);
109 edit_dialog("Add alarm...", TRUE
, "12:00", NULL
, NULL
, do_add
);
113 void do_change(GtkWidget
*widget
, void *data
) {
115 char *time
= NULL
, *date
= NULL
, *ison
= NULL
, *mesg
= NULL
, *at
;
116 char *tokstr
= xstrdup(newalarm
);
117 char *toksav
= tokstr
;
119 alrm
= (Alarm
*)gtk_clist_get_row_data(GTK_CLIST(alarmlist
), selected_row
);
121 at
= strchr(newalarm
, '@');
122 if (at
) ison
= strtok(tokstr
, "@");
123 time
= strtok(at
? NULL
: tokstr
, "-.");
124 if (strchr(newalarm
, '-')) date
= strtok(NULL
, ".");
125 mesg
= strtok(NULL
, "\n\0");
131 alrm
->entry
= xstrdup(newalarm
);
132 alrm
->time
= time
? xstrdup(time
) : NULL
;
133 alrm
->date
= date
? xstrdup(date
) : NULL
;
134 alrm
->on
= ison
? getbool(ison
) : TRUE
;
135 alrm
->msg
= mesg
? xstrdup(mesg
) : NULL
;
146 alrm
= (Alarm
*)gtk_clist_get_row_data(GTK_CLIST(alarmlist
), selected_row
);
147 edit_dialog("Edit alarm...", alrm
->on
, alrm
->time
, alrm
->date
, alrm
->msg
, do_change
);
151 void switch_onoff() {
154 /* get selected default box */
155 alrm
= (Alarm
*)gtk_clist_get_row_data(GTK_CLIST(alarmlist
), selected_row
);
156 alrm
->on
= !alrm
->on
;
157 /* set text in both rows */
158 gtk_clist_set_text(GTK_CLIST(alarmlist
), selected_row
, 0,
159 alrm
->on
? "ON" : "OFF");
164 void remove_alarm() {
167 alrm
= (Alarm
*)gtk_clist_get_row_data(GTK_CLIST(alarmlist
), selected_row
);
169 while (prev
&& (prev
->next
!= alrm
)) {
172 if (alrm
== alarms
) {
174 } else if (prev
!= NULL
) {
175 prev
->next
= alrm
->next
;
177 fprintf(stderr
, "Error when removing alarm...\n");