Mercurial > pidgin
annotate finch/gntnotify.c @ 32774:069919a0896c
Validate utf8 for a few random strings that we read, in case AOL or ICQ
decide to start sending us non-utf8
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 03 May 2012 09:28:11 +0000 |
parents | 85d75e81e12f |
children |
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 */ |
28770
259bbfb423d4
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents:
27587
diff
changeset
|
26 #include <internal.h> |
259bbfb423d4
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <paul@darkrain42.org>
parents:
27587
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 #include <util.h> |
39 | |
40 #include "gntnotify.h" | |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
41 #include "debug.h" |
15817 | 42 |
43 static struct | |
44 { | |
45 GntWidget *window; | |
46 GntWidget *tree; | |
47 } emaildialog; | |
48 | |
49 static void | |
15822 | 50 notify_msg_window_destroy_cb(GntWidget *window, PurpleNotifyMsgType type) |
15817 | 51 { |
15822 | 52 purple_notify_close(type, window); |
15817 | 53 } |
54 | |
55 static void * | |
15822 | 56 finch_notify_message(PurpleNotifyMsgType type, const char *title, |
15817 | 57 const char *primary, const char *secondary) |
58 { | |
59 GntWidget *window, *button; | |
60 GntTextFormatFlags pf = 0, sf = 0; | |
61 | |
62 switch (type) | |
63 { | |
15822 | 64 case PURPLE_NOTIFY_MSG_ERROR: |
15817 | 65 sf |= GNT_TEXT_FLAG_BOLD; |
15822 | 66 case PURPLE_NOTIFY_MSG_WARNING: |
15817 | 67 pf |= GNT_TEXT_FLAG_UNDERLINE; |
15822 | 68 case PURPLE_NOTIFY_MSG_INFO: |
15817 | 69 pf |= GNT_TEXT_FLAG_BOLD; |
70 break; | |
71 } | |
72 | |
22843
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
73 window = gnt_window_box_new(FALSE, TRUE); |
15817 | 74 gnt_box_set_title(GNT_BOX(window), title); |
75 gnt_box_set_fill(GNT_BOX(window), FALSE); | |
76 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
|
77 gnt_box_set_pad(GNT_BOX(window), 0); |
15817 | 78 |
79 if (primary) | |
80 gnt_box_add_widget(GNT_BOX(window), | |
81 gnt_label_new_with_format(primary, pf)); | |
82 | |
83 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
|
84 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
85 if (secondary) { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
86 GntWidget *msg; |
31531
5e574e30256b
finch: finch_notify_message is kinda buggy, conflating PurpleNotifyType and PurpleNotifyMsgType.
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
87 /* XXX: This is broken. type is PurpleNotifyMsgType, not |
5e574e30256b
finch: finch_notify_message is kinda buggy, conflating PurpleNotifyType and PurpleNotifyMsgType.
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
88 * PurpleNotifyType. Also, the if() followed by the |
5e574e30256b
finch: finch_notify_message is kinda buggy, conflating PurpleNotifyType and PurpleNotifyMsgType.
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
89 * inner switch doesn't make much sense. |
5e574e30256b
finch: finch_notify_message is kinda buggy, conflating PurpleNotifyType and PurpleNotifyMsgType.
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
90 */ |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
91 if (type == PURPLE_NOTIFY_FORMATTED) { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
92 int width = -1, height = -1; |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
93 char *plain = (char*)secondary; |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
94 msg = gnt_text_view_new(); |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
95 gnt_text_view_set_flag(GNT_TEXT_VIEW(msg), GNT_TEXT_VIEW_TOP_ALIGN | GNT_TEXT_VIEW_NO_SCROLL); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
96 switch (type) { |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
97 case PURPLE_NOTIFY_FORMATTED: |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
98 plain = purple_markup_strip_html(secondary); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
99 if (gnt_util_parse_xhtml_to_textview(secondary, GNT_TEXT_VIEW(msg))) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
100 break; |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
101 /* Fallthrough */ |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
102 default: |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
103 gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(msg), plain, sf); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
104 } |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
105 gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(msg), button); |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
106 gnt_util_get_text_bound(plain, &width, &height); |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
107 gnt_widget_set_size(msg, width + 3, height + 1); |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
108 if (plain != secondary) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
109 g_free(plain); |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
110 } else { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
111 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
|
112 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
113 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
|
114 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
|
115 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
116 |
15817 | 117 gnt_box_add_widget(GNT_BOX(window), button); |
118 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
119 G_CALLBACK(gnt_widget_destroy), window); | |
120 g_signal_connect(G_OBJECT(window), "destroy", | |
121 G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); | |
122 | |
123 gnt_widget_show(window); | |
124 return window; | |
125 } | |
126 | |
127 /* handle is, in all/most occasions, a GntWidget * */ | |
15822 | 128 static void finch_close_notify(PurpleNotifyType type, void *handle) |
15817 | 129 { |
130 GntWidget *widget = handle; | |
131 | |
132 if (!widget) | |
133 return; | |
134 | |
135 while (widget->parent) | |
136 widget = widget->parent; | |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
28770
diff
changeset
|
137 |
15822 | 138 if (type == PURPLE_NOTIFY_SEARCHRESULTS) |
139 purple_notify_searchresults_free(g_object_get_data(handle, "notify-results")); | |
15817 | 140 #if 1 |
141 /* This did not seem to be necessary */ | |
142 g_signal_handlers_disconnect_by_func(G_OBJECT(widget), | |
143 G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); | |
144 #endif | |
145 gnt_widget_destroy(widget); | |
146 } | |
147 | |
148 static void *finch_notify_formatted(const char *title, const char *primary, | |
149 const char *secondary, const char *text) | |
150 { | |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
151 char *xhtml = NULL; |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
152 char *t = g_strdup_printf("<span>%s%s%s</span>", |
15817 | 153 secondary ? secondary : "", |
154 secondary ? "\n" : "", | |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
155 text ? text : ""); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
156 void *ret; |
15817 | 157 |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
158 purple_markup_html_to_xhtml(t, &xhtml, NULL); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
159 ret = finch_notify_message(PURPLE_NOTIFY_FORMATTED, title, primary, xhtml); |
15817 | 160 |
161 g_free(t); | |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
162 g_free(xhtml); |
15817 | 163 |
164 return ret; | |
165 } | |
166 | |
167 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
|
168 reset_email_dialog(void) |
15817 | 169 { |
170 emaildialog.window = NULL; | |
171 emaildialog.tree = NULL; | |
172 } | |
173 | |
174 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
|
175 setup_email_dialog(void) |
15817 | 176 { |
177 GntWidget *box, *tree, *button; | |
178 if (emaildialog.window) | |
179 return; | |
180 | |
181 emaildialog.window = box = gnt_vbox_new(FALSE); | |
182 gnt_box_set_toplevel(GNT_BOX(box), TRUE); | |
183 gnt_box_set_title(GNT_BOX(box), _("Emails")); | |
184 gnt_box_set_fill(GNT_BOX(box), FALSE); | |
185 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID); | |
186 gnt_box_set_pad(GNT_BOX(box), 0); | |
187 | |
188 gnt_box_add_widget(GNT_BOX(box), | |
189 gnt_label_new_with_format(_("You have mail!"), GNT_TEXT_FLAG_BOLD)); | |
190 | |
191 emaildialog.tree = tree = gnt_tree_new_with_columns(3); | |
17747 | 192 gnt_tree_set_column_titles(GNT_TREE(tree), _("Account"), _("Sender"), _("Subject")); |
15817 | 193 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
194 gnt_tree_set_col_width(GNT_TREE(tree), 0, 15); | |
195 gnt_tree_set_col_width(GNT_TREE(tree), 1, 25); | |
196 gnt_tree_set_col_width(GNT_TREE(tree), 2, 25); | |
197 | |
198 gnt_box_add_widget(GNT_BOX(box), tree); | |
199 | |
200 button = gnt_button_new(_("Close")); | |
201 gnt_box_add_widget(GNT_BOX(box), button); | |
202 | |
203 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), box); | |
204 g_signal_connect(G_OBJECT(box), "destroy", G_CALLBACK(reset_email_dialog), NULL); | |
205 } | |
206 | |
207 static void * | |
15822 | 208 finch_notify_emails(PurpleConnection *gc, size_t count, gboolean detailed, |
15817 | 209 const char **subjects, const char **froms, const char **tos, |
210 const char **urls) | |
211 { | |
15822 | 212 PurpleAccount *account = purple_connection_get_account(gc); |
15817 | 213 GString *message = g_string_new(NULL); |
214 void *ret; | |
20908
9ec0382e6c8d
Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20780
diff
changeset
|
215 static int key = 0; |
15817 | 216 |
26967
9c283917ecf7
Fix Finch not to announce "your gmail account has 0 new messages."
Paul Aurich <paul@darkrain42.org>
parents:
26650
diff
changeset
|
217 if (count == 0) |
9c283917ecf7
Fix Finch not to announce "your gmail account has 0 new messages."
Paul Aurich <paul@darkrain42.org>
parents:
26650
diff
changeset
|
218 return NULL; |
9c283917ecf7
Fix Finch not to announce "your gmail account has 0 new messages."
Paul Aurich <paul@darkrain42.org>
parents:
26650
diff
changeset
|
219 |
15817 | 220 if (!detailed) |
221 { | |
222 g_string_append_printf(message, | |
223 ngettext("%s (%s) has %d new message.", | |
224 "%s (%s) has %d new messages.", | |
225 (int)count), | |
15822 | 226 tos ? *tos : purple_account_get_username(account), |
227 purple_account_get_protocol_name(account), (int)count); | |
15817 | 228 } |
229 else | |
230 { | |
231 char *to; | |
23176
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
232 gboolean newwin = (emaildialog.window == NULL); |
15817 | 233 |
23176
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
234 if (newwin) |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
235 setup_email_dialog(); |
15817 | 236 |
15822 | 237 to = g_strdup_printf("%s (%s)", tos ? *tos : purple_account_get_username(account), |
238 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
|
239 gnt_tree_add_row_after(GNT_TREE(emaildialog.tree), GINT_TO_POINTER(++key), |
15817 | 240 gnt_tree_create_row(GNT_TREE(emaildialog.tree), to, |
241 froms ? *froms : "[Unknown sender]", | |
242 *subjects), | |
243 NULL, NULL); | |
244 g_free(to); | |
23176
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
245 if (newwin) |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
246 gnt_widget_show(emaildialog.window); |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
247 else |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
248 gnt_window_present(emaildialog.window); |
15817 | 249 return NULL; |
250 } | |
251 | |
15822 | 252 ret = finch_notify_message(PURPLE_NOTIFY_EMAIL, _("New Mail"), _("You have mail!"), message->str); |
15817 | 253 g_string_free(message, TRUE); |
254 return ret; | |
255 } | |
256 | |
257 static void * | |
15822 | 258 finch_notify_email(PurpleConnection *gc, const char *subject, const char *from, |
15817 | 259 const char *to, const char *url) |
260 { | |
261 return finch_notify_emails(gc, 1, subject != NULL, | |
262 subject ? &subject : NULL, | |
263 from ? &from : NULL, | |
264 to ? &to : NULL, | |
265 url ? &url : NULL); | |
266 } | |
267 | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
268 /** User information. **/ |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
269 static GHashTable *userinfo; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
270 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
271 static char * |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
272 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
|
273 { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
274 char key[256]; |
25568
e0c8f689f60c
applied changes from aa7ce93329f5ccbe74640a92b6656ae402d8eea8
Ethan Blanton <elb@pidgin.im>
parents:
24028
diff
changeset
|
275 g_snprintf(key, sizeof(key), "%s - %s", purple_account_get_username(account), purple_normalize(account, who)); |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
276 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
|
277 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
278 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
279 static void |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
280 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
|
281 { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
282 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
|
283 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
284 |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
285 static char * |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
286 purple_notify_user_info_get_xhtml(PurpleNotifyUserInfo *user_info) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
287 { |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
288 GList *l; |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
289 GString *text; |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
290 |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
291 text = g_string_new("<span>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
292 |
31909
6283c0f2b02f
Change PurpleNotifyUserInfo->user_info_entries from a GList to a GQueue.
Mark Doliner <mark@kingant.net>
parents:
31848
diff
changeset
|
293 for (l = purple_notify_user_info_get_entries(user_info)->head; l != NULL; |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
294 l = l->next) { |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
295 PurpleNotifyUserInfoEntry *user_info_entry = l->data; |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
296 PurpleNotifyUserInfoEntryType type = purple_notify_user_info_entry_get_type(user_info_entry); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
297 const char *label = purple_notify_user_info_entry_get_label(user_info_entry); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
298 const char *value = purple_notify_user_info_entry_get_value(user_info_entry); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
299 |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
300 /* Handle the label/value pair itself */ |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
301 if (type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
302 g_string_append(text, "<u>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
303 if (label) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
304 g_string_append_printf(text, "<b>%s</b>", label); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
305 g_string_append(text, "<span>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
306 if (label && value) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
307 g_string_append(text, ": "); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
308 if (value) { |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
309 char *strip = purple_markup_strip_html(value); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
310 g_string_append(text, strip); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
311 g_free(strip); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
312 } |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
313 g_string_append(text, "</span>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
314 if (type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
315 g_string_append(text, "</u>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
316 else if (type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
317 g_string_append(text, "<HR/>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
318 g_string_append(text, "<BR/>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
319 } |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
320 g_string_append(text, "</span>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
321 |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
322 return g_string_free(text, FALSE); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
323 } |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
324 |
15817 | 325 static void * |
15822 | 326 finch_notify_userinfo(PurpleConnection *gc, const char *who, PurpleNotifyUserInfo *user_info) |
15817 | 327 { |
328 char *primary; | |
329 char *info; | |
330 void *ui_handle; | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
331 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
|
332 |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
333 info = purple_notify_user_info_get_xhtml(user_info); |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
334 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
335 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
|
336 if (ui_handle != NULL) { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
337 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
|
338 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
|
339 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
|
340 |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17747
diff
changeset
|
341 while (GNT_WIDGET(ui_handle)->parent) |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17747
diff
changeset
|
342 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
|
343 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
|
344 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
|
345 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
346 gnt_text_view_clear(msg); |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
347 if (!gnt_util_parse_xhtml_to_textview(info, msg)) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
348 gnt_text_view_append_text_with_flags(msg, strip, GNT_TEXT_FLAG_NORMAL); |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
349 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
|
350 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
|
351 ntvw += 3; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
352 ntvh++; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
353 |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17747
diff
changeset
|
354 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
|
355 g_free(strip); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
356 g_free(key); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
357 } else { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
358 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
|
359 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
|
360 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
|
361 g_free(primary); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
362 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
|
363 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
364 |
15817 | 365 g_free(info); |
366 return ui_handle; | |
367 } | |
368 | |
369 static void | |
15822 | 370 notify_button_activated(GntWidget *widget, PurpleNotifySearchButton *b) |
15817 | 371 { |
372 GList *list = NULL; | |
15822 | 373 PurpleAccount *account = g_object_get_data(G_OBJECT(widget), "notify-account"); |
15817 | 374 gpointer data = g_object_get_data(G_OBJECT(widget), "notify-data"); |
375 | |
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
|
376 list = gnt_tree_get_selection_text_list(GNT_TREE(g_object_get_data(G_OBJECT(widget), "notify-tree"))); |
15817 | 377 |
15822 | 378 b->callback(purple_account_get_connection(account), list, data); |
15817 | 379 g_list_foreach(list, (GFunc)g_free, NULL); |
380 g_list_free(list); | |
381 } | |
382 | |
383 static void | |
15822 | 384 finch_notify_sr_new_rows(PurpleConnection *gc, |
385 PurpleNotifySearchResults *results, void *data) | |
15817 | 386 { |
387 GntTree *tree = GNT_TREE(data); | |
388 GList *o; | |
32411
85d75e81e12f
Fix insertion order of search results in Finch.
hyc@symas.com
parents:
32401
diff
changeset
|
389 GntTreeRow *prev = NULL; |
15817 | 390 |
391 /* XXX: Do I need to empty the tree here? */ | |
392 | |
393 for (o = results->rows; o; o = o->next) | |
394 { | |
395 gnt_tree_add_row_after(GNT_TREE(tree), o->data, | |
396 gnt_tree_create_row_from_list(GNT_TREE(tree), o->data), | |
32411
85d75e81e12f
Fix insertion order of search results in Finch.
hyc@symas.com
parents:
32401
diff
changeset
|
397 NULL, prev); |
85d75e81e12f
Fix insertion order of search results in Finch.
hyc@symas.com
parents:
32401
diff
changeset
|
398 prev = o->data; |
15817 | 399 } |
400 } | |
401 | |
32401
f13cb8438ee8
Ensure that the user's close callback is invoked when search
hyc@symas.com
parents:
32319
diff
changeset
|
402 static void |
f13cb8438ee8
Ensure that the user's close callback is invoked when search
hyc@symas.com
parents:
32319
diff
changeset
|
403 notify_sr_destroy_cb(GntWidget *window, void *data) |
f13cb8438ee8
Ensure that the user's close callback is invoked when search
hyc@symas.com
parents:
32319
diff
changeset
|
404 { |
f13cb8438ee8
Ensure that the user's close callback is invoked when search
hyc@symas.com
parents:
32319
diff
changeset
|
405 purple_notify_close(PURPLE_NOTIFY_SEARCHRESULTS, window); |
f13cb8438ee8
Ensure that the user's close callback is invoked when search
hyc@symas.com
parents:
32319
diff
changeset
|
406 } |
f13cb8438ee8
Ensure that the user's close callback is invoked when search
hyc@symas.com
parents:
32319
diff
changeset
|
407 |
15817 | 408 static void * |
15822 | 409 finch_notify_searchresults(PurpleConnection *gc, const char *title, |
15817 | 410 const char *primary, const char *secondary, |
15822 | 411 PurpleNotifySearchResults *results, gpointer data) |
15817 | 412 { |
413 GntWidget *window, *tree, *box, *button; | |
414 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
|
415 int columns, i; |
15817 | 416 |
417 window = gnt_vbox_new(FALSE); | |
418 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
419 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
|
420 gnt_box_set_fill(GNT_BOX(window), TRUE); |
15817 | 421 gnt_box_set_pad(GNT_BOX(window), 0); |
422 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); | |
423 | |
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
|
424 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
|
425 gnt_box_add_widget(GNT_BOX(window), |
15817 | 426 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
|
427 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
|
428 gnt_box_add_widget(GNT_BOX(window), |
15817 | 429 gnt_label_new_with_format(secondary, GNT_TEXT_FLAG_NORMAL)); |
430 | |
20100
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
431 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
|
432 tree = gnt_tree_new_with_columns(columns); |
15817 | 433 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
434 gnt_box_add_widget(GNT_BOX(window), tree); | |
435 | |
20100
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
436 i = 0; |
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
437 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
|
438 { |
20908
9ec0382e6c8d
Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20780
diff
changeset
|
439 PurpleNotifySearchColumn *column = iter->data; |
32319
8878ea011fa1
Hide struct PurpleNotifySearchColumn.
andrew.victor@mxit.com
parents:
31909
diff
changeset
|
440 gnt_tree_set_column_title(GNT_TREE(tree), i, purple_notify_searchresult_column_get_title(column)); |
31845 | 441 |
442 if (!purple_notify_searchresult_column_is_visible(column)) | |
443 gnt_tree_set_column_visible(GNT_TREE(tree), i, FALSE); | |
20100
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
444 i++; |
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
445 } |
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
|
446 |
15817 | 447 box = gnt_hbox_new(TRUE); |
448 | |
449 for (iter = results->buttons; iter; iter = iter->next) | |
450 { | |
15822 | 451 PurpleNotifySearchButton *b = iter->data; |
15817 | 452 const char *text; |
453 | |
454 switch (b->type) | |
455 { | |
15822 | 456 case PURPLE_NOTIFY_BUTTON_LABELED: |
15817 | 457 text = b->label; |
458 break; | |
15822 | 459 case PURPLE_NOTIFY_BUTTON_CONTINUE: |
15817 | 460 text = _("Continue"); |
461 break; | |
15822 | 462 case PURPLE_NOTIFY_BUTTON_ADD: |
15817 | 463 text = _("Add"); |
464 break; | |
15822 | 465 case PURPLE_NOTIFY_BUTTON_INFO: |
15817 | 466 text = _("Info"); |
467 break; | |
15822 | 468 case PURPLE_NOTIFY_BUTTON_IM: |
15817 | 469 text = _("IM"); |
470 break; | |
15822 | 471 case PURPLE_NOTIFY_BUTTON_JOIN: |
15817 | 472 text = _("Join"); |
473 break; | |
15822 | 474 case PURPLE_NOTIFY_BUTTON_INVITE: |
15817 | 475 text = _("Invite"); |
476 break; | |
477 default: | |
478 text = _("(none)"); | |
479 } | |
480 | |
481 button = gnt_button_new(text); | |
15822 | 482 g_object_set_data(G_OBJECT(button), "notify-account", purple_connection_get_account(gc)); |
15817 | 483 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
|
484 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
|
485 g_signal_connect(G_OBJECT(button), "activate", |
15817 | 486 G_CALLBACK(notify_button_activated), b); |
487 | |
488 gnt_box_add_widget(GNT_BOX(box), button); | |
489 } | |
490 | |
491 gnt_box_add_widget(GNT_BOX(window), box); | |
32401
f13cb8438ee8
Ensure that the user's close callback is invoked when search
hyc@symas.com
parents:
32319
diff
changeset
|
492 g_signal_connect(G_OBJECT(tree), "destroy", |
f13cb8438ee8
Ensure that the user's close callback is invoked when search
hyc@symas.com
parents:
32319
diff
changeset
|
493 G_CALLBACK(notify_sr_destroy_cb), NULL); |
15817 | 494 |
495 finch_notify_sr_new_rows(gc, results, tree); | |
496 | |
497 gnt_widget_show(window); | |
498 g_object_set_data(G_OBJECT(window), "notify-results", results); | |
499 | |
500 return tree; | |
501 } | |
502 | |
22843
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
503 static void * |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
504 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
|
505 { |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
506 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
|
507 } |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
508 |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
28770
diff
changeset
|
509 static PurpleNotifyUiOps ops = |
15817 | 510 { |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
511 finch_notify_message, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
512 finch_notify_email, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
513 finch_notify_emails, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
514 finch_notify_formatted, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
515 finch_notify_searchresults, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
516 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
|
517 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
|
518 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
|
519 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
|
520 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
|
521 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
522 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
523 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
524 NULL |
15817 | 525 |
526 }; | |
527 | |
15822 | 528 PurpleNotifyUiOps *finch_notify_get_ui_ops() |
15817 | 529 { |
530 return &ops; | |
531 } | |
532 | |
533 void finch_notify_init() | |
534 { | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
535 userinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
15817 | 536 } |
537 | |
538 void finch_notify_uninit() | |
539 { | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
540 g_hash_table_destroy(userinfo); |
15817 | 541 } |
542 | |
543 |