annotate finch/gntrequest.c @ 21672:ab0fd591c7c5

We should have the check to make sure we only set our own display name here too, even though this isn't (yet) a problem here
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 28 Nov 2007 01:30:04 +0000
parents 51cf02dbdb0e
children ae08b1e3ef63
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file gntrequest.c GNT Request API
16194
0f0832c13fcb Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents: 16164
diff changeset
3 * @ingroup finch
20074
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19761
diff changeset
4 */
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19761
diff changeset
5
6bf32c9e15a7 remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents: 19761
diff changeset
6 /* finch
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
15870
66dff3dfdea6 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents: 15843
diff changeset
8 * Finch is the legal property of its developers, whose names are too numerous
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * source distribution.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * (at your option) any later version.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * GNU General Public License for more details.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 19528
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include <gnt.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include <gntbox.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include <gntbutton.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include <gntcheckbox.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include <gntcombobox.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include <gntentry.h>
15927
846a00760176 use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15924
diff changeset
32 #include <gntfilesel.h>
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include <gntlabel.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include <gntline.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include <gnttree.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
37 #include "finch.h"
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #include "gntrequest.h"
16164
87019c619be0 Include header files, not source files. Bah.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15936
diff changeset
39 #include "util.h"
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 typedef struct
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 void *user_data;
15927
846a00760176 use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15924
diff changeset
44 GntWidget *dialog;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 GCallback *cbs;
18410
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
46 gboolean save;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
47 } PurpleGntFileRequest;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 static GntWidget *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 setup_request_window(const char *title, const char *primary,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
51 const char *secondary, PurpleRequestType type)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 GntWidget *window;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 window = gnt_vbox_new(FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 gnt_box_set_title(GNT_BOX(window), title);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 if (primary)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 gnt_box_add_widget(GNT_BOX(window),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 if (secondary)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 gnt_box_add_widget(GNT_BOX(window), gnt_label_new(secondary));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
66 g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(purple_request_close),
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 GINT_TO_POINTER(type));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 return window;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
18333
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
72 /**
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
73 * If the window is closed by the wm (ie, without triggering any of
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
74 * the buttons, then do some default callback.
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
75 */
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
76 static void
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
77 setup_default_callback(GntWidget *window, gpointer default_cb, gpointer data)
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
78 {
20719
2354c9748a66 Do not connect to a signal with a NULL callback. Gets rid of a runtime warning.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20074
diff changeset
79 if (default_cb == NULL)
2354c9748a66 Do not connect to a signal with a NULL callback. Gets rid of a runtime warning.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20074
diff changeset
80 return;
18347
a90f9a0b90c8 Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18333
diff changeset
81 g_object_set_data(G_OBJECT(window), "default-callback", default_cb);
18333
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
82 g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(default_cb), data);
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
83 }
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
84
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
85 static void
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
86 action_performed(GntWidget *button, gpointer data)
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
87 {
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
88 g_signal_handlers_disconnect_matched(data, G_SIGNAL_MATCH_FUNC,
18347
a90f9a0b90c8 Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18333
diff changeset
89 0, 0, NULL,
a90f9a0b90c8 Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18333
diff changeset
90 g_object_get_data(data, "default-callback"),
a90f9a0b90c8 Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18333
diff changeset
91 NULL);
18333
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
92 }
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
93
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
94 /**
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
95 * window: this is the window
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
96 * userdata: the userdata to pass to the primary callbacks
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
97 * cb: the callback
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
98 * data: data for the callback
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
99 * (text, primary-callback) pairs, ended by a NULL
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
100 */
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 static GntWidget *
18333
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
102 setup_button_box(GntWidget *win, gpointer userdata, gpointer cb, gpointer data, ...)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 GntWidget *box, *button;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 va_list list;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 const char *text;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 gpointer callback;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 box = gnt_hbox_new(FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 va_start(list, data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 while ((text = va_arg(list, const char *)))
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 callback = va_arg(list, gpointer);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 button = gnt_button_new(text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 gnt_box_add_widget(GNT_BOX(box), button);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 g_object_set_data(G_OBJECT(button), "activate-callback", callback);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 g_object_set_data(G_OBJECT(button), "activate-userdata", userdata);
18347
a90f9a0b90c8 Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18333
diff changeset
120 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(action_performed), win);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cb), data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 va_end(list);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 return box;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 notify_input_cb(GntWidget *button, GntWidget *entry)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
131 PurpleRequestInputCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 if (callback)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 callback(data, text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 while (button->parent)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 button = button->parent;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
141 purple_request_close(PURPLE_REQUEST_INPUT, button);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 static void *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 finch_request_input(const char *title, const char *primary,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 const char *secondary, const char *default_value,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 gboolean multiline, gboolean masked, gchar *hint,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 const char *ok_text, GCallback ok_cb,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 const char *cancel_text, GCallback cancel_cb,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16310
diff changeset
150 PurpleAccount *account, const char *who, PurpleConversation *conv,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
151 void *user_data)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 GntWidget *window, *box, *entry;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
155 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_INPUT);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 entry = gnt_entry_new(default_value);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 if (masked)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 gnt_entry_set_masked(GNT_ENTRY(entry), TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 gnt_box_add_widget(GNT_BOX(window), entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161
18333
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
162 box = setup_button_box(window, user_data, notify_input_cb, entry,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 ok_text, ok_cb, cancel_text, cancel_cb, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 gnt_box_add_widget(GNT_BOX(window), box);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165
18333
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
166 setup_default_callback(window, cancel_cb, user_data);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 gnt_widget_show(window);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 return window;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
173 finch_close_request(PurpleRequestType type, gpointer ui_handle)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 GntWidget *widget = GNT_WIDGET(ui_handle);
16310
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
176 if (type == PURPLE_REQUEST_FIELDS) {
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
177 PurpleRequestFields *fields = g_object_get_data(G_OBJECT(widget), "fields");
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
178 purple_request_fields_destroy(fields);
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
179 }
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
180
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 while (widget->parent)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 widget = widget->parent;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 gnt_widget_destroy(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 request_choice_cb(GntWidget *button, GntComboBox *combo)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
189 PurpleRequestChoiceCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 int choice = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo))) - 1;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 if (callback)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 callback(data, choice);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 while (button->parent)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 button = button->parent;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
199 purple_request_close(PURPLE_REQUEST_INPUT, button);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 static void *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 finch_request_choice(const char *title, const char *primary,
19528
b7fa8fa4de5b Fix building on older glib versions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18411
diff changeset
204 const char *secondary, int default_value,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 const char *ok_text, GCallback ok_cb,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 const char *cancel_text, GCallback cancel_cb,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16310
diff changeset
207 PurpleAccount *account, const char *who, PurpleConversation *conv,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
208 void *user_data, va_list choices)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 GntWidget *window, *combo, *box;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 const char *text;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 int val;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
214 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_CHOICE);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 combo = gnt_combo_box_new();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 gnt_box_add_widget(GNT_BOX(window), combo);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 while ((text = va_arg(choices, const char *)))
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 val = va_arg(choices, int);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), GINT_TO_POINTER(val + 1), text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), GINT_TO_POINTER(default_value + 1));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224
18333
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
225 box = setup_button_box(window, user_data, request_choice_cb, combo,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 ok_text, ok_cb, cancel_text, cancel_cb, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 gnt_box_add_widget(GNT_BOX(window), box);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228
18333
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
229 setup_default_callback(window, cancel_cb, user_data);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 gnt_widget_show(window);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 return window;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 static void
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 request_action_cb(GntWidget *button, GntWidget *window)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
238 PurpleRequestActionCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 int id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(button), "activate-id"));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 if (callback)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 callback(data, id);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
245 purple_request_close(PURPLE_REQUEST_ACTION, window);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 static void*
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 finch_request_action(const char *title, const char *primary,
19528
b7fa8fa4de5b Fix building on older glib versions.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18411
diff changeset
250 const char *secondary, int default_value,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16310
diff changeset
251 PurpleAccount *account, const char *who, PurpleConversation *conv,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
252 void *user_data, size_t actioncount,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 va_list actions)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 GntWidget *window, *box, *button;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 int i;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
258 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_ACTION);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 box = gnt_hbox_new(FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 gnt_box_add_widget(GNT_BOX(window), box);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 for (i = 0; i < actioncount; i++)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 const char *text = va_arg(actions, const char *);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
265 PurpleRequestActionCb callback = va_arg(actions, PurpleRequestActionCb);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 button = gnt_button_new(text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 gnt_box_add_widget(GNT_BOX(box), button);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 g_object_set_data(G_OBJECT(button), "activate-callback", callback);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 g_object_set_data(G_OBJECT(button), "activate-userdata", user_data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 g_object_set_data(G_OBJECT(button), "activate-id", GINT_TO_POINTER(i));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(request_action_cb), window);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 gnt_widget_show(window);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 return window;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
282 request_fields_cb(GntWidget *button, PurpleRequestFields *fields)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
284 PurpleRequestFieldsCb callback = g_object_get_data(G_OBJECT(button), "activate-callback");
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 gpointer data = g_object_get_data(G_OBJECT(button), "activate-userdata");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 GList *list;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287
16310
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
288 /* Update the data of the fields. Pidgin does this differently. Instead of
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 * updating the fields at the end like here, it updates the appropriate field
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 * instantly whenever a change is made. That allows it to make sure the
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 * 'required' fields are entered before the user can hit OK. It's not the case
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 * here, althought it can be done. I am not honouring the 'required' fields
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 * for the moment. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
294 for (list = purple_request_fields_get_groups(fields); list; list = list->next)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
296 PurpleRequestFieldGroup *group = list->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
297 GList *fields = purple_request_field_group_get_fields(group);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 for (; fields ; fields = fields->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
301 PurpleRequestField *field = fields->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
302 PurpleRequestFieldType type = purple_request_field_get_type(field);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
303 if (type == PURPLE_REQUEST_FIELD_BOOLEAN)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 GntWidget *check = field->ui_data;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 gboolean value = gnt_check_box_get_checked(GNT_CHECK_BOX(check));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
307 purple_request_field_bool_set_value(field, value);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
309 else if (type == PURPLE_REQUEST_FIELD_STRING)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 GntWidget *entry = field->ui_data;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
313 purple_request_field_string_set_value(field, (text && *text) ? text : NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
315 else if (type == PURPLE_REQUEST_FIELD_INTEGER)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 GntWidget *entry = field->ui_data;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 const char *text = gnt_entry_get_text(GNT_ENTRY(entry));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 int value = (text && *text) ? atoi(text) : 0;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
320 purple_request_field_int_set_value(field, value);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
322 else if (type == PURPLE_REQUEST_FIELD_CHOICE)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 GntWidget *combo = field->ui_data;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 int id;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 id = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo)));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
327 purple_request_field_choice_set_value(field, id);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
329 else if (type == PURPLE_REQUEST_FIELD_LIST)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 GList *list = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
332 if (purple_request_field_list_get_multi_select(field))
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 {
18118
ab6d2763b8d8 Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents: 18063
diff changeset
334 GList *iter;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 GntWidget *tree = field->ui_data;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
337 iter = purple_request_field_list_get_items(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 for (; iter; iter = iter->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 const char *text = iter->data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
341 gpointer key = purple_request_field_list_get_data(field, text);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 if (gnt_tree_get_choice(GNT_TREE(tree), key))
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 list = g_list_prepend(list, key);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 GntWidget *combo = field->ui_data;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 gpointer data = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 list = g_list_append(list, data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
353 purple_request_field_list_set_selected(field, list);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 g_list_free(list);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
356 else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 GntWidget *combo = field->ui_data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
359 PurpleAccount *acc = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(combo));
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
360 purple_request_field_account_set_value(field, acc);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 if (callback)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 callback(data, fields);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 while (button->parent)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 button = button->parent;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
371 purple_request_close(PURPLE_REQUEST_FIELDS, button);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373
19761
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
374 static void
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
375 update_selected_account(GntEntry *screenname, const char *start, const char *end,
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
376 GntComboBox *accountlist)
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
377 {
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
378 GList *accounts = gnt_tree_get_rows(GNT_TREE(accountlist->dropdown));
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
379 const char *name = gnt_entry_get_text(screenname);
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
380 while (accounts) {
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
381 if (purple_find_buddy(accounts->data, name)) {
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
382 gnt_combo_box_set_selected(accountlist, accounts->data);
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
383 gnt_widget_draw(GNT_WIDGET(accountlist));
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
384 break;
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
385 }
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
386 accounts = accounts->next;
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
387 }
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
388 }
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
389
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 static void *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 finch_request_fields(const char *title, const char *primary,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
392 const char *secondary, PurpleRequestFields *allfields,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 const char *ok, GCallback ok_cb,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 const char *cancel, GCallback cancel_cb,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16310
diff changeset
395 PurpleAccount *account, const char *who, PurpleConversation *conv,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
396 void *userdata)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 GntWidget *window, *box;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 GList *grlist;
19761
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
400 GntWidget *screenname = NULL, *accountlist = NULL;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
402 window = setup_request_window(title, primary, secondary, PURPLE_REQUEST_FIELDS);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 /* This is how it's going to work: the request-groups are going to be
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 * stacked vertically one after the other. A GntLine will be separating
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 * the groups. */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 box = gnt_vbox_new(FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 gnt_box_set_pad(GNT_BOX(box), 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 gnt_box_set_fill(GNT_BOX(box), TRUE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
410 for (grlist = purple_request_fields_get_groups(allfields); grlist; grlist = grlist->next)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
412 PurpleRequestFieldGroup *group = grlist->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
413 GList *fields = purple_request_field_group_get_fields(group);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 GntWidget *hbox;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
415 const char *title = purple_request_field_group_get_title(group);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 if (title)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 gnt_box_add_widget(GNT_BOX(box),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 gnt_label_new_with_format(title, GNT_TEXT_FLAG_BOLD));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 for (; fields ; fields = fields->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 /* XXX: Break each of the fields into a separate function? */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
424 PurpleRequestField *field = fields->data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
425 PurpleRequestFieldType type = purple_request_field_get_type(field);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
426 const char *label = purple_request_field_get_label(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 hbox = gnt_hbox_new(TRUE); /* hrm */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 gnt_box_add_widget(GNT_BOX(box), hbox);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
431 if (type != PURPLE_REQUEST_FIELD_BOOLEAN && label)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 GntWidget *l = gnt_label_new(label);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 gnt_widget_set_size(l, 0, 1);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 gnt_box_add_widget(GNT_BOX(hbox), l);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
438 if (type == PURPLE_REQUEST_FIELD_BOOLEAN)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 GntWidget *check = gnt_check_box_new(label);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 gnt_check_box_set_checked(GNT_CHECK_BOX(check),
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
442 purple_request_field_bool_get_default_value(field));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 gnt_box_add_widget(GNT_BOX(hbox), check);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 field->ui_data = check;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
446 else if (type == PURPLE_REQUEST_FIELD_STRING)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 {
15829
c12bf63ba2cc s/gaim/purple/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15828
diff changeset
448 const char *hint = purple_request_field_get_type_hint(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 GntWidget *entry = gnt_entry_new(
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
450 purple_request_field_string_get_default_value(field));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 gnt_entry_set_masked(GNT_ENTRY(entry),
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
452 purple_request_field_string_is_masked(field));
18222
ef65d43190e5 Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18118
diff changeset
453 if (hint && purple_str_has_prefix(hint, "screenname")) {
15829
c12bf63ba2cc s/gaim/purple/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15828
diff changeset
454 PurpleBlistNode *node = purple_blist_get_root();
c12bf63ba2cc s/gaim/purple/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15828
diff changeset
455 gboolean offline = purple_str_has_suffix(hint, "all");
c12bf63ba2cc s/gaim/purple/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15828
diff changeset
456 for (; node; node = purple_blist_node_next(node, offline)) {
c12bf63ba2cc s/gaim/purple/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15828
diff changeset
457 if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
15826
f59cfcce68a8 Add auto-complete support in request-entries that have 'screenname' hint set. This can be useful in, for example, 'send im' dialog etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15817
diff changeset
458 continue;
15829
c12bf63ba2cc s/gaim/purple/
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15828
diff changeset
459 gnt_entry_add_suggest(GNT_ENTRY(entry), purple_buddy_get_name((PurpleBuddy*)node));
15826
f59cfcce68a8 Add auto-complete support in request-entries that have 'screenname' hint set. This can be useful in, for example, 'send im' dialog etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15817
diff changeset
460 }
f59cfcce68a8 Add auto-complete support in request-entries that have 'screenname' hint set. This can be useful in, for example, 'send im' dialog etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15817
diff changeset
461 gnt_entry_set_always_suggest(GNT_ENTRY(entry), TRUE);
19761
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
462 screenname = entry;
15843
e74c2488448b Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents: 15829
diff changeset
463 } else if (hint && !strcmp(hint, "group")) {
e74c2488448b Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents: 15829
diff changeset
464 PurpleBlistNode *node;
e74c2488448b Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents: 15829
diff changeset
465 for (node = purple_blist_get_root(); node; node = node->next) {
e74c2488448b Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents: 15829
diff changeset
466 if (PURPLE_BLIST_NODE_IS_GROUP(node))
e74c2488448b Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents: 15829
diff changeset
467 gnt_entry_add_suggest(GNT_ENTRY(entry), ((PurpleGroup *)node)->name);
e74c2488448b Group autocomplete for buddy adding
Richard Nelson <wabz@pidgin.im>
parents: 15829
diff changeset
468 }
15826
f59cfcce68a8 Add auto-complete support in request-entries that have 'screenname' hint set. This can be useful in, for example, 'send im' dialog etc.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15817
diff changeset
469 }
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 gnt_box_add_widget(GNT_BOX(hbox), entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 field->ui_data = entry;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
473 else if (type == PURPLE_REQUEST_FIELD_INTEGER)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 char str[256];
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
476 int val = purple_request_field_int_get_default_value(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 GntWidget *entry;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 snprintf(str, sizeof(str), "%d", val);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 entry = gnt_entry_new(str);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 gnt_entry_set_flag(GNT_ENTRY(entry), GNT_ENTRY_FLAG_INT);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 gnt_box_add_widget(GNT_BOX(hbox), entry);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 field->ui_data = entry;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
485 else if (type == PURPLE_REQUEST_FIELD_CHOICE)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 int id;
18118
ab6d2763b8d8 Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents: 18063
diff changeset
488 GList *list;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 GntWidget *combo = gnt_combo_box_new();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 gnt_box_add_widget(GNT_BOX(hbox), combo);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 field->ui_data = combo;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
493 list = purple_request_field_choice_get_labels(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 for (id = 1; list; list = list->next, id++)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 gnt_combo_box_add_data(GNT_COMBO_BOX(combo),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 GINT_TO_POINTER(id), list->data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo),
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
500 GINT_TO_POINTER(purple_request_field_choice_get_default_value(field)));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
502 else if (type == PURPLE_REQUEST_FIELD_LIST)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 {
18118
ab6d2763b8d8 Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@wiktel.com>
parents: 18063
diff changeset
504 GList *list;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
505 gboolean multi = purple_request_field_list_get_multi_select(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 if (multi)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 GntWidget *tree = gnt_tree_new();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 gnt_box_add_widget(GNT_BOX(hbox), tree);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 field->ui_data = tree;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
512 list = purple_request_field_list_get_items(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 for (; list; list = list->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 const char *text = list->data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
516 gpointer key = purple_request_field_list_get_data(field, text);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 gnt_tree_add_choice(GNT_TREE(tree), key,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 gnt_tree_create_row(GNT_TREE(tree), text), NULL, NULL);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
519 if (purple_request_field_list_is_selected(field, text))
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 gnt_tree_set_choice(GNT_TREE(tree), key, TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 GntWidget *combo = gnt_combo_box_new();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 gnt_box_add_widget(GNT_BOX(hbox), combo);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 field->ui_data = combo;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
530 list = purple_request_field_list_get_items(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 for (; list; list = list->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 const char *text = list->data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
534 gpointer key = purple_request_field_list_get_data(field, text);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), key, text);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
536 if (purple_request_field_list_is_selected(field, text))
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), key);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
541 else if (type == PURPLE_REQUEST_FIELD_ACCOUNT)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 gboolean all;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
544 PurpleAccount *def;
18063
926ccb104da0 disapproval of revision '1411afd7660760db59966c3a9f18e2adab8eb27e'
Richard Laager <rlaager@wiktel.com>
parents: 18058
diff changeset
545 GList *list;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 GntWidget *combo = gnt_combo_box_new();
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 gnt_box_add_widget(GNT_BOX(hbox), combo);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 field->ui_data = combo;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
551 all = purple_request_field_account_get_show_all(field);
16927
43abb4942a6d Select the right account when adding a buddy after authorizing her.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16439
diff changeset
552 def = purple_request_field_account_get_value(field);
43abb4942a6d Select the right account when adding a buddy after authorizing her.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16439
diff changeset
553 if (!def)
43abb4942a6d Select the right account when adding a buddy after authorizing her.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16439
diff changeset
554 def = purple_request_field_account_get_default_value(field);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 if (all)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
557 list = purple_accounts_get_all();
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 else
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
559 list = purple_connections_get_all();
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 for (; list; list = list->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
563 PurpleAccount *account;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 char *text;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 if (all)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 account = list->data;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 else
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
569 account = purple_connection_get_account(list->data);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 text = g_strdup_printf("%s (%s)",
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
572 purple_account_get_username(account),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
573 purple_account_get_protocol_name(account));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), account, text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 g_free(text);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 if (account == def)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), account);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 gnt_widget_set_size(combo, 20, 3); /* ew */
19761
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
580 accountlist = combo;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 gnt_box_add_widget(GNT_BOX(hbox),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 gnt_label_new_with_format(_("Not implemented yet."),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 GNT_TEXT_FLAG_BOLD));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 if (grlist->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 gnt_box_add_widget(GNT_BOX(box), gnt_hline_new());
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 gnt_box_add_widget(GNT_BOX(window), box);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593
18333
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
594 box = setup_button_box(window, userdata, request_fields_cb, allfields,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 ok, ok_cb, cancel, cancel_cb, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596 gnt_box_add_widget(GNT_BOX(window), box);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597
18333
f23a7736586f Consider closing a request dialog equivalent to cancelling it.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18222
diff changeset
598 setup_default_callback(window, cancel_cb, userdata);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 gnt_widget_show(window);
16310
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
600
19761
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
601 if (screenname && accountlist) {
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
602 g_signal_connect(screenname, "completion", G_CALLBACK(update_selected_account), accountlist);
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
603 }
8c356223e182 Select the right account when a buddyname is selected from the suggest-list.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 19681
diff changeset
604
16310
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
605 g_object_set_data(G_OBJECT(window), "fields", allfields);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 return window;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610 static void
18411
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
611 file_cancel_cb(gpointer fq, GntWidget *wid)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
612 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
613 PurpleGntFileRequest *data = fq;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 if (data->cbs[1] != NULL)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
615 ((PurpleRequestFileCb)data->cbs[1])(data->user_data, NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
617 purple_request_close(PURPLE_REQUEST_FILE, data->dialog);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 static void
18411
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
621 file_ok_cb(gpointer fq, GntWidget *widget)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
623 PurpleGntFileRequest *data = fq;
15927
846a00760176 use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15924
diff changeset
624 char *file = gnt_file_sel_get_selected_file(GNT_FILE_SEL(data->dialog));
18410
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
625 char *dir = g_path_get_dirname(file);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 if (data->cbs[0] != NULL)
15927
846a00760176 use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15924
diff changeset
627 ((PurpleRequestFileCb)data->cbs[0])(data->user_data, file);
846a00760176 use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15924
diff changeset
628 g_free(file);
18410
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
629 purple_prefs_set_path(data->save ? "/finch/filelocations/last_save_folder" :
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
630 "/finch/filelocations/last_open_folder", dir);
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
631 g_free(dir);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
633 purple_request_close(PURPLE_REQUEST_FILE, data->dialog);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
637 file_request_destroy(PurpleGntFileRequest *data)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
638 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
639 g_free(data->cbs);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
640 g_free(data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
641 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
643 static void *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644 finch_request_file(const char *title, const char *filename,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 gboolean savedialog,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 GCallback ok_cb, GCallback cancel_cb,
16439
08db93bbd798 Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evan.s@dreskin.net>
parents: 16310
diff changeset
647 PurpleAccount *account, const char *who, PurpleConversation *conv,
21099
51cf02dbdb0e disapproval of revision 'c484d979c4fda4433a9633ff8b69bd8a395c9479'
Richard Laager <rlaager@wiktel.com>
parents: 21095
diff changeset
648 void *user_data)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 {
15927
846a00760176 use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15924
diff changeset
650 GntWidget *window = gnt_file_sel_new();
846a00760176 use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15924
diff changeset
651 GntFileSel *sel = GNT_FILE_SEL(window);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
652 PurpleGntFileRequest *data = g_new0(PurpleGntFileRequest, 1);
18410
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
653 const char *path;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 data->user_data = user_data;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 data->cbs = g_new0(GCallback, 2);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 data->cbs[0] = ok_cb;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 data->cbs[1] = cancel_cb;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 data->dialog = window;
18410
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
660 data->save = savedialog;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 gnt_box_set_title(GNT_BOX(window), title ? title : (savedialog ? _("Save File...") : _("Open File...")));
18410
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
662
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
663 path = purple_prefs_get_path(savedialog ? "/finch/filelocations/last_save_folder" : "/finch/filelocations/last_open_folder");
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
664 gnt_file_sel_set_current_location(sel, (path && *path) ? path : purple_home_dir());
719f73b9a593 Remember the open/save file locations.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18347
diff changeset
665
15936
0f1ab43db297 fix file saving
Richard Nelson <wabz@pidgin.im>
parents: 15927
diff changeset
666 if (savedialog)
0f1ab43db297 fix file saving
Richard Nelson <wabz@pidgin.im>
parents: 15927
diff changeset
667 gnt_file_sel_set_suggested_filename(sel, filename);
18411
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
668
15927
846a00760176 use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15924
diff changeset
669 g_signal_connect(G_OBJECT(sel->cancel), "activate",
18411
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
670 G_CALLBACK(action_performed), window);
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
671 g_signal_connect(G_OBJECT(sel->select), "activate",
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
672 G_CALLBACK(action_performed), window);
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
673 g_signal_connect_swapped(G_OBJECT(sel->cancel), "activate",
15927
846a00760176 use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15924
diff changeset
674 G_CALLBACK(file_cancel_cb), data);
18411
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
675 g_signal_connect_swapped(G_OBJECT(sel->select), "activate",
15927
846a00760176 use file select dialog
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15924
diff changeset
676 G_CALLBACK(file_ok_cb), data);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677
18411
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
678 setup_default_callback(window, file_cancel_cb, data);
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
679 g_object_set_data_full(G_OBJECT(window), "filerequestdata", data,
3849776d0f71 Fix some crashes resulting from rejecting file-transfer requests.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18410
diff changeset
680 (GDestroyNotify)file_request_destroy);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 gnt_widget_show(window);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683 return window;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
686 static PurpleRequestUiOps uiops =
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 {
17091
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
688 finch_request_input,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
689 finch_request_choice,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
690 finch_request_action,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
691 finch_request_fields,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
692 finch_request_file,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
693 finch_close_request,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
694 NULL, /* No plans for request_folder */
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
695 NULL,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
696 NULL,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
697 NULL,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16927
diff changeset
698 NULL
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
701 PurpleRequestUiOps *finch_request_get_ui_ops()
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
703 return &uiops;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706 void finch_request_init()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
709
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710 void finch_request_uninit()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
712 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713
16310
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
714 void finch_request_save_in_prefs(gpointer null, PurpleRequestFields *allfields)
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
715 {
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
716 GList *list;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
717 for (list = purple_request_fields_get_groups(allfields); list; list = list->next) {
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
718 PurpleRequestFieldGroup *group = list->data;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
719 GList *fields = purple_request_field_group_get_fields(group);
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
720
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
721 for (; fields ; fields = fields->next) {
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
722 PurpleRequestField *field = fields->data;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
723 PurpleRequestFieldType type = purple_request_field_get_type(field);
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
724 PurplePrefType pt;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
725 gpointer val = NULL;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
726 const char *id = purple_request_field_get_id(field);
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
727
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
728 switch (type) {
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
729 case PURPLE_REQUEST_FIELD_LIST:
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
730 val = purple_request_field_list_get_selected(field)->data;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
731 break;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
732 case PURPLE_REQUEST_FIELD_BOOLEAN:
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
733 val = GINT_TO_POINTER(purple_request_field_bool_get_value(field));
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
734 break;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
735 case PURPLE_REQUEST_FIELD_INTEGER:
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
736 val = GINT_TO_POINTER(purple_request_field_int_get_value(field));
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
737 break;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
738 case PURPLE_REQUEST_FIELD_STRING:
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
739 val = (gpointer)purple_request_field_string_get_value(field);
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
740 break;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
741 default:
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
742 break;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
743 }
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
744
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
745 pt = purple_prefs_get_type(id);
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
746 switch (pt) {
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
747 case PURPLE_PREF_INT:
17392
a236c67e39b6 A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents: 17091
diff changeset
748 {
18222
ef65d43190e5 Fix a few runtime warnings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 18118
diff changeset
749 long int tmp = GPOINTER_TO_INT(val);
16310
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
750 if (type == PURPLE_REQUEST_FIELD_LIST) /* Lists always return string */
17392
a236c67e39b6 A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents: 17091
diff changeset
751 sscanf(val, "%ld", &tmp);
a236c67e39b6 A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents: 17091
diff changeset
752 purple_prefs_set_int(id, (gint)tmp);
16310
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
753 break;
17392
a236c67e39b6 A change from o_sukhodolsky:
Richard Laager <rlaager@wiktel.com>
parents: 17091
diff changeset
754 }
16310
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
755 case PURPLE_PREF_BOOLEAN:
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
756 purple_prefs_set_bool(id, GPOINTER_TO_INT(val));
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
757 break;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
758 case PURPLE_PREF_STRING:
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
759 purple_prefs_set_string(id, val);
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
760 break;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
761 default:
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
762 break;
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
763 }
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
764 }
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
765 }
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
766 }
8c89913276b3 Implement the plugin-pref ui using the request api. The preferences for the core plugins can now be modified from Finch. And no new strings.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
767