pidgin/pidginpresenceicon.c

Fri, 20 Nov 2020 16:43:26 -0600

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Fri, 20 Nov 2020 16:43:26 -0600
changeset 40620
6507c3c9940b
parent 40604
cd55d0fc0f81
child 40652
0006f8158d6e
permissions
-rw-r--r--

Convert sametime to Gio.

Add a cancellable to sametime data.
Convert sametime to Gio.

Testing Done:
Compile only.

Reviewed at https://reviews.imfreedom.org/r/243/

40601
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "pidgin/pidginpresenceicon.h"
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 struct _PidginPresenceIcon {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 GtkImage parent;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 PurplePresence *presence;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 gchar *fallback;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 GtkIconSize icon_size;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 };
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 enum {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 PROP_0,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 PROP_PRESENCE,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 PROP_FALLBACK,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 PROP_ICON_SIZE,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 N_PROPERTIES
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 };
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 static GParamSpec *properties[N_PROPERTIES] = { NULL, };
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 G_DEFINE_TYPE(PidginPresenceIcon, pidgin_presence_icon, GTK_TYPE_IMAGE)
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 /******************************************************************************
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 * Implementation
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 *****************************************************************************/
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 static void
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 pidgin_presence_icon_update(PidginPresenceIcon *icon) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 const gchar *icon_name = icon->fallback;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 /* Sorry for the pyramid of doom, couldn't come up with a better way to do
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 * this...
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 */
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 if(PURPLE_IS_PRESENCE(icon->presence)) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 PurpleStatus *status = NULL;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 status = purple_presence_get_active_status(icon->presence);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 if(PURPLE_IS_STATUS(status)) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 PurpleStatusType *type = purple_status_get_status_type(status);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 if(type != NULL) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 switch(purple_status_type_get_primitive(type)) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 case PURPLE_STATUS_OFFLINE:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 icon_name = "pidgin-user-offline";
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 case PURPLE_STATUS_AVAILABLE:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 icon_name = "pidgin-user-available";
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 case PURPLE_STATUS_UNAVAILABLE:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 icon_name = "pidgin-user-unavailable";
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 case PURPLE_STATUS_AWAY:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 icon_name = "pidgin-user-away";
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 case PURPLE_STATUS_INVISIBLE:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 icon_name = "pidgin-user-invisible";
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 case PURPLE_STATUS_EXTENDED_AWAY:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 icon_name = "pidgin-user-extended-away";
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 case PURPLE_STATUS_MOBILE:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 case PURPLE_STATUS_TUNE:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 case PURPLE_STATUS_MOOD:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 case PURPLE_STATUS_UNSET:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 default:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 /* Use the fallback which was set above. */
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 gtk_image_set_from_icon_name(GTK_IMAGE(icon), icon_name, icon->icon_size);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 static void
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 pidgin_presence_icon_active_status_changed_cb(GObject *obj, GParamSpec *pspec,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 gpointer data)
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 pidgin_presence_icon_update(PIDGIN_PRESENCE_ICON(data));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 /******************************************************************************
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 * GObject Implementation
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 *****************************************************************************/
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 static void
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 pidgin_presence_icon_get_property(GObject *obj, guint param_id, GValue *value,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 GParamSpec *pspec)
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 PidginPresenceIcon *icon = PIDGIN_PRESENCE_ICON(obj);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 switch(param_id) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 case PROP_PRESENCE:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 g_value_set_object(value, pidgin_presence_icon_get_presence(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 case PROP_FALLBACK:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 g_value_set_string(value, pidgin_presence_icon_get_fallback(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 case PROP_ICON_SIZE:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 g_value_set_enum(value, pidgin_presence_icon_get_icon_size(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 default:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 static void
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 pidgin_presence_icon_set_property(GObject *obj, guint param_id,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 const GValue *value, GParamSpec *pspec)
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 PidginPresenceIcon *icon = PIDGIN_PRESENCE_ICON(obj);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 switch(param_id) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 case PROP_PRESENCE:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 pidgin_presence_icon_set_presence(icon, g_value_get_object(value));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 case PROP_FALLBACK:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 pidgin_presence_icon_set_fallback(icon, g_value_get_string(value));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 case PROP_ICON_SIZE:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 pidgin_presence_icon_set_icon_size(icon, g_value_get_enum(value));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 default:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 break;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 static void
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 pidgin_presence_icon_finalize(GObject *obj) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 PidginPresenceIcon *icon = PIDGIN_PRESENCE_ICON(obj);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 g_clear_object(&icon->presence);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 g_clear_pointer(&icon->fallback, g_free);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 G_OBJECT_CLASS(pidgin_presence_icon_parent_class)->finalize(obj);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 static void
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 pidgin_presence_icon_init(PidginPresenceIcon *presenceicon) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 /* Use the icon name fallback that we're expecting. */
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 g_object_set(G_OBJECT(presenceicon), "use-fallback", TRUE, NULL);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 static void
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 pidgin_presence_icon_class_init(PidginPresenceIconClass *klass) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 obj_class->finalize = pidgin_presence_icon_finalize;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 obj_class->get_property = pidgin_presence_icon_get_property;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 obj_class->set_property = pidgin_presence_icon_set_property;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 /**
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 * PidginPresenceIcon::presence:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 *
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 * The #PurplePresence that this icon will be representing.
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 */
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 properties[PROP_PRESENCE] = g_param_spec_object(
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 "presence", "presence",
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 "The presence that this icon is representing",
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 PURPLE_TYPE_PRESENCE,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 /**
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 * PidginPresenceIcon::fallback:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 *
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 * The name of the icon to use as a fallback when no presence is set.
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 */
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 properties[PROP_FALLBACK] = g_param_spec_string(
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 "fallback", "fallback",
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 "The name of the icon to use as a fallback",
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 "user-invisible",
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 /**
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 * PidginPresenceIcon::icon-size:
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 *
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 * The #GtkIconSize that should be used.
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 */
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 properties[PROP_ICON_SIZE] = g_param_spec_enum(
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 "icon-size", "icon-size",
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 "The GtkIconSize to use",
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 GTK_TYPE_ICON_SIZE,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 GTK_ICON_SIZE_MENU,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 /******************************************************************************
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 * Public API
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 *****************************************************************************/
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 GtkWidget *
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 pidgin_presence_icon_new(PurplePresence *presence, const gchar *fallback,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 GtkIconSize icon_size)
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 return g_object_new(
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 PIDGIN_TYPE_PRESENCE_ICON,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 "presence", presence,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 "fallback", fallback,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 "icon_size", icon_size,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 NULL);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 PurplePresence *
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 pidgin_presence_icon_get_presence(PidginPresenceIcon *icon) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 g_return_val_if_fail(PIDGIN_IS_PRESENCE_ICON(icon), NULL);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 return icon->presence;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 void
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 pidgin_presence_icon_set_presence(PidginPresenceIcon *icon,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 PurplePresence *presence)
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 PurplePresence *old = NULL;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 g_return_if_fail(PIDGIN_IS_PRESENCE_ICON(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 /* We only want to disconnect signal handlers if the presence was changed,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 * but to do that, we need to keep a reference to the old presence.
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 */
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 if(PURPLE_IS_PRESENCE(icon->presence)) {
40604
cd55d0fc0f81 Fix some more new warnings.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 40601
diff changeset
245 old = g_object_ref(icon->presence);
40601
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 if(g_set_object(&icon->presence, presence)) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 if(G_IS_OBJECT(old)) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 /* If we previously had a presence, disconnect our signal handlers.
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 */
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 g_signal_handlers_disconnect_by_data(old, icon);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 if(PURPLE_IS_PRESENCE(icon->presence)) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 g_signal_connect(icon->presence, "notify::active-status",
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 G_CALLBACK(pidgin_presence_icon_active_status_changed_cb),
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 icon);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 g_object_freeze_notify(G_OBJECT(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 pidgin_presence_icon_update(icon);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 g_object_notify_by_pspec(G_OBJECT(icon), properties[PROP_PRESENCE]);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 g_object_thaw_notify(G_OBJECT(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 g_clear_object(&old);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 const gchar *
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 pidgin_presence_icon_get_fallback(PidginPresenceIcon *icon) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 g_return_val_if_fail(PIDGIN_IS_PRESENCE_ICON(icon), NULL);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 return icon->fallback;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 void
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 pidgin_presence_icon_set_fallback(PidginPresenceIcon *icon,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 const gchar *fallback)
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 g_return_if_fail(PIDGIN_IS_PRESENCE_ICON(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 g_return_if_fail(fallback != NULL);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 g_free(icon->fallback);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 icon->fallback = g_strdup(fallback);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 g_object_freeze_notify(G_OBJECT(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 pidgin_presence_icon_update(icon);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 g_object_notify_by_pspec(G_OBJECT(icon), properties[PROP_FALLBACK]);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 g_object_thaw_notify(G_OBJECT(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 GtkIconSize
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 pidgin_presence_icon_get_icon_size(PidginPresenceIcon *icon) {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 g_return_val_if_fail(PIDGIN_IS_PRESENCE_ICON(icon), GTK_ICON_SIZE_INVALID);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 return icon->icon_size;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 }
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306 void
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 pidgin_presence_icon_set_icon_size(PidginPresenceIcon *icon,
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 GtkIconSize icon_size)
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 {
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 g_return_if_fail(PIDGIN_IS_PRESENCE_ICON(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 icon->icon_size = icon_size;
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 g_object_freeze_notify(G_OBJECT(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 pidgin_presence_icon_update(icon);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 g_object_notify_by_pspec(G_OBJECT(icon), properties[PROP_ICON_SIZE]);
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 g_object_thaw_notify(G_OBJECT(icon));
228284223862 Create PidginPresenceIcon that displays the correct icon for its bound PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 }

mercurial