Fri, 20 Dec 2019 02:44:13 +0000
Merged in default (pull request #661)
Add metadata to Glade ui files.
Approved-by: Gary Kramlich
|
22443
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
1 | /* purple |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
2 | * |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
3 | * Purple is the legal property of its developers, whose names are too numerous |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
5 | * source distribution. |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
6 | * |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
7 | * This program is free software; you can redistribute it and/or modify |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
8 | * it under the terms of the GNU General Public License as published by |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
9 | * the Free Software Foundation; either version 2 of the License, or |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
10 | * (at your option) any later version. |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
11 | * |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
12 | * This program is distributed in the hope that it will be useful, |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
15 | * GNU General Public License for more details. |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
16 | * |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
17 | * You should have received a copy of the GNU General Public License |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
18 | * along with this program; if not, write to the Free Software |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
20 | */ |
|
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
21 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
22 | #include "smiley.h" |
|
22443
7b8772af6bb7
Apply the custom smiley patches from #1187, from Jorge Villaseño (Masca) and
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
diff
changeset
|
23 | |
|
39546
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
24 | /** |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
25 | * PurpleSmiley: |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
26 | * |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
27 | * A generic smiley. It can either be a theme smiley, or a custom smiley. |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
28 | */ |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
29 | struct _PurpleSmiley { |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
30 | /*< private >*/ |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
31 | PurpleImage parent; |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
32 | }; |
|
34531
fc9377274d13
Exposed the instance and class structures of PurpleSmiley so that it can be subclassed
Ankit Vani <a@nevitus.org>
parents:
33796
diff
changeset
|
33 | |
|
fc9377274d13
Exposed the instance and class structures of PurpleSmiley so that it can be subclassed
Ankit Vani <a@nevitus.org>
parents:
33796
diff
changeset
|
34 | typedef struct { |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
35 | gchar *shortcut; |
|
34531
fc9377274d13
Exposed the instance and class structures of PurpleSmiley so that it can be subclassed
Ankit Vani <a@nevitus.org>
parents:
33796
diff
changeset
|
36 | } PurpleSmileyPrivate; |
|
22449
4fea5a505737
Hide PurpleSmiley internals.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22446
diff
changeset
|
37 | |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
38 | enum |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
39 | { |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
40 | PROP_0, |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
41 | PROP_SHORTCUT, |
|
35078
9e2aff0b8476
libpurple: started changing g_object_notify to g_object_notify_by_pspec
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
42 | PROP_LAST |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
43 | }; |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
44 | |
|
35078
9e2aff0b8476
libpurple: started changing g_object_notify to g_object_notify_by_pspec
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
45 | static GParamSpec *properties[PROP_LAST]; |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
46 | |
|
39546
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
47 | G_DEFINE_TYPE_WITH_PRIVATE(PurpleSmiley, purple_smiley, PURPLE_TYPE_IMAGE); |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
48 | |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
49 | /******************************************************************************* |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
50 | * Helpers |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
51 | ******************************************************************************/ |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
52 | static void |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38279
diff
changeset
|
53 | _purple_smiley_set_shortcut(PurpleSmiley *smiley, const gchar *shortcut) { |
|
39546
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
54 | PurpleSmileyPrivate *priv = purple_smiley_get_instance_private(smiley); |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
55 | |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38279
diff
changeset
|
56 | g_free(priv->shortcut); |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
57 | |
|
38290
2d8479ba7df8
g_strdup returns NULL if the input was NULL
Gary Kramlich <grim@reaperworld.com>
parents:
38286
diff
changeset
|
58 | priv->shortcut = g_strdup(shortcut); |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
59 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
60 | g_object_notify(G_OBJECT(smiley), "shortcut"); |
|
35749
d71c41a54bb3
Smileys: implement get_image interface
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
61 | } |
|
d71c41a54bb3
Smileys: implement get_image interface
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
62 | |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
63 | /******************************************************************************* |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
64 | * Object stuff |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
65 | ******************************************************************************/ |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38279
diff
changeset
|
66 | |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
67 | static void |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38279
diff
changeset
|
68 | purple_smiley_init(PurpleSmiley *smiley) { |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
69 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
70 | |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
71 | static void |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
72 | purple_smiley_finalize(GObject *obj) { |
|
39546
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
73 | PurpleSmiley *smiley = PURPLE_SMILEY(obj); |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
74 | PurpleSmileyPrivate *priv = purple_smiley_get_instance_private(smiley); |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
75 | |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
76 | g_free(priv->shortcut); |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
77 | |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38279
diff
changeset
|
78 | G_OBJECT_CLASS(purple_smiley_parent_class)->finalize(obj); |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
79 | } |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
80 | |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
81 | static void |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
82 | purple_smiley_get_property(GObject *obj, guint param_id, GValue *value, |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
83 | GParamSpec *pspec) |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
84 | { |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38279
diff
changeset
|
85 | PurpleSmiley *smiley = PURPLE_SMILEY(obj); |
|
34531
fc9377274d13
Exposed the instance and class structures of PurpleSmiley so that it can be subclassed
Ankit Vani <a@nevitus.org>
parents:
33796
diff
changeset
|
86 | |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38279
diff
changeset
|
87 | switch (param_id) { |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
88 | case PROP_SHORTCUT: |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
89 | g_value_set_string(value, purple_smiley_get_shortcut(smiley)); |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
90 | break; |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
91 | default: |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38279
diff
changeset
|
92 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
93 | break; |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
94 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
95 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
96 | |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
97 | static void |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
98 | purple_smiley_set_property(GObject *obj, guint param_id, const GValue *value, |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
99 | GParamSpec *pspec) |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
100 | { |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
101 | PurpleSmiley *smiley = PURPLE_SMILEY(obj); |
|
34531
fc9377274d13
Exposed the instance and class structures of PurpleSmiley so that it can be subclassed
Ankit Vani <a@nevitus.org>
parents:
33796
diff
changeset
|
102 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
103 | switch (param_id) { |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
104 | case PROP_SHORTCUT: |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
105 | _purple_smiley_set_shortcut(smiley, g_value_get_string(value)); |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
106 | break; |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
107 | default: |
|
38281
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38279
diff
changeset
|
108 | G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
109 | break; |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
110 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
111 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
112 | |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
113 | static void |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
114 | purple_smiley_class_init(PurpleSmileyClass *klass) { |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
115 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
116 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
117 | obj_class->get_property = purple_smiley_get_property; |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
118 | obj_class->set_property = purple_smiley_set_property; |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
119 | obj_class->finalize = purple_smiley_finalize; |
|
34531
fc9377274d13
Exposed the instance and class structures of PurpleSmiley so that it can be subclassed
Ankit Vani <a@nevitus.org>
parents:
33796
diff
changeset
|
120 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
121 | properties[PROP_SHORTCUT] = g_param_spec_string( |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
122 | "shortcut", |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
123 | "Shortcut", |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
124 | "A non-escaped textual representation of a smiley.", |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
125 | NULL, |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
126 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
127 | ); |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
128 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
129 | g_object_class_install_properties(obj_class, PROP_LAST, properties); |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
130 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
131 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
132 | /******************************************************************************* |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
133 | * API |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
134 | ******************************************************************************/ |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
135 | PurpleSmiley * |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
136 | purple_smiley_new(const gchar *shortcut, const gchar *path) |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
137 | { |
|
38296
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
138 | PurpleSmiley *smiley = NULL; |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
139 | GBytes *bytes = NULL; |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
140 | gchar *contents = NULL; |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
141 | gsize length = 0; |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
142 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
143 | g_return_val_if_fail(shortcut != NULL, NULL); |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
144 | g_return_val_if_fail(path != NULL, NULL); |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
145 | |
|
38296
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
146 | if(!g_file_get_contents(path, &contents, &length, NULL)) { |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
147 | return NULL; |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
148 | } |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
149 | |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
150 | bytes = g_bytes_new_take(contents, length); |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
151 | |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
152 | smiley = g_object_new( |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
153 | PURPLE_TYPE_SMILEY, |
|
38567
277d8f0ec6f8
This should fix up https://github.com/tieto/sipe/issues/147 as paths for smileys were overlooked
Gary Kramlich <grim@reaperworld.com>
parents:
38296
diff
changeset
|
154 | "path", path, |
|
38296
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
155 | "contents", bytes, |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
156 | "shortcut", shortcut, |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
157 | NULL |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
158 | ); |
|
38296
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
159 | |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
160 | g_bytes_unref(bytes); |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
161 | |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
162 | return smiley; |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
163 | } |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
164 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
165 | PurpleSmiley * |
| 38286 | 166 | purple_smiley_new_from_data(const gchar *shortcut, |
| 167 | const guint8 *data, | |
| 168 | gsize length) | |
| 169 | { | |
| 170 | PurpleSmiley *smiley = NULL; | |
| 171 | GBytes *bytes = NULL; | |
| 172 | ||
| 173 | g_return_val_if_fail(shortcut != NULL, NULL); | |
| 174 | ||
| 175 | bytes = g_bytes_new(data, length); | |
| 176 | ||
| 177 | smiley = g_object_new( | |
| 178 | PURPLE_TYPE_SMILEY, | |
| 179 | "shortcut", shortcut, | |
| 180 | "contents", bytes, | |
| 181 | NULL | |
| 182 | ); | |
| 183 | ||
| 184 | g_bytes_unref(bytes); | |
| 185 | ||
| 186 | return smiley; | |
| 187 | ||
| 188 | } | |
| 189 | ||
| 190 | PurpleSmiley * | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
191 | purple_smiley_new_remote(const gchar *shortcut) { |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
192 | g_return_val_if_fail(shortcut != NULL, NULL); |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
193 | |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
194 | return g_object_new( |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
195 | PURPLE_TYPE_SMILEY, |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
196 | "shortcut", shortcut, |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
197 | NULL |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
198 | ); |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
199 | } |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
200 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
201 | const gchar * |
|
39546
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
202 | purple_smiley_get_shortcut(PurpleSmiley *smiley) |
|
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
203 | { |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
204 | PurpleSmileyPrivate *priv = NULL; |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
205 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
206 | g_return_val_if_fail(PURPLE_IS_SMILEY(smiley), NULL); |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
207 | |
|
39546
9fd07be714dd
Use G_DECLARE* for PurpleSmiley and drop private macro.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39352
diff
changeset
|
208 | priv = purple_smiley_get_instance_private(smiley); |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
209 | |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
210 | return priv->shortcut; |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
211 | } |