Mon, 11 Jan 2021 01:51:14 -0600
Split PurpleProtocolChat to its own file and clean up the API.
Testing Done:
* Compiled and tested bonjour (not affected) and irc locally.
* Built and verified the docs.
* verified `ninja pidgin-pot` was successful.
Bugs closed: 17457
Reviewed at https://reviews.imfreedom.org/r/406/
|
35701
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
1 | /* purple |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
2 | * |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
3 | * Purple is the legal property of its developers, whose names are too numerous |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
5 | * source distribution. |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
6 | * |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
7 | * This program is free software; you can redistribute it and/or modify |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
8 | * it under the terms of the GNU General Public License as published by |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
9 | * the Free Software Foundation; either version 2 of the License, or |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
10 | * (at your option) any later version. |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
11 | * |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
12 | * This program is distributed in the hope that it will be useful, |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
15 | * GNU General Public License for more details. |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
16 | * |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
17 | * You should have received a copy of the GNU General Public License |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
18 | * along with this program; if not, write to the Free Software |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
20 | */ |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
21 | |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
22 | #include "smiley-list.h" |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
23 | |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
24 | #include "debug.h" |
|
35716
80bedd712883
Custom smileys: parse and display in toolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35713
diff
changeset
|
25 | #include "smiley-parser.h" |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
26 | #include "trie.h" |
|
35701
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
27 | |
|
38411
b7f2d7c563fb
smiley-list: Fix missing include for strstr()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38283
diff
changeset
|
28 | #include <string.h> |
|
b7f2d7c563fb
smiley-list: Fix missing include for strstr()
Mike Ruprecht <cmaiku@gmail.com>
parents:
38283
diff
changeset
|
29 | |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
30 | /** |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
31 | * PurpleSmileyList: |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
32 | * |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
33 | * A container for #PurpleSmiley's. |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
34 | */ |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
35 | struct _PurpleSmileyList { |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
36 | GObject parent; |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
37 | }; |
|
35701
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
38 | |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
39 | typedef struct { |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
40 | GList *smileys; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
41 | GList *smileys_end; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
42 | PurpleTrie *trie; |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
43 | GHashTable *path_map; |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
44 | GHashTable *shortcut_map; |
|
35755
d91c44b4a8e6
Remote smileys: correctly handle failed smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35747
diff
changeset
|
45 | |
|
d91c44b4a8e6
Remote smileys: correctly handle failed smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35747
diff
changeset
|
46 | gboolean drop_failed_remotes; |
|
35701
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
47 | } PurpleSmileyListPrivate; |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
48 | |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
49 | enum |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
50 | { |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
51 | PROP_0, |
|
35755
d91c44b4a8e6
Remote smileys: correctly handle failed smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35747
diff
changeset
|
52 | PROP_DROP_FAILED_REMOTES, |
|
35701
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
53 | PROP_LAST |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
54 | }; |
|
34f4a4318d19
Initial PurpleSmileyList implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
diff
changeset
|
55 | |
|
35755
d91c44b4a8e6
Remote smileys: correctly handle failed smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35747
diff
changeset
|
56 | static GParamSpec *properties[PROP_LAST]; |
|
d91c44b4a8e6
Remote smileys: correctly handle failed smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35747
diff
changeset
|
57 | |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
58 | /******************************************************************************* |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
59 | * Object stuff |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
60 | ******************************************************************************/ |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
61 | G_DEFINE_TYPE_WITH_PRIVATE(PurpleSmileyList, purple_smiley_list, G_TYPE_OBJECT); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
62 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
63 | static void |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
64 | purple_smiley_list_init(PurpleSmileyList *list) { |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
65 | PurpleSmileyListPrivate *priv = purple_smiley_list_get_instance_private(list); |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
66 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
67 | priv->trie = purple_trie_new(); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
68 | priv->path_map = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
69 | g_free, NULL); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
70 | priv->shortcut_map = g_hash_table_new_full(g_str_hash, g_str_equal, |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
71 | g_free, NULL); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
72 | } |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
73 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
74 | static void |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
75 | purple_smiley_list_finalize(GObject *obj) { |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
76 | PurpleSmileyList *sl = PURPLE_SMILEY_LIST(obj); |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
77 | PurpleSmileyListPrivate *priv = purple_smiley_list_get_instance_private(sl); |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
78 | GList *it; |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
79 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
80 | g_object_unref(priv->trie); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
81 | g_hash_table_destroy(priv->path_map); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
82 | g_hash_table_destroy(priv->shortcut_map); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
83 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
84 | for (it = priv->smileys; it; it = g_list_next(it)) { |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
85 | PurpleSmiley *smiley = it->data; |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
86 | g_object_set_data(G_OBJECT(smiley), "purple-smiley-list", NULL); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
87 | g_object_set_data(G_OBJECT(smiley), "purple-smiley-list-elem", NULL); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
88 | g_object_unref(smiley); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
89 | } |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
90 | g_list_free(priv->smileys); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
91 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
92 | G_OBJECT_CLASS(purple_smiley_list_parent_class)->finalize(obj); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
93 | } |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
94 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
95 | static void |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
96 | purple_smiley_list_get_property(GObject *obj, guint param_id, GValue *value, |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
97 | GParamSpec *pspec) |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
98 | { |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
99 | PurpleSmileyList *sl = PURPLE_SMILEY_LIST(obj); |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
100 | PurpleSmileyListPrivate *priv = purple_smiley_list_get_instance_private(sl); |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
101 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
102 | switch (param_id) { |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
103 | case PROP_DROP_FAILED_REMOTES: |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
104 | g_value_set_boolean(value, priv->drop_failed_remotes); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
105 | break; |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
106 | default: |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
107 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
108 | break; |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
109 | } |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
110 | } |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
111 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
112 | static void |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
113 | purple_smiley_list_set_property(GObject *obj, guint param_id, |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
114 | const GValue *value, GParamSpec *pspec) |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
115 | { |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
116 | PurpleSmileyList *sl = PURPLE_SMILEY_LIST(obj); |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
117 | PurpleSmileyListPrivate *priv = purple_smiley_list_get_instance_private(sl); |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
118 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
119 | switch (param_id) { |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
120 | case PROP_DROP_FAILED_REMOTES: |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
121 | priv->drop_failed_remotes = g_value_get_boolean(value); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
122 | /* XXX: we could scan for remote smiley's on our list |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
123 | * and change the setting, but we don't care that much. |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
124 | */ |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
125 | break; |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
126 | default: |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
127 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
128 | break; |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
129 | } |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
130 | } |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
131 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
132 | static void |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
133 | purple_smiley_list_class_init(PurpleSmileyListClass *klass) { |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
134 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
135 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
136 | obj_class->get_property = purple_smiley_list_get_property; |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
137 | obj_class->set_property = purple_smiley_list_set_property; |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
138 | obj_class->finalize = purple_smiley_list_finalize; |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
139 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
140 | properties[PROP_DROP_FAILED_REMOTES] = g_param_spec_boolean( |
|
38548
46e985dde7a5
libpurple: Remove references to dropped PurpleRemoteSmileys
Mike Ruprecht <cmaiku@gmail.com>
parents:
38411
diff
changeset
|
141 | "drop-failed-remotes", "Drop failed remote PurpleSmileys", |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
142 | "Watch added remote smileys and remove them from the list, " |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
143 | "if they change their state to failed", FALSE, |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
144 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
145 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
146 | g_object_class_install_properties(obj_class, PROP_LAST, properties); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
147 | } |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
148 | |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
149 | /****************************************************************************** |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
150 | * Helpers |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
151 | *****************************************************************************/ |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
152 | static void |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
153 | _list_append2(GList **head_p, GList **tail_p, gpointer data) |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
154 | { |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
155 | GList *head = *head_p; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
156 | GList *tail = *tail_p; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
157 | GList *elem; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
158 | |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
159 | g_return_if_fail((head == NULL) == (tail == NULL)); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
160 | g_return_if_fail((tail == NULL) || (tail->next == NULL)); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
161 | |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
162 | elem = g_list_alloc(); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
163 | elem->data = data; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
164 | elem->prev = tail; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
165 | elem->next = NULL; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
166 | |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
167 | if (head) { |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
168 | tail->next = elem; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
169 | *tail_p = elem; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
170 | } else |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
171 | *head_p = *tail_p = elem; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
172 | } |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
173 | |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
174 | static void |
|
35758
87c51487e197
Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35757
diff
changeset
|
175 | _list_delete_link2(GList **head_p, GList **tail_p, GList *link) |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
176 | { |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
177 | GList *head = *head_p; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
178 | GList *tail = *tail_p; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
179 | |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
180 | g_return_if_fail(head != NULL); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
181 | g_return_if_fail(tail != NULL); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
182 | |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
183 | if (link == tail) |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
184 | *tail_p = tail->prev; |
|
35758
87c51487e197
Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35757
diff
changeset
|
185 | *head_p = g_list_delete_link(head, link); |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
186 | } |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
187 | |
|
35839
a7f91bd51911
Drop purple_smiley_get_path in favor of purple_image_get_path (or don't use it at all)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
188 | static const gchar * |
|
a7f91bd51911
Drop purple_smiley_get_path in favor of purple_image_get_path (or don't use it at all)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
189 | smiley_get_uniqid(PurpleSmiley *smiley) |
|
a7f91bd51911
Drop purple_smiley_get_path in favor of purple_image_get_path (or don't use it at all)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
190 | { |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
191 | return purple_image_get_path(PURPLE_IMAGE(smiley)); |
|
35839
a7f91bd51911
Drop purple_smiley_get_path in favor of purple_image_get_path (or don't use it at all)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
192 | } |
|
a7f91bd51911
Drop purple_smiley_get_path in favor of purple_image_get_path (or don't use it at all)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
193 | |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
194 | /******************************************************************************* |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
195 | * API implementation |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
196 | ******************************************************************************/ |
|
35709
0d7a84931572
Smileys: implement and use new parser, only themes for now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35702
diff
changeset
|
197 | PurpleSmileyList * |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
198 | purple_smiley_list_new(void) { |
|
35709
0d7a84931572
Smileys: implement and use new parser, only themes for now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35702
diff
changeset
|
199 | return g_object_new(PURPLE_TYPE_SMILEY_LIST, NULL); |
|
0d7a84931572
Smileys: implement and use new parser, only themes for now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35702
diff
changeset
|
200 | } |
|
0d7a84931572
Smileys: implement and use new parser, only themes for now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35702
diff
changeset
|
201 | |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
202 | gboolean |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
203 | purple_smiley_list_add(PurpleSmileyList *list, PurpleSmiley *smiley) { |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
204 | PurpleSmileyListPrivate *priv = NULL; |
|
35713
4423f463a782
Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
205 | const gchar *smiley_path; |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
206 | gboolean succ; |
|
35756
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35755
diff
changeset
|
207 | gchar *shortcut_escaped; |
|
35716
80bedd712883
Custom smileys: parse and display in toolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35713
diff
changeset
|
208 | const gchar *shortcut; |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
209 | |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
210 | g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), FALSE); |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
211 | g_return_val_if_fail(PURPLE_IS_SMILEY(smiley), FALSE); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
212 | |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
213 | priv = purple_smiley_list_get_instance_private(list); |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
214 | |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
215 | if (g_object_get_data(G_OBJECT(smiley), "purple-smiley-list") != NULL) { |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
216 | purple_debug_warning("smiley-list", |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
217 | "smiley is already associated with some list"); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
218 | return FALSE; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
219 | } |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
220 | |
|
35716
80bedd712883
Custom smileys: parse and display in toolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35713
diff
changeset
|
221 | shortcut = purple_smiley_get_shortcut(smiley); |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
222 | |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
223 | if (g_hash_table_lookup(priv->shortcut_map, shortcut) != NULL) |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
224 | return FALSE; |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
225 | |
|
35756
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35755
diff
changeset
|
226 | shortcut_escaped = g_markup_escape_text(shortcut, -1); |
|
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35755
diff
changeset
|
227 | succ = purple_trie_add(priv->trie, shortcut_escaped, smiley); |
|
35847
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
228 | |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
229 | /* A special-case for WebKit, which unescapes apos entity. |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
230 | * Please, don't trust this hack - it may be removed in future releases. |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
231 | */ |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
232 | if (succ && strstr(shortcut_escaped, "'") != NULL) { |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
233 | gchar *tmp = shortcut_escaped; |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
234 | shortcut_escaped = purple_strreplace(shortcut_escaped, |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
235 | "'", "'"); |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
236 | g_free(tmp); |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
237 | succ = purple_trie_add(priv->trie, shortcut_escaped, smiley); |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
238 | } |
|
cbe2085f6355
Fix :'( smiley bug by a tiny hack
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35839
diff
changeset
|
239 | |
|
35756
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35755
diff
changeset
|
240 | g_free(shortcut_escaped); |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
241 | if (!succ) |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
242 | return FALSE; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
243 | |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
244 | g_object_ref(smiley); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
245 | _list_append2(&priv->smileys, &priv->smileys_end, smiley); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
246 | g_object_set_data(G_OBJECT(smiley), "purple-smiley-list", list); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
247 | g_object_set_data(G_OBJECT(smiley), "purple-smiley-list-elem", |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
248 | priv->smileys_end); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
249 | |
|
35747
25085b485441
Remote smileys: parse them too
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
250 | g_hash_table_insert(priv->shortcut_map, g_strdup(shortcut), smiley); |
|
25085b485441
Remote smileys: parse them too
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35746
diff
changeset
|
251 | |
|
35839
a7f91bd51911
Drop purple_smiley_get_path in favor of purple_image_get_path (or don't use it at all)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
252 | smiley_path = smiley_get_uniqid(smiley); |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35738
diff
changeset
|
253 | |
|
35755
d91c44b4a8e6
Remote smileys: correctly handle failed smileys
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35747
diff
changeset
|
254 | /* TODO: add to the table, when the smiley sets the path */ |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35738
diff
changeset
|
255 | if (!smiley_path) |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35738
diff
changeset
|
256 | return TRUE; |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35738
diff
changeset
|
257 | |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
258 | if (g_hash_table_lookup(priv->path_map, smiley_path) == NULL) { |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
259 | g_hash_table_insert(priv->path_map, |
|
35713
4423f463a782
Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
260 | g_strdup(smiley_path), smiley); |
|
4423f463a782
Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
261 | } |
|
4423f463a782
Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
262 | |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
263 | return TRUE; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
264 | } |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
265 | |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
266 | void |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
267 | purple_smiley_list_remove(PurpleSmileyList *list, PurpleSmiley *smiley) { |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
268 | PurpleSmileyListPrivate *priv = NULL; |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
269 | GList *list_elem, *it; |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
270 | const gchar *shortcut, *path; |
|
35756
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35755
diff
changeset
|
271 | gchar *shortcut_escaped; |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
272 | |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
273 | g_return_if_fail(PURPLE_IS_SMILEY_LIST(list)); |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
274 | g_return_if_fail(PURPLE_IS_SMILEY(smiley)); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
275 | |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
276 | priv = purple_smiley_list_get_instance_private(list); |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
277 | |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
278 | if (g_object_get_data(G_OBJECT(smiley), "purple-smiley-list") != list) { |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
279 | purple_debug_warning("smiley-list", "remove: invalid list"); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
280 | return; |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
281 | } |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
282 | |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
283 | list_elem = g_object_get_data(G_OBJECT(smiley), |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
284 | "purple-smiley-list-elem"); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
285 | |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
286 | shortcut = purple_smiley_get_shortcut(smiley); |
|
35839
a7f91bd51911
Drop purple_smiley_get_path in favor of purple_image_get_path (or don't use it at all)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
287 | path = smiley_get_uniqid(smiley); |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
288 | |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
289 | g_hash_table_remove(priv->shortcut_map, shortcut); |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35738
diff
changeset
|
290 | if (path) |
|
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35738
diff
changeset
|
291 | g_hash_table_remove(priv->path_map, path); |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
292 | |
|
35756
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35755
diff
changeset
|
293 | shortcut_escaped = g_markup_escape_text(shortcut, -1); |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
294 | purple_trie_remove(priv->trie, shortcut); |
|
35756
fe6aba70046e
Custom smileys: make it possible to find them by prpl
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35755
diff
changeset
|
295 | g_free(shortcut_escaped); |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
296 | |
|
35758
87c51487e197
Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35757
diff
changeset
|
297 | _list_delete_link2(&priv->smileys, &priv->smileys_end, list_elem); |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
298 | |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
299 | /* re-add entry to path_map if smiley was not unique */ |
|
35746
e4a656378516
Remote smileys: partial implementation with XMPP
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35738
diff
changeset
|
300 | for (it = priv->smileys; it && path; it = g_list_next(it)) { |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
301 | PurpleSmiley *smiley = it->data; |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
302 | |
|
35839
a7f91bd51911
Drop purple_smiley_get_path in favor of purple_image_get_path (or don't use it at all)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
303 | if (g_strcmp0(smiley_get_uniqid(smiley), path) == 0) { |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
304 | g_hash_table_insert(priv->path_map, |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
305 | g_strdup(path), smiley); |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
306 | break; |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
307 | } |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
308 | } |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
309 | |
|
35702
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
310 | g_object_set_data(G_OBJECT(smiley), "purple-smiley-list", NULL); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
311 | g_object_set_data(G_OBJECT(smiley), "purple-smiley-list-elem", NULL); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
312 | g_object_unref(smiley); |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
313 | } |
|
06a934baa610
Smiley list: add/remove
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35701
diff
changeset
|
314 | |
|
35738
030ce6840163
Smileys: toolbar button sensitivity
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35728
diff
changeset
|
315 | gboolean |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
316 | purple_smiley_list_is_empty(PurpleSmileyList *list) |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
317 | { |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
318 | PurpleSmileyListPrivate *priv = NULL; |
|
35738
030ce6840163
Smileys: toolbar button sensitivity
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35728
diff
changeset
|
319 | |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
320 | g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), TRUE); |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
321 | |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
322 | priv = purple_smiley_list_get_instance_private(list); |
|
35738
030ce6840163
Smileys: toolbar button sensitivity
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35728
diff
changeset
|
323 | |
|
030ce6840163
Smileys: toolbar button sensitivity
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35728
diff
changeset
|
324 | return (priv->smileys == NULL); |
|
030ce6840163
Smileys: toolbar button sensitivity
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35728
diff
changeset
|
325 | } |
|
030ce6840163
Smileys: toolbar button sensitivity
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35728
diff
changeset
|
326 | |
|
35717
45bde03f86a6
Custom smileys: simplify storage implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35716
diff
changeset
|
327 | PurpleSmiley * |
|
45bde03f86a6
Custom smileys: simplify storage implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35716
diff
changeset
|
328 | purple_smiley_list_get_by_shortcut(PurpleSmileyList *list, |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
329 | const gchar *shortcut) |
|
35717
45bde03f86a6
Custom smileys: simplify storage implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35716
diff
changeset
|
330 | { |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
331 | PurpleSmileyListPrivate *priv = NULL; |
|
35717
45bde03f86a6
Custom smileys: simplify storage implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35716
diff
changeset
|
332 | |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
333 | g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), NULL); |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
334 | |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
335 | priv = purple_smiley_list_get_instance_private(list); |
|
35717
45bde03f86a6
Custom smileys: simplify storage implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35716
diff
changeset
|
336 | |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
337 | return g_hash_table_lookup(priv->shortcut_map, shortcut); |
|
35717
45bde03f86a6
Custom smileys: simplify storage implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35716
diff
changeset
|
338 | } |
|
45bde03f86a6
Custom smileys: simplify storage implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35716
diff
changeset
|
339 | |
|
35709
0d7a84931572
Smileys: implement and use new parser, only themes for now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35702
diff
changeset
|
340 | PurpleTrie * |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
341 | purple_smiley_list_get_trie(PurpleSmileyList *list) { |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
342 | PurpleSmileyListPrivate *priv = NULL; |
|
35709
0d7a84931572
Smileys: implement and use new parser, only themes for now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35702
diff
changeset
|
343 | |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
344 | g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), NULL); |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
345 | |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
346 | priv = purple_smiley_list_get_instance_private(list); |
|
35709
0d7a84931572
Smileys: implement and use new parser, only themes for now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35702
diff
changeset
|
347 | |
|
0d7a84931572
Smileys: implement and use new parser, only themes for now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35702
diff
changeset
|
348 | return priv->trie; |
|
0d7a84931572
Smileys: implement and use new parser, only themes for now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35702
diff
changeset
|
349 | } |
|
0d7a84931572
Smileys: implement and use new parser, only themes for now
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35702
diff
changeset
|
350 | |
|
35713
4423f463a782
Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
351 | GList * |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
352 | purple_smiley_list_get_unique(PurpleSmileyList *list) { |
|
35799
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
353 | GList *unique = NULL, *it; |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
354 | GHashTable *unique_map; |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
355 | PurpleSmileyListPrivate *priv = NULL; |
|
35713
4423f463a782
Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
356 | |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
357 | g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), NULL); |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
358 | |
|
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
359 | priv = purple_smiley_list_get_instance_private(list); |
|
35713
4423f463a782
Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
360 | |
|
35799
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
361 | /* We could just return g_hash_table_get_values(priv->path_map) here, |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
362 | * but it won't be in order. */ |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
363 | |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
364 | unique_map = g_hash_table_new(g_str_hash, g_str_equal); |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
365 | |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
366 | for (it = priv->smileys; it; it = g_list_next(it)) { |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
367 | PurpleSmiley *smiley = it->data; |
|
35839
a7f91bd51911
Drop purple_smiley_get_path in favor of purple_image_get_path (or don't use it at all)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35838
diff
changeset
|
368 | const gchar *path = smiley_get_uniqid(smiley); |
|
35799
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
369 | |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
370 | if (g_hash_table_lookup(unique_map, path)) |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
371 | continue; |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
372 | |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
373 | unique = g_list_prepend(unique, smiley); |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
374 | g_hash_table_insert(unique_map, (gpointer)path, smiley); |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
375 | } |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
376 | |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
377 | g_hash_table_destroy(unique_map); |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
378 | |
|
04b439a886e6
Smileys: don't shuffle smileys when displaying smiley toolbar window
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
379 | return g_list_reverse(unique); |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
380 | } |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
381 | |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
382 | GList * |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
383 | purple_smiley_list_get_all(PurpleSmileyList *list) { |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
384 | PurpleSmileyListPrivate *priv = NULL; |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
385 | |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
386 | g_return_val_if_fail(PURPLE_IS_SMILEY_LIST(list), NULL); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
387 | |
|
39541
ff728cd0c5ab
Use G_DECLARE_FINAL_TYPE in smiley-list.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
388 | priv = purple_smiley_list_get_instance_private(list); |
|
35728
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
389 | |
|
6cd9aee7f276
Smiley manager: edit, delete
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35717
diff
changeset
|
390 | return g_hash_table_get_values(priv->shortcut_map); |
|
35713
4423f463a782
Smileys in PidginWebviewToolbar
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
391 | } |