Mercurial > pidgin.yaz
annotate src/gtkrequest.c @ 9589:f4654d3b7b8d
[gaim-migrate @ 10432]
Patch by our dedicated crazy patch writer Stu Tomlinson. This
HTML-escapes whois information. It also apparently fixes a bug in the
tracker.
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Sat, 24 Jul 2004 18:17:47 +0000 |
parents | c8e0426c63ed |
children | 4d05b6e9e9cd |
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 */ | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6363
diff
changeset
|
25 #include "gtkinternal.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5846
diff
changeset
|
26 |
7066
87bfe52a4099
[gaim-migrate @ 7630]
Christian Hammond <chipx86@chipx86.com>
parents:
7048
diff
changeset
|
27 #include "prefs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5846
diff
changeset
|
28 |
5480 | 29 #include "gtkrequest.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5846
diff
changeset
|
30 #include "gtkutils.h" |
5480 | 31 #include "stock.h" |
7068
faddd59a0e74
[gaim-migrate @ 7632]
Christian Hammond <chipx86@chipx86.com>
parents:
7066
diff
changeset
|
32 #include "ui.h" |
8697 | 33 #include "gtkimhtml.h" |
34 #include "gtkimhtmltoolbar.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; | |
47 GtkWidget *dialog; | |
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 |
5835
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
137 static gboolean |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
138 field_string_focus_out_cb(GtkWidget *entry, GdkEventFocus *event, |
5846
4676b498ff4b
[gaim-migrate @ 6277]
Christian Hammond <chipx86@chipx86.com>
parents:
5845
diff
changeset
|
139 GaimRequestField *field) |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
140 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
141 const char *value; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
142 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
143 if (gaim_request_field_string_is_multiline(field)) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
144 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
145 GtkTextBuffer *buffer; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
146 GtkTextIter start_iter, end_iter; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
147 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
148 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
149 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
150 gtk_text_buffer_get_start_iter(buffer, &start_iter); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
151 gtk_text_buffer_get_end_iter(buffer, &end_iter); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
152 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
153 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
|
154 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
155 else |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
156 value = gtk_entry_get_text(GTK_ENTRY(entry)); |
5834
77eba2e68d07
[gaim-migrate @ 6265]
Christian Hammond <chipx86@chipx86.com>
parents:
5832
diff
changeset
|
157 |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
158 gaim_request_field_string_set_value(field, |
5834
77eba2e68d07
[gaim-migrate @ 6265]
Christian Hammond <chipx86@chipx86.com>
parents:
5832
diff
changeset
|
159 (*value == '\0' ? NULL : value)); |
5835
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
160 |
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
161 return FALSE; |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
162 } |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
163 |
5835
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
164 static gboolean |
5846
4676b498ff4b
[gaim-migrate @ 6277]
Christian Hammond <chipx86@chipx86.com>
parents:
5845
diff
changeset
|
165 field_int_focus_out_cb(GtkEntry *entry, GdkEventFocus *event, |
4676b498ff4b
[gaim-migrate @ 6277]
Christian Hammond <chipx86@chipx86.com>
parents:
5845
diff
changeset
|
166 GaimRequestField *field) |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
167 { |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
168 gaim_request_field_int_set_value(field, |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
169 atoi(gtk_entry_get_text(entry))); |
5835
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
170 |
9a08899192ee
[gaim-migrate @ 6266]
Christian Hammond <chipx86@chipx86.com>
parents:
5834
diff
changeset
|
171 return FALSE; |
5832
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
172 } |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
173 |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
174 static void |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
175 field_bool_cb(GtkToggleButton *button, GaimRequestField *field) |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
176 { |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
177 gaim_request_field_bool_set_value(field, |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
178 gtk_toggle_button_get_active(button)); |
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 |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
181 static void |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
182 field_choice_menu_cb(GtkOptionMenu *menu, GaimRequestField *field) |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
183 { |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
184 gaim_request_field_choice_set_value(field, |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
185 gtk_option_menu_get_history(menu)); |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
186 } |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
187 |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
188 static void |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
189 field_choice_option_cb(GtkRadioButton *button, GaimRequestField *field) |
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 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
192 gaim_request_field_choice_set_value(field, |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
193 g_slist_index(gtk_radio_button_get_group(button), button)); |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
194 } |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
195 |
db204c4a411b
[gaim-migrate @ 6263]
Christian Hammond <chipx86@chipx86.com>
parents:
5817
diff
changeset
|
196 static void |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
197 field_account_cb(GObject *w, GaimAccount *account, GaimRequestField *field) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
198 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
199 gaim_request_field_account_set_value(field, account); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
200 } |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
201 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
202 static void |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
203 multifield_ok_cb(GtkWidget *button, GaimGtkRequestData *data) |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
204 { |
8521
4cfb32f78d71
[gaim-migrate @ 9260]
Christian Hammond <chipx86@chipx86.com>
parents:
8332
diff
changeset
|
205 if (!GTK_WIDGET_HAS_FOCUS(button)) |
4cfb32f78d71
[gaim-migrate @ 9260]
Christian Hammond <chipx86@chipx86.com>
parents:
8332
diff
changeset
|
206 gtk_widget_grab_focus(button); |
4cfb32f78d71
[gaim-migrate @ 9260]
Christian Hammond <chipx86@chipx86.com>
parents:
8332
diff
changeset
|
207 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
208 if (data->cbs[0] != NULL) |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
209 ((GaimRequestFieldsCb)data->cbs[0])(data->user_data, |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
210 data->u.multifield.fields); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
211 |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
212 gaim_request_close(GAIM_REQUEST_FIELDS, data); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
213 } |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
214 |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
215 static void |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
216 multifield_cancel_cb(GtkWidget *button, GaimGtkRequestData *data) |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
217 { |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
218 if (data->cbs[1] != NULL) |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
219 ((GaimRequestFieldsCb)data->cbs[1])(data->user_data, |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
220 data->u.multifield.fields); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
221 |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
222 gaim_request_close(GAIM_REQUEST_FIELDS, data); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
223 } |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
224 |
8323
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
225 static void |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
226 destroy_multifield_cb(GtkWidget *dialog, GdkEvent *event, |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
227 GaimGtkRequestData *data) |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
228 { |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
229 multifield_cancel_cb(NULL, data); |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
230 } |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
231 |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
232 |
5480 | 233 #define STOCK_ITEMIZE(r, l) \ |
234 if (!strcmp((r), text)) \ | |
235 return (l); | |
236 | |
237 static const char * | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
238 text_to_stock(const char *text) |
5480 | 239 { |
6334
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
240 STOCK_ITEMIZE(_("Yes"), GTK_STOCK_YES); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
241 STOCK_ITEMIZE(_("No"), GTK_STOCK_NO); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
242 STOCK_ITEMIZE(_("OK"), GTK_STOCK_OK); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
243 STOCK_ITEMIZE(_("Cancel"), GTK_STOCK_CANCEL); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
244 STOCK_ITEMIZE(_("Apply"), GTK_STOCK_APPLY); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
245 STOCK_ITEMIZE(_("Close"), GTK_STOCK_CLOSE); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
246 STOCK_ITEMIZE(_("Delete"), GTK_STOCK_DELETE); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
247 STOCK_ITEMIZE(_("Add"), GTK_STOCK_ADD); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
248 STOCK_ITEMIZE(_("Remove"), GTK_STOCK_REMOVE); |
930708df05dd
[gaim-migrate @ 6833]
Christian Hammond <chipx86@chipx86.com>
parents:
6326
diff
changeset
|
249 STOCK_ITEMIZE(_("Save"), GTK_STOCK_SAVE); |
8302
462ead6fc1a0
[gaim-migrate @ 9026]
Christian Hammond <chipx86@chipx86.com>
parents:
8294
diff
changeset
|
250 STOCK_ITEMIZE(_("Alias"), GAIM_STOCK_ALIAS); |
5480 | 251 |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
252 return text; |
5480 | 253 } |
254 | |
6363
b7ef10bbe9bb
[gaim-migrate @ 6868]
Christian Hammond <chipx86@chipx86.com>
parents:
6338
diff
changeset
|
255 static void * |
5480 | 256 gaim_gtk_request_input(const char *title, const char *primary, |
257 const char *secondary, const char *default_value, | |
8697 | 258 gboolean multiline, gboolean masked, gchar *hint, |
5480 | 259 const char *ok_text, GCallback ok_cb, |
260 const char *cancel_text, GCallback cancel_cb, | |
261 void *user_data) | |
262 { | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
263 GaimGtkRequestData *data; |
5480 | 264 GtkWidget *dialog; |
265 GtkWidget *vbox; | |
266 GtkWidget *hbox; | |
267 GtkWidget *label; | |
268 GtkWidget *entry; | |
269 GtkWidget *img; | |
8782
5a2b5e4abf3a
[gaim-migrate @ 9544]
Christian Hammond <chipx86@chipx86.com>
parents:
8697
diff
changeset
|
270 GtkWidget *toolbar; |
5480 | 271 char *label_text; |
272 | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
273 data = g_new0(GaimGtkRequestData, 1); |
5480 | 274 data->type = GAIM_REQUEST_INPUT; |
275 data->user_data = user_data; | |
276 | |
277 data->cb_count = 2; | |
278 data->cbs = g_new0(GCallback, 2); | |
279 | |
280 data->cbs[0] = ok_cb; | |
281 data->cbs[1] = cancel_cb; | |
282 | |
283 /* Create the dialog. */ | |
7678 | 284 dialog = gtk_dialog_new_with_buttons(title ? title : GAIM_ALERT_TITLE, |
285 NULL, 0, | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
286 text_to_stock(cancel_text), 1, |
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
287 text_to_stock(ok_text), 0, |
5485 | 288 NULL); |
5480 | 289 data->dialog = dialog; |
290 | |
291 g_signal_connect(G_OBJECT(dialog), "response", | |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
292 G_CALLBACK(input_response_cb), data); |
5480 | 293 |
294 /* Setup the dialog */ | |
295 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); | |
5510
da18a02c3705
[gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
296 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6); |
5480 | 297 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
298 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); | |
5510
da18a02c3705
[gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
299 gtk_dialog_set_default_response(GTK_DIALOG(dialog), 0); |
5480 | 300 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); |
301 | |
302 /* Setup the main horizontal box */ | |
303 hbox = gtk_hbox_new(FALSE, 12); | |
304 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); | |
305 | |
306 /* Dialog icon. */ | |
307 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, | |
308 GTK_ICON_SIZE_DIALOG); | |
309 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
310 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
311 | |
312 /* Vertical box */ | |
313 vbox = gtk_vbox_new(FALSE, 12); | |
314 | |
315 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); | |
316 | |
317 /* Descriptive label */ | |
7843 | 318 label_text = g_strdup_printf((primary ? "<span weight=\"bold\" size=\"larger\">" |
319 "%s</span>%s%s" : "%s%s%s"), | |
320 (primary ? primary : ""), | |
321 ((primary && secondary) ? "\n\n" : ""), | |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
322 (secondary ? secondary : "")); |
5480 | 323 |
324 label = gtk_label_new(NULL); | |
325 | |
326 gtk_label_set_markup(GTK_LABEL(label), label_text); | |
327 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
328 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
329 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | |
330 | |
331 g_free(label_text); | |
332 | |
333 /* Entry field. */ | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
334 data->u.input.multiline = multiline; |
8697 | 335 data->u.input.hint = (hint == NULL ? NULL : g_strdup(hint)); |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
336 |
8697 | 337 if ((data->u.input.hint != NULL) && (!strcmp(data->u.input.hint, "html"))) { |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
338 GtkWidget *sw; |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
339 |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
340 sw = gtk_scrolled_window_new(NULL, NULL); |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
341 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
342 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
343 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
344 GTK_SHADOW_IN); |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
345 |
7068
faddd59a0e74
[gaim-migrate @ 7632]
Christian Hammond <chipx86@chipx86.com>
parents:
7066
diff
changeset
|
346 gtk_widget_set_size_request(sw, 320, 130); |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
347 |
8697 | 348 /* Toolbar */ |
349 toolbar = gtk_imhtmltoolbar_new(); | |
350 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); | |
351 | |
352 /* GtkIMHtml */ | |
353 entry = gtk_imhtml_new(NULL, NULL); | |
9005 | 354 gtk_widget_set_name(entry, "gaim_gtkrequest_imhtml"); |
8697 | 355 gtk_imhtml_set_editable(GTK_IMHTML(entry), TRUE); |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
356 |
8697 | 357 gtk_imhtml_smiley_shortcuts(GTK_IMHTML(entry), gaim_prefs_get_bool("/gaim/gtk/conversations/smiley_shortcuts")); |
358 gtk_imhtml_html_shortcuts(GTK_IMHTML(entry), gaim_prefs_get_bool("/gaim/gtk/conversations/html_shortcuts")); | |
359 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), entry); | |
360 | |
361 if (default_value != NULL) | |
362 gtk_imhtml_append_text(GTK_IMHTML(entry), default_value, GTK_IMHTML_NO_SCROLL); | |
363 | |
7068
faddd59a0e74
[gaim-migrate @ 7632]
Christian Hammond <chipx86@chipx86.com>
parents:
7066
diff
changeset
|
364 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(entry), GTK_WRAP_WORD_CHAR); |
5480 | 365 |
8697 | 366 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); |
367 | |
7066
87bfe52a4099
[gaim-migrate @ 7630]
Christian Hammond <chipx86@chipx86.com>
parents:
7048
diff
changeset
|
368 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7458
diff
changeset
|
369 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(entry)); |
7066
87bfe52a4099
[gaim-migrate @ 7630]
Christian Hammond <chipx86@chipx86.com>
parents:
7048
diff
changeset
|
370 |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
371 gtk_container_add(GTK_CONTAINER(sw), entry); |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
372 } |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
373 else { |
8697 | 374 if (multiline) { |
375 GtkWidget *sw; | |
376 | |
377 sw = gtk_scrolled_window_new(NULL, NULL); | |
378 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
379 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
380 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
381 GTK_SHADOW_IN); | |
382 | |
383 gtk_widget_set_size_request(sw, 320, 130); | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
384 |
8697 | 385 /* GtkTextView */ |
386 entry = gtk_text_view_new(); | |
387 gtk_text_view_set_editable(GTK_TEXT_VIEW(entry), TRUE); | |
5510
da18a02c3705
[gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
388 |
8697 | 389 if (default_value != NULL) { |
390 GtkTextBuffer *buffer; | |
391 | |
392 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)); | |
393 gtk_text_buffer_set_text(buffer, default_value, -1); | |
394 } | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
395 |
8697 | 396 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(entry), GTK_WRAP_WORD_CHAR); |
397 | |
398 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
399 | |
400 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) | |
401 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(entry)); | |
6035
8c44020a958e
[gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
402 |
8697 | 403 gtk_container_add(GTK_CONTAINER(sw), entry); |
404 } | |
405 else { | |
406 entry = gtk_entry_new(); | |
407 | |
408 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); | |
409 | |
410 gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0); | |
411 | |
412 if (default_value != NULL) | |
413 gtk_entry_set_text(GTK_ENTRY(entry), default_value); | |
414 | |
415 if (masked) | |
416 gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); | |
417 } | |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
418 } |
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
419 |
8137 | 420 gaim_set_accessible_label (entry, label); |
5490
421020171808
[gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents:
5485
diff
changeset
|
421 data->u.input.entry = entry; |
5480 | 422 |
423 /* Show everything. */ | |
424 gtk_widget_show_all(dialog); | |
425 | |
426 return data; | |
427 } | |
428 | |
6363
b7ef10bbe9bb
[gaim-migrate @ 6868]
Christian Hammond <chipx86@chipx86.com>
parents:
6338
diff
changeset
|
429 static void * |
5480 | 430 gaim_gtk_request_choice(const char *title, const char *primary, |
431 const char *secondary, unsigned int default_value, | |
432 const char *ok_text, GCallback ok_cb, | |
433 const char *cancel_text, GCallback cancel_cb, | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
434 void *user_data, size_t choice_count, va_list args) |
5480 | 435 { |
436 return NULL; | |
437 } | |
438 | |
6363
b7ef10bbe9bb
[gaim-migrate @ 6868]
Christian Hammond <chipx86@chipx86.com>
parents:
6338
diff
changeset
|
439 static void * |
5480 | 440 gaim_gtk_request_action(const char *title, const char *primary, |
441 const char *secondary, unsigned int default_action, | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
442 void *user_data, size_t action_count, va_list actions) |
5480 | 443 { |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
444 GaimGtkRequestData *data; |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
445 GtkWidget *dialog; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
446 GtkWidget *vbox; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
447 GtkWidget *hbox; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
448 GtkWidget *label; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
449 GtkWidget *img; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
450 void **buttons; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
451 char *label_text; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
452 int i; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
453 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
454 data = g_new0(GaimGtkRequestData, 1); |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
455 data->type = GAIM_REQUEST_ACTION; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
456 data->user_data = user_data; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
457 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
458 data->cb_count = action_count; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
459 data->cbs = g_new0(GCallback, action_count); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
460 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
461 /* Reverse the buttons */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
462 buttons = g_new0(void *, action_count * 2); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
463 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
464 for (i = 0; i < action_count * 2; i += 2) { |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
465 buttons[(action_count * 2) - i - 2] = va_arg(actions, char *); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
466 buttons[(action_count * 2) - i - 1] = va_arg(actions, GCallback); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
467 } |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
468 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
469 /* Create the dialog. */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
470 data->dialog = dialog = gtk_dialog_new(); |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6363
diff
changeset
|
471 |
6109 | 472 if (title != NULL) |
473 gtk_window_set_title(GTK_WINDOW(dialog), title); | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
474 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
475 for (i = 0; i < action_count; i++) { |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
476 gtk_dialog_add_button(GTK_DIALOG(dialog), |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
477 text_to_stock(buttons[2 * i]), i); |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
478 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
479 data->cbs[i] = buttons[2 * i + 1]; |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
480 } |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
481 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
482 g_free(buttons); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
483 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
484 g_signal_connect(G_OBJECT(dialog), "response", |
5794
5e93fc46d1af
[gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents:
5510
diff
changeset
|
485 G_CALLBACK(action_response_cb), data); |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
486 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
487 /* Setup the dialog */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
488 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
489 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
490 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
491 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
492 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
|
493 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
494 /* Setup the main horizontal box */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
495 hbox = gtk_hbox_new(FALSE, 12); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
496 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
497 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
498 /* Dialog icon. */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
499 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
500 GTK_ICON_SIZE_DIALOG); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
501 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
502 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
503 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
504 /* Vertical box */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
505 vbox = gtk_vbox_new(FALSE, 12); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
506 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
507 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
508 /* Descriptive label */ |
7843 | 509 label_text = g_strdup_printf((primary ? "<span weight=\"bold\" size=\"larger\">" |
510 "%s</span>%s%s" : "%s%s%s"), | |
511 (primary ? primary : ""), | |
512 ((primary && secondary) ? "\n\n" : ""), | |
513 (secondary ? secondary : "")); | |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
514 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
515 label = gtk_label_new(NULL); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
516 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
517 gtk_label_set_markup(GTK_LABEL(label), label_text); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
518 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
519 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
520 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
521 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
522 g_free(label_text); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
523 |
5510
da18a02c3705
[gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
524 if (default_action != -1) |
da18a02c3705
[gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
525 gtk_dialog_set_default_response(GTK_DIALOG(dialog), default_action); |
da18a02c3705
[gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
526 |
5496
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
527 /* Show everything. */ |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
528 gtk_widget_show_all(dialog); |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
529 |
b7c0be69c749
[gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents:
5490
diff
changeset
|
530 return data; |
5480 | 531 } |
532 | |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
533 static void |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
534 req_entry_field_changed_cb(GtkWidget *entry, GaimRequestField *field) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
535 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
536 GaimGtkRequestData *req_data; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
537 const char *text = gtk_entry_get_text(GTK_ENTRY(entry)); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
538 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
539 gaim_request_field_string_set_value(field, (*text == '\0' ? NULL : text)); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
540 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
541 req_data = (GaimGtkRequestData *)field->group->fields_list->ui_data; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
542 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
543 gtk_widget_set_sensitive(req_data->ok_button, |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
544 gaim_request_fields_all_required_filled(field->group->fields_list)); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
545 } |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
546 |
8294
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
547 GList * |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
548 get_online_screennames(void) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
549 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
550 GList *screennames = NULL; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
551 GaimBlistNode *gnode, *cnode, *bnode; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
552 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
553 for (gnode = gaim_get_blist()->root; gnode != NULL; gnode = gnode->next) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
554 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
555 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
556 continue; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
557 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
558 for (cnode = gnode->child; cnode != NULL; cnode = cnode->next) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
559 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
560 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
561 continue; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
562 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
563 for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
564 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
565 GaimBuddy *buddy = (GaimBuddy *)bnode; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
566 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
567 if (!gaim_account_is_connected(buddy->account)) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
568 continue; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
569 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
570 screennames = g_list_append(screennames, g_strdup(buddy->name)); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
571 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
572 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
573 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
574 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
575 return screennames; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
576 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
577 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
578 #ifndef NEW_STYLE_COMPLETION |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
579 static gboolean |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
580 completion_entry_event(GtkEditable *entry, GdkEventKey *event, |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
581 GaimGtkCompletionData *data) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
582 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
583 int pos, end_pos; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
584 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
585 if (event->type == GDK_KEY_PRESS && event->keyval == GDK_Tab) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
586 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
587 gtk_editable_get_selection_bounds(entry, &pos, &end_pos); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
588 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
589 if (data->completion_started && |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
590 pos != end_pos && pos > 1 && |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
591 end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
592 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
593 gtk_editable_select_region(entry, 0, 0); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
594 gtk_editable_set_position(entry, -1); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
595 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
596 return TRUE; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
597 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
598 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
599 else if (event->type == GDK_KEY_PRESS && event->length > 0) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
600 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
601 char *prefix, *nprefix; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
602 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
603 gtk_editable_get_selection_bounds(entry, &pos, &end_pos); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
604 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
605 if (data->completion_started && |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
606 pos != end_pos && pos > 1 && |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
607 end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
608 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
609 char *temp; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
610 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
611 temp = gtk_editable_get_chars(entry, 0, pos); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
612 prefix = g_strconcat(temp, event->string, NULL); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
613 g_free(temp); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
614 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
615 else if (pos == end_pos && pos > 1 && |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
616 end_pos == strlen(gtk_entry_get_text(GTK_ENTRY(entry)))) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
617 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
618 prefix = g_strconcat(gtk_entry_get_text(GTK_ENTRY(entry)), |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
619 event->string, NULL); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
620 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
621 else |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
622 return FALSE; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
623 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
624 pos = strlen(prefix); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
625 nprefix = NULL; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
626 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
627 g_completion_complete(data->completion, prefix, &nprefix); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
628 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
629 if (nprefix != NULL) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
630 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
631 gtk_entry_set_text(GTK_ENTRY(entry), nprefix); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
632 gtk_editable_set_position(entry, pos); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
633 gtk_editable_select_region(entry, pos, -1); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
634 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
635 data->completion_started = TRUE; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
636 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
637 g_free(nprefix); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
638 g_free(prefix); |
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 return TRUE; |
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 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
643 g_free(prefix); |
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 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
646 return FALSE; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
647 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
648 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
649 static void |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
650 destroy_completion_data(GtkWidget *w, GaimGtkCompletionData *data) |
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 g_list_foreach(data->completion->items, (GFunc)g_free, NULL); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
653 g_completion_free(data->completion); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
654 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
655 g_free(data); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
656 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
657 #endif /* !NEW_STYLE_COMPLETION */ |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
658 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
659 static void |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
660 setup_screenname_autocomplete(GtkWidget *entry, GaimRequestField *field) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
661 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
662 #ifdef NEW_STYLE_COMPLETION |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
663 GtkListStore *store; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
664 GtkTreeIter iter; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
665 GtkEntryCompletion *completion; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
666 GList *screennames, *l; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
667 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
668 store = gtk_list_store_new(1, G_TYPE_STRING); |
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 screennames = get_online_screennames(); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
671 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
672 for (l = screennames; l != NULL; l = l->next) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
673 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
674 gtk_list_store_append(store, &iter); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
675 gtk_list_store_set(store, &iter, 0, l->data, -1); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
676 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
677 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
678 g_list_foreach(screennames, (GFunc)g_free, NULL); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
679 g_list_free(screennames); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
680 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
681 completion = gtk_entry_completion_new(); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
682 gtk_entry_set_completion(GTK_ENTRY(entry), completion); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
683 g_object_unref(completion); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
684 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
685 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(store)); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
686 g_object_unref(store); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
687 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
688 gtk_entry_completion_set_text_column(completion, 0); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
689 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
690 #else /* !NEW_STYLE_COMPLETION */ |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
691 GaimGtkCompletionData *data; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
692 GList *screennames; |
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 data = g_new0(GaimGtkCompletionData, 1); |
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 data->completion = g_completion_new(NULL); |
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 g_completion_set_compare(data->completion, g_ascii_strncasecmp); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
699 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
700 screennames = get_online_screennames(); |
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 g_completion_add_items(data->completion, screennames); |
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 g_list_free(screennames); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
705 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
706 g_signal_connect(G_OBJECT(entry), "event", |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
707 G_CALLBACK(completion_entry_event), data); |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
708 g_signal_connect(G_OBJECT(entry), "destroy", |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
709 G_CALLBACK(destroy_completion_data), data); |
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 #endif /* !NEW_STYLE_COMPLETION */ |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
712 } |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
713 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
714 static void |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
715 setup_entry_field(GtkWidget *entry, GaimRequestField *field) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
716 { |
8294
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
717 const char *type_hint; |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
718 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
719 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
720 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
721 if (gaim_request_field_is_required(field)) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
722 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
723 g_signal_connect(G_OBJECT(entry), "changed", |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
724 G_CALLBACK(req_entry_field_changed_cb), field); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
725 } |
8294
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
726 |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
727 if ((type_hint = gaim_request_field_get_type_hint(field)) != NULL) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
728 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
729 if (!strcmp(type_hint, "screenname")) |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
730 { |
d5e59ea083be
[gaim-migrate @ 9018]
Christian Hammond <chipx86@chipx86.com>
parents:
8289
diff
changeset
|
731 setup_screenname_autocomplete(entry, field); |
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 } |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
734 } |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
735 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
736 static GtkWidget * |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
737 create_string_field(GaimRequestField *field) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
738 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
739 const char *value; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
740 GtkWidget *widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
741 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
742 value = gaim_request_field_string_get_default_value(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
743 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
744 if (gaim_request_field_string_is_multiline(field)) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
745 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
746 GtkWidget *textview; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
747 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
748 widget = gtk_scrolled_window_new(NULL, NULL); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
749 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(widget), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
750 GTK_SHADOW_IN); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
751 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget), |
8916 | 752 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
753 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
754 textview = gtk_text_view_new(); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
755 gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
756 TRUE); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
757 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(textview), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
758 GTK_WRAP_WORD_CHAR); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
759 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
760 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
761 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(textview)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
762 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
763 gtk_container_add(GTK_CONTAINER(widget), textview); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
764 gtk_widget_show(textview); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
765 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
766 gtk_widget_set_size_request(widget, -1, 75); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
767 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
768 if (value != NULL) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
769 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
770 GtkTextBuffer *buffer; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
771 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
772 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
773 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
774 gtk_text_buffer_set_text(buffer, value, -1); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
775 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
776 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
777 gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
778 gaim_request_field_string_is_editable(field)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
779 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
780 g_signal_connect(G_OBJECT(textview), "focus-out-event", |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
781 G_CALLBACK(field_string_focus_out_cb), field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
782 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
783 else |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
784 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
785 widget = gtk_entry_new(); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
786 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
787 setup_entry_field(widget, field); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
788 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
789 if (value != NULL) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
790 gtk_entry_set_text(GTK_ENTRY(widget), value); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
791 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
792 gtk_entry_set_visibility(GTK_ENTRY(widget), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
793 !gaim_request_field_string_is_masked(field)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
794 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
795 gtk_editable_set_editable(GTK_EDITABLE(widget), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
796 gaim_request_field_string_is_editable(field)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
797 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
798 g_signal_connect(G_OBJECT(widget), "focus-out-event", |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
799 G_CALLBACK(field_string_focus_out_cb), field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
800 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
801 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
802 return widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
803 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
804 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
805 static GtkWidget * |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
806 create_int_field(GaimRequestField *field) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
807 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
808 int value; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
809 GtkWidget *widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
810 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
811 widget = gtk_entry_new(); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
812 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
813 setup_entry_field(widget, field); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
814 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
815 value = gaim_request_field_int_get_default_value(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
816 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
817 if (value != 0) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
818 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
819 char buf[32]; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
820 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
821 g_snprintf(buf, sizeof(buf), "%d", value); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
822 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
823 gtk_entry_set_text(GTK_ENTRY(widget), buf); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
824 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
825 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
826 g_signal_connect(G_OBJECT(widget), "focus-out-event", |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
827 G_CALLBACK(field_int_focus_out_cb), field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
828 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
829 return widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
830 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
831 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
832 static GtkWidget * |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
833 create_bool_field(GaimRequestField *field) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
834 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
835 GtkWidget *widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
836 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
837 widget = gtk_check_button_new_with_label( |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
838 gaim_request_field_get_label(field)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
839 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
840 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
841 gaim_request_field_bool_get_default_value(field)); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
842 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
843 g_signal_connect(G_OBJECT(widget), "toggled", |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
844 G_CALLBACK(field_bool_cb), field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
845 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
846 return widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
847 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
848 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
849 static GtkWidget * |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
850 create_choice_field(GaimRequestField *field) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
851 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
852 GtkWidget *widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
853 GList *labels; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
854 GList *l; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
855 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
856 labels = gaim_request_field_choice_get_labels(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
857 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
858 if (g_list_length(labels) > 5) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
859 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
860 GtkWidget *menu; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
861 GtkWidget *item; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
862 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
863 widget = gtk_option_menu_new(); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
864 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
865 menu = gtk_menu_new(); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
866 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
867 gtk_option_menu_set_menu(GTK_OPTION_MENU(widget), menu); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
868 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
869 for (l = labels; l != NULL; l = l->next) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
870 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
871 const char *text = l->data; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
872 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
873 item = gtk_menu_item_new_with_label(text); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
874 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
875 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
876 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
877 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
878 g_signal_connect(G_OBJECT(widget), "changed", |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
879 G_CALLBACK(field_choice_menu_cb), field); |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
880 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
881 else |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
882 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
883 GtkWidget *box; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
884 GtkWidget *first_radio = NULL; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
885 GtkWidget *radio; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
886 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
887 if (g_list_length(labels) == 2) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
888 box = gtk_hbox_new(FALSE, 6); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
889 else |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
890 box = gtk_vbox_new(FALSE, 0); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
891 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
892 widget = box; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
893 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
894 for (l = labels; l != NULL; l = l->next) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
895 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
896 const char *text = l->data; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
897 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
898 radio = gtk_radio_button_new_with_label_from_widget( |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
899 GTK_RADIO_BUTTON(first_radio), text); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
900 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
901 if (first_radio == NULL) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
902 first_radio = radio; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
903 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
904 gtk_box_pack_start(GTK_BOX(box), radio, TRUE, TRUE, 0); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
905 gtk_widget_show(radio); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
906 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
907 g_signal_connect(G_OBJECT(radio), "toggled", |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
908 G_CALLBACK(field_choice_option_cb), field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
909 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
910 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
911 |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
912 return widget; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
913 } |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
914 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
915 static GtkWidget * |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
916 create_account_field(GaimRequestField *field) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
917 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
918 GtkWidget *widget; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
919 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
920 widget = gaim_gtk_account_option_menu_new( |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
921 gaim_request_field_account_get_default_value(field), |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
922 gaim_request_field_account_get_show_all(field), |
8289
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8286
diff
changeset
|
923 G_CALLBACK(field_account_cb), |
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8286
diff
changeset
|
924 gaim_request_field_account_get_filter(field), |
e39ea2b4f6cd
[gaim-migrate @ 9013]
Christian Hammond <chipx86@chipx86.com>
parents:
8286
diff
changeset
|
925 field); |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
926 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
927 return widget; |
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 |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
930 static void |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
931 select_field_list_item(GtkTreeModel *model, GtkTreePath *path, |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
932 GtkTreeIter *iter, gpointer data) |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
933 { |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
934 GaimRequestField *field = (GaimRequestField *)data; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
935 const char *text; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
936 |
7909
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
937 gtk_tree_model_get(model, iter, 1, &text, -1); |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
938 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
939 gaim_request_field_list_add_selected(field, text); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
940 } |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
941 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
942 static void |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
943 list_field_select_changed_cb(GtkTreeSelection *sel, GaimRequestField *field) |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
944 { |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
945 gaim_request_field_list_clear_selected(field); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
946 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
947 gtk_tree_selection_selected_foreach(sel, select_field_list_item, field); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
948 } |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
949 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
950 static GtkWidget * |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
951 create_list_field(GaimRequestField *field) |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
952 { |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
953 GtkWidget *sw; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
954 GtkWidget *treeview; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
955 GtkListStore *store; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
956 GtkCellRenderer *renderer; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
957 GtkTreeSelection *sel; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
958 GtkTreeViewColumn *column; |
7909
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
959 GtkTreeIter iter; |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
960 const GList *l; |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
961 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
962 /* Create the scrolled window */ |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
963 sw = gtk_scrolled_window_new(NULL, NULL); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
964 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), |
8332
f4a878d48254
[gaim-migrate @ 9056]
Christian Hammond <chipx86@chipx86.com>
parents:
8323
diff
changeset
|
965 GTK_POLICY_AUTOMATIC, |
f4a878d48254
[gaim-migrate @ 9056]
Christian Hammond <chipx86@chipx86.com>
parents:
8323
diff
changeset
|
966 GTK_POLICY_AUTOMATIC); |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
967 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
968 GTK_SHADOW_IN); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
969 gtk_widget_show(sw); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
970 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
971 /* Create the list store */ |
7909
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
972 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
|
973 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
974 /* Create the tree view */ |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
975 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
976 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
977 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
978 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
979 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
980 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
981 if (gaim_request_field_list_get_multi_select(field)) |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
982 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
983 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
984 g_signal_connect(G_OBJECT(sel), "changed", |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
985 G_CALLBACK(list_field_select_changed_cb), field); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
986 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
987 column = gtk_tree_view_column_new(); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
988 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
989 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
990 renderer = gtk_cell_renderer_text_new(); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
991 gtk_tree_view_column_pack_start(column, renderer, TRUE); |
7909
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
992 gtk_tree_view_column_add_attribute(column, renderer, "text", 1); |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
993 |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
994 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
|
995 { |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
996 const char *text = (const char *)l->data; |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
997 |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
998 gtk_list_store_append(store, &iter); |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
999 |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1000 gtk_list_store_set(store, &iter, |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1001 0, gaim_request_field_list_get_data(field, text), |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1002 1, text, |
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1003 -1); |
7964
a5c70e43ee43
[gaim-migrate @ 8641]
Christian Hammond <chipx86@chipx86.com>
parents:
7951
diff
changeset
|
1004 |
a5c70e43ee43
[gaim-migrate @ 8641]
Christian Hammond <chipx86@chipx86.com>
parents:
7951
diff
changeset
|
1005 if (gaim_request_field_list_is_selected(field, text)) |
a5c70e43ee43
[gaim-migrate @ 8641]
Christian Hammond <chipx86@chipx86.com>
parents:
7951
diff
changeset
|
1006 gtk_tree_selection_select_iter(sel, &iter); |
7909
5be22af4ebfc
[gaim-migrate @ 8569]
Christian Hammond <chipx86@chipx86.com>
parents:
7905
diff
changeset
|
1007 } |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1008 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1009 gtk_container_add(GTK_CONTAINER(sw), treeview); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1010 gtk_widget_show(treeview); |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1011 |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1012 return sw; |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1013 } |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1014 |
6363
b7ef10bbe9bb
[gaim-migrate @ 6868]
Christian Hammond <chipx86@chipx86.com>
parents:
6338
diff
changeset
|
1015 static void * |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1016 gaim_gtk_request_fields(const char *title, const char *primary, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1017 const char *secondary, GaimRequestFields *fields, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1018 const char *ok_text, GCallback ok_cb, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1019 const char *cancel_text, GCallback cancel_cb, |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1020 void *user_data) |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1021 { |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1022 GaimGtkRequestData *data; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1023 GtkWidget *win; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1024 GtkWidget *vbox; |
8524 | 1025 GtkWidget *vbox2; |
6326
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1026 GtkWidget *hbox; |
5815
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1027 GtkWidget *bbox; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1028 GtkWidget *frame; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1029 GtkWidget *label; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1030 GtkWidget *table; |
5815
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1031 GtkWidget *button; |
6326
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1032 GtkWidget *img; |
8524 | 1033 GtkWidget *sw; |
5813
b116f3a73256
[gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
1034 GtkSizeGroup *sg; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1035 GList *gl, *fl; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1036 GaimRequestFieldGroup *group; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1037 GaimRequestField *field; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1038 char *label_text; |
8524 | 1039 int total_fields = 0; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1040 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1041 data = g_new0(GaimGtkRequestData, 1); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1042 data->type = GAIM_REQUEST_FIELDS; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1043 data->user_data = user_data; |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1044 data->u.multifield.fields = fields; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1045 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1046 fields->ui_data = data; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1047 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1048 data->cb_count = 2; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1049 data->cbs = g_new0(GCallback, 2); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1050 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1051 data->cbs[0] = ok_cb; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1052 data->cbs[1] = cancel_cb; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1053 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1054 data->dialog = win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
6325
de67cb0dd09d
[gaim-migrate @ 6824]
Christian Hammond <chipx86@chipx86.com>
parents:
6324
diff
changeset
|
1055 |
6109 | 1056 if (title != NULL) |
1057 gtk_window_set_title(GTK_WINDOW(win), title); | |
6325
de67cb0dd09d
[gaim-migrate @ 6824]
Christian Hammond <chipx86@chipx86.com>
parents:
6324
diff
changeset
|
1058 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1059 gtk_window_set_role(GTK_WINDOW(win), "multifield"); |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1060 gtk_container_set_border_width(GTK_CONTAINER(win), 12); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1061 gtk_window_set_resizable(GTK_WINDOW(win), FALSE); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1062 |
8323
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
1063 g_signal_connect(G_OBJECT(win), "delete_event", |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
1064 G_CALLBACK(destroy_multifield_cb), data); |
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
1065 |
6326
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1066 /* Setup the main horizontal box */ |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1067 hbox = gtk_hbox_new(FALSE, 12); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1068 gtk_container_add(GTK_CONTAINER(win), hbox); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1069 gtk_widget_show(hbox); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1070 |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1071 /* Dialog icon. */ |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1072 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1073 GTK_ICON_SIZE_DIALOG); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1074 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1075 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1076 gtk_widget_show(img); |
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1077 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1078 /* Setup the vbox */ |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1079 vbox = gtk_vbox_new(FALSE, 12); |
6326
f6480d79cb89
[gaim-migrate @ 6825]
Christian Hammond <chipx86@chipx86.com>
parents:
6325
diff
changeset
|
1080 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
|
1081 gtk_widget_show(vbox); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1082 |
5813
b116f3a73256
[gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
1083 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
b116f3a73256
[gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
1084 |
8524 | 1085 if(primary) { |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1086 label_text = g_strdup_printf( |
8524 | 1087 "<span weight=\"bold\" size=\"larger\">%s</span>", primary); |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1088 label = gtk_label_new(NULL); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1089 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1090 gtk_label_set_markup(GTK_LABEL(label), label_text); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1091 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1092 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1093 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
|
1094 gtk_widget_show(label); |
8524 | 1095 g_free(label_text); |
1096 } | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1097 |
8524 | 1098 for (gl = gaim_request_fields_get_groups(fields); gl != NULL; |
1099 gl = gl->next) | |
1100 total_fields += g_list_length(gaim_request_field_group_get_fields(gl->data)); | |
1101 | |
1102 if(total_fields > 9) { | |
1103 sw = gtk_scrolled_window_new(NULL, NULL); | |
1104 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
1105 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
1106 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), | |
1107 GTK_SHADOW_NONE); | |
1108 gtk_widget_set_size_request(sw, -1, 200); | |
1109 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); | |
1110 gtk_widget_show(sw); | |
1111 | |
1112 vbox2 = gtk_vbox_new(FALSE, 12); | |
1113 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), vbox2); | |
1114 gtk_widget_show(vbox2); | |
1115 } else { | |
1116 vbox2 = vbox; | |
1117 } | |
1118 | |
1119 if (secondary) { | |
1120 label = gtk_label_new(NULL); | |
1121 | |
1122 gtk_label_set_markup(GTK_LABEL(label), secondary); | |
1123 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
1124 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
1125 gtk_box_pack_start(GTK_BOX(vbox2), label, TRUE, TRUE, 0); | |
1126 gtk_widget_show(label); | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1127 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1128 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1129 for (gl = gaim_request_fields_get_groups(fields); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1130 gl != NULL; |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1131 gl = gl->next) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1132 { |
5816
64a164aa6f70
[gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents:
5815
diff
changeset
|
1133 GList *field_list; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1134 size_t field_count = 0; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1135 size_t cols = 1; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1136 size_t rows; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1137 size_t col_num; |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1138 size_t row_num = 0; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1139 |
5816
64a164aa6f70
[gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents:
5815
diff
changeset
|
1140 group = gl->data; |
64a164aa6f70
[gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents:
5815
diff
changeset
|
1141 field_list = gaim_request_field_group_get_fields(group); |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1142 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1143 if (gaim_request_field_group_get_title(group) != NULL) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1144 { |
8524 | 1145 frame = gaim_gtk_make_frame(vbox2, |
6324
01ce15fb27eb
[gaim-migrate @ 6823]
Christian Hammond <chipx86@chipx86.com>
parents:
6110
diff
changeset
|
1146 gaim_request_field_group_get_title(group)); |
01ce15fb27eb
[gaim-migrate @ 6823]
Christian Hammond <chipx86@chipx86.com>
parents:
6110
diff
changeset
|
1147 } |
6325
de67cb0dd09d
[gaim-migrate @ 6824]
Christian Hammond <chipx86@chipx86.com>
parents:
6324
diff
changeset
|
1148 else |
8524 | 1149 frame = vbox2; |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1150 |
5816
64a164aa6f70
[gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents:
5815
diff
changeset
|
1151 field_count = g_list_length(field_list); |
8524 | 1152 /* |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1153 if (field_count > 9) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1154 { |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1155 rows = field_count / 2; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1156 cols++; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1157 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1158 else |
8524 | 1159 */ |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1160 rows = field_count; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1161 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1162 col_num = 0; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1163 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1164 for (fl = field_list; fl != NULL; fl = fl->next) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1165 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1166 GaimRequestFieldType type; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1167 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1168 field = (GaimRequestField *)fl->data; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1169 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1170 type = gaim_request_field_get_type(field); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1171 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1172 if (type == GAIM_REQUEST_FIELD_LABEL) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1173 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1174 if (col_num > 0) |
7921 | 1175 rows++; |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1176 |
7921 | 1177 rows++; |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1178 } |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1179 else if (type == GAIM_REQUEST_FIELD_STRING && |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1180 gaim_request_field_string_is_multiline(field)) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1181 { |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1182 if (col_num > 0) |
7921 | 1183 rows++; |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1184 |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1185 rows += 2; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1186 } |
7921 | 1187 |
1188 col_num++; | |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1189 |
8323
4786adbe8720
[gaim-migrate @ 9047]
Christian Hammond <chipx86@chipx86.com>
parents:
8302
diff
changeset
|
1190 if (col_num >= cols) |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1191 col_num = 0; |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1192 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1193 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1194 table = gtk_table_new(rows, 2 * cols, FALSE); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1195 gtk_table_set_row_spacings(GTK_TABLE(table), 6); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1196 gtk_table_set_col_spacings(GTK_TABLE(table), 6); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1197 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1198 gtk_container_add(GTK_CONTAINER(frame), table); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1199 gtk_widget_show(table); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1200 |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1201 for (row_num = 0, fl = field_list; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1202 row_num < rows && fl != NULL; |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1203 row_num++) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1204 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1205 for (col_num = 0; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1206 col_num < cols && fl != NULL; |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1207 col_num++, fl = fl->next) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1208 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1209 size_t col_offset = col_num * 2; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1210 GaimRequestFieldType type; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1211 GtkWidget *widget = NULL; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1212 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1213 field = fl->data; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1214 |
7922 | 1215 if (!gaim_request_field_is_visible(field)) { |
1216 col_num--; | |
7904
9b478c6e0bfa
[gaim-migrate @ 8564]
Christian Hammond <chipx86@chipx86.com>
parents:
7903
diff
changeset
|
1217 continue; |
7922 | 1218 } |
7904
9b478c6e0bfa
[gaim-migrate @ 8564]
Christian Hammond <chipx86@chipx86.com>
parents:
7903
diff
changeset
|
1219 |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1220 type = gaim_request_field_get_type(field); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1221 |
8332
f4a878d48254
[gaim-migrate @ 9056]
Christian Hammond <chipx86@chipx86.com>
parents:
8323
diff
changeset
|
1222 if (type != GAIM_REQUEST_FIELD_BOOLEAN && |
f4a878d48254
[gaim-migrate @ 9056]
Christian Hammond <chipx86@chipx86.com>
parents:
8323
diff
changeset
|
1223 gaim_request_field_get_label(field)) |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1224 { |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1225 char *text; |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1226 |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1227 text = g_strdup_printf("%s:", |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1228 gaim_request_field_get_label(field)); |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1229 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1230 label = gtk_label_new(NULL); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1231 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), text); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1232 g_free(text); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1233 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1234 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1235 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1236 gtk_size_group_add_widget(sg, label); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1237 |
7905
1d0bc32f8038
[gaim-migrate @ 8565]
Christian Hammond <chipx86@chipx86.com>
parents:
7904
diff
changeset
|
1238 if (type == GAIM_REQUEST_FIELD_LABEL || |
1d0bc32f8038
[gaim-migrate @ 8565]
Christian Hammond <chipx86@chipx86.com>
parents:
7904
diff
changeset
|
1239 (type == GAIM_REQUEST_FIELD_STRING && |
1d0bc32f8038
[gaim-migrate @ 8565]
Christian Hammond <chipx86@chipx86.com>
parents:
7904
diff
changeset
|
1240 gaim_request_field_string_is_multiline(field))) |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1241 { |
7921 | 1242 if(col_num > 0) |
1243 row_num++; | |
1244 | |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1245 gtk_table_attach_defaults(GTK_TABLE(table), label, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1246 0, 2 * cols, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1247 row_num, row_num + 1); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1248 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1249 row_num++; |
7921 | 1250 col_num=cols; |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1251 } |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1252 else |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1253 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1254 gtk_table_attach_defaults(GTK_TABLE(table), label, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1255 col_offset, col_offset + 1, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1256 row_num, row_num + 1); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1257 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1258 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1259 gtk_widget_show(label); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1260 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1261 |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1262 if (type == GAIM_REQUEST_FIELD_STRING) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1263 widget = create_string_field(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1264 else if (type == GAIM_REQUEST_FIELD_INTEGER) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1265 widget = create_int_field(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1266 else if (type == GAIM_REQUEST_FIELD_BOOLEAN) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1267 widget = create_bool_field(field); |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1268 else if (type == GAIM_REQUEST_FIELD_CHOICE) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1269 widget = create_choice_field(field); |
7903
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1270 else if (type == GAIM_REQUEST_FIELD_LIST) |
d91806e4ea64
[gaim-migrate @ 8563]
Christian Hammond <chipx86@chipx86.com>
parents:
7900
diff
changeset
|
1271 widget = create_list_field(field); |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1272 else if (type == GAIM_REQUEST_FIELD_ACCOUNT) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1273 widget = create_account_field(field); |
7904
9b478c6e0bfa
[gaim-migrate @ 8564]
Christian Hammond <chipx86@chipx86.com>
parents:
7903
diff
changeset
|
1274 else |
9b478c6e0bfa
[gaim-migrate @ 8564]
Christian Hammond <chipx86@chipx86.com>
parents:
7903
diff
changeset
|
1275 continue; |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1276 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1277 if (type == GAIM_REQUEST_FIELD_STRING && |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1278 gaim_request_field_string_is_multiline(field)) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1279 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1280 gtk_table_attach(GTK_TABLE(table), widget, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1281 0, 2 * cols, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1282 row_num, row_num + 1, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1283 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1284 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1285 5, 0); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1286 } |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1287 else if (type != GAIM_REQUEST_FIELD_BOOLEAN) |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1288 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1289 gtk_table_attach(GTK_TABLE(table), widget, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1290 col_offset + 1, col_offset + 2, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1291 row_num, row_num + 1, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1292 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1293 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1294 5, 0); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1295 } |
7900
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1296 else |
365d8a67972d
[gaim-migrate @ 8560]
Christian Hammond <chipx86@chipx86.com>
parents:
7844
diff
changeset
|
1297 { |
6337
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1298 gtk_table_attach(GTK_TABLE(table), widget, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1299 col_offset, col_offset + 1, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1300 row_num, row_num + 1, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1301 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1302 GTK_FILL | GTK_EXPAND, |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1303 5, 0); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1304 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1305 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1306 gtk_widget_show(widget); |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1307 |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1308 field->ui_data = widget; |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1309 } |
957c1d28b96a
[gaim-migrate @ 6836]
Christian Hammond <chipx86@chipx86.com>
parents:
6335
diff
changeset
|
1310 } |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1311 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1312 |
5813
b116f3a73256
[gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
1313 g_object_unref(sg); |
b116f3a73256
[gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents:
5811
diff
changeset
|
1314 |
5815
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1315 /* Button box. */ |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1316 bbox = gtk_hbutton_box_new(); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1317 gtk_box_set_spacing(GTK_BOX(bbox), 6); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1318 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
|
1319 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1320 gtk_widget_show(bbox); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1321 |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1322 /* Cancel button */ |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1323 button = gtk_button_new_from_stock(text_to_stock(cancel_text)); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1324 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1325 gtk_widget_show(button); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1326 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1327 g_signal_connect(G_OBJECT(button), "clicked", |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1328 G_CALLBACK(multifield_cancel_cb), data); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1329 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1330 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1331 |
5815
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1332 /* OK button */ |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1333 button = gtk_button_new_from_stock(text_to_stock(ok_text)); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1334 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1335 gtk_widget_show(button); |
c900fc823a21
[gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents:
5813
diff
changeset
|
1336 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1337 data->ok_button = button; |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1338 |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1339 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1340 gtk_window_set_default(GTK_WINDOW(win), button); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1341 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1342 g_signal_connect(G_OBJECT(button), "clicked", |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1343 G_CALLBACK(multifield_ok_cb), data); |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1344 |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1345 if (!gaim_request_fields_all_required_filled(fields)) |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1346 gtk_widget_set_sensitive(button, FALSE); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1347 |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1348 gtk_widget_show(win); |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1349 |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1350 return data; |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1351 } |
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1352 |
6363
b7ef10bbe9bb
[gaim-migrate @ 6868]
Christian Hammond <chipx86@chipx86.com>
parents:
6338
diff
changeset
|
1353 static void |
9502 | 1354 file_yes_no_cb(GaimGtkRequestData *data, gint id) |
1355 { | |
1356 if (data->cbs[id] != NULL) | |
1357 ((GaimRequestFileCb)data->cbs[id])(data->user_data, data->u.file.name); | |
1358 | |
1359 if (id == 1) | |
1360 gaim_request_close(GAIM_REQUEST_FILE, data); | |
1361 } | |
1362 | |
9573 | 1363 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
9502 | 1364 static void |
1365 file_ok_check_if_exists_cb(GtkWidget *widget, gint response, GaimGtkRequestData *data) | |
1366 { | |
1367 if (response != GTK_RESPONSE_ACCEPT) { | |
1368 if (data->cbs[0] != NULL) | |
1369 ((GaimRequestFileCb)data->cbs[0])(data->user_data, NULL); | |
1370 gaim_request_close(GAIM_REQUEST_FILE, data); | |
1371 return; | |
1372 } | |
1373 | |
1374 data->u.file.name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data->dialog)); | |
1375 #else /* FILECHOOSER */ | |
9573 | 1376 static void |
9502 | 1377 file_ok_check_if_exists_cb(GtkWidget *button, GaimGtkRequestData *data) |
1378 { | |
9503 | 1379 const gchar *name; |
9502 | 1380 |
9503 | 1381 name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(data->dialog)); |
9513 | 1382 |
1383 /* If name is a directory then change directories */ | |
9502 | 1384 if (gaim_gtk_check_if_dir(name, GTK_FILE_SELECTION(data->dialog))) |
1385 return; | |
9513 | 1386 |
9503 | 1387 data->u.file.name = g_strdup(name); |
9502 | 1388 #endif /* FILECHOOSER */ |
1389 | |
1390 if ((data->u.file.savedialog == TRUE) && | |
1391 (g_file_test(data->u.file.name, G_FILE_TEST_EXISTS))) { | |
1392 gaim_request_yes_no(data, NULL, _("That file already exists"), | |
1393 _("Would you like to overwrite it?"), 1, data, | |
1394 G_CALLBACK(file_yes_no_cb), | |
1395 G_CALLBACK(file_yes_no_cb)); | |
1396 } else | |
1397 file_yes_no_cb(data, 1); | |
1398 } | |
1399 | |
1400 #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
1401 static void | |
9506 | 1402 file_cancel_cb(GaimGtkRequestData *data) |
9502 | 1403 { |
1404 if (data->cbs[0] != NULL) | |
1405 ((GaimRequestFileCb)data->cbs[0])(data->user_data, NULL); | |
1406 | |
1407 gaim_request_close(GAIM_REQUEST_FILE, data); | |
1408 } | |
1409 #endif /* FILECHOOSER */ | |
1410 | |
1411 static void * | |
1412 gaim_gtk_request_file(const char *title, const char *filename, | |
1413 gboolean savedialog, | |
1414 GCallback ok_cb, GCallback cancel_cb, | |
1415 void *user_data) | |
1416 { | |
1417 GaimGtkRequestData *data; | |
1418 GtkWidget *filesel; | |
1419 | |
1420 data = g_new0(GaimGtkRequestData, 1); | |
1421 data->type = GAIM_REQUEST_FILE; | |
1422 data->user_data = user_data; | |
1423 data->cb_count = 2; | |
1424 data->cbs = g_new0(GCallback, 2); | |
1425 data->cbs[0] = cancel_cb; | |
1426 data->cbs[1] = ok_cb; | |
1427 data->u.file.savedialog = savedialog; | |
1428 | |
1429 #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ | |
1430 filesel = gtk_file_chooser_dialog_new( | |
1431 title ? title : (savedialog ? _("Save File...") | |
1432 : _("Open File...")), | |
1433 NULL, | |
1434 savedialog ? GTK_FILE_CHOOSER_ACTION_SAVE | |
1435 : GTK_FILE_CHOOSER_ACTION_OPEN, | |
1436 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
1437 savedialog ? GTK_STOCK_SAVE | |
1438 : GTK_STOCK_OPEN, | |
1439 GTK_RESPONSE_ACCEPT, | |
1440 NULL); | |
1441 gtk_dialog_set_default_response(GTK_DIALOG(filesel), GTK_RESPONSE_ACCEPT); | |
1442 if (filename != NULL) { | |
1443 if (savedialog) | |
1444 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(filesel), filename); | |
1445 else | |
1446 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(filesel), filename); | |
1447 } | |
1448 g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(filesel)), "response", | |
1449 G_CALLBACK(file_ok_check_if_exists_cb), data); | |
1450 #else /* FILECHOOSER */ | |
9506 | 1451 filesel = gtk_file_selection_new(title ? title |
1452 : (savedialog ? _("Save File...") | |
1453 : _("Open File..."))); | |
9502 | 1454 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), filename); |
9506 | 1455 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)), "delete_event", |
1456 G_CALLBACK(file_cancel_cb), data); | |
1457 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), | |
9502 | 1458 "clicked", G_CALLBACK(file_cancel_cb), data); |
9506 | 1459 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), "clicked", |
1460 G_CALLBACK(file_ok_check_if_exists_cb), data); | |
9502 | 1461 #endif /* FILECHOOSER */ |
1462 | |
1463 data->dialog = filesel; | |
1464 gtk_widget_show(filesel); | |
1465 | |
1466 return (void *)data; | |
1467 } | |
1468 | |
1469 static void | |
5480 | 1470 gaim_gtk_close_request(GaimRequestType type, void *ui_handle) |
1471 { | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1472 GaimGtkRequestData *data = (GaimGtkRequestData *)ui_handle; |
5480 | 1473 |
1474 if (data->cbs != NULL) | |
1475 g_free(data->cbs); | |
1476 | |
8286
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1477 gtk_widget_destroy(data->dialog); |
89d9d004e3f3
[gaim-migrate @ 9010]
Christian Hammond <chipx86@chipx86.com>
parents:
8137
diff
changeset
|
1478 |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1479 if (type == GAIM_REQUEST_FIELDS) |
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1480 gaim_request_fields_destroy(data->u.multifield.fields); |
9513 | 1481 else if (type == GAIM_REQUEST_FILE) |
1482 g_free(data->u.file.name); | |
5817
571e895bf6ba
[gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents:
5816
diff
changeset
|
1483 |
5480 | 1484 g_free(data); |
1485 } | |
1486 | |
1487 static GaimRequestUiOps ops = | |
1488 { | |
1489 gaim_gtk_request_input, | |
1490 gaim_gtk_request_choice, | |
1491 gaim_gtk_request_action, | |
5811
9467bff78029
[gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents:
5794
diff
changeset
|
1492 gaim_gtk_request_fields, |
8843 | 1493 gaim_gtk_request_file, |
5480 | 1494 gaim_gtk_close_request |
1495 }; | |
1496 | |
1497 GaimRequestUiOps * | |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
1498 gaim_gtk_request_get_ui_ops(void) |
5480 | 1499 { |
1500 return &ops; | |
1501 } |