diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-02 17:42:02 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-04-02 17:42:02 +0800 |
commit | 6db49cc6901b36e551f9f228eb43ff4a646c540d (patch) | |
tree | 7a31a44919a6ebd136f2b8e9fcddaacb59144dda /libempathy-gtk | |
parent | 70a2a0c5f4d091e765ff4d8108e28a63bcf48b47 (diff) | |
download | gsoc2013-empathy-6db49cc6901b36e551f9f228eb43ff4a646c540d.tar gsoc2013-empathy-6db49cc6901b36e551f9f228eb43ff4a646c540d.tar.gz gsoc2013-empathy-6db49cc6901b36e551f9f228eb43ff4a646c540d.tar.bz2 gsoc2013-empathy-6db49cc6901b36e551f9f228eb43ff4a646c540d.tar.lz gsoc2013-empathy-6db49cc6901b36e551f9f228eb43ff4a646c540d.tar.xz gsoc2013-empathy-6db49cc6901b36e551f9f228eb43ff4a646c540d.tar.zst gsoc2013-empathy-6db49cc6901b36e551f9f228eb43ff4a646c540d.zip |
Add a tooltip property on EmpathyChat
svn path=/trunk/; revision=845
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 164 | ||||
-rw-r--r-- | libempathy-gtk/empathy-chat.h | 1 |
2 files changed, 110 insertions, 55 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index fd5adcdf7..d2f59a6cc 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -63,6 +63,7 @@ struct _EmpathyChatPriv { McAccount *account; gchar *name; gchar *subject; + gchar *tooltip; EmpathyContact *selected_contact; gchar *id; @@ -111,6 +112,7 @@ enum { PROP_ACCOUNT, PROP_NAME, PROP_SUBJECT, + PROP_TOOLTIP, PROP_SELECTED_CONTACT, PROP_ID }; @@ -140,6 +142,9 @@ chat_get_property (GObject *object, case PROP_SUBJECT: g_value_set_string (value, priv->subject); break; + case PROP_TOOLTIP: + g_value_set_string (value, priv->tooltip); + break; case PROP_SELECTED_CONTACT: g_value_set_object (value, priv->selected_contact); break; @@ -260,58 +265,6 @@ chat_composing_stop (EmpathyChat *chat) } static void -chat_finalize (GObject *object) -{ - EmpathyChat *chat; - EmpathyChatPriv *priv; - - chat = EMPATHY_CHAT (object); - priv = GET_PRIV (chat); - - empathy_debug (DEBUG_DOMAIN, "Finalized: %p", object); - - g_slist_foreach (priv->sent_messages, (GFunc) g_free, NULL); - g_slist_free (priv->sent_messages); - - g_list_foreach (priv->compositors, (GFunc) g_object_unref, NULL); - g_list_free (priv->compositors); - - g_list_foreach (priv->backlog_messages, (GFunc) g_object_unref, NULL); - g_list_free (priv->backlog_messages); - - chat_composing_remove_timeout (chat); - - dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc), "AccountStatusChanged", - G_CALLBACK (chat_status_changed_cb), - chat); - g_object_unref (priv->mc); - g_object_unref (priv->log_manager); - - - if (priv->tp_chat) { - g_object_unref (priv->tp_chat); - } - - if (priv->account) { - g_object_unref (priv->account); - } - - if (priv->selected_contact) { - g_object_unref (priv->selected_contact); - } - - if (priv->block_events_timeout_id) { - g_source_remove (priv->block_events_timeout_id); - } - - g_free (priv->id); - g_free (priv->name); - g_free (priv->subject); - - G_OBJECT_CLASS (empathy_chat_parent_class)->finalize (object); -} - -static void chat_destroy_cb (EmpathyTpChat *tp_chat, EmpathyChat *chat) { @@ -643,7 +596,31 @@ chat_property_changed_cb (EmpathyTpChat *tp_chat, g_free (priv->name); priv->name = g_value_dup_string (value); g_object_notify (G_OBJECT (chat), "name"); + } else { + return; } + + g_free (priv->tooltip); + priv->tooltip = g_strconcat (priv->name, "\n", + _("Topic: "), priv->subject, NULL); + g_object_notify (G_OBJECT (chat), "tooltip"); +} + +static void +chat_selected_contact_notify_cb (EmpathyChat *chat) +{ + EmpathyChatPriv *priv = GET_PRIV (chat); + + g_free (priv->name); + priv->name = g_strdup (empathy_contact_get_name (priv->selected_contact)); + g_object_notify (G_OBJECT (chat), "name"); + + g_free (priv->tooltip); + priv->tooltip = g_strconcat (empathy_contact_get_id (priv->selected_contact), + "\n", + empathy_contact_get_status (priv->selected_contact), + NULL); + g_object_notify (G_OBJECT (chat), "tooltip"); } static void @@ -658,15 +635,19 @@ chat_remote_contact_notify_cb (EmpathyChat *chat) } if (priv->selected_contact) { + g_signal_handlers_disconnect_by_func (contact, + chat_selected_contact_notify_cb, + chat); g_object_unref (priv->selected_contact); priv->selected_contact = NULL; } if (contact) { - g_free (priv->name); priv->selected_contact = g_object_ref (contact); - priv->name = g_strdup (empathy_contact_get_name (contact)); - g_object_notify (G_OBJECT (chat), "name"); + g_signal_connect_swapped (contact, "notify", + G_CALLBACK (chat_selected_contact_notify_cb), + chat); + chat_selected_contact_notify_cb (chat); } g_object_notify (G_OBJECT (chat), "selected-contact"); @@ -1350,6 +1331,62 @@ chat_create_ui (EmpathyChat *chat) } static void +chat_finalize (GObject *object) +{ + EmpathyChat *chat; + EmpathyChatPriv *priv; + + chat = EMPATHY_CHAT (object); + priv = GET_PRIV (chat); + + empathy_debug (DEBUG_DOMAIN, "Finalized: %p", object); + + g_slist_foreach (priv->sent_messages, (GFunc) g_free, NULL); + g_slist_free (priv->sent_messages); + + g_list_foreach (priv->compositors, (GFunc) g_object_unref, NULL); + g_list_free (priv->compositors); + + g_list_foreach (priv->backlog_messages, (GFunc) g_object_unref, NULL); + g_list_free (priv->backlog_messages); + + chat_composing_remove_timeout (chat); + + dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (priv->mc), "AccountStatusChanged", + G_CALLBACK (chat_status_changed_cb), + chat); + g_object_unref (priv->mc); + g_object_unref (priv->log_manager); + + + if (priv->tp_chat) { + g_object_unref (priv->tp_chat); + } + + if (priv->account) { + g_object_unref (priv->account); + } + + if (priv->selected_contact) { + g_signal_handlers_disconnect_by_func (priv->selected_contact, + chat_selected_contact_notify_cb, + chat); + g_object_unref (priv->selected_contact); + } + + if (priv->block_events_timeout_id) { + g_source_remove (priv->block_events_timeout_id); + } + + g_free (priv->id); + g_free (priv->name); + g_free (priv->subject); + g_free (priv->tooltip); + + G_OBJECT_CLASS (empathy_chat_parent_class)->finalize (object); +} + +static void chat_constructed (GObject *object) { chat_add_logs (EMPATHY_CHAT (object)); @@ -1397,6 +1434,13 @@ empathy_chat_class_init (EmpathyChatClass *klass) NULL, G_PARAM_READABLE)); g_object_class_install_property (object_class, + PROP_TOOLTIP, + g_param_spec_string ("tooltip", + "Chat's tooltip", + "The tooltip of the chat", + NULL, + G_PARAM_READABLE)); + g_object_class_install_property (object_class, PROP_SELECTED_CONTACT, g_param_spec_object ("selected-contact", "The selected contact", @@ -1614,6 +1658,16 @@ empathy_chat_get_subject (EmpathyChat *chat) return priv->subject; } +const gchar * +empathy_chat_get_tooltip (EmpathyChat *chat) +{ + EmpathyChatPriv *priv = GET_PRIV (chat); + + g_return_val_if_fail (EMPATHY_IS_CHAT (chat), NULL); + + return priv->tooltip; +} + EmpathyContact * empathy_chat_get_selected_contact (EmpathyChat *chat) { diff --git a/libempathy-gtk/empathy-chat.h b/libempathy-gtk/empathy-chat.h index 174c4506e..1aff3d1b8 100644 --- a/libempathy-gtk/empathy-chat.h +++ b/libempathy-gtk/empathy-chat.h @@ -69,6 +69,7 @@ void empathy_chat_set_tp_chat (EmpathyChat *chat, McAccount * empathy_chat_get_account (EmpathyChat *chat); const gchar * empathy_chat_get_name (EmpathyChat *chat); const gchar * empathy_chat_get_subject (EmpathyChat *chat); +const gchar * empathy_chat_get_tooltip (EmpathyChat *chat); EmpathyContact * empathy_chat_get_selected_contact (EmpathyChat *chat); const gchar * empathy_chat_get_id (EmpathyChat *chat); void empathy_chat_clear (EmpathyChat *chat); |