Wed, 20 Jun 2018 02:13:44 -0400
prefs: Add binding versions of pref widget functions.
These just bind settings to existing widgets and copy the saved value to
the widget, except for combos which are produced from runtime lists.
Those are populated in a similar way as before.
There are some extra _bind_ words that will probably be dropped once the
other functions are unused.
|
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" |
|
23022
ed4aeaec12e3
Expose the smiley API to dbus.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23016
diff
changeset
|
23 | #include "dbus-maybe.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
|
24 | |
|
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
|
25 | #define PURPLE_SMILEY_GET_PRIVATE(obj) \ |
|
fc9377274d13
Exposed the instance and class structures of PurpleSmiley so that it can be subclassed
Ankit Vani <a@nevitus.org>
parents:
33796
diff
changeset
|
26 | (G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_SMILEY, PurpleSmileyPrivate)) |
|
fc9377274d13
Exposed the instance and class structures of PurpleSmiley so that it can be subclassed
Ankit Vani <a@nevitus.org>
parents:
33796
diff
changeset
|
27 | |
|
fc9377274d13
Exposed the instance and class structures of PurpleSmiley so that it can be subclassed
Ankit Vani <a@nevitus.org>
parents:
33796
diff
changeset
|
28 | typedef struct { |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
29 | 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
|
30 | } PurpleSmileyPrivate; |
|
22449
4fea5a505737
Hide PurpleSmiley internals.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22446
diff
changeset
|
31 | |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
32 | enum |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
33 | { |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
34 | PROP_0, |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
35 | 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
|
36 | PROP_LAST |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
37 | }; |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
38 | |
|
35078
9e2aff0b8476
libpurple: started changing g_object_notify to g_object_notify_by_pspec
Ankit Vani <a@nevitus.org>
parents:
35065
diff
changeset
|
39 | static GParamSpec *properties[PROP_LAST]; |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
40 | |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
41 | /******************************************************************************* |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
42 | * Helpers |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
43 | ******************************************************************************/ |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
44 | 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
|
45 | _purple_smiley_set_shortcut(PurpleSmiley *smiley, const gchar *shortcut) { |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
46 | PurpleSmileyPrivate *priv = PURPLE_SMILEY_GET_PRIVATE(smiley); |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
47 | |
|
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
|
48 | g_free(priv->shortcut); |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
49 | |
|
38290
2d8479ba7df8
g_strdup returns NULL if the input was NULL
Gary Kramlich <grim@reaperworld.com>
parents:
38286
diff
changeset
|
50 | priv->shortcut = g_strdup(shortcut); |
|
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 | g_object_notify(G_OBJECT(smiley), "shortcut"); |
|
35749
d71c41a54bb3
Smileys: implement get_image interface
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
53 | } |
|
d71c41a54bb3
Smileys: implement get_image interface
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35709
diff
changeset
|
54 | |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
55 | /******************************************************************************* |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
56 | * Object stuff |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
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:
38279
diff
changeset
|
58 | G_DEFINE_TYPE_WITH_PRIVATE(PurpleSmiley, purple_smiley, PURPLE_TYPE_IMAGE); |
|
df274be2afa2
A bunch more hack and slash with a bit more design on the fly
Gary Kramlich <grim@reaperworld.com>
parents:
38279
diff
changeset
|
59 | |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
60 | 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
|
61 | purple_smiley_init(PurpleSmiley *smiley) { |
|
23022
ed4aeaec12e3
Expose the smiley API to dbus.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23016
diff
changeset
|
62 | PURPLE_DBUS_REGISTER_POINTER(smiley, PurpleSmiley); |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
63 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
64 | |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
65 | static void |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
66 | purple_smiley_finalize(GObject *obj) { |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
67 | PurpleSmileyPrivate *priv = PURPLE_SMILEY_GET_PRIVATE(obj); |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
68 | |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
69 | g_free(priv->shortcut); |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
70 | |
|
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
71 | PURPLE_DBUS_UNREGISTER_POINTER(smiley); |
|
35810
246fb7cd2d93
Smiley: add missing parent finalize calls
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35774
diff
changeset
|
72 | |
|
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
|
73 | G_OBJECT_CLASS(purple_smiley_parent_class)->finalize(obj); |
|
35698
302a7cb4c1ab
Initial generic PurpleSmiley implementation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35470
diff
changeset
|
74 | } |
|
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 | static void |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
77 | 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
|
78 | GParamSpec *pspec) |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
79 | { |
|
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
|
80 | 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
|
81 | |
|
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
|
82 | switch (param_id) { |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
83 | case PROP_SHORTCUT: |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
84 | 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
|
85 | break; |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
86 | 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
|
87 | 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
|
88 | break; |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
89 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
90 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
91 | |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
92 | static void |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
93 | 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
|
94 | GParamSpec *pspec) |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
95 | { |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
96 | 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
|
97 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
98 | switch (param_id) { |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
99 | case PROP_SHORTCUT: |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
100 | _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
|
101 | break; |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
102 | 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
|
103 | 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
|
104 | break; |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
105 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
106 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
107 | |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
108 | static void |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
109 | purple_smiley_class_init(PurpleSmileyClass *klass) { |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
110 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
111 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
112 | obj_class->get_property = purple_smiley_get_property; |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
113 | obj_class->set_property = purple_smiley_set_property; |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
114 | 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
|
115 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
116 | properties[PROP_SHORTCUT] = g_param_spec_string( |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
117 | "shortcut", |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
118 | "Shortcut", |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
119 | "A non-escaped textual representation of a smiley.", |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
120 | NULL, |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
121 | 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
|
122 | ); |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
123 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
124 | 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
|
125 | } |
|
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
126 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
127 | /******************************************************************************* |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
128 | * API |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
129 | ******************************************************************************/ |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
130 | PurpleSmiley * |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
131 | 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
|
132 | { |
|
38296
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
133 | PurpleSmiley *smiley = NULL; |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
134 | GBytes *bytes = NULL; |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
135 | gchar *contents = NULL; |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
136 | gsize length = 0; |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
137 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
138 | g_return_val_if_fail(shortcut != NULL, NULL); |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
139 | g_return_val_if_fail(path != NULL, NULL); |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
140 | |
|
38296
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
141 | 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
|
142 | return NULL; |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
143 | } |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
144 | |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
145 | 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
|
146 | |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
147 | smiley = g_object_new( |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
148 | 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
|
149 | "path", path, |
|
38296
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
150 | "contents", bytes, |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
151 | "shortcut", shortcut, |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
152 | NULL |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
153 | ); |
|
38296
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
154 | |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
155 | g_bytes_unref(bytes); |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
156 | |
|
2fc408bdc848
Actually use the path variable pasted to purple_smiley_new
Gary Kramlich <grim@reaperworld.com>
parents:
38290
diff
changeset
|
157 | return smiley; |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
158 | } |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
159 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
160 | PurpleSmiley * |
| 38286 | 161 | purple_smiley_new_from_data(const gchar *shortcut, |
| 162 | const guint8 *data, | |
| 163 | gsize length) | |
| 164 | { | |
| 165 | PurpleSmiley *smiley = NULL; | |
| 166 | GBytes *bytes = NULL; | |
| 167 | ||
| 168 | g_return_val_if_fail(shortcut != NULL, NULL); | |
| 169 | ||
| 170 | bytes = g_bytes_new(data, length); | |
| 171 | ||
| 172 | smiley = g_object_new( | |
| 173 | PURPLE_TYPE_SMILEY, | |
| 174 | "shortcut", shortcut, | |
| 175 | "contents", bytes, | |
| 176 | NULL | |
| 177 | ); | |
| 178 | ||
| 179 | g_bytes_unref(bytes); | |
| 180 | ||
| 181 | return smiley; | |
| 182 | ||
| 183 | } | |
| 184 | ||
| 185 | PurpleSmiley * | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
186 | purple_smiley_new_remote(const gchar *shortcut) { |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
187 | g_return_val_if_fail(shortcut != NULL, NULL); |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
188 | |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
189 | return g_object_new( |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
190 | PURPLE_TYPE_SMILEY, |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
191 | "shortcut", shortcut, |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
192 | 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 | } |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
195 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
196 | const gchar * |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
197 | purple_smiley_get_shortcut(const PurpleSmiley *smiley) { |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
198 | PurpleSmileyPrivate *priv = NULL; |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
199 | |
|
38279
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
200 | 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
|
201 | |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
202 | priv = PURPLE_SMILEY_GET_PRIVATE(smiley); |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
203 | |
|
a04046a1d93f
A bunch of cleanups for smileys
Gary Kramlich <grim@reaperworld.com>
parents:
38277
diff
changeset
|
204 | return priv->shortcut; |
|
23013
18f4fad1f9af
Make PurpleSmiley a GObject.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22896
diff
changeset
|
205 | } |