pidgin/plugins/gtkbuddynote.c

Fri, 09 Sep 2016 12:43:59 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 09 Sep 2016 12:43:59 -0500
changeset 38040
8f2b9a832dec
parent 37203
0da690bbe012
child 40222
40f2888f85c1
permissions
-rw-r--r--

enable meanwhile

17681
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
1 /*
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
2 * GtkBuddyNote - Store notes on particular buddies
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
3 * Copyright (C) 2007 Etan Reisner <deryni@pidgin.im>
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
4 *
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
6 * modify it under the terms of the GNU General Public License
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
7 * as published by the Free Software Foundation; either version 2
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
8 * of the License, or (at your option) any later version.
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
9 *
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
13 * GNU General Public License for more details.
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
14 *
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18889
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA.
17681
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
18 */
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
19 #include "internal.h"
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
20
34708
dd67596485ca Undo renames of UI blist headers back to gntblist.h and gtkblist.h
Ankit Vani <a@nevitus.org>
parents: 34706
diff changeset
21 #include <gtkblist.h>
17681
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
22 #include <gtkplugin.h>
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
23
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
24 #include <debug.h>
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
25 #include <version.h>
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
26
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
27 static void
34864
0e292d8887de Renamed PurpleBListNode back to PurpleBlistNode
Ankit Vani <a@nevitus.org>
parents: 34708
diff changeset
28 append_to_tooltip(PurpleBlistNode *node, GString *text, gboolean full)
17681
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
29 {
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
30 if (full) {
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
31 const gchar *note = purple_blist_node_get_string(node, "notes");
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
32
18324
7ebbdeaaa30d Make gtkbuddynote load itself if it finds buddynote was loaded and it is
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 17681
diff changeset
33 if ((note != NULL) && (*note != '\0')) {
29770
ae8b684d1a59 Escape buddy notes when adding them to the tooltip so notes can't totally
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
34 char *tmp, *esc;
20095
c3c62efefdd0 applied changes from 23c81a483086f0c1541212be4c849abb05f9f3bd
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
35 purple_markup_html_to_xhtml(note, NULL, &tmp);
29770
ae8b684d1a59 Escape buddy notes when adding them to the tooltip so notes can't totally
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
36 esc = g_markup_escape_text(tmp, -1);
ae8b684d1a59 Escape buddy notes when adding them to the tooltip so notes can't totally
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
37 g_free(tmp);
18324
7ebbdeaaa30d Make gtkbuddynote load itself if it finds buddynote was loaded and it is
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 17681
diff changeset
38 g_string_append_printf(text, _("\n<b>Buddy Note</b>: %s"),
29770
ae8b684d1a59 Escape buddy notes when adding them to the tooltip so notes can't totally
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
39 esc);
ae8b684d1a59 Escape buddy notes when adding them to the tooltip so notes can't totally
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 20288
diff changeset
40 g_free(esc);
17681
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
41 }
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
42 }
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
43 }
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
44
36756
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
45 static PidginPluginInfo *
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
46 plugin_query(GError **error)
17681
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
47 {
36756
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
48 const gchar * const authors[] = {
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
49 "Etan Reisner <deryni@pidgin.im>",
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
50 NULL
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
51 };
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
52
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
53 const gchar * const dependencies[] = {
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
54 "core-plugin_pack-buddynote",
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
55 NULL
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
56 };
18889
2eda48021b49 Fix core plugin dependency registering for gtkbuddynote to happen in plugin_init() so that it can work correctly. Add an additional sanity check in the core plugin unloading so that messed up dependency registrations don't cause crashes in the future. Thanks to deryni for helping figure this out.
Daniel Atallah <datallah@pidgin.im>
parents: 18324
diff changeset
57
36756
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
58 return pidgin_plugin_info_new(
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
59 "id", "gtkbuddynote",
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
60 "name", N_("Buddy Note Tooltips"),
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
61 "version", DISPLAY_VERSION,
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
62 "category", N_("User interface"),
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
63 "summary", N_("Shows stored buddy notes on the buddy's tooltip."),
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
64 "description", N_("Shows stored buddy notes on the buddy's tooltip."),
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
65 "authors", authors,
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
66 "website", PURPLE_WEBSITE,
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
67 "abi-version", PURPLE_ABI_VERSION,
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
68 "dependencies", dependencies,
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
69 NULL
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
70 );
17681
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
71 }
b16ce226d996 Fix #318 which asked for the buddynote plugins notes to be shown in the
Etan Reisner <deryni@pidgin.im>
parents:
diff changeset
72
36756
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
73 static gboolean
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
74 plugin_load(PurplePlugin *plugin, GError **error)
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
75 {
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
76 purple_signal_connect(pidgin_blist_get_handle(), "drawing-tooltip",
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
77 plugin, PURPLE_CALLBACK(append_to_tooltip), NULL);
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
78 return TRUE;
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
79 }
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
80
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
81 static gboolean
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
82 plugin_unload(PurplePlugin *plugin, GError **error)
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
83 {
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
84 return TRUE;
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
85 }
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
86
1bcc14114857 Refactored gtkbuddynote to use the new plugin API.
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
87 PURPLE_PLUGIN_INIT(gtkbuddynote, plugin_query, plugin_load, plugin_unload);

mercurial