annotate src/gtkrequest.c @ 5820:a929723531c8

[gaim-migrate @ 6250] another misnamed pref committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Mon, 09 Jun 2003 03:30:48 +0000
parents 571e895bf6ba
children db204c4a411b
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 *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * 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
11 * the Free Software Foundation; either version 2 of the License, or
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * (at your option) any later version.
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * GNU General Public License for more details.
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "gtkrequest.h"
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "stock.h"
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include <gtk/gtk.h>
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 #include <string.h>
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 /* XXX For _(..) */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 #include "gaim.h"
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 typedef struct
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 GaimRequestType type;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 void *user_data;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 GtkWidget *dialog;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 size_t cb_count;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 GCallback *cbs;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
41 union
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
42 {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
43 struct
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
44 {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
45 GtkWidget *entry;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
46
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
47 gboolean multiline;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
48
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
49 } input;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
50
5817
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
51 struct
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
52 {
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
53 GaimRequestFields *fields;
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
54
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
55 } multifield;
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
56
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
57 } u;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
58
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
59 } GaimGtkRequestData;
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 static void
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
62 input_response_cb(GtkDialog *dialog, gint id, GaimGtkRequestData *data)
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 {
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
64 const char *value;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
65
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
66 if (data->u.input.multiline) {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
67 GtkTextIter start_iter, end_iter;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
68 GtkTextBuffer *buffer =
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
69 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
70
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
71 gtk_text_buffer_get_start_iter(buffer, &start_iter);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
72 gtk_text_buffer_get_end_iter(buffer, &end_iter);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
73
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
74 value = gtk_text_buffer_get_text(buffer, &start_iter, &end_iter,
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
75 FALSE);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 }
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
77 else
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
78 value = gtk_entry_get_text(GTK_ENTRY(data->u.input.entry));
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
79
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
80 if (id < data->cb_count && data->cbs[id] != NULL)
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5496
diff changeset
81 ((GaimRequestInputCb)data->cbs[id])(data->user_data, value);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 gaim_request_close(GAIM_REQUEST_INPUT, data);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
86 static void
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
87 action_response_cb(GtkDialog *dialog, gint id, GaimGtkRequestData *data)
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
88 {
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
89 if (id < data->cb_count && data->cbs[id] != NULL)
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5496
diff changeset
90 ((GaimRequestActionCb)data->cbs[id])(data->user_data, id);
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
91
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
92 gaim_request_close(GAIM_REQUEST_INPUT, data);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
93 }
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
94
5817
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
95 static void
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
96 multifield_ok_cb(GtkWidget *button, GaimGtkRequestData *data)
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
97 {
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
98 if (data->cbs[0] != NULL)
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
99 ((GaimRequestFieldsCb)data->cbs[0])(data->user_data,
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
100 data->u.multifield.fields);
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
101
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
102 gaim_request_close(GAIM_REQUEST_FIELDS, data);
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
103 }
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
104
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
105 static void
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
106 multifield_cancel_cb(GtkWidget *button, GaimGtkRequestData *data)
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
107 {
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
108 if (data->cbs[1] != NULL)
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
109 ((GaimRequestFieldsCb)data->cbs[1])(data->user_data,
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
110 data->u.multifield.fields);
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
111
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
112 gaim_request_close(GAIM_REQUEST_FIELDS, data);
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
113 }
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
114
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 #define STOCK_ITEMIZE(r, l) \
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 if (!strcmp((r), text)) \
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 return (l);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 static const char *
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5510
diff changeset
120 text_to_stock(const char *text)
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 STOCK_ITEMIZE(_("Yes"), GTK_STOCK_YES);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 STOCK_ITEMIZE(_("No"), GTK_STOCK_NO);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 STOCK_ITEMIZE(_("OK"), GTK_STOCK_OK);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125 STOCK_ITEMIZE(_("Cancel"), GTK_STOCK_CANCEL);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 STOCK_ITEMIZE(_("Apply"), GTK_STOCK_APPLY);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 STOCK_ITEMIZE(_("Close"), GTK_STOCK_CLOSE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 STOCK_ITEMIZE(_("Delete"), GTK_STOCK_DELETE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 STOCK_ITEMIZE(_("Add"), GTK_STOCK_ADD);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 STOCK_ITEMIZE(_("Remove"), GTK_STOCK_REMOVE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
132 return text;
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 void *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 gaim_gtk_request_input(const char *title, const char *primary,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 const char *secondary, const char *default_value,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 gboolean multiline,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 const char *ok_text, GCallback ok_cb,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 const char *cancel_text, GCallback cancel_cb,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 void *user_data)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 {
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
143 GaimGtkRequestData *data;
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 GtkWidget *dialog;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 GtkWidget *vbox;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 GtkWidget *hbox;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 GtkWidget *label;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 GtkWidget *entry;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 GtkWidget *img;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 char *label_text;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
152 data = g_new0(GaimGtkRequestData, 1);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 data->type = GAIM_REQUEST_INPUT;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 data->user_data = user_data;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 data->cb_count = 2;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 data->cbs = g_new0(GCallback, 2);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 data->cbs[0] = ok_cb;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 data->cbs[1] = cancel_cb;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 /* Create the dialog. */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 dialog = gtk_dialog_new_with_buttons("", NULL, 0,
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5510
diff changeset
164 text_to_stock(cancel_text), 1,
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5510
diff changeset
165 text_to_stock(ok_text), 0,
5485
c103ba09c62a [gaim-migrate @ 5881]
Sean Egan <seanegan@gmail.com>
parents: 5480
diff changeset
166 NULL);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 data->dialog = dialog;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 g_signal_connect(G_OBJECT(dialog), "response",
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5510
diff changeset
170 G_CALLBACK(input_response_cb), data);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 /* Setup the dialog */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
5510
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
174 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
5510
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
177 gtk_dialog_set_default_response(GTK_DIALOG(dialog), 0);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 /* Setup the main horizontal box */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 hbox = gtk_hbox_new(FALSE, 12);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 /* Dialog icon. */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 GTK_ICON_SIZE_DIALOG);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 /* Vertical box */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 vbox = gtk_vbox_new(FALSE, 12);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195 /* Descriptive label */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 label_text = g_strdup_printf("<span weight=\"bold\" size=\"larger\">"
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 "%s</span>\n\n%s",
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198 primary, (secondary ? secondary : ""));
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 label = gtk_label_new(NULL);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 gtk_label_set_markup(GTK_LABEL(label), label_text);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 g_free(label_text);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 /* Entry field. */
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
210 data->u.input.multiline = multiline;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
211
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
212 if (multiline) {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
213 GtkWidget *sw;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
214
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
215 sw = gtk_scrolled_window_new(NULL, NULL);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
216 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
217 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
218 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
219 GTK_SHADOW_IN);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
220
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
221 gtk_widget_set_size_request(sw, 300, 75);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
222
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
223 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
224
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
225 entry = gtk_text_view_new();
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
226 gtk_text_view_set_editable(GTK_TEXT_VIEW(entry), TRUE);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
228 gtk_container_add(GTK_CONTAINER(sw), entry);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
229
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
230 if (default_value != NULL) {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
231 GtkTextBuffer *buffer;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
232
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
233 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry));
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
234 gtk_text_buffer_set_text(buffer, default_value, -1);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
235 }
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
236 }
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
237 else {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
238 entry = gtk_entry_new();
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
239
5510
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
240 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
241
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
242 gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
243
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
244 if (default_value != NULL)
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
245 gtk_entry_set_text(GTK_ENTRY(entry), default_value);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
246 }
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
247
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
248 data->u.input.entry = entry;
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 /* Show everything. */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 gtk_widget_show_all(dialog);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253 return data;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 void *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257 gaim_gtk_request_choice(const char *title, const char *primary,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 const char *secondary, unsigned int default_value,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 const char *ok_text, GCallback ok_cb,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 const char *cancel_text, GCallback cancel_cb,
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
261 void *user_data, size_t choice_count, va_list args)
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
262 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263 return NULL;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266 void *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
267 gaim_gtk_request_action(const char *title, const char *primary,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
268 const char *secondary, unsigned int default_action,
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
269 void *user_data, size_t action_count, va_list actions)
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
270 {
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
271 GaimGtkRequestData *data;
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
272 GtkWidget *dialog;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
273 GtkWidget *vbox;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
274 GtkWidget *hbox;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
275 GtkWidget *label;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
276 GtkWidget *img;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
277 void **buttons;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
278 char *label_text;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
279 int i;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
280
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
281 data = g_new0(GaimGtkRequestData, 1);
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
282 data->type = GAIM_REQUEST_ACTION;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
283 data->user_data = user_data;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
284
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
285 data->cb_count = action_count;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
286 data->cbs = g_new0(GCallback, action_count);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
287
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
288 /* Reverse the buttons */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
289 buttons = g_new0(void *, action_count * 2);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
290
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
291 for (i = 0; i < action_count * 2; i += 2) {
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
292 buttons[(action_count * 2) - i - 2] = va_arg(actions, char *);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
293 buttons[(action_count * 2) - i - 1] = va_arg(actions, GCallback);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
294 }
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
295
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
296 /* Create the dialog. */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
297 data->dialog = dialog = gtk_dialog_new();
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
298
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
299 for (i = 0; i < action_count; i++) {
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
300 gtk_dialog_add_button(GTK_DIALOG(dialog),
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5510
diff changeset
301 text_to_stock(buttons[2 * i]), i);
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
302
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
303 data->cbs[i] = buttons[2 * i + 1];
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
304 }
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
305
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
306 g_free(buttons);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
307
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
308 g_signal_connect(G_OBJECT(dialog), "response",
5794
5e93fc46d1af [gaim-migrate @ 6219]
Christian Hammond <chipx86@chipx86.com>
parents: 5510
diff changeset
309 G_CALLBACK(action_response_cb), data);
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
310
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
311 /* Setup the dialog */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
312 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
313 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
314 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
315 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
316 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
317
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
318 /* Setup the main horizontal box */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
319 hbox = gtk_hbox_new(FALSE, 12);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
320 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
321
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
322 /* Dialog icon. */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
323 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION,
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
324 GTK_ICON_SIZE_DIALOG);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
325 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
326 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
327
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
328 /* Vertical box */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
329 vbox = gtk_vbox_new(FALSE, 12);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
330
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
331 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
332
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
333 /* Descriptive label */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
334 label_text = g_strdup_printf("<span weight=\"bold\" size=\"larger\">"
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
335 "%s</span>\n\n%s",
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
336 primary, (secondary ? secondary : ""));
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
337
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
338 label = gtk_label_new(NULL);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
339
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
340 gtk_label_set_markup(GTK_LABEL(label), label_text);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
341 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
342 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
343 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
344
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
345 g_free(label_text);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
346
5510
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
347 if (default_action != -1)
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
348 gtk_dialog_set_default_response(GTK_DIALOG(dialog), default_action);
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
349
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
350 /* Show everything. */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
351 gtk_widget_show_all(dialog);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
352
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
353 return data;
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
356 void *
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
357 gaim_gtk_request_fields(const char *title, const char *primary,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
358 const char *secondary, GaimRequestFields *fields,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
359 const char *ok_text, GCallback ok_cb,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
360 const char *cancel_text, GCallback cancel_cb,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
361 void *user_data)
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
362 {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
363 GaimGtkRequestData *data;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
364 GtkWidget *win;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
365 GtkWidget *vbox;
5815
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
366 GtkWidget *bbox;
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
367 GtkWidget *frame;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
368 GtkWidget *label;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
369 GtkWidget *table;
5815
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
370 GtkWidget *sep;
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
371 GtkWidget *button;
5813
b116f3a73256 [gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents: 5811
diff changeset
372 GtkSizeGroup *sg;
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
373 GList *gl, *fl;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
374 GaimRequestFieldGroup *group;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
375 GaimRequestField *field;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
376 char *text;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
377 char *label_text;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
378
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
379 data = g_new0(GaimGtkRequestData, 1);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
380 data->type = GAIM_REQUEST_FIELDS;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
381 data->user_data = user_data;
5817
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
382 data->u.multifield.fields = fields;
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
383
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
384 data->cb_count = 2;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
385 data->cbs = g_new0(GCallback, 2);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
386
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
387 data->cbs[0] = ok_cb;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
388 data->cbs[1] = cancel_cb;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
389
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
390 data->dialog = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
5817
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
391 gtk_window_set_role(GTK_WINDOW(win), "multifield");
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
392 gtk_container_set_border_width(GTK_CONTAINER(win), 12);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
393 gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
394
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
395 /* Setup the vbox */
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
396 vbox = gtk_vbox_new(FALSE, 12);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
397 gtk_container_add(GTK_CONTAINER(win), vbox);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
398 gtk_widget_show(vbox);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
399
5813
b116f3a73256 [gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents: 5811
diff changeset
400 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
b116f3a73256 [gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents: 5811
diff changeset
401
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
402 if (primary != NULL || secondary != NULL) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
403 label_text = g_strdup_printf("<span weight=\"bold\" size=\"larger\">"
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
404 "%s</span>\n\n%s",
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
405 (primary ? primary : ""),
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
406 (secondary ? secondary : ""));
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
407
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
408 label = gtk_label_new(NULL);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
409
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
410 gtk_label_set_markup(GTK_LABEL(label), label_text);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
411 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
412 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
413 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
414
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
415 g_free(label_text);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
416 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
417
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
418 for (gl = gaim_request_fields_get_groups(fields);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
419 gl != NULL;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
420 gl = gl->next) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
421
5816
64a164aa6f70 [gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents: 5815
diff changeset
422 GList *field_list;
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
423 size_t field_count = 0;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
424 size_t cols = 1;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
425 size_t rows;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
426 size_t col_num;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
427 size_t row_num;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
428
5816
64a164aa6f70 [gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents: 5815
diff changeset
429 group = gl->data;
64a164aa6f70 [gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents: 5815
diff changeset
430 field_list = gaim_request_field_group_get_fields(group);
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
431
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
432 frame = gaim_gtk_make_frame(vbox,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
433 gaim_request_field_group_get_title(group));
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
434
5816
64a164aa6f70 [gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents: 5815
diff changeset
435 field_count = g_list_length(field_list);
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
436
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
437 if (field_count > 9) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
438 rows = field_count / 2;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
439 cols++;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
440 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
441 else
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
442 rows = field_count;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
443
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
444 table = gtk_table_new(rows, 2 * cols, FALSE);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
445 gtk_table_set_row_spacings(GTK_TABLE(table), 6);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
446 gtk_table_set_col_spacings(GTK_TABLE(table), 6);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
447
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
448 gtk_container_add(GTK_CONTAINER(frame), table);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
449 gtk_widget_show(table);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
450
5816
64a164aa6f70 [gaim-migrate @ 6246]
Christian Hammond <chipx86@chipx86.com>
parents: 5815
diff changeset
451 for (col_num = 0, fl = field_list;
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
452 col_num < cols && fl != NULL;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
453 col_num++) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
454
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
455 for (row_num = 0;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
456 row_num < rows && fl != NULL;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
457 row_num++, fl = fl->next) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
458
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
459 size_t col_offset = col_num * 2;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
460 GaimRequestFieldType type;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
461 GtkWidget *widget = NULL;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
462
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
463 field = fl->data;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
464
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
465 type = gaim_request_field_get_type(field);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
466
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
467 if (type != GAIM_REQUEST_FIELD_BOOLEAN) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
468 text = g_strdup_printf("%s:",
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
469 gaim_request_field_get_label(field));
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
470 label = gtk_label_new(text);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
471 g_free(text);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
472
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
473 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
474
5813
b116f3a73256 [gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents: 5811
diff changeset
475 gtk_size_group_add_widget(sg, label);
b116f3a73256 [gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents: 5811
diff changeset
476
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
477 gtk_table_attach_defaults(GTK_TABLE(table), label,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
478 col_offset, col_offset + 1,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
479 row_num, row_num + 1);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
480 gtk_widget_show(label);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
481 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
482
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
483 if (type == GAIM_REQUEST_FIELD_STRING) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
484 const char *value;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
485
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
486 widget = gtk_entry_new();
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
487
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
488 value = gaim_request_field_string_get_default_value(field);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
489
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
490 if (value != NULL)
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
491 gtk_entry_set_text(GTK_ENTRY(widget), value);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
492 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
493 else if (type == GAIM_REQUEST_FIELD_INTEGER) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
494 int value;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
495
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
496 widget = gtk_entry_new();
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
497
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
498 value = gaim_request_field_int_get_default_value(field);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
499
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
500 if (value != 0) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
501 char buf[32];
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
502
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
503 g_snprintf(buf, sizeof(buf), "%d", value);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
504
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
505 gtk_entry_set_text(GTK_ENTRY(widget), buf);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
506 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
507 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
508 else if (type == GAIM_REQUEST_FIELD_BOOLEAN) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
509 widget = gtk_check_button_new_with_label(
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
510 gaim_request_field_get_label(field));
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
511
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
512 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
513 gaim_request_field_bool_get_default_value(field));
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
514 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
515 else if (type == GAIM_REQUEST_FIELD_CHOICE) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
516 GList *labels;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
517 GList *l;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
518
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
519 labels = gaim_request_field_choice_get_labels(field);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
520
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
521 if (g_list_length(labels) > 5) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
522 GtkWidget *menu;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
523 GtkWidget *item;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
524
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
525 widget = gtk_option_menu_new();
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
526
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
527 menu = gtk_menu_new();
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
528
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
529 gtk_option_menu_set_menu(GTK_OPTION_MENU(widget), menu);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
530
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
531 for (l = labels; l != NULL; l = l->next) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
532 const char *text = l->data;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
533
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
534 item = gtk_menu_item_new_with_label(text);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
535
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
536 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
537 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
538 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
539 else {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
540 GtkWidget *box;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
541 GtkWidget *first_radio = NULL;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
542 GtkWidget *radio;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
543
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
544 if (g_list_length(labels) == 2)
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
545 box = gtk_hbox_new(FALSE, 6);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
546 else
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
547 box = gtk_vbox_new(FALSE, 0);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
548
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
549 widget = box;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
550
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
551 for (l = labels; l != NULL; l = l->next) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
552 const char *text = l->data;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
553
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
554 radio =
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
555 gtk_radio_button_new_with_label_from_widget(
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
556 GTK_RADIO_BUTTON(first_radio), text);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
557
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
558 if (first_radio == NULL)
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
559 first_radio = radio;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
560
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
561 gtk_box_pack_start(GTK_BOX(box), radio,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
562 TRUE, TRUE, 0);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
563 gtk_widget_show(radio);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
564 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
565 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
566 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
567
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
568 if (type != GAIM_REQUEST_FIELD_BOOLEAN) {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
569 gtk_table_attach(GTK_TABLE(table), widget,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
570 col_offset + 1, col_offset + 2,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
571 row_num, row_num + 1,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
572 GTK_FILL | GTK_EXPAND,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
573 GTK_FILL | GTK_EXPAND,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
574 5, 0);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
575 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
576 else {
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
577 gtk_table_attach(GTK_TABLE(table), widget,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
578 col_offset, col_offset + 1,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
579 row_num, row_num + 1,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
580 GTK_FILL | GTK_EXPAND,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
581 GTK_FILL | GTK_EXPAND,
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
582 5, 0);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
583 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
584
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
585 gtk_widget_show(widget);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
586
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
587 field->ui_data = widget;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
588 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
589 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
590 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
591
5813
b116f3a73256 [gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents: 5811
diff changeset
592 g_object_unref(sg);
b116f3a73256 [gaim-migrate @ 6243]
Christian Hammond <chipx86@chipx86.com>
parents: 5811
diff changeset
593
5815
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
594 /* Separator */
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
595 sep = gtk_hseparator_new();
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
596 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
597 gtk_widget_show(sep);
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
598
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
599 /* Button box. */
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
600 bbox = gtk_hbutton_box_new();
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
601 gtk_box_set_spacing(GTK_BOX(bbox), 6);
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
602 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
603 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
604 gtk_widget_show(bbox);
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
605
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
606 /* Cancel button */
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
607 button = gtk_button_new_from_stock(text_to_stock(cancel_text));
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
608 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
609 gtk_widget_show(button);
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
610
5817
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
611 g_signal_connect(G_OBJECT(button), "clicked",
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
612 G_CALLBACK(multifield_cancel_cb), data);
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
613
5815
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
614 /* OK button */
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
615 button = gtk_button_new_from_stock(text_to_stock(ok_text));
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
616 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
617 gtk_widget_show(button);
c900fc823a21 [gaim-migrate @ 6245]
Christian Hammond <chipx86@chipx86.com>
parents: 5813
diff changeset
618
5817
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
619 g_signal_connect(G_OBJECT(button), "clicked",
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
620 G_CALLBACK(multifield_ok_cb), data);
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
621
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
622 gtk_widget_show(win);
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
623
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
624 return data;
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
625 }
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
626
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
627 void
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
628 gaim_gtk_close_request(GaimRequestType type, void *ui_handle)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
629 {
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
630 GaimGtkRequestData *data = (GaimGtkRequestData *)ui_handle;
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
631
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
632 if (data->cbs != NULL)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
633 g_free(data->cbs);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
634
5817
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
635 if (type == GAIM_REQUEST_FIELDS)
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
636 gaim_request_fields_destroy(data->u.multifield.fields);
571e895bf6ba [gaim-migrate @ 6247]
Christian Hammond <chipx86@chipx86.com>
parents: 5816
diff changeset
637
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
638 gtk_widget_destroy(data->dialog);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
639
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
640 g_free(data);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
641 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
642
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
643 static GaimRequestUiOps ops =
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
644 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
645 gaim_gtk_request_input,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
646 gaim_gtk_request_choice,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
647 gaim_gtk_request_action,
5811
9467bff78029 [gaim-migrate @ 6241]
Christian Hammond <chipx86@chipx86.com>
parents: 5794
diff changeset
648 gaim_gtk_request_fields,
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
649 gaim_gtk_close_request
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
650 };
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
651
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
652 GaimRequestUiOps *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
653 gaim_get_gtk_request_ui_ops(void)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
654 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
655 return &ops;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
656 }