wmclockmon: fix global variables causing linkage failure
[dockapps.git] / wmclockmon / wmclockmon-config / dialogs.c
blob978dbe949008de8dfdf0dea594720184f2a8d4f3
1 /*
2 * dialogs.
3 */
6 #include "../config.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <strings.h>
11 #include <gtk/gtk.h>
12 #include "defines.h"
13 #include "dialogs.h"
16 void ync_dialog(const char *title, const char *text, void *f_yes, void *f_no) {
17 GtkWidget *dialog;
18 GtkWidget *bouton;
19 GtkWidget *label;
21 dialog = gtk_dialog_new();
22 gtk_window_set_title(GTK_WINDOW(dialog), title);
23 gtk_signal_connect(GTK_OBJECT(dialog), "delete_event",
24 GTK_SIGNAL_FUNC(gtk_widget_destroy),
25 NULL);
26 gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
27 GTK_SIGNAL_FUNC(gtk_widget_destroy),
28 NULL);
30 bouton = gtk_button_new_with_label("Yes");
31 gtk_signal_connect(GTK_OBJECT(bouton), "clicked",
32 GTK_SIGNAL_FUNC(f_yes),
33 NULL);
34 gtk_signal_connect_object(GTK_OBJECT(bouton), "clicked",
35 GTK_SIGNAL_FUNC(gtk_widget_destroy),
36 GTK_OBJECT(dialog));
37 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
38 bouton, TRUE, TRUE, 0);
39 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton), GTK_CAN_DEFAULT);
40 gtk_widget_grab_default(GTK_WIDGET(bouton));
41 gtk_widget_show(bouton);
43 bouton = gtk_button_new_with_label("No");
44 gtk_signal_connect(GTK_OBJECT(bouton), "clicked",
45 GTK_SIGNAL_FUNC(f_no),
46 NULL);
47 gtk_signal_connect_object(GTK_OBJECT(bouton), "clicked",
48 GTK_SIGNAL_FUNC(gtk_widget_destroy),
49 GTK_OBJECT(dialog));
50 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
51 bouton, TRUE, TRUE, 0);
52 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton), GTK_CAN_DEFAULT);
53 gtk_widget_show(bouton);
55 bouton = gtk_button_new_with_label("Cancel");
56 gtk_signal_connect_object(GTK_OBJECT(bouton), "clicked",
57 GTK_SIGNAL_FUNC(gtk_widget_destroy),
58 GTK_OBJECT(dialog));
59 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
60 bouton, TRUE, TRUE, 0);
61 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton), GTK_CAN_DEFAULT);
62 gtk_widget_show(bouton);
64 gtk_container_set_border_width(GTK_CONTAINER
65 (GTK_DIALOG(dialog)->vbox), 6);
66 label = gtk_label_new(text);
67 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE,
68 TRUE, 6);
69 gtk_widget_show(label);
71 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
72 gtk_widget_show(dialog);
76 void ok_dialog(const char *title, const char *text) {
77 GtkWidget *dialog;
78 GtkWidget *bouton;
79 GtkWidget *label;
81 dialog = gtk_dialog_new();
82 gtk_window_set_title(GTK_WINDOW(dialog), title);
83 gtk_signal_connect(GTK_OBJECT(dialog), "delete_event",
84 GTK_SIGNAL_FUNC(gtk_widget_destroy),
85 NULL);
86 gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
87 GTK_SIGNAL_FUNC(gtk_widget_destroy),
88 NULL);
90 bouton = gtk_button_new_with_label("OK");
91 gtk_signal_connect_object(GTK_OBJECT(bouton), "clicked",
92 GTK_SIGNAL_FUNC(gtk_widget_destroy),
93 GTK_OBJECT(dialog));
94 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
95 bouton, TRUE, TRUE, 0);
96 GTK_WIDGET_SET_FLAGS(GTK_WIDGET(bouton), GTK_CAN_DEFAULT);
97 gtk_widget_grab_default(GTK_WIDGET(bouton));
98 gtk_widget_show(bouton);
100 gtk_container_set_border_width(GTK_CONTAINER
101 (GTK_DIALOG(dialog)->vbox), 6);
102 label = gtk_label_new(text);
103 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, TRUE,
104 TRUE, 6);
105 gtk_widget_show(label);
107 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
108 gtk_widget_show(dialog);
112 void file_dialog(const char *title,
113 const char *dir, const char *filter,
114 void *ok_cb, void *cancel_cb) {
115 GtkWidget *dialog;
117 if (! title) title = "File...";
119 dialog = gtk_file_selection_new(title);
120 gtk_signal_connect(GTK_OBJECT(dialog), "delete_event",
121 GTK_SIGNAL_FUNC(gtk_widget_destroy),
122 NULL);
123 gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
124 GTK_SIGNAL_FUNC(gtk_widget_destroy),
125 NULL);
127 if (ok_cb != NULL)
128 gtk_signal_connect(
129 GTK_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button),
130 "clicked",
131 GTK_SIGNAL_FUNC(ok_cb), dialog);
132 gtk_signal_connect_object(
133 GTK_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button),
134 "clicked",
135 GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(dialog));
137 if (cancel_cb != NULL)
138 gtk_signal_connect(
139 GTK_OBJECT(GTK_FILE_SELECTION(dialog)->cancel_button),
140 "clicked",
141 GTK_SIGNAL_FUNC(cancel_cb), dialog);
142 gtk_signal_connect_object(
143 GTK_OBJECT(GTK_FILE_SELECTION(dialog)->cancel_button),
144 "clicked",
145 GTK_SIGNAL_FUNC(gtk_widget_destroy),
146 GTK_OBJECT(dialog));
148 if (dir) {
149 gtk_file_selection_set_filename(
150 GTK_FILE_SELECTION(dialog),
151 dir);
154 if (filter) {
155 gtk_file_selection_complete(GTK_FILE_SELECTION(dialog), filter);
158 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
159 gtk_widget_show(dialog);