annotate src/gtkrequest.c @ 5483:00032269c317

[gaim-migrate @ 5879] Added the request API to the core.h file. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 22 May 2003 10:22:32 +0000
parents f19620d8694f
children c103ba09c62a
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 GtkWidget *entry;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 size_t cb_count;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 GCallback *cbs;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 } GaimRequestData;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 static void
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 __input_response_cb(GtkDialog *dialog, gint id, GaimRequestData *data)
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 if (id < data->cb_count && data->cbs[id] != NULL) {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 ((GaimRequestInputCb)data->cbs[id])(
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 gtk_entry_get_text(GTK_ENTRY(data->entry)), data->user_data);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52 gaim_request_close(GAIM_REQUEST_INPUT, data);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 }
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 #define STOCK_ITEMIZE(r, l) \
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 if (!strcmp((r), text)) \
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57 return (l);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 static const char *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 __text_to_stock(const char *text)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 STOCK_ITEMIZE(_("Yes"), GTK_STOCK_YES);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 STOCK_ITEMIZE(_("No"), GTK_STOCK_NO);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 STOCK_ITEMIZE(_("OK"), GTK_STOCK_OK);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 STOCK_ITEMIZE(_("Cancel"), GTK_STOCK_CANCEL);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 STOCK_ITEMIZE(_("Apply"), GTK_STOCK_APPLY);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 STOCK_ITEMIZE(_("Close"), GTK_STOCK_CLOSE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 STOCK_ITEMIZE(_("Delete"), GTK_STOCK_DELETE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 STOCK_ITEMIZE(_("Add"), GTK_STOCK_ADD);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70 STOCK_ITEMIZE(_("Remove"), GTK_STOCK_REMOVE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 return NULL;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 void *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 gaim_gtk_request_input(const char *title, const char *primary,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 const char *secondary, const char *default_value,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78 gboolean multiline,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 const char *ok_text, GCallback ok_cb,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 const char *cancel_text, GCallback cancel_cb,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 void *user_data)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 GaimRequestData *data;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 GtkWidget *dialog;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 GtkWidget *vbox;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86 GtkWidget *hbox;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 GtkWidget *label;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 GtkWidget *entry;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 GtkWidget *img;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 char *label_text;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 data = g_new0(GaimRequestData, 1);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 data->type = GAIM_REQUEST_INPUT;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 data->user_data = user_data;
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 data->cb_count = 2;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 data->cbs = g_new0(GCallback, 2);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 data->cbs[0] = ok_cb;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 data->cbs[1] = cancel_cb;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 #if 0
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103 data->dialog = dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 gtk_window_set_role(GTK_WINDOW(dialog), "input");
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 #endif
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 /* Create the dialog. */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 dialog = gtk_dialog_new_with_buttons("", NULL, 0,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 __text_to_stock(ok_text), 0,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 __text_to_stock(cancel_text), 1,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 NULL);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 data->dialog = dialog;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 g_signal_connect(G_OBJECT(dialog), "response",
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 G_CALLBACK(__input_response_cb), data);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 /* Setup the dialog */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 gtk_container_set_border_width(GTK_CONTAINER(dialog), 6);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog)->vbox), 12);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 gtk_container_set_border_width(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), 6);
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 /* Setup the main horizontal box */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 hbox = gtk_hbox_new(FALSE, 12);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox);
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 /* Dialog icon. */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 GTK_ICON_SIZE_DIALOG);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 gtk_misc_set_alignment(GTK_MISC(img), 0, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
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 /* Vertical box */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 vbox = gtk_vbox_new(FALSE, 12);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 /* Descriptive label */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 label_text = g_strdup_printf("<span weight=\"bold\" size=\"larger\">"
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 "%s</span>\n\n%s",
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 primary, (secondary ? secondary : ""));
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 label = gtk_label_new(NULL);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 gtk_label_set_markup(GTK_LABEL(label), label_text);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 g_free(label_text);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155 /* Entry field. */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 data->entry = entry = gtk_entry_new();
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 if (default_value != NULL)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 gtk_entry_set_text(GTK_ENTRY(entry), default_value);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 /* Show everything. */
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 gtk_widget_show_all(dialog);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165 return data;
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
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168 void *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 gaim_gtk_request_choice(const char *title, const char *primary,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 const char *secondary, unsigned int default_value,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171 const char *ok_text, GCallback ok_cb,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 const char *cancel_text, GCallback cancel_cb,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 void *user_data, va_list args)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 return NULL;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
176 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 void *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 gaim_gtk_request_action(const char *title, const char *primary,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180 const char *secondary, unsigned int default_action,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 void *user_data, va_list actions)
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 return NULL;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
185
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186 void
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 gaim_gtk_close_request(GaimRequestType type, void *ui_handle)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189 GaimRequestData *data = (GaimRequestData *)ui_handle;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 if (data->cbs != NULL)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 g_free(data->cbs);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
194 gtk_widget_destroy(data->dialog);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 g_free(data);
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 }
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199 static GaimRequestUiOps ops =
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 gaim_gtk_request_input,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 gaim_gtk_request_choice,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 gaim_gtk_request_action,
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 gaim_gtk_close_request
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205 };
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 GaimRequestUiOps *
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208 gaim_get_gtk_request_ui_ops(void)
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 {
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210 return &ops;
f19620d8694f [gaim-migrate @ 5876]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 }