Mercurial > pidgin
annotate finch/gntnotify.c @ 23808:903fb6879521
Broken merge.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 27 May 2008 06:51:21 +0000 |
parents | ff29208e03ef |
children | bb99ee66120e |
rev | line source |
---|---|
15817 | 1 /** |
2 * @file gntnotify.c GNT Notify API | |
16194
0f0832c13fcb
Rename the Doxygen group from gntui to finch and define the finch group
Richard Laager <rlaager@wiktel.com>
parents:
15870
diff
changeset
|
3 * @ingroup finch |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19681
diff
changeset
|
6 /* finch |
15817 | 7 * |
15870
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15822
diff
changeset
|
8 * Finch is the legal property of its developers, whose names are too numerous |
15817 | 9 * to list here. Please refer to the COPYRIGHT file distributed with this |
10 * source distribution. | |
11 * | |
12 * This program is free software; you can redistribute it and/or modify | |
13 * it under the terms of the GNU General Public License as published by | |
14 * the Free Software Foundation; either version 2 of the License, or | |
15 * (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, | |
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 * GNU General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU General Public License | |
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:
18347
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15817 | 25 */ |
23759
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18347
diff
changeset
|
26 #include <util.h> |
315151da0dc6
Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents:
18347
diff
changeset
|
27 |
15817 | 28 #include <gnt.h> |
29 #include <gntbox.h> | |
30 #include <gntbutton.h> | |
31 #include <gntlabel.h> | |
32 #include <gnttree.h> | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
33 #include <gntutils.h> |
22843
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
34 #include <gntwindow.h> |
15817 | 35 |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
17805
diff
changeset
|
36 #include "finch.h" |
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
17805
diff
changeset
|
37 |
15817 | 38 |
39 #include "gntnotify.h" | |
40 | |
41 static struct | |
42 { | |
43 GntWidget *window; | |
44 GntWidget *tree; | |
45 } emaildialog; | |
46 | |
47 static void | |
15822 | 48 notify_msg_window_destroy_cb(GntWidget *window, PurpleNotifyMsgType type) |
15817 | 49 { |
15822 | 50 purple_notify_close(type, window); |
15817 | 51 } |
52 | |
53 static void * | |
15822 | 54 finch_notify_message(PurpleNotifyMsgType type, const char *title, |
15817 | 55 const char *primary, const char *secondary) |
56 { | |
57 GntWidget *window, *button; | |
58 GntTextFormatFlags pf = 0, sf = 0; | |
59 | |
60 switch (type) | |
61 { | |
15822 | 62 case PURPLE_NOTIFY_MSG_ERROR: |
15817 | 63 sf |= GNT_TEXT_FLAG_BOLD; |
15822 | 64 case PURPLE_NOTIFY_MSG_WARNING: |
15817 | 65 pf |= GNT_TEXT_FLAG_UNDERLINE; |
15822 | 66 case PURPLE_NOTIFY_MSG_INFO: |
15817 | 67 pf |= GNT_TEXT_FLAG_BOLD; |
68 break; | |
69 } | |
70 | |
22843
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
71 window = gnt_window_box_new(FALSE, TRUE); |
15817 | 72 gnt_box_set_title(GNT_BOX(window), title); |
73 gnt_box_set_fill(GNT_BOX(window), FALSE); | |
74 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); | |
17805
7f652ef12ed6
Remove the confusing 'OK' button from the auth dialog.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17804
diff
changeset
|
75 gnt_box_set_pad(GNT_BOX(window), 0); |
15817 | 76 |
77 if (primary) | |
78 gnt_box_add_widget(GNT_BOX(window), | |
79 gnt_label_new_with_format(primary, pf)); | |
80 | |
81 button = gnt_button_new(_("OK")); | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
82 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
83 if (secondary) { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
84 GntWidget *msg; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
85 if (type == PURPLE_NOTIFY_FORMATTED) { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
86 int width = -1, height = -1; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
87 msg = gnt_text_view_new(); |
20780
e587a7be2916
Top align the notification message.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20100
diff
changeset
|
88 gnt_text_view_set_flag(GNT_TEXT_VIEW(msg), GNT_TEXT_VIEW_TOP_ALIGN); |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
89 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(msg), secondary, sf); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
90 gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(msg), button); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
91 gnt_util_get_text_bound(secondary, &width, &height); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
92 gnt_widget_set_size(msg, width + 3, height + 1); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
93 } else { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
94 msg = gnt_label_new_with_format(secondary, sf); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
95 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
96 gnt_box_add_widget(GNT_BOX(window), msg); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
97 g_object_set_data(G_OBJECT(window), "info-widget", msg); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
98 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
99 |
15817 | 100 gnt_box_add_widget(GNT_BOX(window), button); |
101 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
102 G_CALLBACK(gnt_widget_destroy), window); | |
103 g_signal_connect(G_OBJECT(window), "destroy", | |
104 G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); | |
105 | |
106 gnt_widget_show(window); | |
107 return window; | |
108 } | |
109 | |
110 /* handle is, in all/most occasions, a GntWidget * */ | |
15822 | 111 static void finch_close_notify(PurpleNotifyType type, void *handle) |
15817 | 112 { |
113 GntWidget *widget = handle; | |
114 | |
115 if (!widget) | |
116 return; | |
117 | |
118 while (widget->parent) | |
119 widget = widget->parent; | |
120 | |
15822 | 121 if (type == PURPLE_NOTIFY_SEARCHRESULTS) |
122 purple_notify_searchresults_free(g_object_get_data(handle, "notify-results")); | |
15817 | 123 #if 1 |
124 /* This did not seem to be necessary */ | |
125 g_signal_handlers_disconnect_by_func(G_OBJECT(widget), | |
126 G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); | |
127 #endif | |
128 gnt_widget_destroy(widget); | |
129 } | |
130 | |
131 static void *finch_notify_formatted(const char *title, const char *primary, | |
132 const char *secondary, const char *text) | |
133 { | |
134 /* XXX: For now, simply strip the html and use _notify_message. For future use, | |
135 * there should be some way of parsing the makrups from GntTextView */ | |
15822 | 136 char *unformat = purple_markup_strip_html(text); |
15817 | 137 char *t = g_strdup_printf("%s%s%s", |
138 secondary ? secondary : "", | |
139 secondary ? "\n" : "", | |
140 unformat ? unformat : ""); | |
141 | |
15822 | 142 void *ret = finch_notify_message(PURPLE_NOTIFY_FORMATTED, title, primary, t); |
15817 | 143 |
144 g_free(t); | |
145 g_free(unformat); | |
146 | |
147 return ret; | |
148 } | |
149 | |
150 static void | |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
20908
diff
changeset
|
151 reset_email_dialog(void) |
15817 | 152 { |
153 emaildialog.window = NULL; | |
154 emaildialog.tree = NULL; | |
155 } | |
156 | |
157 static void | |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
20908
diff
changeset
|
158 setup_email_dialog(void) |
15817 | 159 { |
160 GntWidget *box, *tree, *button; | |
161 if (emaildialog.window) | |
162 return; | |
163 | |
164 emaildialog.window = box = gnt_vbox_new(FALSE); | |
165 gnt_box_set_toplevel(GNT_BOX(box), TRUE); | |
166 gnt_box_set_title(GNT_BOX(box), _("Emails")); | |
167 gnt_box_set_fill(GNT_BOX(box), FALSE); | |
168 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID); | |
169 gnt_box_set_pad(GNT_BOX(box), 0); | |
170 | |
171 gnt_box_add_widget(GNT_BOX(box), | |
172 gnt_label_new_with_format(_("You have mail!"), GNT_TEXT_FLAG_BOLD)); | |
173 | |
174 emaildialog.tree = tree = gnt_tree_new_with_columns(3); | |
17747 | 175 gnt_tree_set_column_titles(GNT_TREE(tree), _("Account"), _("Sender"), _("Subject")); |
15817 | 176 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
177 gnt_tree_set_col_width(GNT_TREE(tree), 0, 15); | |
178 gnt_tree_set_col_width(GNT_TREE(tree), 1, 25); | |
179 gnt_tree_set_col_width(GNT_TREE(tree), 2, 25); | |
180 | |
181 gnt_box_add_widget(GNT_BOX(box), tree); | |
182 | |
183 button = gnt_button_new(_("Close")); | |
184 gnt_box_add_widget(GNT_BOX(box), button); | |
185 | |
186 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), box); | |
187 g_signal_connect(G_OBJECT(box), "destroy", G_CALLBACK(reset_email_dialog), NULL); | |
188 } | |
189 | |
190 static void * | |
15822 | 191 finch_notify_emails(PurpleConnection *gc, size_t count, gboolean detailed, |
15817 | 192 const char **subjects, const char **froms, const char **tos, |
193 const char **urls) | |
194 { | |
15822 | 195 PurpleAccount *account = purple_connection_get_account(gc); |
15817 | 196 GString *message = g_string_new(NULL); |
197 void *ret; | |
20908
9ec0382e6c8d
Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20780
diff
changeset
|
198 static int key = 0; |
15817 | 199 |
200 if (!detailed) | |
201 { | |
202 g_string_append_printf(message, | |
203 ngettext("%s (%s) has %d new message.", | |
204 "%s (%s) has %d new messages.", | |
205 (int)count), | |
15822 | 206 tos ? *tos : purple_account_get_username(account), |
207 purple_account_get_protocol_name(account), (int)count); | |
15817 | 208 } |
209 else | |
210 { | |
211 char *to; | |
23176
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
212 gboolean newwin = (emaildialog.window == NULL); |
15817 | 213 |
23176
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
214 if (newwin) |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
215 setup_email_dialog(); |
15817 | 216 |
15822 | 217 to = g_strdup_printf("%s (%s)", tos ? *tos : purple_account_get_username(account), |
218 purple_account_get_protocol_name(account)); | |
20908
9ec0382e6c8d
Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20780
diff
changeset
|
219 gnt_tree_add_row_after(GNT_TREE(emaildialog.tree), GINT_TO_POINTER(++key), |
15817 | 220 gnt_tree_create_row(GNT_TREE(emaildialog.tree), to, |
221 froms ? *froms : "[Unknown sender]", | |
222 *subjects), | |
223 NULL, NULL); | |
224 g_free(to); | |
23176
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
225 if (newwin) |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
226 gnt_widget_show(emaildialog.window); |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
227 else |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
228 gnt_window_present(emaildialog.window); |
15817 | 229 return NULL; |
230 } | |
231 | |
15822 | 232 ret = finch_notify_message(PURPLE_NOTIFY_EMAIL, _("New Mail"), _("You have mail!"), message->str); |
15817 | 233 g_string_free(message, TRUE); |
234 return ret; | |
235 } | |
236 | |
237 static void * | |
15822 | 238 finch_notify_email(PurpleConnection *gc, const char *subject, const char *from, |
15817 | 239 const char *to, const char *url) |
240 { | |
241 return finch_notify_emails(gc, 1, subject != NULL, | |
242 subject ? &subject : NULL, | |
243 from ? &from : NULL, | |
244 to ? &to : NULL, | |
245 url ? &url : NULL); | |
246 } | |
247 | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
248 /** User information. **/ |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
249 static GHashTable *userinfo; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
250 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
251 static char * |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
252 userinfo_hash(PurpleAccount *account, const char *who) |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
253 { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
254 char key[256]; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
255 snprintf(key, sizeof(key), "%s - %s", purple_account_get_username(account), purple_normalize(account, who)); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
256 return g_utf8_strup(key, -1); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
257 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
258 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
259 static void |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
260 remove_userinfo(GntWidget *widget, gpointer key) |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
261 { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
262 g_hash_table_remove(userinfo, key); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
263 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
264 |
15817 | 265 static void * |
15822 | 266 finch_notify_userinfo(PurpleConnection *gc, const char *who, PurpleNotifyUserInfo *user_info) |
15817 | 267 { |
268 char *primary; | |
269 char *info; | |
270 void *ui_handle; | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
271 char *key = userinfo_hash(purple_connection_get_account(gc), who); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
272 |
15822 | 273 info = purple_notify_user_info_get_text_with_newline(user_info, "<BR>"); |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
274 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
275 ui_handle = g_hash_table_lookup(userinfo, key); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
276 if (ui_handle != NULL) { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
277 GntTextView *msg = GNT_TEXT_VIEW(g_object_get_data(G_OBJECT(ui_handle), "info-widget")); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
278 char *strip = purple_markup_strip_html(info); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
279 int tvw, tvh, width, height, ntvw, ntvh; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
280 |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17747
diff
changeset
|
281 while (GNT_WIDGET(ui_handle)->parent) |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17747
diff
changeset
|
282 ui_handle = GNT_WIDGET(ui_handle)->parent; |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
283 gnt_widget_get_size(GNT_WIDGET(ui_handle), &width, &height); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
284 gnt_widget_get_size(GNT_WIDGET(msg), &tvw, &tvh); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
285 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
286 gnt_text_view_clear(msg); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
287 gnt_text_view_append_text_with_flags(msg, strip, GNT_TEXT_FLAG_NORMAL); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
288 gnt_text_view_scroll(msg, 0); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
289 gnt_util_get_text_bound(strip, &ntvw, &ntvh); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
290 ntvw += 3; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
291 ntvh++; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
292 |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17747
diff
changeset
|
293 gnt_screen_resize_widget(GNT_WIDGET(ui_handle), width + MAX(0, ntvw - tvw), height + MAX(0, ntvh - tvh)); |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
294 g_free(strip); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
295 g_free(key); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
296 } else { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
297 primary = g_strdup_printf(_("Info for %s"), who); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
298 ui_handle = finch_notify_formatted(_("Buddy Information"), primary, NULL, info); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
299 g_hash_table_insert(userinfo, key, ui_handle); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
300 g_free(primary); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
301 g_signal_connect(G_OBJECT(ui_handle), "destroy", G_CALLBACK(remove_userinfo), key); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
302 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
303 |
15817 | 304 g_free(info); |
305 return ui_handle; | |
306 } | |
307 | |
308 static void | |
15822 | 309 notify_button_activated(GntWidget *widget, PurpleNotifySearchButton *b) |
15817 | 310 { |
311 GList *list = NULL; | |
15822 | 312 PurpleAccount *account = g_object_get_data(G_OBJECT(widget), "notify-account"); |
15817 | 313 gpointer data = g_object_get_data(G_OBJECT(widget), "notify-data"); |
314 | |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
315 list = gnt_tree_get_selection_text_list(GNT_TREE(g_object_get_data(G_OBJECT(widget), "notify-tree"))); |
15817 | 316 |
15822 | 317 b->callback(purple_account_get_connection(account), list, data); |
15817 | 318 g_list_foreach(list, (GFunc)g_free, NULL); |
319 g_list_free(list); | |
320 } | |
321 | |
322 static void | |
15822 | 323 finch_notify_sr_new_rows(PurpleConnection *gc, |
324 PurpleNotifySearchResults *results, void *data) | |
15817 | 325 { |
326 GntTree *tree = GNT_TREE(data); | |
327 GList *o; | |
328 | |
329 /* XXX: Do I need to empty the tree here? */ | |
330 | |
331 for (o = results->rows; o; o = o->next) | |
332 { | |
333 gnt_tree_add_row_after(GNT_TREE(tree), o->data, | |
334 gnt_tree_create_row_from_list(GNT_TREE(tree), o->data), | |
335 NULL, NULL); | |
336 } | |
337 } | |
338 | |
339 static void * | |
15822 | 340 finch_notify_searchresults(PurpleConnection *gc, const char *title, |
15817 | 341 const char *primary, const char *secondary, |
15822 | 342 PurpleNotifySearchResults *results, gpointer data) |
15817 | 343 { |
344 GntWidget *window, *tree, *box, *button; | |
345 GList *iter; | |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
346 int columns, i; |
15817 | 347 |
348 window = gnt_vbox_new(FALSE); | |
349 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
350 gnt_box_set_title(GNT_BOX(window), title); | |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
351 gnt_box_set_fill(GNT_BOX(window), TRUE); |
15817 | 352 gnt_box_set_pad(GNT_BOX(window), 0); |
353 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); | |
354 | |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
355 if (primary) |
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
356 gnt_box_add_widget(GNT_BOX(window), |
15817 | 357 gnt_label_new_with_format(primary, GNT_TEXT_FLAG_BOLD)); |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
358 if (secondary) |
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
359 gnt_box_add_widget(GNT_BOX(window), |
15817 | 360 gnt_label_new_with_format(secondary, GNT_TEXT_FLAG_NORMAL)); |
361 | |
20100
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
362 columns = g_list_length(results->columns); |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
363 tree = gnt_tree_new_with_columns(columns); |
15817 | 364 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
365 gnt_box_add_widget(GNT_BOX(window), tree); | |
366 | |
20100
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
367 i = 0; |
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
368 for (iter = results->columns; iter; iter = iter->next) |
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
369 { |
20908
9ec0382e6c8d
Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20780
diff
changeset
|
370 PurpleNotifySearchColumn *column = iter->data; |
9ec0382e6c8d
Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20780
diff
changeset
|
371 gnt_tree_set_column_title(GNT_TREE(tree), i, column->title); |
20100
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
372 i++; |
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
373 } |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
374 |
15817 | 375 box = gnt_hbox_new(TRUE); |
376 | |
377 for (iter = results->buttons; iter; iter = iter->next) | |
378 { | |
15822 | 379 PurpleNotifySearchButton *b = iter->data; |
15817 | 380 const char *text; |
381 | |
382 switch (b->type) | |
383 { | |
15822 | 384 case PURPLE_NOTIFY_BUTTON_LABELED: |
15817 | 385 text = b->label; |
386 break; | |
15822 | 387 case PURPLE_NOTIFY_BUTTON_CONTINUE: |
15817 | 388 text = _("Continue"); |
389 break; | |
15822 | 390 case PURPLE_NOTIFY_BUTTON_ADD: |
15817 | 391 text = _("Add"); |
392 break; | |
15822 | 393 case PURPLE_NOTIFY_BUTTON_INFO: |
15817 | 394 text = _("Info"); |
395 break; | |
15822 | 396 case PURPLE_NOTIFY_BUTTON_IM: |
15817 | 397 text = _("IM"); |
398 break; | |
15822 | 399 case PURPLE_NOTIFY_BUTTON_JOIN: |
15817 | 400 text = _("Join"); |
401 break; | |
15822 | 402 case PURPLE_NOTIFY_BUTTON_INVITE: |
15817 | 403 text = _("Invite"); |
404 break; | |
405 default: | |
406 text = _("(none)"); | |
407 } | |
408 | |
409 button = gnt_button_new(text); | |
15822 | 410 g_object_set_data(G_OBJECT(button), "notify-account", purple_connection_get_account(gc)); |
15817 | 411 g_object_set_data(G_OBJECT(button), "notify-data", data); |
18347
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
412 g_object_set_data(G_OBJECT(button), "notify-tree", tree); |
a90f9a0b90c8
Update search-api to not crash. Searching for users in xmpp/oscar works now.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18210
diff
changeset
|
413 g_signal_connect(G_OBJECT(button), "activate", |
15817 | 414 G_CALLBACK(notify_button_activated), b); |
415 | |
416 gnt_box_add_widget(GNT_BOX(box), button); | |
417 } | |
418 | |
419 gnt_box_add_widget(GNT_BOX(window), box); | |
420 | |
421 finch_notify_sr_new_rows(gc, results, tree); | |
422 | |
423 gnt_widget_show(window); | |
424 g_object_set_data(G_OBJECT(window), "notify-results", results); | |
425 | |
426 return tree; | |
427 } | |
428 | |
22843
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
429 static void * |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
430 finch_notify_uri(const char *url) |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
431 { |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
432 return finch_notify_message(PURPLE_NOTIFY_URI, _("URI"), url, NULL); |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
433 } |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
434 |
15822 | 435 static PurpleNotifyUiOps ops = |
15817 | 436 { |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
437 finch_notify_message, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
438 finch_notify_email, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
439 finch_notify_emails, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
440 finch_notify_formatted, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
441 finch_notify_searchresults, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
442 finch_notify_sr_new_rows, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
443 finch_notify_userinfo, |
22843
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
444 finch_notify_uri, |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
445 finch_close_notify, /* The rest of the notify-uiops return a GntWidget. |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
446 These widgets should be destroyed from here. */ |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
447 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
448 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
449 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
450 NULL |
15817 | 451 |
452 }; | |
453 | |
15822 | 454 PurpleNotifyUiOps *finch_notify_get_ui_ops() |
15817 | 455 { |
456 return &ops; | |
457 } | |
458 | |
459 void finch_notify_init() | |
460 { | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
461 userinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
15817 | 462 } |
463 | |
464 void finch_notify_uninit() | |
465 { | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
466 g_hash_table_destroy(userinfo); |
15817 | 467 } |
468 | |
469 |