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