annotate src/gtkrequest.c @ 11908:34ea75bdd0c9

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