annotate console/gntrequest.c @ 15800:76bdff454d6f

Minor cleanup.
author Daniel Atallah <daniel.atallah@gmail.com>
date Sat, 17 Mar 2007 17:47:40 +0000
parents 836d7c247d22
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14558
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
1 /**
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
2 * @file gntrequest.c GNT Request API
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
3 * @ingroup gntui
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
4 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
5 * gaim
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
6 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
9 * source distribution.
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
10 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
11 * This program is free software; you can redistribute it and/or modify
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
12 * it under the terms of the GNU General Public License as published by
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
14 * (at your option) any later version.
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
15 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
16 * This program is distributed in the hope that it will be useful,
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
19 * GNU General Public License for more details.
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
20 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
21 * You should have received a copy of the GNU General Public License
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
22 * along with this program; if not, write to the Free Software
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14351
diff changeset
24 */
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 #include <gnt.h>
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 #include <gntbox.h>
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 #include <gntbutton.h>
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
28 #include <gntcheckbox.h>
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 #include <gntcombobox.h>
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 #include <gntentry.h>
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 #include <gntlabel.h>
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
32 #include <gntline.h>
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
33 #include <gnttree.h>
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
35 #include "gntgaim.h"
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 #include "gntrequest.h"
15654
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
37 #include "util.c"
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
38
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
39 typedef struct
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
40 {
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
41 void *user_data;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
42 GntWidget *entry, *dialog;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
43 GCallback *cbs;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
44 } GaimGntFileRequest;
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 static GntWidget *
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 setup_request_window(const char *title, const char *primary,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
48 const char *secondary, GaimRequestType type)
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 GntWidget *window;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 window = gnt_vbox_new(FALSE);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 gnt_box_set_title(GNT_BOX(window), title);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 if (primary)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 gnt_box_add_widget(GNT_BOX(window),
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD));
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 if (secondary)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 gnt_box_add_widget(GNT_BOX(window), gnt_label_new(secondary));
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
63 g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(gaim_request_close),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
64 GINT_TO_POINTER(type));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
65
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 return window;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 static GntWidget *
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70 setup_button_box(gpointer userdata, gpointer cb, gpointer data, ...)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 GntWidget *box, *button;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 va_list list;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 const char *text;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 gpointer callback;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
77 box = gnt_hbox_new(FALSE);
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 va_start(list, data);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 while ((text = va_arg(list, const char *)))
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 callback = va_arg(list, gpointer);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 button = gnt_button_new(text);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 gnt_box_add_widget(GNT_BOX(box), button);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 g_object_set_data(G_OBJECT(button), "activate-callback", callback);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 g_object_set_data(G_OBJECT(button), "activate-userdata", userdata);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cb), data);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 va_end(list);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 return box;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 static void
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 notify_input_cb(GntWidget *button, GntWidget *entry)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 GaimRequestInputCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 if (callback)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 callback(data, text);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 while (button->parent)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 button = button->parent;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108 gaim_request_close(GAIM_REQUEST_INPUT, button);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 static void *
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 gg_request_input(const char *title, const char *primary,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 const char *secondary, const char *default_value,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 gboolean multiline, gboolean masked, gchar *hint,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 const char *ok_text, GCallback ok_cb,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 const char *cancel_text, GCallback cancel_cb,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 void *user_data)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 GntWidget *window, *box, *entry;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
121 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_INPUT);
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 entry = gnt_entry_new(default_value);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 if (masked)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 gnt_entry_set_masked(GNT_ENTRY(entry), TRUE);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 gnt_box_add_widget(GNT_BOX(window), entry);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 box = setup_button_box(user_data, notify_input_cb, entry,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 ok_text, ok_cb, cancel_text, cancel_cb, NULL);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 gnt_box_add_widget(GNT_BOX(window), box);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 gnt_widget_show(window);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 return window;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137 static void
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 gg_close_request(GaimRequestType type, gpointer ui_handle)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 GntWidget *widget = GNT_WIDGET(ui_handle);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 while (widget->parent)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142 widget = widget->parent;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 gnt_widget_destroy(widget);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 static void
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 request_choice_cb(GntWidget *button, GntComboBox *combo)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 GaimRequestChoiceCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 int choice = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))) - 1;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 if (callback)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154 callback(data, choice);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
155
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
156 while (button->parent)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157 button = button->parent;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 gaim_request_close(GAIM_REQUEST_INPUT, button);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 static void *
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 gg_request_choice(const char *title, const char *primary,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 const char *secondary, unsigned int default_value,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 const char *ok_text, GCallback ok_cb,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 const char *cancel_text, GCallback cancel_cb,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 void *user_data, va_list choices)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 GntWidget *window, *combo, *box;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 const char *text;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 int val;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
173 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_CHOICE);
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 combo = gnt_combo_box_new();
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 gnt_box_add_widget(GNT_BOX(window), combo);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 while ((text = va_arg(choices, const char *)))
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 val = va_arg(choices, int);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), GINT_TO_POINTER(val + 1), text);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), GINT_TO_POINTER(default_value + 1));
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 box = setup_button_box(user_data, request_choice_cb, combo,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185 ok_text, ok_cb, cancel_text, cancel_cb, NULL);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186 gnt_box_add_widget(GNT_BOX(window), box);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 gnt_widget_show(window);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 return window;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 static void
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194 request_action_cb(GntWidget *button, GntWidget *window)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 GaimRequestActionCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
198 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "activate-id"));
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
199
14019
19a1812e6c46 [gaim-migrate @ 16615]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
200 if (callback)
19a1812e6c46 [gaim-migrate @ 16615]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
201 callback(data, id);
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 gaim_request_close(GAIM_REQUEST_ACTION, window);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 static void*
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 gg_request_action(const char *title, const char *primary,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 const char *secondary, unsigned int default_value,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 void *user_data, size_t actioncount,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210 va_list actions)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 GntWidget *window, *box, *button;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 int i;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
215 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_ACTION);
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
216
14064
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
217 box = gnt_hbox_new(FALSE);
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218 gnt_box_add_widget(GNT_BOX(window), box);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 for (i = 0; i < actioncount; i++)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 const char *text = va_arg(actions, const char *);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 GaimRequestActionCb callback = va_arg(actions, GaimRequestActionCb);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 button = gnt_button_new(text);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 gnt_box_add_widget(GNT_BOX(box), button);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 g_object_set_data(G_OBJECT(button), "activate-callback", callback);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 g_object_set_data(G_OBJECT(button), "activate-userdata", user_data);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 g_object_set_data(G_OBJECT(button), "activate-id", GINT_TO_POINTER(i));
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(request_action_cb), window);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 gnt_widget_show(window);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 return window;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
238 static void
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
239 request_fields_cb(GntWidget *button, GaimRequestFields *fields)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
240 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
241 GaimRequestFieldsCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
242 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
243 GList *list;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
244
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
245 /* Update the data of the fields. GtkGaim does this differently. Instead of
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
246 * updating the fields at the end like here, it updates the appropriate field
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
247 * instantly whenever a change is made. That allows it to make sure the
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
248 * 'required' fields are entered before the user can hit OK. It's not the case
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
249 * here, althought it can be done. I am not honouring the 'required' fields
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
250 * for the moment. */
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
251 for (list = gaim_request_fields_get_groups(fields); list; list = list->next)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
252 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
253 GaimRequestFieldGroup *group = list->data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
254 GList *fields = gaim_request_field_group_get_fields(group);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
255
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
256 for (; fields ; fields = fields->next)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
257 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
258 GaimRequestField *field = fields->data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
259 GaimRequestFieldType type = gaim_request_field_get_type(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
260 if (type == GAIM_REQUEST_FIELD_BOOLEAN)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
261 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
262 GntWidget *check = field->ui_data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
263 gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(check));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
264 gaim_request_field_bool_set_value(field, value);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
265 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
266 else if (type == GAIM_REQUEST_FIELD_STRING)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
267 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
268 GntWidget *entry = field->ui_data;
14063
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
269 const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
270 gaim_request_field_string_set_value(field, (text && *text) ? text : NULL);
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
271 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
272 else if (type == GAIM_REQUEST_FIELD_INTEGER)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
273 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
274 GntWidget *entry = field->ui_data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
275 const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
276 int value = (text && *text) ? atoi(text) : 0;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
277 gaim_request_field_int_set_value(field, value);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
278 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
279 else if (type == GAIM_REQUEST_FIELD_CHOICE)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
280 {
14226
b02b7017930f [gaim-migrate @ 16907]
Stu Tomlinson <stu@nosnilmot.com>
parents: 14198
diff changeset
281 GntWidget *combo = field->ui_data;
14198
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14064
diff changeset
282 int id;
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14064
diff changeset
283 id = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)));
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
284 gaim_request_field_choice_set_value(field, id);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
285 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
286 else if (type == GAIM_REQUEST_FIELD_LIST)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
287 {
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
288 GList *list = NULL;
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
289 if (gaim_request_field_list_get_multi_select(field))
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
290 {
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
291 const GList *iter;
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
292 GntWidget *tree = field->ui_data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
293
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
294 iter = gaim_request_field_list_get_items(field);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
295 for (; iter; iter = iter->next)
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
296 {
14690
97df6766c945 [gaim-migrate @ 17442]
Stu Tomlinson <stu@nosnilmot.com>
parents: 14558
diff changeset
297 const char *text = iter->data;
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
298 gpointer key = gaim_request_field_list_get_data(field, text);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
299 if (gnt_tree_get_choice(GNT_TREE(tree), key))
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
300 list = g_list_prepend(list, key);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
301 }
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
302 }
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
303 else
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
304 {
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
305 GntWidget *combo = field->ui_data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
306 gpointer data = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
307 list = g_list_append(list, data);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
308 }
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
309
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
310 gaim_request_field_list_set_selected(field, list);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
311 g_list_free(list);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
312 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
313 else if (type == GAIM_REQUEST_FIELD_ACCOUNT)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
314 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
315 GntWidget *combo = field->ui_data;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
316 GaimAccount *acc = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
317 gaim_request_field_account_set_value(field, acc);
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
318 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
319 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
320 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
321
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
322 if (callback)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
323 callback(data, fields);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
324
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
325 while (button->parent)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
326 button = button->parent;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
327
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
328 gaim_request_close(GAIM_REQUEST_FIELDS, button);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
329 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
330
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
331 static void *
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
332 gg_request_fields(const char *title, const char *primary,
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
333 const char *secondary, GaimRequestFields *allfields,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
334 const char *ok, GCallback ok_cb,
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
335 const char *cancel, GCallback cancel_cb,
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
336 void *userdata)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
337 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
338 GntWidget *window, *box;
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
339 GList *grlist;
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
340
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
341 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_FIELDS);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
342
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
343 /* This is how it's going to work: the request-groups are going to be
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
344 * stacked vertically one after the other. A GntLine will be separating
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
345 * the groups. */
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
346 box = gnt_vbox_new(FALSE);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
347 gnt_box_set_pad(GNT_BOX(box), 0);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
348 gnt_box_set_fill(GNT_BOX(box), TRUE);
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
349 for (grlist = gaim_request_fields_get_groups(allfields); grlist; grlist = grlist->next)
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
350 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
351 GaimRequestFieldGroup *group = grlist->data;
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
352 GList *fields = gaim_request_field_group_get_fields(group);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
353 GntWidget *hbox;
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
354 const char *title = gaim_request_field_group_get_title(group);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
355
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
356 if (title)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
357 gnt_box_add_widget(GNT_BOX(box),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
358 gnt_label_new_with_format(title, GNT_TEXT_FLAG_BOLD));
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
359
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
360 for (; fields ; fields = fields->next)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
361 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
362 /* XXX: Break each of the fields into a separate function? */
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
363 GaimRequestField *field = fields->data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
364 GaimRequestFieldType type = gaim_request_field_get_type(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
365 const char *label = gaim_request_field_get_label(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
366
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
367 hbox = gnt_hbox_new(TRUE); /* hrm */
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
368 gnt_box_add_widget(GNT_BOX(box), hbox);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
369
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
370 if (type != GAIM_REQUEST_FIELD_BOOLEAN && label)
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
371 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
372 GntWidget *l = gnt_label_new(label);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
373 gnt_widget_set_size(l, 0, 1);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
374 gnt_box_add_widget(GNT_BOX(hbox), l);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
375 }
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
376
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
377 if (type == GAIM_REQUEST_FIELD_BOOLEAN)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
378 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
379 GntWidget *check = gnt_check_box_new(label);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
380 gnt_check_box_set_checked(GNT_CHECK_BOX(check),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
381 gaim_request_field_bool_get_default_value(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
382 gnt_box_add_widget(GNT_BOX(hbox), check);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
383 field->ui_data = check;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
384 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
385 else if (type == GAIM_REQUEST_FIELD_STRING)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
386 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
387 GntWidget *entry = gnt_entry_new(
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
388 gaim_request_field_string_get_default_value(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
389 gnt_entry_set_masked(GNT_ENTRY(entry),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
390 gaim_request_field_string_is_masked(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
391 gnt_box_add_widget(GNT_BOX(hbox), entry);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
392 field->ui_data = entry;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
393 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
394 else if (type == GAIM_REQUEST_FIELD_INTEGER)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
395 {
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14226
diff changeset
396 char str[256];
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14226
diff changeset
397 int val = gaim_request_field_int_get_default_value(field);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14226
diff changeset
398 GntWidget *entry;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14226
diff changeset
399
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14226
diff changeset
400 snprintf(str, sizeof(str), "%d", val);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14226
diff changeset
401 entry = gnt_entry_new(str);
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
402 gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
403 gnt_box_add_widget(GNT_BOX(hbox), entry);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
404 field->ui_data = entry;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
405 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
406 else if (type == GAIM_REQUEST_FIELD_CHOICE)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
407 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
408 int id;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
409 const GList *list;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
410 GntWidget *combo = gnt_combo_box_new();
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
411 gnt_box_add_widget(GNT_BOX(hbox), combo);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
412 field->ui_data = combo;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
413
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
414 list = gaim_request_field_choice_get_labels(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
415 for (id = 1; list; list = list->next, id++)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
416 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
417 gnt_combo_box_add_data(GNT_COMBO_BOX(combo),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
418 GINT_TO_POINTER(id), list->data);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
419 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
420 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
421 GINT_TO_POINTER(gaim_request_field_choice_get_default_value(field)));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
422 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
423 else if (type == GAIM_REQUEST_FIELD_LIST)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
424 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
425 const GList *list;
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
426 gboolean multi = gaim_request_field_list_get_multi_select(field);
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
427 if (multi)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
428 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
429 GntWidget *tree = gnt_tree_new();
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
430 gnt_box_add_widget(GNT_BOX(hbox), tree);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
431 field->ui_data = tree;
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
432
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
433 list = gaim_request_field_list_get_items(field);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
434 for (; list; list = list->next)
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
435 {
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
436 const char *text = list->data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
437 gpointer key = gaim_request_field_list_get_data(field, text);
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
438 gnt_tree_add_choice(GNT_TREE(tree), key,
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
439 gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
440 if (gaim_request_field_list_is_selected(field, text))
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
441 gnt_tree_set_choice(GNT_TREE(tree), key, TRUE);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
442 }
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
443 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
444 else
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
445 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
446 GntWidget *combo = gnt_combo_box_new();
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
447 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
448 gnt_box_add_widget(GNT_BOX(hbox), combo);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
449 field->ui_data = combo;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
450
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
451 list = gaim_request_field_list_get_items(field);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
452 for (; list; list = list->next)
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
453 {
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
454 const char *text = list->data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
455 gpointer key = gaim_request_field_list_get_data(field, text);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
456 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), key, text);
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
457 if (gaim_request_field_list_is_selected(field, text))
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
458 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), key);
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
459 }
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
460 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
461 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
462 else if (type == GAIM_REQUEST_FIELD_ACCOUNT)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
463 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
464 gboolean all;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
465 GaimAccount *def;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
466 GList *list;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
467 GntWidget *combo = gnt_combo_box_new();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
468 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
469 gnt_box_add_widget(GNT_BOX(hbox), combo);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
470 field->ui_data = combo;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
471
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
472 all = gaim_request_field_account_get_show_all(field);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
473 def = gaim_request_field_account_get_default_value(field);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
474
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
475 if (all)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
476 list = gaim_accounts_get_all();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
477 else
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
478 list = gaim_connections_get_all();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
479
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
480 for (; list; list = list->next)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
481 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
482 GaimAccount *account;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
483 char *text;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
484
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
485 if (all)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
486 account = list->data;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
487 else
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
488 account = gaim_connection_get_account(list->data);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
489
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
490 text = g_strdup_printf("%s (%s)",
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
491 gaim_account_get_username(account),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
492 gaim_account_get_protocol_name(account));
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
493 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
494 g_free(text);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
495 if (account == def)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
496 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
497 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
498 gnt_widget_set_size(combo, 20, 3); /* ew */
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
499 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
500 else
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
501 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
502 gnt_box_add_widget(GNT_BOX(hbox),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
503 gnt_label_new_with_format(_("Not implemented yet."),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
504 GNT_TEXT_FLAG_BOLD));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
505 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
506 }
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
507 if (grlist->next)
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
508 gnt_box_add_widget(GNT_BOX(box), gnt_hline_new());
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
509 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
510 gnt_box_add_widget(GNT_BOX(window), box);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
511
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
512 box = setup_button_box(userdata, request_fields_cb, allfields,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
513 ok, ok_cb, cancel, cancel_cb, NULL);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
514 gnt_box_add_widget(GNT_BOX(window), box);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
515
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
516 gnt_widget_show(window);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
517
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
518 return window;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
519 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
520
15654
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
521 static void
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
522 file_cancel_cb(GntWidget *wid, gpointer fq)
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
523 {
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
524 GaimGntFileRequest *data = fq;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
525 if (data->cbs[1] != NULL)
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
526 ((GaimRequestFileCb)data->cbs[1])(data->user_data, NULL);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
527
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
528 gaim_request_close(GAIM_REQUEST_FILE, data->dialog);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
529 }
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
530
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
531 static void
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
532 file_ok_cb(GntWidget *wid, gpointer fq)
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
533 {
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
534 GaimGntFileRequest *data = fq;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
535 if (data->cbs[0] != NULL)
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
536 ((GaimRequestFileCb)data->cbs[0])(data->user_data, gnt_entry_get_text(GNT_ENTRY(data->entry)));
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
537
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
538 gaim_request_close(GAIM_REQUEST_FILE, data->dialog);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
539 }
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
540
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
541 static void
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
542 file_request_destroy(GaimGntFileRequest *data)
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
543 {
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
544 g_free(data->cbs);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
545 g_free(data);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
546 }
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
547
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
548 static void *
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
549 gg_request_file(const char *title, const char *filename,
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
550 gboolean savedialog,
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
551 GCallback ok_cb, GCallback cancel_cb,
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
552 void *user_data)
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
553 {
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
554 GntWidget *window = gnt_vbox_new(FALSE);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
555 GntWidget *entry, *hbox, *button;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
556 GaimGntFileRequest *data = g_new0(GaimGntFileRequest, 1);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
557
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
558 data->user_data = user_data;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
559 data->cbs = g_new0(GCallback, 2);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
560 data->cbs[0] = ok_cb;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
561 data->cbs[1] = cancel_cb;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
562 data->dialog = window;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
563 data->entry = entry = gnt_entry_new(g_strconcat(gaim_home_dir(), G_DIR_SEPARATOR_S, filename, NULL));
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
564 gnt_widget_set_size(entry, 30, 1);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
565 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
566 gnt_box_set_title(GNT_BOX(window), title ? title : (savedialog ? _("Save File...") : _("Open File...")));
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
567 #if 0
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
568 /* After the string freeze */
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
569 gnt_box_add_widget(GNT_BOX(window), gnt_label_new(_("Please enter a full path for a file")));
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
570 #endif
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
571 gnt_box_add_widget(GNT_BOX(window), entry);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
572
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
573 hbox = gnt_hbox_new(TRUE);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
574 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
575
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
576 button = gnt_button_new(_("Cancel"));
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
577 g_signal_connect(G_OBJECT(button), "activate",
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
578 G_CALLBACK(file_cancel_cb), data);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
579 gnt_box_add_widget(GNT_BOX(hbox), button);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
580
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
581 button = gnt_button_new(_("OK"));
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
582 g_signal_connect(G_OBJECT(button), "activate",
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
583 G_CALLBACK(file_ok_cb), data);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
584 gnt_box_add_widget(GNT_BOX(hbox), button);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
585
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
586 gnt_box_add_widget(GNT_BOX(window), hbox);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
587
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
588 g_signal_connect_swapped(G_OBJECT(window), "destroy",
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
589 G_CALLBACK(file_request_destroy), data);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
590
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
591 gnt_widget_show(window);
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
592
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
593 return window;
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
594 }
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
595
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
596 static GaimRequestUiOps uiops =
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
597 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
598 .request_input = gg_request_input,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
599 .close_request = gg_close_request,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
600 .request_choice = gg_request_choice,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
601 .request_action = gg_request_action,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
602 .request_fields = gg_request_fields,
15654
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
603 .request_file = gg_request_file,
836d7c247d22 The rest of Richard 'wabz' Nelson's patch for adding file-transfer ui.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14690
diff changeset
604 .request_folder = NULL /* No plans for this */
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
605 };
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
606
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
607 GaimRequestUiOps *gg_request_get_ui_ops()
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
608 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
609 return &uiops;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
610 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
611
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
612 void gg_request_init()
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
613 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
614 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
615
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
616 void gg_request_uninit()
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
617 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
618 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
619