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