annotate console/gntrequest.c @ 14198:c65ed4f6eea8

[gaim-migrate @ 16870] Do the right thing: remove the compile warnings. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 19 Aug 2006 03:38:23 +0000
parents fec4fadf30c9
children b02b7017930f
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;;
14198
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14064
diff changeset
250 int id;
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14064
diff changeset
251 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
252 gaim_request_field_choice_set_value(field, id);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
253 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
254 else if (type == GAIM_REQUEST_FIELD_LIST)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
255 {
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
256 GList *list = NULL;
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
257 if (gaim_request_field_list_get_multi_select(field))
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
258 {
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
259 const GList *iter;
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
260 GntWidget *tree = field->ui_data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
261
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
262 iter = gaim_request_field_list_get_items(field);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
263 for (; iter; iter = iter->next)
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
264 {
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
265 const char *text = list->data;
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
266 gpointer key = gaim_request_field_list_get_data(field, text);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
267 if (gnt_tree_get_choice(GNT_TREE(tree), key))
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
268 list = g_list_prepend(list, key);
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 }
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
271 else
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
272 {
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
273 GntWidget *combo = field->ui_data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
274 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
275 list = g_list_append(list, data);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
276 }
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
277
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
278 gaim_request_field_list_set_selected(field, list);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
279 g_list_free(list);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
280 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
281 else if (type == GAIM_REQUEST_FIELD_ACCOUNT)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
282 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
283 GntWidget *combo = field->ui_data;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
284 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
285 gaim_request_field_account_set_value(field, acc);
14047
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
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
290 if (callback)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
291 callback(data, fields);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
292
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
293 while (button->parent)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
294 button = button->parent;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
295
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
296 gaim_request_close(GAIM_REQUEST_FIELDS, button);
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
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
299 static void *
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
300 gg_request_fields(const char *title, const char *primary,
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
301 const char *secondary, GaimRequestFields *allfields,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
302 const char *ok, GCallback ok_cb,
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
303 const char *cancel, GCallback cancel_cb,
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
304 void *userdata)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
305 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
306 GntWidget *window, *box;
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
307 GList *grlist;
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
308
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
309 window = setup_request_window(title, primary, secondary, GAIM_REQUEST_FIELDS);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
310
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
311 /* 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
312 * 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
313 * the groups. */
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
314 box = gnt_vbox_new(FALSE);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
315 gnt_box_set_pad(GNT_BOX(box), 0);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
316 gnt_box_set_fill(GNT_BOX(box), TRUE);
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
317 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
318 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
319 GaimRequestFieldGroup *group = grlist->data;
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
320 GList *fields = gaim_request_field_group_get_fields(group);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
321 GntWidget *hbox;
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
322 const char *title = gaim_request_field_group_get_title(group);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
323
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
324 if (title)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
325 gnt_box_add_widget(GNT_BOX(box),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
326 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
327
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
328 for (; fields ; fields = fields->next)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
329 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
330 /* 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
331 GaimRequestField *field = fields->data;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
332 GaimRequestFieldType type = gaim_request_field_get_type(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
333 const char *label = gaim_request_field_get_label(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
334
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
335 hbox = gnt_hbox_new(TRUE); /* hrm */
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
336 gnt_box_add_widget(GNT_BOX(box), hbox);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
337
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
338 if (type != GAIM_REQUEST_FIELD_BOOLEAN && label)
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
339 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
340 GntWidget *l = gnt_label_new(label);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
341 gnt_widget_set_size(l, 0, 1);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
342 gnt_box_add_widget(GNT_BOX(hbox), l);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
343 }
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
344
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
345 if (type == GAIM_REQUEST_FIELD_BOOLEAN)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
346 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
347 GntWidget *check = gnt_check_box_new(label);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
348 gnt_check_box_set_checked(GNT_CHECK_BOX(check),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
349 gaim_request_field_bool_get_default_value(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
350 gnt_box_add_widget(GNT_BOX(hbox), check);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
351 field->ui_data = check;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
352 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
353 else if (type == GAIM_REQUEST_FIELD_STRING)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
354 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
355 GntWidget *entry = gnt_entry_new(
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
356 gaim_request_field_string_get_default_value(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
357 gnt_entry_set_masked(GNT_ENTRY(entry),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
358 gaim_request_field_string_is_masked(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
359 gnt_box_add_widget(GNT_BOX(hbox), entry);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
360 field->ui_data = entry;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
361 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
362 else if (type == GAIM_REQUEST_FIELD_INTEGER)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
363 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
364 GntWidget *entry = gnt_entry_new(
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
365 gaim_request_field_string_get_default_value(field));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
366 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
367 gnt_box_add_widget(GNT_BOX(hbox), entry);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
368 field->ui_data = entry;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
369 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
370 else if (type == GAIM_REQUEST_FIELD_CHOICE)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
371 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
372 int id;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
373 const GList *list;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
374 GntWidget *combo = gnt_combo_box_new();
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
375 gnt_box_add_widget(GNT_BOX(hbox), combo);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
376 field->ui_data = combo;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
377
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
378 list = gaim_request_field_choice_get_labels(field);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
379 for (id = 1; list; list = list->next, id++)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
380 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
381 gnt_combo_box_add_data(GNT_COMBO_BOX(combo),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
382 GINT_TO_POINTER(id), list->data);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
383 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
384 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
385 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
386 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
387 else if (type == GAIM_REQUEST_FIELD_LIST)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
388 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
389 const GList *list;
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
390 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
391 if (multi)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
392 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
393 GntWidget *tree = gnt_tree_new();
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
394 gnt_box_add_widget(GNT_BOX(hbox), tree);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
395 field->ui_data = tree;
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
396
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
397 list = gaim_request_field_list_get_items(field);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
398 for (; list; list = list->next)
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
399 {
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
400 const char *text = list->data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
401 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
402 gnt_tree_add_choice(GNT_TREE(tree), key,
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
403 gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
404 if (gaim_request_field_list_is_selected(field, text))
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
405 gnt_tree_set_choice(GNT_TREE(tree), key, TRUE);
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
406 }
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
407 }
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
408 else
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
409 {
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
410 GntWidget *combo = gnt_combo_box_new();
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
411 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
412 gnt_box_add_widget(GNT_BOX(hbox), combo);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
413 field->ui_data = combo;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
414
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
415 list = gaim_request_field_list_get_items(field);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
416 for (; list; list = list->next)
14048
9c4bec886220 [gaim-migrate @ 16661]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
417 {
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
418 const char *text = list->data;
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
419 gpointer key = gaim_request_field_list_get_data(field, text);
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
420 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
421 if (gaim_request_field_list_is_selected(field, text))
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
422 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
423 }
14047
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 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
426 else if (type == GAIM_REQUEST_FIELD_ACCOUNT)
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
427 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
428 gboolean all;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
429 GaimAccount *def;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
430 GList *list;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
431 GntWidget *combo = gnt_combo_box_new();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
432 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
433 gnt_box_add_widget(GNT_BOX(hbox), combo);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
434 field->ui_data = combo;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
435
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
436 all = gaim_request_field_account_get_show_all(field);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
437 def = gaim_request_field_account_get_default_value(field);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
438
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
439 if (all)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
440 list = gaim_accounts_get_all();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
441 else
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
442 list = gaim_connections_get_all();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
443
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
444 for (; list; list = list->next)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
445 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
446 GaimAccount *account;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
447 char *text;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
448
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
449 if (all)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
450 account = list->data;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
451 else
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
452 account = gaim_connection_get_account(list->data);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
453
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
454 text = g_strdup_printf("%s (%s)",
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
455 gaim_account_get_username(account),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
456 gaim_account_get_protocol_name(account));
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
457 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
458 g_free(text);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
459 if (account == def)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
460 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
461 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
462 gnt_widget_set_size(combo, 20, 3); /* ew */
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
463 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
464 else
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
465 {
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
466 gnt_box_add_widget(GNT_BOX(hbox),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
467 gnt_label_new_with_format(_("Not implemented yet."),
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
468 GNT_TEXT_FLAG_BOLD));
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
469 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
470 }
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
471 if (grlist->next)
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14048
diff changeset
472 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
473 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
474 gnt_box_add_widget(GNT_BOX(window), box);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
475
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
476 box = setup_button_box(userdata, request_fields_cb, allfields,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
477 ok, ok_cb, cancel, cancel_cb, NULL);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
478 gnt_box_add_widget(GNT_BOX(window), box);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
479
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
480 gnt_widget_show(window);
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
481
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
482 return window;
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
483 }
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
484
13983
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
485 static GaimRequestUiOps uiops =
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
486 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
487 .request_input = gg_request_input,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
488 .close_request = gg_close_request,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
489 .request_choice = gg_request_choice,
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
490 .request_action = gg_request_action,
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
491 .request_fields = gg_request_fields,
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
492 .request_file = NULL, /* No plans for these */
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14019
diff changeset
493 .request_folder = NULL
13983
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
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
496 GaimRequestUiOps *gg_request_get_ui_ops()
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
497 {
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
498 return &uiops;
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
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
501 void gg_request_init()
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
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
505 void gg_request_uninit()
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 }
b7a99d54a5a9 [gaim-migrate @ 16552]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
508