16 static GtkWidget
*wid_status
;
17 static GtkWidget
*wid_time
;
18 static GtkWidget
*wid_date
;
19 static GtkWidget
*wid_mesg
;
21 void set_data(GtkWidget
*widget
, GtkWidget
*data
) {
22 char *wstat
= gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(wid_status
)->entry
));
23 char *wtime
= gtk_entry_get_text(GTK_ENTRY(wid_time
));
24 char *wdate
= gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(wid_date
)->entry
));
25 char *wmesg
= gtk_entry_get_text(GTK_ENTRY(wid_mesg
));
26 int has_day
= (strcmp(wdate
, "ALL") != 0);
27 int has_msg
= (strcmp(wdate
, "") != 0);
28 int len
= strlen(wstat
) + 1 + strlen(wtime
) + 1;
30 len
+= has_day
? strlen(wdate
) + 1 : 0;
31 len
+= has_msg
? strlen(wmesg
) + 1 : 0;
32 newalarm
= xmalloc(len
);
34 sprintf(newalarm
, "%s@%s%s%s%s%s",
40 has_msg
? wmesg
: "");
44 void edit_dialog(const char *title
,
58 dialog
= gtk_dialog_new();
59 gtk_window_set_title(GTK_WINDOW(dialog
), title
);
60 gtk_signal_connect(GTK_OBJECT(dialog
), "delete_event",
61 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
63 gtk_signal_connect(GTK_OBJECT(dialog
), "destroy",
64 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
67 bouton
= gtk_button_new_with_label("Ok");
68 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
69 GTK_SIGNAL_FUNC(set_data
),
71 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
72 GTK_SIGNAL_FUNC(f_ok
),
74 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
75 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
77 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
78 bouton
, TRUE
, TRUE
, 0);
79 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
80 gtk_widget_grab_default(GTK_WIDGET(bouton
));
81 gtk_widget_show(bouton
);
83 bouton
= gtk_button_new_with_label("Cancel");
84 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
85 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
87 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
88 bouton
, TRUE
, TRUE
, 0);
89 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
90 gtk_widget_show(bouton
);
92 gtk_container_set_border_width(GTK_CONTAINER
93 (GTK_DIALOG(dialog
)->vbox
), 6);
95 hbox
= gtk_hbox_new(FALSE
, 1);
96 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog
)->vbox
), hbox
);
97 gtk_widget_show(hbox
);
100 vbox
= gtk_vbox_new(FALSE
, 1);
101 gtk_container_add(GTK_CONTAINER(hbox
), vbox
);
102 gtk_widget_show(vbox
);
104 label
= gtk_label_new("Status");
105 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
106 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 6);
107 gtk_widget_show(label
);
109 items
= g_list_append(items
, "On");
110 items
= g_list_append(items
, "Off");
111 wid_status
= gtk_combo_new();
112 gtk_combo_set_popdown_strings(GTK_COMBO(wid_status
), items
);
113 gtk_combo_set_value_in_list(GTK_COMBO(wid_status
), TRUE
, FALSE
);
114 gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(wid_status
)->entry
), FALSE
);
115 gtk_box_pack_start(GTK_BOX(vbox
), wid_status
, FALSE
, TRUE
, 6);
116 gtk_widget_show(wid_status
);
118 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wid_status
)->entry
), "On");
120 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wid_status
)->entry
), "Off");
124 vbox
= gtk_vbox_new(FALSE
, 1);
125 gtk_container_add(GTK_CONTAINER(hbox
), vbox
);
126 gtk_widget_show(vbox
);
128 label
= gtk_label_new("Hour");
129 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
130 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 6);
131 gtk_widget_show(label
);
133 wid_time
= gtk_entry_new();
134 if (atime
) gtk_entry_set_text(GTK_ENTRY(wid_time
), atime
);
135 gtk_box_pack_start(GTK_BOX(vbox
), wid_time
, FALSE
, TRUE
, 6);
136 gtk_widget_show(wid_time
);
140 vbox
= gtk_vbox_new(FALSE
, 1);
141 gtk_container_add(GTK_CONTAINER(hbox
), vbox
);
142 gtk_widget_show(vbox
);
144 label
= gtk_label_new("Day");
145 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
146 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 6);
147 gtk_widget_show(label
);
150 items
= g_list_append(items
, "ALL");
151 items
= g_list_append(items
, "1");
152 items
= g_list_append(items
, "2");
153 items
= g_list_append(items
, "3");
154 items
= g_list_append(items
, "4");
155 items
= g_list_append(items
, "5");
156 items
= g_list_append(items
, "6");
157 items
= g_list_append(items
, "7");
158 wid_date
= gtk_combo_new();
159 gtk_combo_set_popdown_strings(GTK_COMBO(wid_date
), items
);
160 gtk_combo_set_value_in_list(GTK_COMBO(wid_date
), TRUE
, TRUE
);
161 gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(wid_date
)->entry
), FALSE
);
162 gtk_box_pack_start(GTK_BOX(vbox
), wid_date
, FALSE
, TRUE
, 6);
163 gtk_widget_show(wid_date
);
165 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wid_date
)->entry
), adate
);
169 vbox
= gtk_vbox_new(FALSE
, 1);
170 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog
)->vbox
), vbox
);
171 gtk_widget_show(vbox
);
173 label
= gtk_label_new("Message");
174 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
175 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 6);
176 gtk_widget_show(label
);
178 wid_mesg
= gtk_entry_new();
179 if (amesg
) gtk_entry_set_text(GTK_ENTRY(wid_mesg
), amesg
);
180 gtk_box_pack_start(GTK_BOX(vbox
), wid_mesg
, FALSE
, TRUE
, 6);
181 gtk_widget_show(wid_mesg
);
185 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
186 gtk_widget_show(dialog
);