| 32 GtkBox parent; |
32 GtkBox parent; |
| 33 |
33 |
| 34 PurpleConversation *conversation; |
34 PurpleConversation *conversation; |
| 35 |
35 |
| 36 GtkWidget *hbox; |
36 GtkWidget *hbox; |
| 37 GtkWidget *presence_icon; |
37 GtkWidget *avatar; |
| 38 |
38 |
| 39 GtkWidget *name; |
39 GtkWidget *name; |
| 40 GBinding *name_binding; |
40 GBinding *name_binding; |
| 41 |
41 |
| 42 GtkWidget *topic; |
42 GtkWidget *topic; |
| 43 GBinding *topic_binding; |
43 GBinding *topic_binding; |
| 44 |
|
| 45 GtkWidget *avatar; |
|
| 46 }; |
44 }; |
| 47 |
45 |
| 48 enum { |
46 enum { |
| 49 PROP_0, |
47 PROP_0, |
| 50 PROP_CONVERSATION, |
48 PROP_CONVERSATION, |
| 51 N_PROPERTIES, |
49 N_PROPERTIES, |
| 52 }; |
50 }; |
| 53 static GParamSpec *properties[N_PROPERTIES] = {NULL, }; |
51 static GParamSpec *properties[N_PROPERTIES] = {NULL, }; |
| 54 |
52 |
| 55 G_DEFINE_TYPE(PidginInfoPane, pidgin_info_pane, GTK_TYPE_BOX) |
53 G_DEFINE_TYPE(PidginInfoPane, pidgin_info_pane, GTK_TYPE_BOX) |
| |
54 |
| |
55 /****************************************************************************** |
| |
56 * Helpers |
| |
57 *****************************************************************************/ |
| |
58 static gboolean |
| |
59 pidgin_info_pane_topic_to_label(G_GNUC_UNUSED GBinding *binding, |
| |
60 const GValue *from_value, |
| |
61 GValue *to_value, |
| |
62 gpointer data) |
| |
63 { |
| |
64 PidginInfoPane *pane = data; |
| |
65 const char *topic = NULL; |
| |
66 gboolean visible = FALSE; |
| |
67 |
| |
68 topic = g_value_get_string(from_value); |
| |
69 visible = !purple_strempty(topic); |
| |
70 g_value_set_string(to_value, topic); |
| |
71 |
| |
72 gtk_widget_set_visible(pane->topic, visible); |
| |
73 |
| |
74 return TRUE; |
| |
75 } |
| 56 |
76 |
| 57 /****************************************************************************** |
77 /****************************************************************************** |
| 58 * GObject Implementation |
78 * GObject Implementation |
| 59 *****************************************************************************/ |
79 *****************************************************************************/ |
| 60 static void |
80 static void |
| 130 "/im/pidgin/Pidgin3/Conversations/infopane.ui" |
150 "/im/pidgin/Pidgin3/Conversations/infopane.ui" |
| 131 ); |
151 ); |
| 132 |
152 |
| 133 gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, hbox); |
153 gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, hbox); |
| 134 gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, avatar); |
154 gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, avatar); |
| 135 gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, presence_icon); |
|
| 136 gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, name); |
155 gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, name); |
| 137 gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, topic); |
156 gtk_widget_class_bind_template_child(widget_class, PidginInfoPane, topic); |
| 138 } |
157 } |
| 139 |
158 |
| 140 /****************************************************************************** |
159 /****************************************************************************** |
| 172 /* Tell the avatar about the new conversation. */ |
191 /* Tell the avatar about the new conversation. */ |
| 173 pidgin_avatar_set_conversation(PIDGIN_AVATAR(pane->avatar), |
192 pidgin_avatar_set_conversation(PIDGIN_AVATAR(pane->avatar), |
| 174 pane->conversation); |
193 pane->conversation); |
| 175 |
194 |
| 176 if(PURPLE_IS_CONVERSATION(conversation)) { |
195 if(PURPLE_IS_CONVERSATION(conversation)) { |
| 177 PidginPresenceIcon *presence_icon = NULL; |
|
| 178 PurplePresence *presence = NULL; |
|
| 179 const gchar *fallback = "person"; |
|
| 180 |
|
| 181 pane->name_binding = |
196 pane->name_binding = |
| 182 g_object_bind_property(G_OBJECT(conversation), "name", |
197 g_object_bind_property(G_OBJECT(conversation), "name", |
| 183 G_OBJECT(pane->name), "label", |
198 G_OBJECT(pane->name), "label", |
| 184 G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); |
199 G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); |
| 185 |
200 |
| 186 pane->topic_binding = |
201 pane->topic_binding = |
| 187 g_object_bind_property(G_OBJECT(conversation), "topic", |
202 g_object_bind_property_full(G_OBJECT(conversation), "topic", |
| 188 G_OBJECT(pane->topic), "label", |
203 G_OBJECT(pane->topic), "label", |
| 189 G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); |
204 G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE, |
| 190 |
205 pidgin_info_pane_topic_to_label, |
| 191 if(PURPLE_IS_CHAT_CONVERSATION(conversation)) { |
206 NULL, |
| 192 fallback = "chat"; |
207 pane, NULL); |
| 193 } else if(PURPLE_IS_IM_CONVERSATION(conversation)) { |
|
| 194 PurpleAccount *account = NULL; |
|
| 195 PurpleBuddy *buddy = NULL; |
|
| 196 const gchar *name = NULL; |
|
| 197 |
|
| 198 account = purple_conversation_get_account(conversation); |
|
| 199 name = purple_conversation_get_name(conversation); |
|
| 200 buddy = purple_blist_find_buddy(account, name); |
|
| 201 |
|
| 202 if(PURPLE_IS_BUDDY(buddy)) { |
|
| 203 presence = purple_buddy_get_presence(buddy); |
|
| 204 } |
|
| 205 |
|
| 206 fallback = "person"; |
|
| 207 } |
|
| 208 |
|
| 209 presence_icon = PIDGIN_PRESENCE_ICON(pane->presence_icon); |
|
| 210 pidgin_presence_icon_set_fallback(presence_icon, fallback); |
|
| 211 pidgin_presence_icon_set_presence(presence_icon, presence); |
|
| 212 } |
208 } |
| 213 |
209 |
| 214 /* Notify that we changed. */ |
210 /* Notify that we changed. */ |
| 215 g_object_notify_by_pspec(G_OBJECT(pane), properties[PROP_CONVERSATION]); |
211 g_object_notify_by_pspec(G_OBJECT(pane), properties[PROP_CONVERSATION]); |
| 216 } |
212 } |