14 static GtkWidget
*wid_status
;
15 static GtkWidget
*wid_time
;
16 static GtkWidget
*wid_date
;
17 static GtkWidget
*wid_mesg
;
19 void set_data(GtkWidget
*widget
, GtkWidget
*data
) {
20 char *wstat
= gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(wid_status
)->entry
));
21 char *wtime
= gtk_entry_get_text(GTK_ENTRY(wid_time
));
22 char *wdate
= gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(wid_date
)->entry
));
23 char *wmesg
= gtk_entry_get_text(GTK_ENTRY(wid_mesg
));
24 int has_day
= (strcmp(wdate
, "ALL") != 0);
25 int has_msg
= (strcmp(wdate
, "") != 0);
26 int len
= strlen(wstat
) + 1 + strlen(wtime
) + 1;
28 len
+= has_day
? strlen(wdate
) + 1 : 0;
29 len
+= has_msg
? strlen(wmesg
) + 1 : 0;
30 newalarm
= xmalloc(len
);
32 sprintf(newalarm
, "%s@%s%s%s%s%s",
38 has_msg
? wmesg
: "");
42 void edit_dialog(const char *title
,
56 dialog
= gtk_dialog_new();
57 gtk_window_set_title(GTK_WINDOW(dialog
), title
);
58 gtk_signal_connect(GTK_OBJECT(dialog
), "delete_event",
59 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
61 gtk_signal_connect(GTK_OBJECT(dialog
), "destroy",
62 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
65 bouton
= gtk_button_new_with_label("Ok");
66 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
67 GTK_SIGNAL_FUNC(set_data
),
69 gtk_signal_connect(GTK_OBJECT(bouton
), "clicked",
70 GTK_SIGNAL_FUNC(f_ok
),
72 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
73 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
75 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
76 bouton
, TRUE
, TRUE
, 0);
77 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
78 gtk_widget_grab_default(GTK_WIDGET(bouton
));
79 gtk_widget_show(bouton
);
81 bouton
= gtk_button_new_with_label("Cancel");
82 gtk_signal_connect_object(GTK_OBJECT(bouton
), "clicked",
83 GTK_SIGNAL_FUNC(gtk_widget_destroy
),
85 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog
)->action_area
),
86 bouton
, TRUE
, TRUE
, 0);
87 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton
), GTK_CAN_DEFAULT
);
88 gtk_widget_show(bouton
);
90 gtk_container_set_border_width(GTK_CONTAINER
91 (GTK_DIALOG(dialog
)->vbox
), 6);
93 hbox
= gtk_hbox_new(FALSE
, 1);
94 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog
)->vbox
), hbox
);
95 gtk_widget_show(hbox
);
98 vbox
= gtk_vbox_new(FALSE
, 1);
99 gtk_container_add(GTK_CONTAINER(hbox
), vbox
);
100 gtk_widget_show(vbox
);
102 label
= gtk_label_new("Status");
103 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
104 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 6);
105 gtk_widget_show(label
);
107 items
= g_list_append(items
, "On");
108 items
= g_list_append(items
, "Off");
109 wid_status
= gtk_combo_new();
110 gtk_combo_set_popdown_strings(GTK_COMBO(wid_status
), items
);
111 gtk_combo_set_value_in_list(GTK_COMBO(wid_status
), TRUE
, FALSE
);
112 gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(wid_status
)->entry
), FALSE
);
113 gtk_box_pack_start(GTK_BOX(vbox
), wid_status
, FALSE
, TRUE
, 6);
114 gtk_widget_show(wid_status
);
116 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wid_status
)->entry
), "On");
118 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wid_status
)->entry
), "Off");
122 vbox
= gtk_vbox_new(FALSE
, 1);
123 gtk_container_add(GTK_CONTAINER(hbox
), vbox
);
124 gtk_widget_show(vbox
);
126 label
= gtk_label_new("Hour");
127 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
128 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 6);
129 gtk_widget_show(label
);
131 wid_time
= gtk_entry_new();
132 if (atime
) gtk_entry_set_text(GTK_ENTRY(wid_time
), atime
);
133 gtk_box_pack_start(GTK_BOX(vbox
), wid_time
, FALSE
, TRUE
, 6);
134 gtk_widget_show(wid_time
);
138 vbox
= gtk_vbox_new(FALSE
, 1);
139 gtk_container_add(GTK_CONTAINER(hbox
), vbox
);
140 gtk_widget_show(vbox
);
142 label
= gtk_label_new("Day");
143 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
144 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 6);
145 gtk_widget_show(label
);
148 items
= g_list_append(items
, "ALL");
149 items
= g_list_append(items
, "1");
150 items
= g_list_append(items
, "2");
151 items
= g_list_append(items
, "3");
152 items
= g_list_append(items
, "4");
153 items
= g_list_append(items
, "5");
154 items
= g_list_append(items
, "6");
155 items
= g_list_append(items
, "7");
156 wid_date
= gtk_combo_new();
157 gtk_combo_set_popdown_strings(GTK_COMBO(wid_date
), items
);
158 gtk_combo_set_value_in_list(GTK_COMBO(wid_date
), TRUE
, TRUE
);
159 gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(wid_date
)->entry
), FALSE
);
160 gtk_box_pack_start(GTK_BOX(vbox
), wid_date
, FALSE
, TRUE
, 6);
161 gtk_widget_show(wid_date
);
163 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(wid_date
)->entry
), adate
);
167 vbox
= gtk_vbox_new(FALSE
, 1);
168 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog
)->vbox
), vbox
);
169 gtk_widget_show(vbox
);
171 label
= gtk_label_new("Message");
172 gtk_misc_set_alignment(GTK_MISC(label
), 0.0f
, 0.5f
);
173 gtk_box_pack_start(GTK_BOX(vbox
), label
, FALSE
, FALSE
, 6);
174 gtk_widget_show(label
);
176 wid_mesg
= gtk_entry_new();
177 if (amesg
) gtk_entry_set_text(GTK_ENTRY(wid_mesg
), amesg
);
178 gtk_box_pack_start(GTK_BOX(vbox
), wid_mesg
, FALSE
, TRUE
, 6);
179 gtk_widget_show(wid_mesg
);
183 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
184 gtk_widget_show(dialog
);