annotate finch/gntnotify.c @ 26044:b04508e5cc6c

merge of 'd43b253ca7568a3f07aa77bf397fe4351db73a90' and 'dcc53c9783aecbdde6269c4310ec4b0cf511bd9e'
author Marcus Lundblad <ml@update.uu.se>
date Mon, 12 Jan 2009 19:27:55 +0000
parents bb99ee66120e
children 1c73d2ef9ddc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file 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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
15870
66dff3dfdea6 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents: 15822
diff changeset
8 * Finch is the legal property of its developers, whose names are too numerous
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * to list here. Please refer to the COPYRIGHT file distributed with this
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * source distribution.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * This program is free software; you can redistribute it and/or modify
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * it under the terms of the GNU General Public License as published by
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * the Free Software Foundation; either version 2 of the License, or
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * (at your option) any later version.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * This program is distributed in the hope that it will be useful,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * GNU General Public License for more details.
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * You should have received a copy of the GNU General Public License
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18347
diff changeset
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 */
23759
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18347
diff changeset
26 #include <util.h>
315151da0dc6 Basic Google Talk voice call support. No UI; receiving a call auto-accepts it.
Sean Egan <seanegan@gmail.com>
parents: 18347
diff changeset
27
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include <gnt.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include <gntbox.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include <gntbutton.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include <gntlabel.h>
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "gntnotify.h"
24028
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
40 #include "debug.h"
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 static struct
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 GntWidget *window;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 GntWidget *tree;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 } emaildialog;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
49 notify_msg_window_destroy_cb(GntWidget *window, PurpleNotifyMsgType type)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
51 purple_notify_close(type, window);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 static void *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
55 finch_notify_message(PurpleNotifyMsgType type, const char *title,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 const char *primary, const char *secondary)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 GntWidget *window, *button;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 GntTextFormatFlags pf = 0, sf = 0;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 switch (type)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
63 case PURPLE_NOTIFY_MSG_ERROR:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 sf |= GNT_TEXT_FLAG_BOLD;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
65 case PURPLE_NOTIFY_MSG_WARNING:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 pf |= GNT_TEXT_FLAG_UNDERLINE;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
67 case PURPLE_NOTIFY_MSG_INFO:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 pf |= GNT_TEXT_FLAG_BOLD;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
22843
a9141d049266 Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
72 window = gnt_window_box_new(FALSE, TRUE);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 gnt_box_set_title(GNT_BOX(window), title);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 gnt_box_set_fill(GNT_BOX(window), FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 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
76 gnt_box_set_pad(GNT_BOX(window), 0);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 if (primary)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 gnt_box_add_widget(GNT_BOX(window),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 gnt_label_new_with_format(primary, pf));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 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
83
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
84 if (secondary) {
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
85 GntWidget *msg;
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
86 if (type == PURPLE_NOTIFY_FORMATTED) {
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
87 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
88 char *plain = (char*)secondary;
16925
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
89 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
90 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
91 switch (type) {
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
92 case PURPLE_NOTIFY_FORMATTED:
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
93 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
94 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
95 break;
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
96 /* Fallthrough */
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
97 default:
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
98 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
99 }
16925
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
100 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
101 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
102 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
103 if (plain != secondary)
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
104 g_free(plain);
16925
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
105 } else {
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
106 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
107 }
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
108 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
109 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
110 }
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
111
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 gnt_box_add_widget(GNT_BOX(window), button);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 g_signal_connect_swapped(G_OBJECT(button), "activate",
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 G_CALLBACK(gnt_widget_destroy), window);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 g_signal_connect(G_OBJECT(window), "destroy",
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 gnt_widget_show(window);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 return window;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 /* handle is, in all/most occasions, a GntWidget * */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
123 static void finch_close_notify(PurpleNotifyType type, void *handle)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 GntWidget *widget = handle;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 if (!widget)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 while (widget->parent)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 widget = widget->parent;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
133 if (type == PURPLE_NOTIFY_SEARCHRESULTS)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
134 purple_notify_searchresults_free(g_object_get_data(handle, "notify-results"));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 #if 1
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 /* This did not seem to be necessary */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 g_signal_handlers_disconnect_by_func(G_OBJECT(widget),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 G_CALLBACK(notify_msg_window_destroy_cb), GINT_TO_POINTER(type));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 #endif
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 gnt_widget_destroy(widget);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 static void *finch_notify_formatted(const char *title, const char *primary,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 const char *secondary, const char *text)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 {
24028
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
146 char *xhtml = NULL;
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
147 char *t = g_strdup_printf("<span>%s%s%s</span>",
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 secondary ? secondary : "",
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 secondary ? "\n" : "",
24028
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
150 text ? text : "");
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
151 void *ret;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152
24028
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
153 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
154 ret = finch_notify_message(PURPLE_NOTIFY_FORMATTED, title, primary, xhtml);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 g_free(t);
24028
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
157 g_free(xhtml);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 return ret;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 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
163 reset_email_dialog(void)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 emaildialog.window = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 emaildialog.tree = NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 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
170 setup_email_dialog(void)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 GntWidget *box, *tree, *button;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 if (emaildialog.window)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 return;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 emaildialog.window = box = gnt_vbox_new(FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 gnt_box_set_toplevel(GNT_BOX(box), TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 gnt_box_set_title(GNT_BOX(box), _("Emails"));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 gnt_box_set_fill(GNT_BOX(box), FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_MID);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 gnt_box_set_pad(GNT_BOX(box), 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 gnt_box_add_widget(GNT_BOX(box),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 gnt_label_new_with_format(_("You have mail!"), GNT_TEXT_FLAG_BOLD));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 emaildialog.tree = tree = gnt_tree_new_with_columns(3);
17747
bac7cec1609d Fix #1159.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17091
diff changeset
187 gnt_tree_set_column_titles(GNT_TREE(tree), _("Account"), _("Sender"), _("Subject"));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 gnt_tree_set_col_width(GNT_TREE(tree), 0, 15);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 gnt_tree_set_col_width(GNT_TREE(tree), 1, 25);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 gnt_tree_set_col_width(GNT_TREE(tree), 2, 25);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 gnt_box_add_widget(GNT_BOX(box), tree);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 button = gnt_button_new(_("Close"));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 gnt_box_add_widget(GNT_BOX(box), button);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), box);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 g_signal_connect(G_OBJECT(box), "destroy", G_CALLBACK(reset_email_dialog), NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 static void *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
203 finch_notify_emails(PurpleConnection *gc, size_t count, gboolean detailed,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 const char **subjects, const char **froms, const char **tos,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 const char **urls)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
207 PurpleAccount *account = purple_connection_get_account(gc);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 GString *message = g_string_new(NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 void *ret;
20908
9ec0382e6c8d Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20780
diff changeset
210 static int key = 0;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 if (!detailed)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 g_string_append_printf(message,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 ngettext("%s (%s) has %d new message.",
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 "%s (%s) has %d new messages.",
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 (int)count),
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
218 tos ? *tos : purple_account_get_username(account),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
219 purple_account_get_protocol_name(account), (int)count);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 else
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 char *to;
23176
41171963c986 Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22843
diff changeset
224 gboolean newwin = (emaildialog.window == NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225
23176
41171963c986 Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22843
diff changeset
226 if (newwin)
41171963c986 Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22843
diff changeset
227 setup_email_dialog();
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
229 to = g_strdup_printf("%s (%s)", tos ? *tos : purple_account_get_username(account),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
230 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
231 gnt_tree_add_row_after(GNT_TREE(emaildialog.tree), GINT_TO_POINTER(++key),
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 gnt_tree_create_row(GNT_TREE(emaildialog.tree), to,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 froms ? *froms : "[Unknown sender]",
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 *subjects),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 NULL, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 g_free(to);
23176
41171963c986 Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22843
diff changeset
237 if (newwin)
41171963c986 Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22843
diff changeset
238 gnt_widget_show(emaildialog.window);
41171963c986 Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22843
diff changeset
239 else
41171963c986 Highlight the mail window for new mails.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22843
diff changeset
240 gnt_window_present(emaildialog.window);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 return NULL;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
244 ret = finch_notify_message(PURPLE_NOTIFY_EMAIL, _("New Mail"), _("You have mail!"), message->str);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 g_string_free(message, TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 return ret;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 static void *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
250 finch_notify_email(PurpleConnection *gc, const char *subject, const char *from,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 const char *to, const char *url)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 return finch_notify_emails(gc, 1, subject != NULL,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 subject ? &subject : NULL,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 from ? &from : NULL,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 to ? &to : NULL,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 url ? &url : NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
16925
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
260 /** User information. **/
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
261 static GHashTable *userinfo;
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
262
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
263 static char *
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
264 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
265 {
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
266 char key[256];
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
267 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
268 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
269 }
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 void
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
272 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
273 {
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
274 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
275 }
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
276
24028
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
277 static char *
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
278 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
279 {
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
280 GList *l;
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
281 GString *text;
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
282
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
283 text = g_string_new("<span>");
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
284
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
285 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
286 l = l->next) {
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
287 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
288 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
289 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
290 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
291
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
292 /* 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
293 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
294 g_string_append(text, "<u>");
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
295 if (label)
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
296 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
297 g_string_append(text, "<span>");
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
298 if (label && value)
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
299 g_string_append(text, ": ");
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
300 if (value) {
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
301 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
302 g_string_append(text, strip);
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
303 g_free(strip);
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
304 }
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 (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
307 g_string_append(text, "</u>");
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
308 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
309 g_string_append(text, "<HR/>");
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
310 g_string_append(text, "<BR/>");
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
311 }
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
312 g_string_append(text, "</span>");
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
313
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
314 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
315 }
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
316
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 static void *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
318 finch_notify_userinfo(PurpleConnection *gc, const char *who, PurpleNotifyUserInfo *user_info)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 char *primary;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 char *info;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 void *ui_handle;
16925
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
323 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
324
24028
4df8161acc3b Try to preserve HTML attributes in notification dialogs
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 23176
diff changeset
325 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
326
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
327 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
328 if (ui_handle != NULL) {
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
329 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
330 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
331 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
332
17804
464840043c66 Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17747
diff changeset
333 while (GNT_WIDGET(ui_handle)->parent)
464840043c66 Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17747
diff changeset
334 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
335 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
336 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
337
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
338 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
339 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
340 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
341 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
342 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
343 ntvw += 3;
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
344 ntvh++;
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
345
17804
464840043c66 Show information about the user requesting authorization.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 17747
diff changeset
346 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
347 g_free(strip);
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
348 g_free(key);
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
349 } else {
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
350 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
351 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
352 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
353 g_free(primary);
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
354 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
355 }
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
356
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 g_free(info);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 return ui_handle;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
362 notify_button_activated(GntWidget *widget, PurpleNotifySearchButton *b)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 GList *list = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
365 PurpleAccount *account = g_object_get_data(G_OBJECT(widget), "notify-account");
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 gpointer data = g_object_get_data(G_OBJECT(widget), "notify-data");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367
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
368 list = gnt_tree_get_selection_text_list(GNT_TREE(g_object_get_data(G_OBJECT(widget), "notify-tree")));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
370 b->callback(purple_account_get_connection(account), list, data);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 g_list_foreach(list, (GFunc)g_free, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 g_list_free(list);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
376 finch_notify_sr_new_rows(PurpleConnection *gc,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
377 PurpleNotifySearchResults *results, void *data)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 GntTree *tree = GNT_TREE(data);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 GList *o;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 /* XXX: Do I need to empty the tree here? */
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 for (o = results->rows; o; o = o->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 gnt_tree_add_row_after(GNT_TREE(tree), o->data,
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 gnt_tree_create_row_from_list(GNT_TREE(tree), o->data),
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 NULL, NULL);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 static void *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
393 finch_notify_searchresults(PurpleConnection *gc, const char *title,
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 const char *primary, const char *secondary,
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
395 PurpleNotifySearchResults *results, gpointer data)
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 GntWidget *window, *tree, *box, *button;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 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
399 int columns, i;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 window = gnt_vbox_new(FALSE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 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
404 gnt_box_set_fill(GNT_BOX(window), TRUE);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 gnt_box_set_pad(GNT_BOX(window), 0);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407
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
408 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
409 gnt_box_add_widget(GNT_BOX(window),
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 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
411 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
412 gnt_box_add_widget(GNT_BOX(window),
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 gnt_label_new_with_format(secondary, GNT_TEXT_FLAG_NORMAL));
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414
20100
a3f07fa68e90 Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents: 20074
diff changeset
415 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
416 tree = gnt_tree_new_with_columns(columns);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 gnt_box_add_widget(GNT_BOX(window), tree);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419
20100
a3f07fa68e90 Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents: 20074
diff changeset
420 i = 0;
a3f07fa68e90 Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents: 20074
diff changeset
421 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
422 {
20908
9ec0382e6c8d Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20780
diff changeset
423 PurpleNotifySearchColumn *column = iter->data;
9ec0382e6c8d Fix the searchresult thingy nosnilmot fixed in pidgin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20780
diff changeset
424 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
425 i++;
a3f07fa68e90 Access search results directly instead of going through the API because
Mark Doliner <mark@kingant.net>
parents: 20074
diff changeset
426 }
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
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 box = gnt_hbox_new(TRUE);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 for (iter = results->buttons; iter; iter = iter->next)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
432 PurpleNotifySearchButton *b = iter->data;
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 const char *text;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 switch (b->type)
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
437 case PURPLE_NOTIFY_BUTTON_LABELED:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 text = b->label;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
440 case PURPLE_NOTIFY_BUTTON_CONTINUE:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 text = _("Continue");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
443 case PURPLE_NOTIFY_BUTTON_ADD:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 text = _("Add");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
446 case PURPLE_NOTIFY_BUTTON_INFO:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 text = _("Info");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
449 case PURPLE_NOTIFY_BUTTON_IM:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 text = _("IM");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
452 case PURPLE_NOTIFY_BUTTON_JOIN:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 text = _("Join");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 break;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
455 case PURPLE_NOTIFY_BUTTON_INVITE:
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 text = _("Invite");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 break;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 default:
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 text = _("(none)");
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 button = gnt_button_new(text);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
463 g_object_set_data(G_OBJECT(button), "notify-account", purple_connection_get_account(gc));
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 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
465 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
466 g_signal_connect(G_OBJECT(button), "activate",
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 G_CALLBACK(notify_button_activated), b);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 gnt_box_add_widget(GNT_BOX(box), button);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 gnt_box_add_widget(GNT_BOX(window), box);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 finch_notify_sr_new_rows(gc, results, tree);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 gnt_widget_show(window);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 g_object_set_data(G_OBJECT(window), "notify-results", results);
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 return tree;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481
22843
a9141d049266 Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
482 static void *
a9141d049266 Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
483 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
484 {
a9141d049266 Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
485 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
486 }
a9141d049266 Show the url, instead of silently ignoring a url-open request.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 22007
diff changeset
487
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
488 static PurpleNotifyUiOps ops =
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 {
17091
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16925
diff changeset
490 finch_notify_message,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16925
diff changeset
491 finch_notify_email,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16925
diff changeset
492 finch_notify_emails,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16925
diff changeset
493 finch_notify_formatted,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16925
diff changeset
494 finch_notify_searchresults,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16925
diff changeset
495 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
496 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
497 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
498 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
499 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
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,
46f2f86e08e4 Death to more futuristic struct initialization. This should be the last.
Richard Laager <rlaager@wiktel.com>
parents: 16925
diff changeset
503 NULL
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 };
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15817
diff changeset
507 PurpleNotifyUiOps *finch_notify_get_ui_ops()
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 {
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 return &ops;
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 void finch_notify_init()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 {
16925
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
514 userinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 void finch_notify_uninit()
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 {
16925
9a568611fa4a When getting information, show "Information: Retrieving..." before the
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16194
diff changeset
519 g_hash_table_destroy(userinfo);
15817
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 }
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521
0e3a8505ebbe renamed gaim-text to finch
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522