Mercurial > pidgin
annotate src/gtkrequest.c @ 13434:ffd724befbf8
[gaim-migrate @ 15809]
Cleanup the busy cursor handling code to eliminate a bunch of these loops:
while (gtk_events_pending())
gtk_main_iteration();
They seem like a race condition waiting to happen. This code is also simpler,
and more generic.
This leaves only one such loop, in src/gtkblist.c's gaim_gtk_blist_expand_contact_cb().
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 07 Mar 2006 05:48:54 +0000 |
parents | fb178093e364 |
children | b0df520aceea |
rev | line source |
---|---|
5480 | 1 /** |
2 * @file gtkrequest.c GTK+ Request API | |
3 * @ingroup gtkui | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
10 * |
5480 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
9791 | 25 #include "internal.h" |
26 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5846
diff
changeset
|
27 |
7066
87bfe52a4099
[gaim-migrate @ 7630]
Christian Hammond <chipx86@chipx86.com>
parents:
7048
diff
changeset
|
28 #include "prefs.h" |
11780 | 29 #include "util.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5846
diff
changeset
|
30 |
9709 | 31 #include "gtkimhtml.h" |
32 #include "gtkimhtmltoolbar.h" | |
5480 | 33 #include "gtkrequest.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5846
diff
changeset
|
34 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10294
diff
changeset
|
35 #include "gtkstock.h" |
5480 | 36 |
8294
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
37 #include <gdk/gdkkeysyms.h> |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
38 |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
39 static GtkWidget * create_account_field(GaimRequestField *field); |
8294
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
40 |
5480 | 41 typedef struct |
42 { | |
43 GaimRequestType type; | |
44 | |
45 void *user_data; | |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11071
diff
changeset
|
46 GtkWidget *dialog; |
5480 | 47 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
48 GtkWidget *ok_button; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
49 |
5480 | 50 size_t cb_count; |
51 GCallback *cbs; | |
52 | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
53 union |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
54 { |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
55 struct |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
56 { |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
57 GtkWidget *entry; |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
58 |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
59 gboolean multiline; |
8697 | 60 gchar *hint; |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
61 |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
62 } input; |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
63 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
64 struct |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
65 { |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
66 GaimRequestFields *fields; |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
67 |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
68 } multifield; |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
69 |
9502 | 70 struct |
71 { | |
72 gboolean savedialog; | |
73 gchar *name; | |
74 | |
75 } file; | |
76 | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
77 } u; |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
78 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
79 } GaimGtkRequestData; |
5480 | 80 |
81 static void | |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
82 generic_response_start(GaimGtkRequestData *data) |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
83 { |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
84 GdkCursor *cursor; |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
85 |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13372
diff
changeset
|
86 g_return_if_fail(data != NULL); |
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13372
diff
changeset
|
87 |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
88 /* Tell the user we're doing something. */ |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13372
diff
changeset
|
89 gaim_gtk_set_cursor(GTK_WIDGET(data->dialog), GDK_WATCH); |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
90 } |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
91 |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
92 static void |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
93 input_response_cb(GtkDialog *dialog, gint id, GaimGtkRequestData *data) |
5480 | 94 { |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
95 const char *value; |
7174 | 96 char *multiline_value = NULL; |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
97 |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
98 generic_response_start(data); |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
99 |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
100 if (data->u.input.multiline) { |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
101 GtkTextIter start_iter, end_iter; |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
102 GtkTextBuffer *buffer = |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
103 gtk_text_view_get_buffer(GTK_TEXT_VIEW(data->u.input.entry)); |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
104 |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
105 gtk_text_buffer_get_start_iter(buffer, &start_iter); |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
106 gtk_text_buffer_get_end_iter(buffer, &end_iter); |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
107 |
8697 | 108 if ((data->u.input.hint != NULL) && (!strcmp(data->u.input.hint, "html"))) |
109 multiline_value = gtk_imhtml_get_markup(GTK_IMHTML(data->u.input.entry)); | |
110 else | |
111 multiline_value = gtk_text_buffer_get_text(buffer, &start_iter, &end_iter, | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
112 FALSE); |
8697 | 113 |
7172 | 114 value = multiline_value; |
5480 | 115 } |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
116 else |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
117 value = gtk_entry_get_text(GTK_ENTRY(data->u.input.entry)); |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
118 |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
119 if (id < data->cb_count && data->cbs[id] != NULL) |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
120 ((GaimRequestInputCb)data->cbs[id])(data->user_data, value); |
6110 | 121 else if (data->cbs[1] != NULL) |
6109 | 122 ((GaimRequestInputCb)data->cbs[1])(data->user_data, value); |
5480 | 123 |
7172 | 124 if (data->u.input.multiline) |
125 g_free(multiline_value); | |
126 | |
5480 | 127 gaim_request_close(GAIM_REQUEST_INPUT, data); |
128 } | |
129 | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
130 static void |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
131 action_response_cb(GtkDialog *dialog, gint id, GaimGtkRequestData *data) |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
132 { |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
133 generic_response_start(data); |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
134 |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
135 if (id < data->cb_count && data->cbs[id] != NULL) |
5498
cce2d7868c78
[gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents:
5496
diff
changeset
|
136 ((GaimRequestActionCb)data->cbs[id])(data->user_data, id); |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
137 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
138 gaim_request_close(GAIM_REQUEST_INPUT, data); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
139 } |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
140 |
10229 | 141 |
142 static void | |
143 choice_response_cb(GtkDialog *dialog, gint id, GaimGtkRequestData *data) | |
144 { | |
145 GtkWidget *radio = g_object_get_data(G_OBJECT(dialog), "radio"); | |
146 GSList *group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio)); | |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
147 |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
148 generic_response_start(data); |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
149 |
10980
842a21e7480b
[gaim-migrate @ 12810]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10943
diff
changeset
|
150 if (id < data->cb_count && data->cbs[id] != NULL) |
10229 | 151 while (group) { |
152 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(group->data))) { | |
153 ((GaimRequestChoiceCb)data->cbs[id])(data->user_data, GPOINTER_TO_INT(g_object_get_data(G_OBJECT(group->data), "choice_id"))); | |
154 break; | |
155 } | |
156 group = group->next; | |
157 } | |
158 gaim_request_close(GAIM_REQUEST_INPUT, data); | |
159 } | |
160 | |
5835
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
161 static gboolean |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
162 field_string_focus_out_cb(GtkWidget *entry, GdkEventFocus *event, |
5846
4676b498ff4b
[gaim-migrate @ 6277]
Christian Hammond <chipx86@chipx86.com>
parents:
5845
diff
changeset
|
163 GaimRequestField *field) |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
164 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
165 const char *value; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
166 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
167 if (gaim_request_field_string_is_multiline(field)) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
168 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
169 GtkTextBuffer *buffer; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
170 GtkTextIter start_iter, end_iter; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
171 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
172 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
173 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
174 gtk_text_buffer_get_start_iter(buffer, &start_iter); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
175 gtk_text_buffer_get_end_iter(buffer, &end_iter); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
176 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
177 value = gtk_text_buffer_get_text(buffer, &start_iter, &end_iter, FALSE); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
178 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
179 else |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
180 value = gtk_entry_get_text(GTK_ENTRY(entry)); |
5834
77eba2e68d07
[gaim-migrate @ 6265]
Christian Hammond <chipx86@chipx86.com>
parents:
5832
diff
changeset
|
181 |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
182 gaim_request_field_string_set_value(field, |
5834
77eba2e68d07
[gaim-migrate @ 6265]
Christian Hammond <chipx86@chipx86.com>
parents:
5832
diff
changeset
|
183 (*value == '\0' ? NULL : value)); |
5835
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
184 |
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
185 return FALSE; |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
186 } |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
187 |
5835
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
188 static gboolean |
5846
4676b498ff4b
[gaim-migrate @ 6277]
Christian Hammond <chipx86@chipx86.com>
parents:
5845
diff
changeset
|
189 field_int_focus_out_cb(GtkEntry *entry, GdkEventFocus *event, |
4676b498ff4b
[gaim-migrate @ 6277]
Christian Hammond <chipx86@chipx86.com>
parents:
5845
diff
changeset
|
190 GaimRequestField *field) |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
191 { |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
192 gaim_request_field_int_set_value(field, |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
193 atoi(gtk_entry_get_text(entry))); |
5835
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
194 |
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
195 return FALSE; |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
196 } |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
197 |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
198 static void |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
199 field_bool_cb(GtkToggleButton *button, GaimRequestField *field) |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
200 { |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
201 gaim_request_field_bool_set_value(field, |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
202 gtk_toggle_button_get_active(button)); |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
203 } |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
204 |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
205 static void |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
206 field_choice_menu_cb(GtkOptionMenu *menu, GaimRequestField *field) |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
207 { |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
208 gaim_request_field_choice_set_value(field, |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
209 gtk_option_menu_get_history(menu)); |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
210 } |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
211 |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
212 static void |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
213 field_choice_option_cb(GtkRadioButton *button, GaimRequestField *field) |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
214 { |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
215 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
216 gaim_request_field_choice_set_value(field, |
10943 | 217 (g_slist_length(gtk_radio_button_get_group(button)) - |
218 g_slist_index(gtk_radio_button_get_group(button), button)) - 1); | |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
219 } |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
220 |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
221 static void |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
222 field_account_cb(GObject *w, GaimAccount *account, GaimRequestField *field) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
223 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
224 gaim_request_field_account_set_value(field, account); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
225 } |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
226 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
227 static void |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
228 multifield_ok_cb(GtkWidget *button, GaimGtkRequestData *data) |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
229 { |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
230 generic_response_start(data); |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
231 |
8521
4cfb32f78d71
[gaim-migrate @ 9260]
Christian Hammond <chipx86@chipx86.com>
parents:
8332
diff
changeset
|
232 if (!GTK_WIDGET_HAS_FOCUS(button)) |
4cfb32f78d71
[gaim-migrate @ 9260]
Christian Hammond <chipx86@chipx86.com>
parents:
8332
diff
changeset
|
233 gtk_widget_grab_focus(button); |
4cfb32f78d71
[gaim-migrate @ 9260]
Christian Hammond <chipx86@chipx86.com>
parents:
8332
diff
changeset
|
234 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
235 if (data->cbs[0] != NULL) |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
236 ((GaimRequestFieldsCb)data->cbs[0])(data->user_data, |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
237 data->u.multifield.fields); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
238 |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
239 gaim_request_close(GAIM_REQUEST_FIELDS, data); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
240 } |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
241 |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
242 static void |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
243 multifield_cancel_cb(GtkWidget *button, GaimGtkRequestData *data) |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
244 { |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
245 generic_response_start(data); |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
246 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
247 if (data->cbs[1] != NULL) |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
248 ((GaimRequestFieldsCb)data->cbs[1])(data->user_data, |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
249 data->u.multifield.fields); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
250 |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
251 gaim_request_close(GAIM_REQUEST_FIELDS, data); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
252 } |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
253 |
8323
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
254 static void |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
255 destroy_multifield_cb(GtkWidget *dialog, GdkEvent *event, |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
256 GaimGtkRequestData *data) |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
257 { |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
258 multifield_cancel_cb(NULL, data); |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
259 } |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
260 |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
261 |
5480 | 262 #define STOCK_ITEMIZE(r, l) \ |
263 if (!strcmp((r), text)) \ | |
264 return (l); | |
265 | |
266 static const char * | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
267 text_to_stock(const char *text) |
5480 | 268 { |
6334
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
269 STOCK_ITEMIZE(_("Yes"), GTK_STOCK_YES); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
270 STOCK_ITEMIZE(_("No"), GTK_STOCK_NO); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
271 STOCK_ITEMIZE(_("OK"), GTK_STOCK_OK); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
272 STOCK_ITEMIZE(_("Cancel"), GTK_STOCK_CANCEL); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
273 STOCK_ITEMIZE(_("Apply"), GTK_STOCK_APPLY); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
274 STOCK_ITEMIZE(_("Close"), GTK_STOCK_CLOSE); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
275 STOCK_ITEMIZE(_("Delete"), GTK_STOCK_DELETE); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
276 STOCK_ITEMIZE(_("Add"), GTK_STOCK_ADD); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
277 STOCK_ITEMIZE(_("Remove"), GTK_STOCK_REMOVE); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
278 STOCK_ITEMIZE(_("Save"), GTK_STOCK_SAVE); |
8302
462ead6fc1a0
[gaim-migrate @ 9026]
Christian Hammond <chipx86@chipx86.com>
parents:
8294
diff
changeset
|
279 STOCK_ITEMIZE(_("Alias"), GAIM_STOCK_ALIAS); |
5480 | 280 |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
281 return text; |
5480 | 282 } |
283 | |
6363
b7ef10bbe9bb
[gaim-migrate @ 6868]
Christian Hammond <chipx86@chipx86.com>
parents:
6338
diff
changeset
|
284 static void * |
5480 | 285 gaim_gtk_request_input(const char *title, const char *primary, |
286 const char *secondary, const char *default_value, | |
8697 | 287 gboolean multiline, gboolean masked, gchar *hint, |
5480 | 288 const char *ok_text, GCallback ok_cb, |
289 const char *cancel_text, GCallback cancel_cb, | |
290 void *user_data) | |
291 { | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
292 GaimGtkRequestData *data; |
5480 | 293 GtkWidget *dialog; |
294 GtkWidget *vbox; | |
295 GtkWidget *hbox; | |
296 GtkWidget *label; | |
297 GtkWidget *entry; | |
298 GtkWidget *img; | |
8782
5a2b5e4abf3a
[gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents:
8697
diff
changeset
|
299 GtkWidget *toolbar; |
5480 | 300 char *label_text; |
10774 | 301 char *primary_esc, *secondary_esc; |
5480 | 302 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
303 data = g_new0(GaimGtkRequestData, 1); |
5480 | 304 data->type = GAIM_REQUEST_INPUT; |
305 data->user_data = user_data; | |
306 | |
307 data->cb_count = 2; | |
308 data->cbs = g_new0(GCallback, 2); | |
309 | |
310 data->cbs[0] = ok_cb; | |
311 data->cbs[1] = cancel_cb; | |
312 | |
313 /* Create the dialog. */ | |
7678 | 314 dialog = gtk_dialog_new_with_buttons(title ? title : GAIM_ALERT_TITLE, |
315 NULL, 0, | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
316 text_to_stock(cancel_text), 1, |
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
317 text_to_stock(ok_text), 0, |
5485 | 318 NULL); |
5480 | 319 data->dialog = dialog; |
320 | |
321 g_signal_connect(G_OBJECT(dialog), "response", | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
322 G_CALLBACK(input_response_cb), data); |
5480 | 323 |
324 /* Setup the dialog */ | |
11243 | 325 gtk_container_set_border_width(GTK_CONTAINER(dialog), GAIM_HIG_BORDER/2); |
326 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER/2); | |
5480 | 327 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
328 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
5510
da18a02c3705
[gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
329 gtk_dialog_set_default_response(GTK_DIALOG(dialog), 0); |
11243 | 330 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER); |
5480 | 331 |
332 /* Setup the main horizontal box */ | |
11243 | 333 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
5480 | 334 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
335 | |
336 /* Dialog icon. */ | |
337 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
338 GTK_ICON_SIZE_DIALOG); | |
339 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
340 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
341 | |
342 /* Vertical box */ | |
11243 | 343 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
5480 | 344 |
345 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); | |
346 | |
347 /* Descriptive label */ | |
10774 | 348 primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; |
349 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; | |
7843 | 350 label_text = g_strdup_printf((primary ? "<span weight=\"bold\" size=\"larger\">" |
351 "%s</span>%s%s" : "%s%s%s"), | |
10774 | 352 (primary ? primary_esc : ""), |
7843 | 353 ((primary && secondary) ? "\n\n" : ""), |
10774 | 354 (secondary ? secondary_esc : "")); |
355 g_free(primary_esc); | |
356 g_free(secondary_esc); | |
5480 | 357 |
358 label = gtk_label_new(NULL); | |
359 | |
360 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
361 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
362 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
363 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | |
364 | |
365 g_free(label_text); | |
366 | |
367 /* Entry field. */ | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
368 data->u.input.multiline = multiline; |
8697 | 369 data->u.input.hint = (hint == NULL ? NULL : g_strdup(hint)); |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
370 |
8697 | 371 if ((data->u.input.hint != NULL) && (!strcmp(data->u.input.hint, "html"))) { |
10146 | 372 GtkWidget *frame; |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
373 |
10181 | 374 /* imhtml */ |
13280
3de53fe8345f
[gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents:
13269
diff
changeset
|
375 frame = gaim_gtk_create_imhtml(TRUE, &entry, &toolbar, NULL); |
10181 | 376 gtk_widget_set_size_request(entry, 320, 130); |
377 gtk_widget_set_name(entry, "gaim_gtkrequest_imhtml"); | |
378 if (default_value != NULL) | |
379 gtk_imhtml_append_text(GTK_IMHTML(entry), default_value, GTK_IMHTML_NO_SCROLL); | |
10146 | 380 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
381 gtk_widget_show(frame); | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
382 } |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
383 else { |
8697 | 384 if (multiline) { |
385 GtkWidget *sw; | |
386 | |
387 sw = gtk_scrolled_window_new(NULL, NULL); | |
388 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
389 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
390 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
391 GTK_SHADOW_IN); | |
392 | |
393 gtk_widget_set_size_request(sw, 320, 130); | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
394 |
8697 | 395 /* GtkTextView */ |
396 entry = gtk_text_view_new(); | |
397 gtk_text_view_set_editable(GTK_TEXT_VIEW(entry), TRUE); | |
5510
da18a02c3705
[gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
398 |
8697 | 399 if (default_value != NULL) { |
400 GtkTextBuffer *buffer; | |
401 | |
402 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)); | |
403 gtk_text_buffer_set_text(buffer, default_value, -1); | |
404 } | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
405 |
8697 | 406 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(entry), GTK_WRAP_WORD_CHAR); |
407 | |
408 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
409 | |
410 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) | |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
411 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(entry)); |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
412 |
8697 | 413 gtk_container_add(GTK_CONTAINER(sw), entry); |
414 } | |
415 else { | |
416 entry = gtk_entry_new(); | |
417 | |
418 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); | |
419 | |
420 gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0); | |
421 | |
422 if (default_value != NULL) | |
423 gtk_entry_set_text(GTK_ENTRY(entry), default_value); | |
424 | |
425 if (masked) | |
11986 | 426 { |
8697 | 427 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); |
11986 | 428 gtk_entry_set_invisible_char(GTK_ENTRY(entry), GAIM_INVISIBLE_CHAR); |
429 } | |
8697 | 430 } |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
431 } |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
432 |
8137 | 433 gaim_set_accessible_label (entry, label); |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
434 data->u.input.entry = entry; |
5480 | 435 |
436 /* Show everything. */ | |
437 gtk_widget_show_all(dialog); | |
438 | |
439 return data; | |
440 } | |
441 | |
6363
b7ef10bbe9bb
[gaim-migrate @ 6868]
Christian Hammond <chipx86@chipx86.com>
parents:
6338
diff
changeset
|
442 static void * |
5480 | 443 gaim_gtk_request_choice(const char *title, const char *primary, |
10229 | 444 const char *secondary, unsigned int default_value, |
445 const char *ok_text, GCallback ok_cb, | |
446 const char *cancel_text, GCallback cancel_cb, | |
447 void *user_data, va_list args) | |
5480 | 448 { |
10229 | 449 GaimGtkRequestData *data; |
450 GtkWidget *dialog; | |
451 GtkWidget *vbox, *vbox2; | |
452 GtkWidget *hbox; | |
453 GtkWidget *label; | |
454 GtkWidget *img; | |
455 GtkWidget *radio = NULL; | |
456 char *label_text; | |
457 char *radio_text; | |
10774 | 458 char *primary_esc, *secondary_esc; |
10233 | 459 |
10229 | 460 data = g_new0(GaimGtkRequestData, 1); |
461 data->type = GAIM_REQUEST_ACTION; | |
462 data->user_data = user_data; | |
463 | |
464 data->cb_count = 2; | |
465 data->cbs = g_new0(GCallback, 2); | |
466 data->cbs[0] = cancel_cb; | |
467 data->cbs[1] = ok_cb; | |
468 | |
469 /* Create the dialog. */ | |
470 data->dialog = dialog = gtk_dialog_new(); | |
471 | |
472 if (title != NULL) | |
473 gtk_window_set_title(GTK_WINDOW(dialog), title); | |
474 | |
475 | |
476 gtk_dialog_add_button(GTK_DIALOG(dialog), | |
477 text_to_stock(cancel_text), 0); | |
10233 | 478 |
10229 | 479 gtk_dialog_add_button(GTK_DIALOG(dialog), |
480 text_to_stock(ok_text), 1); | |
481 | |
482 g_signal_connect(G_OBJECT(dialog), "response", | |
483 G_CALLBACK(choice_response_cb), data); | |
484 | |
485 /* Setup the dialog */ | |
11243 | 486 gtk_container_set_border_width(GTK_CONTAINER(dialog), GAIM_HIG_BORDER/2); |
487 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER/2); | |
10229 | 488 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
489 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
11243 | 490 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER); |
10229 | 491 |
492 /* Setup the main horizontal box */ | |
11243 | 493 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
10229 | 494 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
495 | |
496 /* Dialog icon. */ | |
497 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
498 GTK_ICON_SIZE_DIALOG); | |
499 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
500 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
501 | |
502 /* Vertical box */ | |
11243 | 503 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
10229 | 504 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
10233 | 505 |
10229 | 506 /* Descriptive label */ |
10774 | 507 primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; |
508 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; | |
10229 | 509 label_text = g_strdup_printf((primary ? "<span weight=\"bold\" size=\"larger\">" |
510 "%s</span>%s%s" : "%s%s%s"), | |
10774 | 511 (primary ? primary_esc : ""), |
10229 | 512 ((primary && secondary) ? "\n\n" : ""), |
10774 | 513 (secondary ? secondary_esc : "")); |
514 g_free(primary_esc); | |
515 g_free(secondary_esc); | |
10233 | 516 |
10229 | 517 label = gtk_label_new(NULL); |
518 | |
519 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
520 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
521 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
522 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | |
523 | |
524 g_free(label_text); | |
10233 | 525 |
11243 | 526 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
10229 | 527 gtk_box_pack_start(GTK_BOX(vbox), vbox2, FALSE, FALSE, 0); |
528 while ((radio_text = va_arg(args, char*))) { | |
529 int resp = va_arg(args, int); | |
530 radio = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(radio), radio_text); | |
531 gtk_box_pack_start(GTK_BOX(vbox2), radio, FALSE, FALSE, 0); | |
532 g_object_set_data(G_OBJECT(radio), "choice_id", GINT_TO_POINTER(resp)); | |
533 if (resp == default_value) | |
534 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE); | |
535 } | |
10233 | 536 |
10229 | 537 g_object_set_data(G_OBJECT(dialog), "radio", radio); |
538 | |
539 /* Show everything. */ | |
540 gtk_widget_show_all(dialog); | |
541 | |
542 return data; | |
5480 | 543 } |
544 | |
6363
b7ef10bbe9bb
[gaim-migrate @ 6868]
Christian Hammond <chipx86@chipx86.com>
parents:
6338
diff
changeset
|
545 static void * |
5480 | 546 gaim_gtk_request_action(const char *title, const char *primary, |
547 const char *secondary, unsigned int default_action, | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
548 void *user_data, size_t action_count, va_list actions) |
5480 | 549 { |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
550 GaimGtkRequestData *data; |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
551 GtkWidget *dialog; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
552 GtkWidget *vbox; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
553 GtkWidget *hbox; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
554 GtkWidget *label; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
555 GtkWidget *img; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
556 void **buttons; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
557 char *label_text; |
10774 | 558 char *primary_esc, *secondary_esc; |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
559 int i; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
560 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
561 data = g_new0(GaimGtkRequestData, 1); |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
562 data->type = GAIM_REQUEST_ACTION; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
563 data->user_data = user_data; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
564 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
565 data->cb_count = action_count; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
566 data->cbs = g_new0(GCallback, action_count); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
567 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
568 /* Reverse the buttons */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
569 buttons = g_new0(void *, action_count * 2); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
570 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
571 for (i = 0; i < action_count * 2; i += 2) { |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
572 buttons[(action_count * 2) - i - 2] = va_arg(actions, char *); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
573 buttons[(action_count * 2) - i - 1] = va_arg(actions, GCallback); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
574 } |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
575 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
576 /* Create the dialog. */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
577 data->dialog = dialog = gtk_dialog_new(); |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6363
diff
changeset
|
578 |
6109 | 579 if (title != NULL) |
580 gtk_window_set_title(GTK_WINDOW(dialog), title); | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
581 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
582 for (i = 0; i < action_count; i++) { |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
583 gtk_dialog_add_button(GTK_DIALOG(dialog), |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
584 text_to_stock(buttons[2 * i]), i); |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
585 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
586 data->cbs[i] = buttons[2 * i + 1]; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
587 } |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
588 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
589 g_free(buttons); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
590 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
591 g_signal_connect(G_OBJECT(dialog), "response", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
592 G_CALLBACK(action_response_cb), data); |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
593 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
594 /* Setup the dialog */ |
11243 | 595 gtk_container_set_border_width(GTK_CONTAINER(dialog), GAIM_HIG_BORDER/2); |
596 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER/2); | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
597 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
598 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
11243 | 599 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), GAIM_HIG_BORDER); |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
600 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
601 /* Setup the main horizontal box */ |
11243 | 602 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
603 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
604 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
605 /* Dialog icon. */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
606 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
607 GTK_ICON_SIZE_DIALOG); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
608 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
609 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
610 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
611 /* Vertical box */ |
11243 | 612 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
613 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
614 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
615 /* Descriptive label */ |
10774 | 616 primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; |
617 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; | |
7843 | 618 label_text = g_strdup_printf((primary ? "<span weight=\"bold\" size=\"larger\">" |
619 "%s</span>%s%s" : "%s%s%s"), | |
10774 | 620 (primary ? primary_esc : ""), |
7843 | 621 ((primary && secondary) ? "\n\n" : ""), |
10774 | 622 (secondary ? secondary_esc : "")); |
623 g_free(primary_esc); | |
624 g_free(secondary_esc); | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
625 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
626 label = gtk_label_new(NULL); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
627 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
628 gtk_label_set_markup(GTK_LABEL(label), label_text); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
629 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
630 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
631 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
632 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
633 g_free(label_text); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
634 |
9948 | 635 |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12234
diff
changeset
|
636 if (default_action == GAIM_DEFAULT_ACTION_NONE) { |
10418 | 637 GTK_WIDGET_SET_FLAGS(img, GTK_CAN_DEFAULT); |
638 GTK_WIDGET_SET_FLAGS(img, GTK_CAN_FOCUS); | |
9948 | 639 gtk_widget_grab_focus(img); |
640 gtk_widget_grab_default(img); | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12234
diff
changeset
|
641 } else |
5510
da18a02c3705
[gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
642 gtk_dialog_set_default_response(GTK_DIALOG(dialog), default_action); |
da18a02c3705
[gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
643 |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
644 /* Show everything. */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
645 gtk_widget_show_all(dialog); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
646 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
647 return data; |
5480 | 648 } |
649 | |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
650 static void |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
651 req_entry_field_changed_cb(GtkWidget *entry, GaimRequestField *field) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
652 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
653 GaimGtkRequestData *req_data; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
654 const char *text = gtk_entry_get_text(GTK_ENTRY(entry)); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
655 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
656 gaim_request_field_string_set_value(field, (*text == '\0' ? NULL : text)); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
657 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
658 req_data = (GaimGtkRequestData *)field->group->fields_list->ui_data; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
659 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
660 gtk_widget_set_sensitive(req_data->ok_button, |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
661 gaim_request_fields_all_required_filled(field->group->fields_list)); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
662 } |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
663 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
664 static void |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
665 setup_entry_field(GtkWidget *entry, GaimRequestField *field) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
666 { |
8294
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
667 const char *type_hint; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
668 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
669 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
670 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
671 if (gaim_request_field_is_required(field)) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
672 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
673 g_signal_connect(G_OBJECT(entry), "changed", |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
674 G_CALLBACK(req_entry_field_changed_cb), field); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
675 } |
8294
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
676 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
677 if ((type_hint = gaim_request_field_get_type_hint(field)) != NULL) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
678 { |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
679 if (gaim_str_has_prefix(type_hint, "screenname")) |
8294
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
680 { |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
681 GtkWidget *optmenu = NULL; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
682 GList *fields = field->group->fields; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
683 while (fields) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
684 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
685 GaimRequestField *fld = fields->data; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
686 fields = fields->next; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
687 |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
688 if (gaim_request_field_get_type(fld) == GAIM_REQUEST_FIELD_ACCOUNT) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
689 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
690 const char *type_hint = gaim_request_field_get_type_hint(fld); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
691 if (type_hint != NULL && strcmp(type_hint, "account") == 0) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
692 { |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
693 if (fld->ui_data == NULL) |
13361
9b4a80566fd5
[gaim-migrate @ 15734]
Richard Laager <rlaager@wiktel.com>
parents:
13360
diff
changeset
|
694 fld->ui_data = create_account_field(fld); |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
695 optmenu = GTK_WIDGET(fld->ui_data); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
696 break; |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
697 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
698 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
699 } |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
700 gaim_gtk_setup_screenname_autocomplete(entry, optmenu, !strcmp(type_hint, "screenname-all")); |
8294
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
701 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
702 } |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
703 } |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
704 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
705 static GtkWidget * |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
706 create_string_field(GaimRequestField *field) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
707 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
708 const char *value; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
709 GtkWidget *widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
710 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
711 value = gaim_request_field_string_get_default_value(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
712 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
713 if (gaim_request_field_string_is_multiline(field)) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
714 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
715 GtkWidget *textview; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
716 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
717 widget = gtk_scrolled_window_new(NULL, NULL); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
718 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(widget), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
719 GTK_SHADOW_IN); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
720 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget), |
8916 | 721 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
722 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
723 textview = gtk_text_view_new(); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
724 gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
725 TRUE); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
726 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
727 GTK_WRAP_WORD_CHAR); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
728 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
729 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
730 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(textview)); |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
731 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
732 gtk_container_add(GTK_CONTAINER(widget), textview); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
733 gtk_widget_show(textview); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
734 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
735 gtk_widget_set_size_request(widget, -1, 75); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
736 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
737 if (value != NULL) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
738 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
739 GtkTextBuffer *buffer; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
740 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
741 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
742 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
743 gtk_text_buffer_set_text(buffer, value, -1); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
744 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
745 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
746 gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
747 gaim_request_field_string_is_editable(field)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
748 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
749 g_signal_connect(G_OBJECT(textview), "focus-out-event", |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
750 G_CALLBACK(field_string_focus_out_cb), field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
751 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
752 else |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
753 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
754 widget = gtk_entry_new(); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
755 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
756 setup_entry_field(widget, field); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
757 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
758 if (value != NULL) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
759 gtk_entry_set_text(GTK_ENTRY(widget), value); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
760 |
11986 | 761 if (gaim_request_field_string_is_masked(field)) |
762 { | |
763 gtk_entry_set_visibility(GTK_ENTRY(widget), FALSE); | |
764 gtk_entry_set_invisible_char(GTK_ENTRY(widget), GAIM_INVISIBLE_CHAR); | |
765 } | |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
766 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
767 gtk_editable_set_editable(GTK_EDITABLE(widget), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
768 gaim_request_field_string_is_editable(field)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
769 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
770 g_signal_connect(G_OBJECT(widget), "focus-out-event", |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
771 G_CALLBACK(field_string_focus_out_cb), field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
772 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
773 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
774 return widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
775 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
776 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
777 static GtkWidget * |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
778 create_int_field(GaimRequestField *field) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
779 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
780 int value; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
781 GtkWidget *widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
782 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
783 widget = gtk_entry_new(); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
784 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
785 setup_entry_field(widget, field); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
786 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
787 value = gaim_request_field_int_get_default_value(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
788 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
789 if (value != 0) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
790 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
791 char buf[32]; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
792 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
793 g_snprintf(buf, sizeof(buf), "%d", value); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
794 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
795 gtk_entry_set_text(GTK_ENTRY(widget), buf); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
796 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
797 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
798 g_signal_connect(G_OBJECT(widget), "focus-out-event", |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
799 G_CALLBACK(field_int_focus_out_cb), field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
800 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
801 return widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
802 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
803 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
804 static GtkWidget * |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
805 create_bool_field(GaimRequestField *field) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
806 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
807 GtkWidget *widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
808 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
809 widget = gtk_check_button_new_with_label( |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
810 gaim_request_field_get_label(field)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
811 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
812 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
813 gaim_request_field_bool_get_default_value(field)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
814 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
815 g_signal_connect(G_OBJECT(widget), "toggled", |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
816 G_CALLBACK(field_bool_cb), field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
817 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
818 return widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
819 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
820 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
821 static GtkWidget * |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
822 create_choice_field(GaimRequestField *field) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
823 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
824 GtkWidget *widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
825 GList *labels; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
826 GList *l; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
827 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
828 labels = gaim_request_field_choice_get_labels(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
829 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
830 if (g_list_length(labels) > 5) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
831 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
832 GtkWidget *menu; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
833 GtkWidget *item; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
834 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
835 widget = gtk_option_menu_new(); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
836 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
837 menu = gtk_menu_new(); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
838 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
839 for (l = labels; l != NULL; l = l->next) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
840 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
841 const char *text = l->data; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
842 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
843 item = gtk_menu_item_new_with_label(text); |
10294
6484242e4e30
[gaim-migrate @ 11473]
Luke Schierer <lschiere@pidgin.im>
parents:
10233
diff
changeset
|
844 gtk_widget_show(item); |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
845 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
846 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
847 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
848 |
10294
6484242e4e30
[gaim-migrate @ 11473]
Luke Schierer <lschiere@pidgin.im>
parents:
10233
diff
changeset
|
849 gtk_widget_show(menu); |
6484242e4e30
[gaim-migrate @ 11473]
Luke Schierer <lschiere@pidgin.im>
parents:
10233
diff
changeset
|
850 gtk_option_menu_set_menu(GTK_OPTION_MENU(widget), menu); |
6484242e4e30
[gaim-migrate @ 11473]
Luke Schierer <lschiere@pidgin.im>
parents:
10233
diff
changeset
|
851 gtk_option_menu_set_history(GTK_OPTION_MENU(widget), |
6484242e4e30
[gaim-migrate @ 11473]
Luke Schierer <lschiere@pidgin.im>
parents:
10233
diff
changeset
|
852 gaim_request_field_choice_get_default_value(field)); |
6484242e4e30
[gaim-migrate @ 11473]
Luke Schierer <lschiere@pidgin.im>
parents:
10233
diff
changeset
|
853 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
854 g_signal_connect(G_OBJECT(widget), "changed", |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
855 G_CALLBACK(field_choice_menu_cb), field); |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
856 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
857 else |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
858 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
859 GtkWidget *box; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
860 GtkWidget *first_radio = NULL; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
861 GtkWidget *radio; |
10943 | 862 gint i; |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
863 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
864 if (g_list_length(labels) == 2) |
11243 | 865 box = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
866 else |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
867 box = gtk_vbox_new(FALSE, 0); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
868 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
869 widget = box; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
870 |
10943 | 871 for (l = labels, i = 0; l != NULL; l = l->next, i++) |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
872 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
873 const char *text = l->data; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
874 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
875 radio = gtk_radio_button_new_with_label_from_widget( |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
876 GTK_RADIO_BUTTON(first_radio), text); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
877 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
878 if (first_radio == NULL) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
879 first_radio = radio; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
880 |
10943 | 881 if (i == gaim_request_field_choice_get_default_value(field)) |
882 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE); | |
883 | |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
884 gtk_box_pack_start(GTK_BOX(box), radio, TRUE, TRUE, 0); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
885 gtk_widget_show(radio); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
886 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
887 g_signal_connect(G_OBJECT(radio), "toggled", |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
888 G_CALLBACK(field_choice_option_cb), field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
889 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
890 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
891 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
892 return widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
893 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
894 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
895 static GtkWidget * |
11357 | 896 create_image_field(GaimRequestField *field) |
897 { | |
898 GtkWidget *widget; | |
899 GdkPixbuf *buf, *scale; | |
900 GdkPixbufLoader *loader; | |
901 | |
902 loader = gdk_pixbuf_loader_new(); | |
903 gdk_pixbuf_loader_write(loader, | |
904 (const guchar *)gaim_request_field_image_get_buffer(field), | |
905 gaim_request_field_image_get_size(field), | |
906 NULL); | |
907 gdk_pixbuf_loader_close(loader, NULL); | |
908 buf = gdk_pixbuf_loader_get_pixbuf(loader); | |
909 | |
910 scale = gdk_pixbuf_scale_simple(buf, | |
911 gaim_request_field_image_get_scale_x(field) * gdk_pixbuf_get_width(buf), | |
912 gaim_request_field_image_get_scale_y(field) * gdk_pixbuf_get_height(buf), | |
913 GDK_INTERP_BILINEAR); | |
914 widget = gtk_image_new_from_pixbuf(scale); | |
915 g_object_unref(G_OBJECT(buf)); | |
916 g_object_unref(G_OBJECT(scale)); | |
917 | |
918 return widget; | |
919 } | |
920 | |
921 static GtkWidget * | |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
922 create_account_field(GaimRequestField *field) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
923 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
924 GtkWidget *widget; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
925 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
926 widget = gaim_gtk_account_option_menu_new( |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
927 gaim_request_field_account_get_default_value(field), |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
928 gaim_request_field_account_get_show_all(field), |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8286
diff
changeset
|
929 G_CALLBACK(field_account_cb), |
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8286
diff
changeset
|
930 gaim_request_field_account_get_filter(field), |
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8286
diff
changeset
|
931 field); |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
932 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
933 return widget; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
934 } |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
935 |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
936 static void |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
937 select_field_list_item(GtkTreeModel *model, GtkTreePath *path, |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
938 GtkTreeIter *iter, gpointer data) |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
939 { |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
940 GaimRequestField *field = (GaimRequestField *)data; |
13355
d278dac585a5
[gaim-migrate @ 15728]
Richard Laager <rlaager@wiktel.com>
parents:
13282
diff
changeset
|
941 char *text; |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
942 |
7909
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
943 gtk_tree_model_get(model, iter, 1, &text, -1); |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
944 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
945 gaim_request_field_list_add_selected(field, text); |
13355
d278dac585a5
[gaim-migrate @ 15728]
Richard Laager <rlaager@wiktel.com>
parents:
13282
diff
changeset
|
946 g_free(text); |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
947 } |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
948 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
949 static void |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
950 list_field_select_changed_cb(GtkTreeSelection *sel, GaimRequestField *field) |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
951 { |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
952 gaim_request_field_list_clear_selected(field); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
953 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
954 gtk_tree_selection_selected_foreach(sel, select_field_list_item, field); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
955 } |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
956 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
957 static GtkWidget * |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
958 create_list_field(GaimRequestField *field) |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
959 { |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
960 GtkWidget *sw; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
961 GtkWidget *treeview; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
962 GtkListStore *store; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
963 GtkCellRenderer *renderer; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
964 GtkTreeSelection *sel; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
965 GtkTreeViewColumn *column; |
7909
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
966 GtkTreeIter iter; |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
967 const GList *l; |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
968 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
969 /* Create the scrolled window */ |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
970 sw = gtk_scrolled_window_new(NULL, NULL); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
971 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
8332
f4a878d48254
[gaim-migrate @ 9056]
Christian Hammond <chipx86@chipx86.com>
parents:
8323
diff
changeset
|
972 GTK_POLICY_AUTOMATIC, |
f4a878d48254
[gaim-migrate @ 9056]
Christian Hammond <chipx86@chipx86.com>
parents:
8323
diff
changeset
|
973 GTK_POLICY_AUTOMATIC); |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
974 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
975 GTK_SHADOW_IN); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
976 gtk_widget_show(sw); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
977 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
978 /* Create the list store */ |
7909
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
979 store = gtk_list_store_new(2, G_TYPE_POINTER, G_TYPE_STRING); |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
980 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
981 /* Create the tree view */ |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
982 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
983 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
984 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
985 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
986 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
987 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
988 if (gaim_request_field_list_get_multi_select(field)) |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
989 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
990 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
991 g_signal_connect(G_OBJECT(sel), "changed", |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
992 G_CALLBACK(list_field_select_changed_cb), field); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
993 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
994 column = gtk_tree_view_column_new(); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
995 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
996 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
997 renderer = gtk_cell_renderer_text_new(); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
998 gtk_tree_view_column_pack_start(column, renderer, TRUE); |
7909
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
999 gtk_tree_view_column_add_attribute(column, renderer, "text", 1); |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1000 |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1001 for (l = gaim_request_field_list_get_items(field); l != NULL; l = l->next) |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1002 { |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1003 const char *text = (const char *)l->data; |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1004 |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1005 gtk_list_store_append(store, &iter); |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1006 |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1007 gtk_list_store_set(store, &iter, |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1008 0, gaim_request_field_list_get_data(field, text), |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1009 1, text, |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1010 -1); |
7964
a5c70e43ee43
[gaim-migrate @ 8641]
Christian Hammond <chipx86@chipx86.com>
parents:
7951
diff
changeset
|
1011 |
a5c70e43ee43
[gaim-migrate @ 8641]
Christian Hammond <chipx86@chipx86.com>
parents:
7951
diff
changeset
|
1012 if (gaim_request_field_list_is_selected(field, text)) |
a5c70e43ee43
[gaim-migrate @ 8641]
Christian Hammond <chipx86@chipx86.com>
parents:
7951
diff
changeset
|
1013 gtk_tree_selection_select_iter(sel, &iter); |
7909
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1014 } |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1015 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1016 gtk_container_add(GTK_CONTAINER(sw), treeview); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1017 gtk_widget_show(treeview); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1018 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1019 return sw; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1020 } |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1021 |
6363
b7ef10bbe9bb
[gaim-migrate @ 6868]
Christian Hammond <chipx86@chipx86.com>
parents:
6338
diff
changeset
|
1022 static void * |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1023 gaim_gtk_request_fields(const char *title, const char *primary, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1024 const char *secondary, GaimRequestFields *fields, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1025 const char *ok_text, GCallback ok_cb, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1026 const char *cancel_text, GCallback cancel_cb, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1027 void *user_data) |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1028 { |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1029 GaimGtkRequestData *data; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1030 GtkWidget *win; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1031 GtkWidget *vbox; |
8524 | 1032 GtkWidget *vbox2; |
6326
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1033 GtkWidget *hbox; |
5815
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1034 GtkWidget *bbox; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1035 GtkWidget *frame; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1036 GtkWidget *label; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1037 GtkWidget *table; |
5815
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1038 GtkWidget *button; |
6326
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1039 GtkWidget *img; |
8524 | 1040 GtkWidget *sw; |
5813
b116f3a73256
[gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
1041 GtkSizeGroup *sg; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1042 GList *gl, *fl; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1043 GaimRequestFieldGroup *group; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1044 GaimRequestField *field; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1045 char *label_text; |
10774 | 1046 char *primary_esc, *secondary_esc; |
8524 | 1047 int total_fields = 0; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1048 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1049 data = g_new0(GaimGtkRequestData, 1); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1050 data->type = GAIM_REQUEST_FIELDS; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1051 data->user_data = user_data; |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1052 data->u.multifield.fields = fields; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1053 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1054 fields->ui_data = data; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1055 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1056 data->cb_count = 2; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1057 data->cbs = g_new0(GCallback, 2); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1058 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1059 data->cbs[0] = ok_cb; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1060 data->cbs[1] = cancel_cb; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1061 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1062 data->dialog = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
6325
de67cb0dd09d
[gaim-migrate @ 6824]
Christian Hammond <chipx86@chipx86.com>
parents:
6324
diff
changeset
|
1063 |
6109 | 1064 if (title != NULL) |
1065 gtk_window_set_title(GTK_WINDOW(win), title); | |
6325
de67cb0dd09d
[gaim-migrate @ 6824]
Christian Hammond <chipx86@chipx86.com>
parents:
6324
diff
changeset
|
1066 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1067 gtk_window_set_role(GTK_WINDOW(win), "multifield"); |
11243 | 1068 gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER); |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1069 gtk_window_set_resizable(GTK_WINDOW(win), FALSE); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1070 |
8323
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
1071 g_signal_connect(G_OBJECT(win), "delete_event", |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
1072 G_CALLBACK(destroy_multifield_cb), data); |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
1073 |
6326
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1074 /* Setup the main horizontal box */ |
11243 | 1075 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
6326
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1076 gtk_container_add(GTK_CONTAINER(win), hbox); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1077 gtk_widget_show(hbox); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1078 |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1079 /* Dialog icon. */ |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1080 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1081 GTK_ICON_SIZE_DIALOG); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1082 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1083 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1084 gtk_widget_show(img); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1085 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1086 /* Setup the vbox */ |
11243 | 1087 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
6326
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1088 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1089 gtk_widget_show(vbox); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1090 |
5813
b116f3a73256
[gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
1091 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
b116f3a73256
[gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
1092 |
8524 | 1093 if(primary) { |
10774 | 1094 primary_esc = g_markup_escape_text(primary, -1); |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1095 label_text = g_strdup_printf( |
10774 | 1096 "<span weight=\"bold\" size=\"larger\">%s</span>", primary_esc); |
1097 g_free(primary_esc); | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1098 label = gtk_label_new(NULL); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1099 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1100 gtk_label_set_markup(GTK_LABEL(label), label_text); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1101 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1102 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1103 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); |
6325
de67cb0dd09d
[gaim-migrate @ 6824]
Christian Hammond <chipx86@chipx86.com>
parents:
6324
diff
changeset
|
1104 gtk_widget_show(label); |
8524 | 1105 g_free(label_text); |
1106 } | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1107 |
8524 | 1108 for (gl = gaim_request_fields_get_groups(fields); gl != NULL; |
1109 gl = gl->next) | |
1110 total_fields += g_list_length(gaim_request_field_group_get_fields(gl->data)); | |
1111 | |
1112 if(total_fields > 9) { | |
1113 sw = gtk_scrolled_window_new(NULL, NULL); | |
1114 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
1115 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
1116 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
1117 GTK_SHADOW_NONE); | |
1118 gtk_widget_set_size_request(sw, -1, 200); | |
1119 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
1120 gtk_widget_show(sw); | |
1121 | |
11243 | 1122 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BORDER); |
8524 | 1123 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), vbox2); |
1124 gtk_widget_show(vbox2); | |
1125 } else { | |
1126 vbox2 = vbox; | |
1127 } | |
1128 | |
1129 if (secondary) { | |
10774 | 1130 secondary_esc = g_markup_escape_text(secondary, -1); |
8524 | 1131 label = gtk_label_new(NULL); |
1132 | |
10774 | 1133 gtk_label_set_markup(GTK_LABEL(label), secondary_esc); |
1134 g_free(secondary_esc); | |
8524 | 1135 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
1136 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
1137 gtk_box_pack_start(GTK_BOX(vbox2), label, TRUE, TRUE, 0); | |
1138 gtk_widget_show(label); | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1139 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1140 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1141 for (gl = gaim_request_fields_get_groups(fields); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1142 gl != NULL; |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1143 gl = gl->next) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1144 { |
5816
64a164aa6f70
[gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents:
5815
diff
changeset
|
1145 GList *field_list; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1146 size_t field_count = 0; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1147 size_t cols = 1; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1148 size_t rows; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1149 size_t col_num; |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1150 size_t row_num = 0; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1151 |
5816
64a164aa6f70
[gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents:
5815
diff
changeset
|
1152 group = gl->data; |
64a164aa6f70
[gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents:
5815
diff
changeset
|
1153 field_list = gaim_request_field_group_get_fields(group); |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1154 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1155 if (gaim_request_field_group_get_title(group) != NULL) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1156 { |
8524 | 1157 frame = gaim_gtk_make_frame(vbox2, |
6324
01ce15fb27eb
[gaim-migrate @ 6823]
Christian Hammond <chipx86@chipx86.com>
parents:
6110
diff
changeset
|
1158 gaim_request_field_group_get_title(group)); |
01ce15fb27eb
[gaim-migrate @ 6823]
Christian Hammond <chipx86@chipx86.com>
parents:
6110
diff
changeset
|
1159 } |
6325
de67cb0dd09d
[gaim-migrate @ 6824]
Christian Hammond <chipx86@chipx86.com>
parents:
6324
diff
changeset
|
1160 else |
8524 | 1161 frame = vbox2; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1162 |
5816
64a164aa6f70
[gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents:
5815
diff
changeset
|
1163 field_count = g_list_length(field_list); |
8524 | 1164 /* |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1165 if (field_count > 9) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1166 { |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1167 rows = field_count / 2; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1168 cols++; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1169 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1170 else |
8524 | 1171 */ |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1172 rows = field_count; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1173 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1174 col_num = 0; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1175 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1176 for (fl = field_list; fl != NULL; fl = fl->next) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1177 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1178 GaimRequestFieldType type; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1179 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1180 field = (GaimRequestField *)fl->data; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1181 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1182 type = gaim_request_field_get_type(field); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1183 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1184 if (type == GAIM_REQUEST_FIELD_LABEL) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1185 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1186 if (col_num > 0) |
7921 | 1187 rows++; |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1188 |
7921 | 1189 rows++; |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1190 } |
10627
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1191 else if ((type == GAIM_REQUEST_FIELD_LIST) || |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1192 (type == GAIM_REQUEST_FIELD_STRING && |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1193 gaim_request_field_string_is_multiline(field))) |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1194 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1195 if (col_num > 0) |
7921 | 1196 rows++; |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1197 |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1198 rows += 2; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1199 } |
7921 | 1200 |
1201 col_num++; | |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1202 |
8323
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
1203 if (col_num >= cols) |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1204 col_num = 0; |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1205 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1206 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1207 table = gtk_table_new(rows, 2 * cols, FALSE); |
11243 | 1208 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
1209 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1210 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1211 gtk_container_add(GTK_CONTAINER(frame), table); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1212 gtk_widget_show(table); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1213 |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1214 for (row_num = 0, fl = field_list; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1215 row_num < rows && fl != NULL; |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1216 row_num++) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1217 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1218 for (col_num = 0; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1219 col_num < cols && fl != NULL; |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1220 col_num++, fl = fl->next) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1221 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1222 size_t col_offset = col_num * 2; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1223 GaimRequestFieldType type; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1224 GtkWidget *widget = NULL; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1225 |
12666
8765dee8f517
[gaim-migrate @ 15009]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1226 label = NULL; |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1227 field = fl->data; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1228 |
7922 | 1229 if (!gaim_request_field_is_visible(field)) { |
1230 col_num--; | |
7904
9b478c6e0bfa
[gaim-migrate @ 8564]
Christian Hammond <chipx86@chipx86.com>
parents:
7903
diff
changeset
|
1231 continue; |
7922 | 1232 } |
7904
9b478c6e0bfa
[gaim-migrate @ 8564]
Christian Hammond <chipx86@chipx86.com>
parents:
7903
diff
changeset
|
1233 |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1234 type = gaim_request_field_get_type(field); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1235 |
8332
f4a878d48254
[gaim-migrate @ 9056]
Christian Hammond <chipx86@chipx86.com>
parents:
8323
diff
changeset
|
1236 if (type != GAIM_REQUEST_FIELD_BOOLEAN && |
f4a878d48254
[gaim-migrate @ 9056]
Christian Hammond <chipx86@chipx86.com>
parents:
8323
diff
changeset
|
1237 gaim_request_field_get_label(field)) |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1238 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1239 char *text; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1240 |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1241 text = g_strdup_printf("%s:", |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1242 gaim_request_field_get_label(field)); |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1243 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1244 label = gtk_label_new(NULL); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1245 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), text); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1246 g_free(text); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1247 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1248 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1249 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1250 gtk_size_group_add_widget(sg, label); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1251 |
7905
1d0bc32f8038
[gaim-migrate @ 8565]
Christian Hammond <chipx86@chipx86.com>
parents:
7904
diff
changeset
|
1252 if (type == GAIM_REQUEST_FIELD_LABEL || |
10627
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1253 type == GAIM_REQUEST_FIELD_LIST || |
7905
1d0bc32f8038
[gaim-migrate @ 8565]
Christian Hammond <chipx86@chipx86.com>
parents:
7904
diff
changeset
|
1254 (type == GAIM_REQUEST_FIELD_STRING && |
1d0bc32f8038
[gaim-migrate @ 8565]
Christian Hammond <chipx86@chipx86.com>
parents:
7904
diff
changeset
|
1255 gaim_request_field_string_is_multiline(field))) |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1256 { |
7921 | 1257 if(col_num > 0) |
1258 row_num++; | |
1259 | |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1260 gtk_table_attach_defaults(GTK_TABLE(table), label, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1261 0, 2 * cols, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1262 row_num, row_num + 1); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1263 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1264 row_num++; |
7921 | 1265 col_num=cols; |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1266 } |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1267 else |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1268 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1269 gtk_table_attach_defaults(GTK_TABLE(table), label, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1270 col_offset, col_offset + 1, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1271 row_num, row_num + 1); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1272 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1273 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1274 gtk_widget_show(label); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1275 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1276 |
13360
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
1277 if (field->ui_data != NULL) |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
1278 widget = GTK_WIDGET(field->ui_data); |
2e6dda9f9159
[gaim-migrate @ 15733]
Richard Laager <rlaager@wiktel.com>
parents:
13355
diff
changeset
|
1279 else if (type == GAIM_REQUEST_FIELD_STRING) |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1280 widget = create_string_field(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1281 else if (type == GAIM_REQUEST_FIELD_INTEGER) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1282 widget = create_int_field(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1283 else if (type == GAIM_REQUEST_FIELD_BOOLEAN) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1284 widget = create_bool_field(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1285 else if (type == GAIM_REQUEST_FIELD_CHOICE) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1286 widget = create_choice_field(field); |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1287 else if (type == GAIM_REQUEST_FIELD_LIST) |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1288 widget = create_list_field(field); |
11357 | 1289 else if (type == GAIM_REQUEST_FIELD_IMAGE) |
1290 widget = create_image_field(field); | |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1291 else if (type == GAIM_REQUEST_FIELD_ACCOUNT) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1292 widget = create_account_field(field); |
7904
9b478c6e0bfa
[gaim-migrate @ 8564]
Christian Hammond <chipx86@chipx86.com>
parents:
7903
diff
changeset
|
1293 else |
9b478c6e0bfa
[gaim-migrate @ 8564]
Christian Hammond <chipx86@chipx86.com>
parents:
7903
diff
changeset
|
1294 continue; |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1295 |
12666
8765dee8f517
[gaim-migrate @ 15009]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1296 if (label) |
8765dee8f517
[gaim-migrate @ 15009]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1297 gtk_label_set_mnemonic_widget(GTK_LABEL(label), widget); |
8765dee8f517
[gaim-migrate @ 15009]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
1298 |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1299 if (type == GAIM_REQUEST_FIELD_STRING && |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1300 gaim_request_field_string_is_multiline(field)) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1301 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1302 gtk_table_attach(GTK_TABLE(table), widget, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1303 0, 2 * cols, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1304 row_num, row_num + 1, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1305 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1306 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1307 5, 0); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1308 } |
10627
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1309 else if (type == GAIM_REQUEST_FIELD_LIST) |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1310 { |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1311 gtk_table_attach(GTK_TABLE(table), widget, |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1312 0, 2 * cols, |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1313 row_num, row_num + 1, |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1314 GTK_FILL | GTK_EXPAND, |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1315 GTK_FILL | GTK_EXPAND, |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1316 5, 0); |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1317 } |
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1318 else if (type == GAIM_REQUEST_FIELD_BOOLEAN) |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1319 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1320 gtk_table_attach(GTK_TABLE(table), widget, |
10627
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1321 col_offset, col_offset + 1, |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1322 row_num, row_num + 1, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1323 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1324 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1325 5, 0); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1326 } |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1327 else |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1328 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1329 gtk_table_attach(GTK_TABLE(table), widget, |
10627
57589eb36449
[gaim-migrate @ 12102]
Luke Schierer <lschiere@pidgin.im>
parents:
10605
diff
changeset
|
1330 1, 2 * cols, |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1331 row_num, row_num + 1, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1332 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1333 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1334 5, 0); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1335 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1336 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1337 gtk_widget_show(widget); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1338 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1339 field->ui_data = widget; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1340 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1341 } |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1342 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1343 |
5813
b116f3a73256
[gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
1344 g_object_unref(sg); |
b116f3a73256
[gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
1345 |
5815
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1346 /* Button box. */ |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1347 bbox = gtk_hbutton_box_new(); |
11243 | 1348 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); |
5815
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1349 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1350 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1351 gtk_widget_show(bbox); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1352 |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1353 /* Cancel button */ |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1354 button = gtk_button_new_from_stock(text_to_stock(cancel_text)); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1355 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1356 gtk_widget_show(button); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1357 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1358 g_signal_connect(G_OBJECT(button), "clicked", |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1359 G_CALLBACK(multifield_cancel_cb), data); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1360 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1361 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1362 |
5815
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1363 /* OK button */ |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1364 button = gtk_button_new_from_stock(text_to_stock(ok_text)); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1365 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1366 gtk_widget_show(button); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1367 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1368 data->ok_button = button; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1369 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1370 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1371 gtk_window_set_default(GTK_WINDOW(win), button); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1372 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1373 g_signal_connect(G_OBJECT(button), "clicked", |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1374 G_CALLBACK(multifield_ok_cb), data); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1375 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1376 if (!gaim_request_fields_all_required_filled(fields)) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1377 gtk_widget_set_sensitive(button, FALSE); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1378 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1379 gtk_widget_show(win); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1380 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1381 return data; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1382 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1383 |
6363
b7ef10bbe9bb
[gaim-migrate @ 6868]
Christian Hammond <chipx86@chipx86.com>
parents:
6338
diff
changeset
|
1384 static void |
9502 | 1385 file_yes_no_cb(GaimGtkRequestData *data, gint id) |
1386 { | |
10605 | 1387 /* Only call the callback if yes was selected, otherwise the request |
1388 * (eg. file transfer) will be cancelled, then when a new filename is chosen | |
1389 * things go BOOM */ | |
1390 if (id == 1) { | |
1391 if (data->cbs[1] != NULL) | |
1392 ((GaimRequestFileCb)data->cbs[1])(data->user_data, data->u.file.name); | |
13282
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1393 gaim_request_close(data->type, data); |
13372
fb178093e364
[gaim-migrate @ 15745]
Richard Laager <rlaager@wiktel.com>
parents:
13361
diff
changeset
|
1394 } else { |
13434
ffd724befbf8
[gaim-migrate @ 15809]
Richard Laager <rlaager@wiktel.com>
parents:
13372
diff
changeset
|
1395 gaim_gtk_clear_cursor(GTK_WIDGET(data->dialog)); |
10605 | 1396 } |
9502 | 1397 } |
1398 | |
9573 | 1399 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
9502 | 1400 static void |
1401 file_ok_check_if_exists_cb(GtkWidget *widget, gint response, GaimGtkRequestData *data) | |
1402 { | |
10536 | 1403 gchar *current_folder; |
1404 | |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
1405 generic_response_start(data); |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
1406 |
9502 | 1407 if (response != GTK_RESPONSE_ACCEPT) { |
1408 if (data->cbs[0] != NULL) | |
1409 ((GaimRequestFileCb)data->cbs[0])(data->user_data, NULL); | |
13282
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1410 gaim_request_close(data->type, data); |
9502 | 1411 return; |
1412 } | |
1413 | |
1414 data->u.file.name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data->dialog)); | |
10605 | 1415 current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(data->dialog)); |
1416 if (current_folder != NULL) { | |
1417 if (data->u.file.savedialog) { | |
1418 gaim_prefs_set_string("/gaim/gtk/filelocations/last_save_folder", current_folder); | |
1419 } else { | |
1420 gaim_prefs_set_string("/gaim/gtk/filelocations/last_open_folder", current_folder); | |
10536 | 1421 } |
10605 | 1422 g_free(current_folder); |
10536 | 1423 } |
10605 | 1424 |
9502 | 1425 #else /* FILECHOOSER */ |
10605 | 1426 |
9573 | 1427 static void |
9502 | 1428 file_ok_check_if_exists_cb(GtkWidget *button, GaimGtkRequestData *data) |
1429 { | |
9503 | 1430 const gchar *name; |
10605 | 1431 gchar *current_folder; |
9502 | 1432 |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
1433 generic_response_start(data); |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
1434 |
9503 | 1435 name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data->dialog)); |
9513 | 1436 |
1437 /* If name is a directory then change directories */ | |
13282
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1438 if (data->type == GAIM_REQUEST_FILE) { |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1439 if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(data->dialog))) |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1440 return; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1441 } |
9513 | 1442 |
10605 | 1443 current_folder = g_path_get_dirname(name); |
13282
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1444 |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1445 g_free(data->u.file.name); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1446 if (data->type == GAIM_REQUEST_FILE) |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1447 data->u.file.name = g_strdup(name); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1448 else |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1449 { |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1450 if (g_file_test(name, G_FILE_TEST_IS_DIR)) |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1451 data->u.file.name = g_strdup(name); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1452 else |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1453 data->u.file.name = g_strdup(current_folder); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1454 } |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1455 |
10605 | 1456 if (current_folder != NULL) { |
1457 if (data->u.file.savedialog) { | |
1458 gaim_prefs_set_string("/gaim/gtk/filelocations/last_save_folder", current_folder); | |
1459 } else { | |
1460 gaim_prefs_set_string("/gaim/gtk/filelocations/last_open_folder", current_folder); | |
1461 } | |
1462 g_free(current_folder); | |
1463 } | |
1464 | |
9502 | 1465 #endif /* FILECHOOSER */ |
1466 | |
1467 if ((data->u.file.savedialog == TRUE) && | |
1468 (g_file_test(data->u.file.name, G_FILE_TEST_EXISTS))) { | |
1469 gaim_request_yes_no(data, NULL, _("That file already exists"), | |
10116 | 1470 _("Would you like to overwrite it?"), 0, data, |
9502 | 1471 G_CALLBACK(file_yes_no_cb), |
1472 G_CALLBACK(file_yes_no_cb)); | |
1473 } else | |
1474 file_yes_no_cb(data, 1); | |
1475 } | |
1476 | |
1477 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
1478 static void | |
9506 | 1479 file_cancel_cb(GaimGtkRequestData *data) |
9502 | 1480 { |
12234
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
1481 generic_response_start(data); |
7de5514bc406
[gaim-migrate @ 14536]
Richard Laager <rlaager@wiktel.com>
parents:
12067
diff
changeset
|
1482 |
9502 | 1483 if (data->cbs[0] != NULL) |
1484 ((GaimRequestFileCb)data->cbs[0])(data->user_data, NULL); | |
1485 | |
13282
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1486 gaim_request_close(data->type, data); |
9502 | 1487 } |
1488 #endif /* FILECHOOSER */ | |
1489 | |
1490 static void * | |
1491 gaim_gtk_request_file(const char *title, const char *filename, | |
1492 gboolean savedialog, | |
1493 GCallback ok_cb, GCallback cancel_cb, | |
1494 void *user_data) | |
1495 { | |
1496 GaimGtkRequestData *data; | |
1497 GtkWidget *filesel; | |
10605 | 1498 const gchar *current_folder; |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1499 #if GTK_CHECK_VERSION(2,4,0) |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1500 gboolean folder_set = FALSE; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1501 #endif |
9502 | 1502 |
1503 data = g_new0(GaimGtkRequestData, 1); | |
1504 data->type = GAIM_REQUEST_FILE; | |
1505 data->user_data = user_data; | |
1506 data->cb_count = 2; | |
1507 data->cbs = g_new0(GCallback, 2); | |
1508 data->cbs[0] = cancel_cb; | |
1509 data->cbs[1] = ok_cb; | |
1510 data->u.file.savedialog = savedialog; | |
1511 | |
1512 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
1513 filesel = gtk_file_chooser_dialog_new( | |
1514 title ? title : (savedialog ? _("Save File...") | |
1515 : _("Open File...")), | |
1516 NULL, | |
1517 savedialog ? GTK_FILE_CHOOSER_ACTION_SAVE | |
1518 : GTK_FILE_CHOOSER_ACTION_OPEN, | |
1519 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
1520 savedialog ? GTK_STOCK_SAVE | |
1521 : GTK_STOCK_OPEN, | |
1522 GTK_RESPONSE_ACCEPT, | |
1523 NULL); | |
1524 gtk_dialog_set_default_response(GTK_DIALOG(filesel), GTK_RESPONSE_ACCEPT); | |
10605 | 1525 |
1526 if (savedialog) { | |
1527 current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_save_folder"); | |
1528 } else { | |
1529 current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_open_folder"); | |
9502 | 1530 } |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1531 |
10605 | 1532 if (filename != NULL) |
1533 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(filesel), filename); | |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1534 if ((current_folder != NULL) && (*current_folder != '\0')) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1535 folder_set = gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(filesel), current_folder); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1536 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1537 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1538 #ifdef _WIN32 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1539 if (!folder_set) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1540 char *my_documents = wgaim_get_special_folder(CSIDL_PERSONAL); |
10605 | 1541 |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1542 if (my_documents != NULL) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1543 gtk_file_chooser_set_current_folder( |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1544 GTK_FILE_CHOOSER(filesel), my_documents); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1545 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1546 g_free(my_documents); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1547 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1548 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1549 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1550 #endif |
9502 | 1551 g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(filesel)), "response", |
1552 G_CALLBACK(file_ok_check_if_exists_cb), data); | |
1553 #else /* FILECHOOSER */ | |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1554 filesel = gtk_file_selection_new( |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1555 title ? title : (savedialog ? _("Save File...") |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10668
diff
changeset
|
1556 : _("Open File..."))); |
10605 | 1557 if (savedialog) { |
1558 current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_save_folder"); | |
1559 } else { | |
1560 current_folder = gaim_prefs_get_string("/gaim/gtk/filelocations/last_open_folder"); | |
1561 } | |
1562 if (current_folder != NULL) { | |
1563 gchar *path = g_strdup_printf("%s%s", current_folder, G_DIR_SEPARATOR_S); | |
1564 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), path); | |
1565 g_free(path); | |
1566 } | |
10225 | 1567 if (filename != NULL) |
1568 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), filename); | |
10605 | 1569 |
9506 | 1570 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)), "delete_event", |
1571 G_CALLBACK(file_cancel_cb), data); | |
1572 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), | |
9502 | 1573 "clicked", G_CALLBACK(file_cancel_cb), data); |
9506 | 1574 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), "clicked", |
1575 G_CALLBACK(file_ok_check_if_exists_cb), data); | |
9502 | 1576 #endif /* FILECHOOSER */ |
1577 | |
1578 data->dialog = filesel; | |
1579 gtk_widget_show(filesel); | |
1580 | |
1581 return (void *)data; | |
1582 } | |
1583 | |
13282
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1584 static void * |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1585 gaim_gtk_request_folder(const char *title, const char *dirname, |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1586 GCallback ok_cb, GCallback cancel_cb, |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1587 void *user_data) |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1588 { |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1589 GaimGtkRequestData *data; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1590 GtkWidget *dirsel; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1591 |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1592 data = g_new0(GaimGtkRequestData, 1); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1593 data->type = GAIM_REQUEST_FOLDER; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1594 data->user_data = user_data; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1595 data->cb_count = 2; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1596 data->cbs = g_new0(GCallback, 2); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1597 data->cbs[0] = cancel_cb; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1598 data->cbs[1] = ok_cb; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1599 data->u.file.savedialog = FALSE; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1600 |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1601 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1602 /* Use a translated "Select Folder..." in place of NULL after strings thaw. */ |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1603 dirsel = gtk_file_chooser_dialog_new( |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1604 title ? title : NULL, |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1605 NULL, |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1606 GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1607 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1608 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1609 NULL); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1610 gtk_dialog_set_default_response(GTK_DIALOG(dirsel), GTK_RESPONSE_ACCEPT); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1611 |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1612 if ((dirname != NULL) && (*dirname != '\0')) |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1613 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dirsel), dirname); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1614 |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1615 g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(dirsel)), "response", |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1616 G_CALLBACK(file_ok_check_if_exists_cb), data); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1617 #else |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1618 /* Use a translated "Select Folder..." in place of NULL after strings thaw. */ |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1619 dirsel = gtk_file_selection_new(title ? title : NULL); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1620 |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1621 g_signal_connect_swapped(G_OBJECT(dirsel), "delete_event", |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1622 G_CALLBACK(file_cancel_cb), data); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1623 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(dirsel)->cancel_button), |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1624 "clicked", G_CALLBACK(file_cancel_cb), data); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1625 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dirsel)->ok_button), "clicked", |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1626 G_CALLBACK(file_ok_check_if_exists_cb), data); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1627 #endif |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1628 |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1629 data->dialog = dirsel; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1630 gtk_widget_show(dirsel); |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1631 |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1632 return (void *)data; |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1633 } |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1634 |
9502 | 1635 static void |
5480 | 1636 gaim_gtk_close_request(GaimRequestType type, void *ui_handle) |
1637 { | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1638 GaimGtkRequestData *data = (GaimGtkRequestData *)ui_handle; |
5480 | 1639 |
1640 if (data->cbs != NULL) | |
1641 g_free(data->cbs); | |
1642 | |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1643 gtk_widget_destroy(data->dialog); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1644 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1645 if (type == GAIM_REQUEST_FIELDS) |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1646 gaim_request_fields_destroy(data->u.multifield.fields); |
9513 | 1647 else if (type == GAIM_REQUEST_FILE) |
1648 g_free(data->u.file.name); | |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1649 |
5480 | 1650 g_free(data); |
1651 } | |
1652 | |
1653 static GaimRequestUiOps ops = | |
1654 { | |
1655 gaim_gtk_request_input, | |
1656 gaim_gtk_request_choice, | |
1657 gaim_gtk_request_action, | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1658 gaim_gtk_request_fields, |
8843 | 1659 gaim_gtk_request_file, |
13282
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1660 gaim_gtk_close_request, |
a651bfe0a922
[gaim-migrate @ 15648]
Richard Laager <rlaager@wiktel.com>
parents:
13280
diff
changeset
|
1661 gaim_gtk_request_folder |
5480 | 1662 }; |
1663 | |
1664 GaimRequestUiOps * | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1665 gaim_gtk_request_get_ui_ops(void) |
5480 | 1666 { |
1667 return &ops; | |
1668 } |