Mercurial > pidgin
annotate finch/gntnotify.c @ 26451:e7bbcc1e2778
Remove an unused function
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 04 Apr 2009 05:00:44 +0000 |
parents | 1c73d2ef9ddc |
children | 951102c642c5 |
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 */ |
26 #include <gnt.h> | |
27 #include <gntbox.h> | |
28 #include <gntbutton.h> | |
29 #include <gntlabel.h> | |
30 #include <gnttree.h> | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
31 #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
|
32 #include <gntwindow.h> |
15817 | 33 |
18210
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
17805
diff
changeset
|
34 #include "finch.h" |
b8572b937c09
#include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents:
17805
diff
changeset
|
35 |
26347
1c73d2ef9ddc
Remove some extra edits that snuck into Finch.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24939
diff
changeset
|
36 #include <util.h> |
15817 | 37 |
38 #include "gntnotify.h" | |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
39 #include "debug.h" |
15817 | 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; |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
87 char *plain = (char*)secondary; |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
88 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
|
89 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
|
90 switch (type) { |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
91 case PURPLE_NOTIFY_FORMATTED: |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
92 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
|
93 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
|
94 break; |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
95 /* Fallthrough */ |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
96 default: |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
97 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
|
98 } |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
99 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
|
100 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
|
101 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
|
102 if (plain != secondary) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
103 g_free(plain); |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
104 } else { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
105 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
|
106 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
107 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
|
108 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
|
109 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
110 |
15817 | 111 gnt_box_add_widget(GNT_BOX(window), button); |
112 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
113 G_CALLBACK(gnt_widget_destroy), window); | |
114 g_signal_connect(G_OBJECT(window), "destroy", | |
115 G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); | |
116 | |
117 gnt_widget_show(window); | |
118 return window; | |
119 } | |
120 | |
121 /* handle is, in all/most occasions, a GntWidget * */ | |
15822 | 122 static void finch_close_notify(PurpleNotifyType type, void *handle) |
15817 | 123 { |
124 GntWidget *widget = handle; | |
125 | |
126 if (!widget) | |
127 return; | |
128 | |
129 while (widget->parent) | |
130 widget = widget->parent; | |
131 | |
15822 | 132 if (type == PURPLE_NOTIFY_SEARCHRESULTS) |
133 purple_notify_searchresults_free(g_object_get_data(handle, "notify-results")); | |
15817 | 134 #if 1 |
135 /* This did not seem to be necessary */ | |
136 g_signal_handlers_disconnect_by_func(G_OBJECT(widget), | |
137 G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type)); | |
138 #endif | |
139 gnt_widget_destroy(widget); | |
140 } | |
141 | |
142 static void *finch_notify_formatted(const char *title, const char *primary, | |
143 const char *secondary, const char *text) | |
144 { | |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
145 char *xhtml = NULL; |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
146 char *t = g_strdup_printf("<span>%s%s%s</span>", |
15817 | 147 secondary ? secondary : "", |
148 secondary ? "\n" : "", | |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
149 text ? text : ""); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
150 void *ret; |
15817 | 151 |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
152 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
|
153 ret = finch_notify_message(PURPLE_NOTIFY_FORMATTED, title, primary, xhtml); |
15817 | 154 |
155 g_free(t); | |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
156 g_free(xhtml); |
15817 | 157 |
158 return ret; | |
159 } | |
160 | |
161 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
|
162 reset_email_dialog(void) |
15817 | 163 { |
164 emaildialog.window = NULL; | |
165 emaildialog.tree = NULL; | |
166 } | |
167 | |
168 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
|
169 setup_email_dialog(void) |
15817 | 170 { |
171 GntWidget *box, *tree, *button; | |
172 if (emaildialog.window) | |
173 return; | |
174 | |
175 emaildialog.window = box = gnt_vbox_new(FALSE); | |
176 gnt_box_set_toplevel(GNT_BOX(box), TRUE); | |
177 gnt_box_set_title(GNT_BOX(box), _("Emails")); | |
178 gnt_box_set_fill(GNT_BOX(box), FALSE); | |
179 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID); | |
180 gnt_box_set_pad(GNT_BOX(box), 0); | |
181 | |
182 gnt_box_add_widget(GNT_BOX(box), | |
183 gnt_label_new_with_format(_("You have mail!"), GNT_TEXT_FLAG_BOLD)); | |
184 | |
185 emaildialog.tree = tree = gnt_tree_new_with_columns(3); | |
17747 | 186 gnt_tree_set_column_titles(GNT_TREE(tree), _("Account"), _("Sender"), _("Subject")); |
15817 | 187 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
188 gnt_tree_set_col_width(GNT_TREE(tree), 0, 15); | |
189 gnt_tree_set_col_width(GNT_TREE(tree), 1, 25); | |
190 gnt_tree_set_col_width(GNT_TREE(tree), 2, 25); | |
191 | |
192 gnt_box_add_widget(GNT_BOX(box), tree); | |
193 | |
194 button = gnt_button_new(_("Close")); | |
195 gnt_box_add_widget(GNT_BOX(box), button); | |
196 | |
197 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), box); | |
198 g_signal_connect(G_OBJECT(box), "destroy", G_CALLBACK(reset_email_dialog), NULL); | |
199 } | |
200 | |
201 static void * | |
15822 | 202 finch_notify_emails(PurpleConnection *gc, size_t count, gboolean detailed, |
15817 | 203 const char **subjects, const char **froms, const char **tos, |
204 const char **urls) | |
205 { | |
15822 | 206 PurpleAccount *account = purple_connection_get_account(gc); |
15817 | 207 GString *message = g_string_new(NULL); |
208 void *ret; | |
20908
9ec0382e6c8d
Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20780
diff
changeset
|
209 static int key = 0; |
15817 | 210 |
211 if (!detailed) | |
212 { | |
213 g_string_append_printf(message, | |
214 ngettext("%s (%s) has %d new message.", | |
215 "%s (%s) has %d new messages.", | |
216 (int)count), | |
15822 | 217 tos ? *tos : purple_account_get_username(account), |
218 purple_account_get_protocol_name(account), (int)count); | |
15817 | 219 } |
220 else | |
221 { | |
222 char *to; | |
23176
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
223 gboolean newwin = (emaildialog.window == NULL); |
15817 | 224 |
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 setup_email_dialog(); |
15817 | 227 |
15822 | 228 to = g_strdup_printf("%s (%s)", tos ? *tos : purple_account_get_username(account), |
229 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
|
230 gnt_tree_add_row_after(GNT_TREE(emaildialog.tree), GINT_TO_POINTER(++key), |
15817 | 231 gnt_tree_create_row(GNT_TREE(emaildialog.tree), to, |
232 froms ? *froms : "[Unknown sender]", | |
233 *subjects), | |
234 NULL, NULL); | |
235 g_free(to); | |
23176
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
236 if (newwin) |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
237 gnt_widget_show(emaildialog.window); |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
238 else |
41171963c986
Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22843
diff
changeset
|
239 gnt_window_present(emaildialog.window); |
15817 | 240 return NULL; |
241 } | |
242 | |
15822 | 243 ret = finch_notify_message(PURPLE_NOTIFY_EMAIL, _("New Mail"), _("You have mail!"), message->str); |
15817 | 244 g_string_free(message, TRUE); |
245 return ret; | |
246 } | |
247 | |
248 static void * | |
15822 | 249 finch_notify_email(PurpleConnection *gc, const char *subject, const char *from, |
15817 | 250 const char *to, const char *url) |
251 { | |
252 return finch_notify_emails(gc, 1, subject != NULL, | |
253 subject ? &subject : NULL, | |
254 from ? &from : NULL, | |
255 to ? &to : NULL, | |
256 url ? &url : NULL); | |
257 } | |
258 | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
259 /** User information. **/ |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
260 static GHashTable *userinfo; |
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 static char * |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
263 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
|
264 { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
265 char key[256]; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
266 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
|
267 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
|
268 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
269 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
270 static void |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
271 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
|
272 { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
273 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
|
274 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
275 |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
276 static char * |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
277 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
|
278 { |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
279 GList *l; |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
280 GString *text; |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
281 |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
282 text = g_string_new("<span>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
283 |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
284 for (l = purple_notify_user_info_get_entries(user_info); l != NULL; |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
285 l = l->next) { |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
286 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
|
287 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
|
288 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
|
289 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
|
290 |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
291 /* 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
|
292 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
|
293 g_string_append(text, "<u>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
294 if (label) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
295 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
|
296 g_string_append(text, "<span>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
297 if (label && value) |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
298 g_string_append(text, ": "); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
299 if (value) { |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
300 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
|
301 g_string_append(text, strip); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
302 g_free(strip); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
303 } |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
304 g_string_append(text, "</span>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
305 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
|
306 g_string_append(text, "</u>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
307 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
|
308 g_string_append(text, "<HR/>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
309 g_string_append(text, "<BR/>"); |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
310 } |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
311 g_string_append(text, "</span>"); |
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 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
|
314 } |
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
315 |
15817 | 316 static void * |
15822 | 317 finch_notify_userinfo(PurpleConnection *gc, const char *who, PurpleNotifyUserInfo *user_info) |
15817 | 318 { |
319 char *primary; | |
320 char *info; | |
321 void *ui_handle; | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
322 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
|
323 |
24028
4df8161acc3b
Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23176
diff
changeset
|
324 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
|
325 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
326 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
|
327 if (ui_handle != NULL) { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
328 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
|
329 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
|
330 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
|
331 |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17747
diff
changeset
|
332 while (GNT_WIDGET(ui_handle)->parent) |
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17747
diff
changeset
|
333 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
|
334 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
|
335 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
|
336 |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
337 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
|
338 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
|
339 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
|
340 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
|
341 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
|
342 ntvw += 3; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
343 ntvh++; |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
344 |
17804
464840043c66
Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17747
diff
changeset
|
345 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
|
346 g_free(strip); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
347 g_free(key); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
348 } else { |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
349 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
|
350 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
|
351 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
|
352 g_free(primary); |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
353 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
|
354 } |
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
355 |
15817 | 356 g_free(info); |
357 return ui_handle; | |
358 } | |
359 | |
360 static void | |
15822 | 361 notify_button_activated(GntWidget *widget, PurpleNotifySearchButton *b) |
15817 | 362 { |
363 GList *list = NULL; | |
15822 | 364 PurpleAccount *account = g_object_get_data(G_OBJECT(widget), "notify-account"); |
15817 | 365 gpointer data = g_object_get_data(G_OBJECT(widget), "notify-data"); |
366 | |
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
|
367 list = gnt_tree_get_selection_text_list(GNT_TREE(g_object_get_data(G_OBJECT(widget), "notify-tree"))); |
15817 | 368 |
15822 | 369 b->callback(purple_account_get_connection(account), list, data); |
15817 | 370 g_list_foreach(list, (GFunc)g_free, NULL); |
371 g_list_free(list); | |
372 } | |
373 | |
374 static void | |
15822 | 375 finch_notify_sr_new_rows(PurpleConnection *gc, |
376 PurpleNotifySearchResults *results, void *data) | |
15817 | 377 { |
378 GntTree *tree = GNT_TREE(data); | |
379 GList *o; | |
380 | |
381 /* XXX: Do I need to empty the tree here? */ | |
382 | |
383 for (o = results->rows; o; o = o->next) | |
384 { | |
385 gnt_tree_add_row_after(GNT_TREE(tree), o->data, | |
386 gnt_tree_create_row_from_list(GNT_TREE(tree), o->data), | |
387 NULL, NULL); | |
388 } | |
389 } | |
390 | |
391 static void * | |
15822 | 392 finch_notify_searchresults(PurpleConnection *gc, const char *title, |
15817 | 393 const char *primary, const char *secondary, |
15822 | 394 PurpleNotifySearchResults *results, gpointer data) |
15817 | 395 { |
396 GntWidget *window, *tree, *box, *button; | |
397 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
|
398 int columns, i; |
15817 | 399 |
400 window = gnt_vbox_new(FALSE); | |
401 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | |
402 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
|
403 gnt_box_set_fill(GNT_BOX(window), TRUE); |
15817 | 404 gnt_box_set_pad(GNT_BOX(window), 0); |
405 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); | |
406 | |
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
|
407 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
|
408 gnt_box_add_widget(GNT_BOX(window), |
15817 | 409 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
|
410 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
|
411 gnt_box_add_widget(GNT_BOX(window), |
15817 | 412 gnt_label_new_with_format(secondary, GNT_TEXT_FLAG_NORMAL)); |
413 | |
20100
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
414 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
|
415 tree = gnt_tree_new_with_columns(columns); |
15817 | 416 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
417 gnt_box_add_widget(GNT_BOX(window), tree); | |
418 | |
20100
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
419 i = 0; |
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
420 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
|
421 { |
20908
9ec0382e6c8d
Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20780
diff
changeset
|
422 PurpleNotifySearchColumn *column = iter->data; |
9ec0382e6c8d
Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20780
diff
changeset
|
423 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
|
424 i++; |
a3f07fa68e90
Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents:
20074
diff
changeset
|
425 } |
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
|
426 |
15817 | 427 box = gnt_hbox_new(TRUE); |
428 | |
429 for (iter = results->buttons; iter; iter = iter->next) | |
430 { | |
15822 | 431 PurpleNotifySearchButton *b = iter->data; |
15817 | 432 const char *text; |
433 | |
434 switch (b->type) | |
435 { | |
15822 | 436 case PURPLE_NOTIFY_BUTTON_LABELED: |
15817 | 437 text = b->label; |
438 break; | |
15822 | 439 case PURPLE_NOTIFY_BUTTON_CONTINUE: |
15817 | 440 text = _("Continue"); |
441 break; | |
15822 | 442 case PURPLE_NOTIFY_BUTTON_ADD: |
15817 | 443 text = _("Add"); |
444 break; | |
15822 | 445 case PURPLE_NOTIFY_BUTTON_INFO: |
15817 | 446 text = _("Info"); |
447 break; | |
15822 | 448 case PURPLE_NOTIFY_BUTTON_IM: |
15817 | 449 text = _("IM"); |
450 break; | |
15822 | 451 case PURPLE_NOTIFY_BUTTON_JOIN: |
15817 | 452 text = _("Join"); |
453 break; | |
15822 | 454 case PURPLE_NOTIFY_BUTTON_INVITE: |
15817 | 455 text = _("Invite"); |
456 break; | |
457 default: | |
458 text = _("(none)"); | |
459 } | |
460 | |
461 button = gnt_button_new(text); | |
15822 | 462 g_object_set_data(G_OBJECT(button), "notify-account", purple_connection_get_account(gc)); |
15817 | 463 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
|
464 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
|
465 g_signal_connect(G_OBJECT(button), "activate", |
15817 | 466 G_CALLBACK(notify_button_activated), b); |
467 | |
468 gnt_box_add_widget(GNT_BOX(box), button); | |
469 } | |
470 | |
471 gnt_box_add_widget(GNT_BOX(window), box); | |
472 | |
473 finch_notify_sr_new_rows(gc, results, tree); | |
474 | |
475 gnt_widget_show(window); | |
476 g_object_set_data(G_OBJECT(window), "notify-results", results); | |
477 | |
478 return tree; | |
479 } | |
480 | |
22843
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
481 static void * |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
482 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
|
483 { |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
484 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
|
485 } |
a9141d049266
Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22007
diff
changeset
|
486 |
15822 | 487 static PurpleNotifyUiOps ops = |
15817 | 488 { |
17091
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
489 finch_notify_message, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
490 finch_notify_email, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
491 finch_notify_emails, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
492 finch_notify_formatted, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
493 finch_notify_searchresults, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
494 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
500 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
501 NULL, |
46f2f86e08e4
Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents:
16925
diff
changeset
|
502 NULL |
15817 | 503 |
504 }; | |
505 | |
15822 | 506 PurpleNotifyUiOps *finch_notify_get_ui_ops() |
15817 | 507 { |
508 return &ops; | |
509 } | |
510 | |
511 void finch_notify_init() | |
512 { | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
513 userinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
15817 | 514 } |
515 | |
516 void finch_notify_uninit() | |
517 { | |
16925
9a568611fa4a
When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
16194
diff
changeset
|
518 g_hash_table_destroy(userinfo); |
15817 | 519 } |
520 | |
521 |