annotate console/gntrequest.c @ 14078:20a17388c767

[gaim-migrate @ 16699] Leak fix. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 11 Aug 2006 02:40:31 +0000
parents fec4fadf30c9
children c65ed4f6eea8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 #include <gnt.h>
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 #include <gntbox.h>
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 #include <gntbutton.h>
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
4 #include <gntcheckbox.h>
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 #include <gntcombobox.h>
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 #include <gntentry.h>
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7 #include <gntlabel.h>
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
8 #include <gntline.h>
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
9 #include <gnttree.h>
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
11 #include "gntgaim.h"
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 #include "gntrequest.h"
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 static GntWidget *
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 setup_request_window(const char *title, const char *primary,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
16 const char *secondary, GaimRequestType type)
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 GntWidget *window;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 window = gnt_vbox_new(FALSE);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 gnt_box_set_title(GNT_BOX(window), title);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 if (primary)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 gnt_box_add_widget(GNT_BOX(window),
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD));
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 if (secondary)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 gnt_box_add_widget(GNT_BOX(window), gnt_label_new(secondary));
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
31 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
32 GINT_TO_POINTER(type));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
33
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 return window;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 static GntWidget *
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 setup_button_box(gpointer userdata, gpointer cb, gpointer data, ...)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 GntWidget *box, *button;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 va_list list;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 const char *text;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 gpointer callback;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
45 box = gnt_hbox_new(FALSE);
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 va_start(list, data);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 while ((text = va_arg(list, const char *)))
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 callback = va_arg(list, gpointer);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 button = gnt_button_new(text);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 gnt_box_add_widget(GNT_BOX(box), button);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 g_object_set_data(G_OBJECT(button), "activate-callback", callback);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 g_object_set_data(G_OBJECT(button), "activate-userdata", userdata);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cb), data);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59 va_end(list);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 return box;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 static void
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64 notify_input_cb(GntWidget *button, GntWidget *entry)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
65 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
66 GaimRequestInputCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
67 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
68 const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70 if (callback)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
71 callback(data, text);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 while (button->parent)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 button = button->parent;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 gaim_request_close(GAIM_REQUEST_INPUT, button);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 }
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 static void *
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 gg_request_input(const char *title, const char *primary,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 const char *secondary, const char *default_value,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 gboolean multiline, gboolean masked, gchar *hint,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 const char *ok_text, GCallback ok_cb,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 const char *cancel_text, GCallback cancel_cb,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 void *user_data)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 GntWidget *window, *box, *entry;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
89 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_INPUT);
13983
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 entry = gnt_entry_new(default_value);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 if (masked)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 gnt_entry_set_masked(GNT_ENTRY(entry), TRUE);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 gnt_box_add_widget(GNT_BOX(window), entry);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 box = setup_button_box(user_data, notify_input_cb, entry,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 ok_text, ok_cb, cancel_text, cancel_cb, NULL);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 gnt_box_add_widget(GNT_BOX(window), box);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 gnt_widget_show(window);
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 return window;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 }
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 static void
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 gg_close_request(GaimRequestType type, gpointer ui_handle)
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 GntWidget *widget = GNT_WIDGET(ui_handle);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109 while (widget->parent)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 widget = widget->parent;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 gnt_widget_destroy(widget);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 static void
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 request_choice_cb(GntWidget *button, GntComboBox *combo)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 GaimRequestChoiceCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
118 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 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
120
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 if (callback)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122 callback(data, choice);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 while (button->parent)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 button = button->parent;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 gaim_request_close(GAIM_REQUEST_INPUT, button);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 static void *
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 gg_request_choice(const char *title, const char *primary,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 const char *secondary, unsigned int default_value,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133 const char *ok_text, GCallback ok_cb,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 const char *cancel_text, GCallback cancel_cb,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 void *user_data, va_list choices)
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 GntWidget *window, *combo, *box;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 const char *text;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 int val;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
141 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_CHOICE);
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 combo = gnt_combo_box_new();
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 gnt_box_add_widget(GNT_BOX(window), combo);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 while ((text = va_arg(choices, const char *)))
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 val = va_arg(choices, int);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148 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
149 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150 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
151
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
152 box = setup_button_box(user_data, request_choice_cb, combo,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
153 ok_text, ok_cb, cancel_text, cancel_cb, NULL);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
154 gnt_box_add_widget(GNT_BOX(window), box);
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 gnt_widget_show(window);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
157
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
158 return window;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 }
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 static void
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 request_action_cb(GntWidget *button, GntWidget *window)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 GaimRequestActionCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 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
167
14019
19a1812e6c46 [gaim-migrate @ 16615]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
168 if (callback)
19a1812e6c46 [gaim-migrate @ 16615]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13983
diff changeset
169 callback(data, id);
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171 gaim_request_close(GAIM_REQUEST_ACTION, window);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 static void*
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 gg_request_action(const char *title, const char *primary,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 const char *secondary, unsigned int default_value,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 void *user_data, size_t actioncount,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 va_list actions)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 GntWidget *window, *box, *button;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 int i;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
183 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_ACTION);
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184
14064
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
185 box = gnt_hbox_new(FALSE);
13983
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 for (i = 0; i < actioncount; i++)
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 const char *text = va_arg(actions, const char *);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190 GaimRequestActionCb callback = va_arg(actions, GaimRequestActionCb);
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 button = gnt_button_new(text);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
193 gnt_box_add_widget(GNT_BOX(box), button);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
194
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195 g_object_set_data(G_OBJECT(button), "activate-callback", callback);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 g_object_set_data(G_OBJECT(button), "activate-userdata", user_data);
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 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
198 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
199 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 gnt_widget_show(window);
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 return 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
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
206 static void
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
207 request_fields_cb(GntWidget *button, GaimRequestFields *fields)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
208 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
209 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
210 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
211 GList *list;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
212
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
213 /* 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
214 * 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
215 * 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
216 * '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
217 * 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
218 * for the moment. */
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
219 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
220 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
221 GaimRequestFieldGroup *group = list->data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
222 GList *fields = gaim_request_field_group_get_fields(group);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
223
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
224 for (; fields ; fields = fields->next)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
225 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
226 GaimRequestField *field = fields->data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
227 GaimRequestFieldType type = gaim_request_field_get_type(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
228 if (type == GAIM_REQUEST_FIELD_BOOLEAN)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
229 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
230 GntWidget *check = field->ui_data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
231 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
232 gaim_request_field_bool_set_value(field, value);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
233 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
234 else if (type == GAIM_REQUEST_FIELD_STRING)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
235 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
236 GntWidget *entry = field->ui_data;
14063
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
237 const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
238 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
239 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
240 else if (type == GAIM_REQUEST_FIELD_INTEGER)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
241 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
242 GntWidget *entry = field->ui_data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
243 const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
244 int value = (text && *text) ? atoi(text) : 0;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
245 gaim_request_field_int_set_value(field, value);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
246 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
247 else if (type == GAIM_REQUEST_FIELD_CHOICE)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
248 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
249 GntWidget *combo = field->ui_data;;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
250 int id = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
251 gaim_request_field_choice_set_value(field, id);
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 else if (type == GAIM_REQUEST_FIELD_LIST)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
254 {
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
255 GList *list = NULL;
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
256 if (gaim_request_field_list_get_multi_select(field))
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
257 {
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
258 const GList *iter;
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
259 GntWidget *tree = field->ui_data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
260
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
261 iter = gaim_request_field_list_get_items(field);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
262 for (; iter; iter = iter->next)
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
263 {
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
264 const char *text = list->data;
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
265 gpointer key = gaim_request_field_list_get_data(field, text);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
266 if (gnt_tree_get_choice(GNT_TREE(tree), key))
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
267 list = g_list_prepend(list, key);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
268 }
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
269 }
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
270 else
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
271 {
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
272 GntWidget *combo = field->ui_data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
273 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
274 list = g_list_append(list, data);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
275 }
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
276
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
277 gaim_request_field_list_set_selected(field, list);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
278 g_list_free(list);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
279 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
280 else if (type == GAIM_REQUEST_FIELD_ACCOUNT)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
281 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
282 GntWidget *combo = field->ui_data;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
283 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
284 gaim_request_field_account_set_value(field, acc);
14047
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 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
287 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
288
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
289 if (callback)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
290 callback(data, fields);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
291
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
292 while (button->parent)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
293 button = button->parent;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
294
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
295 gaim_request_close(GAIM_REQUEST_FIELDS, button);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
296 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
297
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
298 static void *
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
299 gg_request_fields(const char *title, const char *primary,
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
300 const char *secondary, GaimRequestFields *allfields,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
301 const char *ok, GCallback ok_cb,
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
302 const char *cancel, GCallback cancel_cb,
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
303 void *userdata)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
304 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
305 GntWidget *window, *box;
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
306 GList *grlist;
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
307
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
308 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_FIELDS);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
309
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
310 /* 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
311 * 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
312 * the groups. */
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
313 box = gnt_vbox_new(FALSE);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
314 gnt_box_set_pad(GNT_BOX(box), 0);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
315 gnt_box_set_fill(GNT_BOX(box), TRUE);
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
316 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
317 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
318 GaimRequestFieldGroup *group = grlist->data;
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
319 GList *fields = gaim_request_field_group_get_fields(group);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
320 GntWidget *hbox;
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
321 const char *title = gaim_request_field_group_get_title(group);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
322
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
323 if (title)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
324 gnt_box_add_widget(GNT_BOX(box),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
325 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
326
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
327 for (; fields ; fields = fields->next)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
328 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
329 /* 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
330 GaimRequestField *field = fields->data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
331 GaimRequestFieldType type = gaim_request_field_get_type(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
332 const char *label = gaim_request_field_get_label(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
333
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
334 hbox = gnt_hbox_new(TRUE); /* hrm */
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
335 gnt_box_add_widget(GNT_BOX(box), hbox);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
336
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
337 if (type != GAIM_REQUEST_FIELD_BOOLEAN && label)
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
338 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
339 GntWidget *l = gnt_label_new(label);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
340 gnt_widget_set_size(l, 0, 1);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
341 gnt_box_add_widget(GNT_BOX(hbox), l);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
342 }
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
343
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
344 if (type == GAIM_REQUEST_FIELD_BOOLEAN)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
345 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
346 GntWidget *check = gnt_check_box_new(label);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
347 gnt_check_box_set_checked(GNT_CHECK_BOX(check),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
348 gaim_request_field_bool_get_default_value(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
349 gnt_box_add_widget(GNT_BOX(hbox), check);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
350 field->ui_data = check;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
351 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
352 else if (type == GAIM_REQUEST_FIELD_STRING)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
353 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
354 GntWidget *entry = gnt_entry_new(
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
355 gaim_request_field_string_get_default_value(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
356 gnt_entry_set_masked(GNT_ENTRY(entry),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
357 gaim_request_field_string_is_masked(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
358 gnt_box_add_widget(GNT_BOX(hbox), entry);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
359 field->ui_data = entry;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
360 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
361 else if (type == GAIM_REQUEST_FIELD_INTEGER)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
362 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
363 GntWidget *entry = gnt_entry_new(
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
364 gaim_request_field_string_get_default_value(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
365 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
366 gnt_box_add_widget(GNT_BOX(hbox), entry);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
367 field->ui_data = entry;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
368 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
369 else if (type == GAIM_REQUEST_FIELD_CHOICE)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
370 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
371 int id;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
372 const GList *list;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
373 GntWidget *combo = gnt_combo_box_new();
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
374 gnt_box_add_widget(GNT_BOX(hbox), combo);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
375 field->ui_data = combo;
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 list = gaim_request_field_choice_get_labels(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
378 for (id = 1; list; list = list->next, id++)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
379 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
380 gnt_combo_box_add_data(GNT_COMBO_BOX(combo),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
381 GINT_TO_POINTER(id), list->data);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
382 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
383 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
384 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
385 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
386 else if (type == GAIM_REQUEST_FIELD_LIST)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
387 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
388 const GList *list;
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
389 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
390 if (multi)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
391 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
392 GntWidget *tree = gnt_tree_new();
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
393 gnt_box_add_widget(GNT_BOX(hbox), tree);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
394 field->ui_data = tree;
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
395
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
396 list = gaim_request_field_list_get_items(field);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
397 for (; list; list = list->next)
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
398 {
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
399 const char *text = list->data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
400 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
401 gnt_tree_add_choice(GNT_TREE(tree), key,
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
402 gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
403 if (gaim_request_field_list_is_selected(field, text))
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
404 gnt_tree_set_choice(GNT_TREE(tree), key, TRUE);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
405 }
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
406 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
407 else
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
408 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
409 GntWidget *combo = gnt_combo_box_new();
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
410 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
411 gnt_box_add_widget(GNT_BOX(hbox), combo);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
412 field->ui_data = combo;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
413
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
414 list = gaim_request_field_list_get_items(field);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
415 for (; list; list = list->next)
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
416 {
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
417 const char *text = list->data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
418 gpointer key = gaim_request_field_list_get_data(field, text);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
419 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
420 if (gaim_request_field_list_is_selected(field, text))
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
421 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
422 }
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
423 }
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 else if (type == GAIM_REQUEST_FIELD_ACCOUNT)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
426 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
427 gboolean all;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
428 GaimAccount *def;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
429 GList *list;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
430 GntWidget *combo = gnt_combo_box_new();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
431 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
432 gnt_box_add_widget(GNT_BOX(hbox), combo);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
433 field->ui_data = combo;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
434
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
435 all = gaim_request_field_account_get_show_all(field);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
436 def = gaim_request_field_account_get_default_value(field);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
437
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
438 if (all)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
439 list = gaim_accounts_get_all();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
440 else
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
441 list = gaim_connections_get_all();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
442
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
443 for (; list; list = list->next)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
444 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
445 GaimAccount *account;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
446 char *text;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
447
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
448 if (all)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
449 account = list->data;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
450 else
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
451 account = gaim_connection_get_account(list->data);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
452
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
453 text = g_strdup_printf("%s (%s)",
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
454 gaim_account_get_username(account),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
455 gaim_account_get_protocol_name(account));
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
456 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
457 g_free(text);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
458 if (account == def)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
459 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
460 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
461 gnt_widget_set_size(combo, 20, 3); /* ew */
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
462 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
463 else
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
464 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
465 gnt_box_add_widget(GNT_BOX(hbox),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
466 gnt_label_new_with_format(_("Not implemented yet."),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
467 GNT_TEXT_FLAG_BOLD));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
468 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
469 }
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
470 if (grlist->next)
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
471 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
472 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
473 gnt_box_add_widget(GNT_BOX(window), box);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
474
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
475 box = setup_button_box(userdata, request_fields_cb, allfields,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
476 ok, ok_cb, cancel, cancel_cb, NULL);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
477 gnt_box_add_widget(GNT_BOX(window), box);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
478
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
479 gnt_widget_show(window);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
480
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
481 return window;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
482 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
483
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
484 static GaimRequestUiOps uiops =
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
485 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
486 .request_input = gg_request_input,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
487 .close_request = gg_close_request,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
488 .request_choice = gg_request_choice,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
489 .request_action = gg_request_action,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
490 .request_fields = gg_request_fields,
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
491 .request_file = NULL, /* No plans for these */
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
492 .request_folder = NULL
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
493 };
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
494
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
495 GaimRequestUiOps *gg_request_get_ui_ops()
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
496 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
497 return &uiops;
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
498 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
499
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
500 void gg_request_init()
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
501 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
502 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
503
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
504 void gg_request_uninit()
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
505 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
506 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
507