annotate src/gtkrequest.c @ 5638:0bdfa28c678e

[gaim-migrate @ 6047] We're slowly killing off multi.h. The proto_user_split and proto_user_opt have been replaced with GaimAccountOption and GaimAccountUserSplit structures, which of course have an API. The account dialog is being rewritten as well, and will soon allow you to add and modify accounts again. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 01 Jun 2003 17:40:20 +0000
parents da18a02c3705
children 5e93fc46d1af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file gtkrequest.c GTK+ Request API
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 * @ingroup gtkui
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 * gaim
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * (at your option) any later version.
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * GNU General Public License for more details.
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "gtkrequest.h"
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "stock.h"
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include <gtk/gtk.h>
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 #include <string.h>
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 /* XXX For _(..) */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 #include "gaim.h"
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 typedef struct
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 GaimRequestType type;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 void *user_data;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 GtkWidget *dialog;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 size_t cb_count;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 GCallback *cbs;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
41 union
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
42 {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
43 struct
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
44 {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
45 GtkWidget *entry;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
46
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
47 gboolean multiline;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
48
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
49 } input;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
50
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
51 } u;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
52
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 } GaimRequestData;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 static void
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 __input_response_cb(GtkDialog *dialog, gint id, GaimRequestData *data)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 {
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
58 const char *value;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
59
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
60 if (data->u.input.multiline) {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
61 GtkTextIter start_iter, end_iter;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
62 GtkTextBuffer *buffer =
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
63 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
64
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
65 gtk_text_buffer_get_start_iter(buffer, &start_iter);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
66 gtk_text_buffer_get_end_iter(buffer, &end_iter);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
67
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
68 value = gtk_text_buffer_get_text(buffer, &start_iter, &end_iter,
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
69 FALSE);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 }
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
71 else
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
72 value = gtk_entry_get_text(GTK_ENTRY(data->u.input.entry));
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
73
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
74 if (id < data->cb_count && data->cbs[id] != NULL)
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5496
diff changeset
75 ((GaimRequestInputCb)data->cbs[id])(data->user_data, value);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 gaim_request_close(GAIM_REQUEST_INPUT, data);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
80 static void
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
81 __action_response_cb(GtkDialog *dialog, gint id, GaimRequestData *data)
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
82 {
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
83 if (id < data->cb_count && data->cbs[id] != NULL)
5498
cce2d7868c78 [gaim-migrate @ 5894]
Christian Hammond <chipx86@chipx86.com>
parents: 5496
diff changeset
84 ((GaimRequestActionCb)data->cbs[id])(data->user_data, id);
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
85
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
86 gaim_request_close(GAIM_REQUEST_INPUT, data);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
87 }
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
88
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 #define STOCK_ITEMIZE(r, l) \
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 if (!strcmp((r), text)) \
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 return (l);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 static const char *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 __text_to_stock(const char *text)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 STOCK_ITEMIZE(_("Yes"), GTK_STOCK_YES);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 STOCK_ITEMIZE(_("No"), GTK_STOCK_NO);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 STOCK_ITEMIZE(_("OK"), GTK_STOCK_OK);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 STOCK_ITEMIZE(_("Cancel"), GTK_STOCK_CANCEL);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 STOCK_ITEMIZE(_("Apply"), GTK_STOCK_APPLY);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 STOCK_ITEMIZE(_("Close"), GTK_STOCK_CLOSE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 STOCK_ITEMIZE(_("Delete"), GTK_STOCK_DELETE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 STOCK_ITEMIZE(_("Add"), GTK_STOCK_ADD);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 STOCK_ITEMIZE(_("Remove"), GTK_STOCK_REMOVE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
106 return text;
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109 void *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 gaim_gtk_request_input(const char *title, const char *primary,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 const char *secondary, const char *default_value,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 gboolean multiline,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 const char *ok_text, GCallback ok_cb,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 const char *cancel_text, GCallback cancel_cb,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 void *user_data)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 GaimRequestData *data;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 GtkWidget *dialog;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 GtkWidget *vbox;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 GtkWidget *hbox;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 GtkWidget *label;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 GtkWidget *entry;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 GtkWidget *img;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 char *label_text;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 data = g_new0(GaimRequestData, 1);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 data->type = GAIM_REQUEST_INPUT;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 data->user_data = user_data;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 data->cb_count = 2;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 data->cbs = g_new0(GCallback, 2);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 data->cbs[0] = ok_cb;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 data->cbs[1] = cancel_cb;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 /* Create the dialog. */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 dialog = gtk_dialog_new_with_buttons("", NULL, 0,
5485
c103ba09c62a [gaim-migrate @ 5881]
Sean Egan <seanegan@gmail.com>
parents: 5480
diff changeset
138 __text_to_stock(cancel_text), 1,
c103ba09c62a [gaim-migrate @ 5881]
Sean Egan <seanegan@gmail.com>
parents: 5480
diff changeset
139 __text_to_stock(ok_text), 0,
c103ba09c62a [gaim-migrate @ 5881]
Sean Egan <seanegan@gmail.com>
parents: 5480
diff changeset
140 NULL);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 data->dialog = dialog;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 g_signal_connect(G_OBJECT(dialog), "response",
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 G_CALLBACK(__input_response_cb), data);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 /* Setup the dialog */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
5510
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
148 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
5510
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
151 gtk_dialog_set_default_response(GTK_DIALOG(dialog), 0);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 /* Setup the main horizontal box */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 hbox = gtk_hbox_new(FALSE, 12);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 /* Dialog icon. */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 GTK_ICON_SIZE_DIALOG);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 /* Vertical box */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 vbox = gtk_vbox_new(FALSE, 12);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 /* Descriptive label */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 label_text = g_strdup_printf("<span weight=\"bold\" size=\"larger\">"
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 "%s</span>\n\n%s",
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 primary, (secondary ? secondary : ""));
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 label = gtk_label_new(NULL);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 gtk_label_set_markup(GTK_LABEL(label), label_text);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 g_free(label_text);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 /* Entry field. */
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
184 data->u.input.multiline = multiline;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
185
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
186 if (multiline) {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
187 GtkWidget *sw;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
188
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
189 sw = gtk_scrolled_window_new(NULL, NULL);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
190 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
191 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
192 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
193 GTK_SHADOW_IN);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
194
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
195 gtk_widget_set_size_request(sw, 300, 75);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
196
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
197 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
198
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
199 entry = gtk_text_view_new();
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
200 gtk_text_view_set_editable(GTK_TEXT_VIEW(entry), TRUE);
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
202 gtk_container_add(GTK_CONTAINER(sw), entry);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
203
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
204 if (default_value != NULL) {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
205 GtkTextBuffer *buffer;
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
206
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
207 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry));
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
208 gtk_text_buffer_set_text(buffer, default_value, -1);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
209 }
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
210 }
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
211 else {
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
212 entry = gtk_entry_new();
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
213
5510
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
214 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
215
5490
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
216 gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
217
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
218 if (default_value != NULL)
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
219 gtk_entry_set_text(GTK_ENTRY(entry), default_value);
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
220 }
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
221
421020171808 [gaim-migrate @ 5886]
Christian Hammond <chipx86@chipx86.com>
parents: 5485
diff changeset
222 data->u.input.entry = entry;
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 /* Show everything. */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 gtk_widget_show_all(dialog);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 return data;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 void *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 gaim_gtk_request_choice(const char *title, const char *primary,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232 const char *secondary, unsigned int default_value,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 const char *ok_text, GCallback ok_cb,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
234 const char *cancel_text, GCallback cancel_cb,
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
235 void *user_data, size_t choice_count, va_list args)
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
236 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
237 return NULL;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
238 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
239
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 void *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 gaim_gtk_request_action(const char *title, const char *primary,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 const char *secondary, unsigned int default_action,
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
243 void *user_data, size_t action_count, va_list actions)
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 {
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
245 GaimRequestData *data;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
246 GtkWidget *dialog;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
247 GtkWidget *vbox;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
248 GtkWidget *hbox;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
249 GtkWidget *label;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
250 GtkWidget *img;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
251 void **buttons;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
252 char *label_text;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
253 int i;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
254
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
255 data = g_new0(GaimRequestData, 1);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
256 data->type = GAIM_REQUEST_ACTION;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
257 data->user_data = user_data;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
258
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
259 data->cb_count = action_count;
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
260 data->cbs = g_new0(GCallback, action_count);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
261
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
262 /* Reverse the buttons */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
263 buttons = g_new0(void *, action_count * 2);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
264
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
265 for (i = 0; i < action_count * 2; i += 2) {
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
266 buttons[(action_count * 2) - i - 2] = va_arg(actions, char *);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
267 buttons[(action_count * 2) - i - 1] = va_arg(actions, GCallback);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
268 }
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
269
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
270 /* Create the dialog. */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
271 data->dialog = dialog = gtk_dialog_new();
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
272
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
273 for (i = 0; i < action_count; i++) {
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
274 gtk_dialog_add_button(GTK_DIALOG(dialog),
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
275 __text_to_stock(buttons[2 * i]), i);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
276
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
277 data->cbs[i] = buttons[2 * i + 1];
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
278 }
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
279
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
280 g_free(buttons);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
281
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
282 g_signal_connect(G_OBJECT(dialog), "response",
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
283 G_CALLBACK(__action_response_cb), data);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
284
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
285 /* Setup the dialog */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
286 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
287 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
288 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
289 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
290 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
291
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
292 /* Setup the main horizontal box */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
293 hbox = gtk_hbox_new(FALSE, 12);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
294 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
295
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
296 /* Dialog icon. */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
297 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION,
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
298 GTK_ICON_SIZE_DIALOG);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
299 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
300 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
301
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
302 /* Vertical box */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
303 vbox = gtk_vbox_new(FALSE, 12);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
304
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
305 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
306
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
307 /* Descriptive label */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
308 label_text = g_strdup_printf("<span weight=\"bold\" size=\"larger\">"
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
309 "%s</span>\n\n%s",
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
310 primary, (secondary ? secondary : ""));
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
311
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
312 label = gtk_label_new(NULL);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
313
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
314 gtk_label_set_markup(GTK_LABEL(label), label_text);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
315 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
316 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
317 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
318
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
319 g_free(label_text);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
320
5510
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
321 if (default_action != -1)
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
322 gtk_dialog_set_default_response(GTK_DIALOG(dialog), default_action);
da18a02c3705 [gaim-migrate @ 5909]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
323
5496
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
324 /* Show everything. */
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
325 gtk_widget_show_all(dialog);
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
326
b7c0be69c749 [gaim-migrate @ 5892]
Christian Hammond <chipx86@chipx86.com>
parents: 5490
diff changeset
327 return data;
5480
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330 void
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 gaim_gtk_close_request(GaimRequestType type, void *ui_handle)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333 GaimRequestData *data = (GaimRequestData *)ui_handle;
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 if (data->cbs != NULL)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336 g_free(data->cbs);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
338 gtk_widget_destroy(data->dialog);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
339
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
340 g_free(data);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
341 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
342
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
343 static GaimRequestUiOps ops =
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
344 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
345 gaim_gtk_request_input,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
346 gaim_gtk_request_choice,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 gaim_gtk_request_action,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348 gaim_gtk_close_request
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
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 GaimRequestUiOps *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352 gaim_get_gtk_request_ui_ops(void)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
354 return &ops;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 }