| 23 #include "pidgin/pidginpresenceicon.h" |
23 #include "pidgin/pidginpresenceicon.h" |
| 24 |
24 |
| 25 #include "pidgin/pidginiconname.h" |
25 #include "pidgin/pidginiconname.h" |
| 26 |
26 |
| 27 struct _PidginPresenceIcon { |
27 struct _PidginPresenceIcon { |
| 28 GtkImage parent; |
28 GtkBox parent; |
| |
29 |
| |
30 GtkWidget *icon; |
| 29 |
31 |
| 30 PurplePresence *presence; |
32 PurplePresence *presence; |
| 31 gchar *fallback; |
33 gchar *fallback; |
| 32 GtkIconSize icon_size; |
34 GtkIconSize icon_size; |
| 33 }; |
35 }; |
| 39 PROP_ICON_SIZE, |
41 PROP_ICON_SIZE, |
| 40 N_PROPERTIES |
42 N_PROPERTIES |
| 41 }; |
43 }; |
| 42 static GParamSpec *properties[N_PROPERTIES] = { NULL, }; |
44 static GParamSpec *properties[N_PROPERTIES] = { NULL, }; |
| 43 |
45 |
| 44 G_DEFINE_TYPE(PidginPresenceIcon, pidgin_presence_icon, GTK_TYPE_IMAGE) |
46 G_DEFINE_TYPE(PidginPresenceIcon, pidgin_presence_icon, GTK_TYPE_BOX) |
| 45 |
47 |
| 46 /****************************************************************************** |
48 /****************************************************************************** |
| 47 * Implementation |
49 * Implementation |
| 48 *****************************************************************************/ |
50 *****************************************************************************/ |
| 49 static void |
51 static void |
| 50 pidgin_presence_icon_update(PidginPresenceIcon *icon) { |
52 pidgin_presence_icon_update(PidginPresenceIcon *icon) { |
| 51 const gchar *icon_name = NULL; |
53 const gchar *icon_name = NULL; |
| 52 |
54 |
| 53 icon_name = pidgin_icon_name_from_presence(icon->presence, icon->fallback); |
55 icon_name = pidgin_icon_name_from_presence(icon->presence, icon->fallback); |
| 54 |
56 |
| 55 gtk_image_set_from_icon_name(GTK_IMAGE(icon), icon_name, icon->icon_size); |
57 gtk_image_set_from_icon_name(GTK_IMAGE(icon->icon), icon_name, |
| |
58 icon->icon_size); |
| 56 } |
59 } |
| 57 |
60 |
| 58 static void |
61 static void |
| 59 pidgin_presence_icon_active_status_changed_cb(GObject *obj, GParamSpec *pspec, |
62 pidgin_presence_icon_active_status_changed_cb(GObject *obj, GParamSpec *pspec, |
| 60 gpointer data) |
63 gpointer data) |
| 119 G_OBJECT_CLASS(pidgin_presence_icon_parent_class)->finalize(obj); |
122 G_OBJECT_CLASS(pidgin_presence_icon_parent_class)->finalize(obj); |
| 120 } |
123 } |
| 121 |
124 |
| 122 static void |
125 static void |
| 123 pidgin_presence_icon_init(PidginPresenceIcon *presenceicon) { |
126 pidgin_presence_icon_init(PidginPresenceIcon *presenceicon) { |
| 124 /* Use the icon name fallback that we're expecting. */ |
127 gtk_widget_init_template(GTK_WIDGET(presenceicon)); |
| 125 g_object_set(G_OBJECT(presenceicon), "use-fallback", TRUE, NULL); |
|
| 126 } |
128 } |
| 127 |
129 |
| 128 static void |
130 static void |
| 129 pidgin_presence_icon_class_init(PidginPresenceIconClass *klass) { |
131 pidgin_presence_icon_class_init(PidginPresenceIconClass *klass) { |
| 130 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
132 GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
| |
133 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
| 131 |
134 |
| 132 obj_class->finalize = pidgin_presence_icon_finalize; |
135 obj_class->finalize = pidgin_presence_icon_finalize; |
| 133 obj_class->get_property = pidgin_presence_icon_get_property; |
136 obj_class->get_property = pidgin_presence_icon_get_property; |
| 134 obj_class->set_property = pidgin_presence_icon_set_property; |
137 obj_class->set_property = pidgin_presence_icon_set_property; |
| 135 |
138 |
| 166 GTK_TYPE_ICON_SIZE, |
169 GTK_TYPE_ICON_SIZE, |
| 167 GTK_ICON_SIZE_MENU, |
170 GTK_ICON_SIZE_MENU, |
| 168 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); |
171 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); |
| 169 |
172 |
| 170 g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
173 g_object_class_install_properties(obj_class, N_PROPERTIES, properties); |
| |
174 |
| |
175 gtk_widget_class_set_template_from_resource( |
| |
176 widget_class, |
| |
177 "/im/pidgin/Pidgin3/presenceicon.ui" |
| |
178 ); |
| |
179 |
| |
180 gtk_widget_class_bind_template_child(widget_class, PidginPresenceIcon, |
| |
181 icon); |
| 171 } |
182 } |
| 172 |
183 |
| 173 /****************************************************************************** |
184 /****************************************************************************** |
| 174 * Public API |
185 * Public API |
| 175 *****************************************************************************/ |
186 *****************************************************************************/ |