annotate src/gtkrequest.c @ 13572:7773c79bbe01

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