diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-01-25 00:33:33 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-01-25 00:33:33 +0800 |
commit | a687b7c513d3bb967781f17dc5d247161bcffd8c (patch) | |
tree | 116b335b3c4fe96ddd09c64e9aa382516168af03 /libempathy-gtk | |
parent | ff21a5f6bfedae8ca32ac871ccad5c106e831b28 (diff) | |
download | gsoc2013-empathy-a687b7c513d3bb967781f17dc5d247161bcffd8c.tar gsoc2013-empathy-a687b7c513d3bb967781f17dc5d247161bcffd8c.tar.gz gsoc2013-empathy-a687b7c513d3bb967781f17dc5d247161bcffd8c.tar.bz2 gsoc2013-empathy-a687b7c513d3bb967781f17dc5d247161bcffd8c.tar.lz gsoc2013-empathy-a687b7c513d3bb967781f17dc5d247161bcffd8c.tar.xz gsoc2013-empathy-a687b7c513d3bb967781f17dc5d247161bcffd8c.tar.zst gsoc2013-empathy-a687b7c513d3bb967781f17dc5d247161bcffd8c.zip |
Remove EmpathyPresence object and have "presence" and "presence-message" properties directly in EmpathyContact
svn path=/trunk/; revision=601
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-chat-window.c | 10 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-store.c | 36 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-widget.c | 3 | ||||
-rw-r--r-- | libempathy-gtk/empathy-presence-chooser.c | 16 | ||||
-rw-r--r-- | libempathy-gtk/empathy-presence-chooser.h | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-status-icon.c | 4 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 25 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.h | 4 |
8 files changed, 35 insertions, 65 deletions
diff --git a/libempathy-gtk/empathy-chat-window.c b/libempathy-gtk/empathy-chat-window.c index 5acddc1e6..444616039 100644 --- a/libempathy-gtk/empathy-chat-window.c +++ b/libempathy-gtk/empathy-chat-window.c @@ -781,21 +781,21 @@ chat_window_update_menu (EmpathyChatWindow *window) chat_window_show_contacts_toggled_cb, window); } else { - EmpathyPrivateChat *chat; - EmpathyContact *contact; - EmpathyPresence *presence; + EmpathyPrivateChat *chat; + EmpathyContact *contact; + McPresence presence; chat = EMPATHY_PRIVATE_CHAT (priv->current_chat); /* Show / Hide widgets */ gtk_widget_hide (priv->menu_room); - /* presence==NULL means this contact refuses to send us his + /* Unset presence means this contact refuses to send us his * presence. By adding the contact we ask the contact to accept * to send his presence. */ contact = empathy_private_chat_get_contact (chat); presence = empathy_contact_get_presence (contact); - if (!presence) { + if (presence == MC_PRESENCE_UNSET) { gtk_widget_show (priv->menu_conv_add_contact); } else { gtk_widget_hide (priv->menu_conv_add_contact); diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c index bd5e9bc5e..7cabea78f 100644 --- a/libempathy-gtk/empathy-contact-list-store.c +++ b/libempathy-gtk/empathy-contact-list-store.c @@ -820,6 +820,9 @@ contact_list_store_members_changed_cb (EmpathyContactList *list_iface, g_signal_connect (contact, "notify::presence", G_CALLBACK (contact_list_store_contact_updated_cb), store); + g_signal_connect (contact, "notify::presence-message", + G_CALLBACK (contact_list_store_contact_updated_cb), + store); g_signal_connect (contact, "notify::name", G_CALLBACK (contact_list_store_contact_updated_cb), store); @@ -1351,8 +1354,8 @@ contact_list_store_state_sort_func (GtkTreeModel *model, gint ret_val = 0; gchar *name_a, *name_b; gboolean is_separator_a, is_separator_b; - EmpathyContact *contact_a, *contact_b; - EmpathyPresence *presence_a, *presence_b; + EmpathyContact *contact_a, *contact_b; + guint presence_a, presence_b; gtk_tree_model_get (model, iter_a, EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name_a, @@ -1389,32 +1392,17 @@ contact_list_store_state_sort_func (GtkTreeModel *model, * the presences. */ presence_a = empathy_contact_get_presence (EMPATHY_CONTACT (contact_a)); + presence_a = contact_list_store_ordered_presence (presence_a); presence_b = empathy_contact_get_presence (EMPATHY_CONTACT (contact_b)); + presence_b = contact_list_store_ordered_presence (presence_b); - if (!presence_a && presence_b) { - ret_val = 1; - } else if (presence_a && !presence_b) { + if (presence_a < presence_b) { ret_val = -1; - } else if (!presence_a && !presence_b) { - /* Both offline, sort by name */ - ret_val = g_utf8_collate (name_a, name_b); + } else if (presence_a > presence_b) { + ret_val = 1; } else { - guint state_a, state_b; - - state_a = empathy_presence_get_state (presence_a); - state_b = empathy_presence_get_state (presence_b); - - state_a = contact_list_store_ordered_presence (state_a); - state_b = contact_list_store_ordered_presence (state_b); - - if (state_a < state_b) { - ret_val = -1; - } else if (state_a > state_b) { - ret_val = 1; - } else { - /* Fallback: compare by name */ - ret_val = g_utf8_collate (name_a, name_b); - } + /* Fallback: compare by name */ + ret_val = g_utf8_collate (name_a, name_b); } free_and_out: diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index a03571d9a..c290ef6a3 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -429,6 +429,9 @@ contact_widget_contact_update (EmpathyContactWidget *information) g_signal_connect_swapped (information->contact, "notify::presence", G_CALLBACK (contact_widget_presence_notify_cb), information); + g_signal_connect_swapped (information->contact, "notify::presence-message", + G_CALLBACK (contact_widget_presence_notify_cb), + information); g_signal_connect_swapped (information->contact, "notify::avatar", G_CALLBACK (contact_widget_avatar_notify_cb), information); diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index c64962afa..e543a5f1f 100644 --- a/libempathy-gtk/empathy-presence-chooser.c +++ b/libempathy-gtk/empathy-presence-chooser.c @@ -381,7 +381,7 @@ presence_chooser_scroll_event_cb (EmpathyPresenceChooser *chooser, /* If we didn't get any match at all, it means the last state * was a custom one. Just switch to the first one. */ - status = empathy_presence_state_get_default_status (states[0]); + status = empathy_presence_get_default_message (states[0]); presence_chooser_reset_scroll_timeout (chooser); empathy_idle_set_presence (priv->idle, states[0], status); @@ -404,7 +404,7 @@ presence_chooser_get_presets (EmpathyPresenceChooser *chooser) StateAndStatus *sas; const gchar *status; - status = empathy_presence_state_get_default_status (states[i]); + status = empathy_presence_get_default_message (states[i]); sas = presence_chooser_state_and_status_new (states[i], status); list = g_list_prepend (list, sas); @@ -455,7 +455,7 @@ presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser) } gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), - empathy_icon_name_for_presence_state (state), + empathy_icon_name_for_presence (state), GTK_ICON_SIZE_MENU); on = !on; @@ -500,7 +500,7 @@ presence_chooser_flash_stop (EmpathyPresenceChooser *chooser, } gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), - empathy_icon_name_for_presence_state (state), + empathy_icon_name_for_presence (state), GTK_ICON_SIZE_MENU); priv->last_state = state; @@ -665,7 +665,7 @@ empathy_presence_chooser_create_menu (void) for (i = 0; i < G_N_ELEMENTS (states); i += 2) { GList *list, *l; - status = empathy_presence_state_get_default_status (states[i]); + status = empathy_presence_get_default_message (states[i]); presence_chooser_menu_add_item (menu, status, states[i]); @@ -714,7 +714,7 @@ presence_chooser_menu_add_item (GtkWidget *menu, const gchar *icon_name; item = gtk_image_menu_item_new_with_label (str); - icon_name = empathy_icon_name_for_presence_state (state); + icon_name = empathy_icon_name_for_presence (state); g_signal_connect (item, "activate", G_CALLBACK (presence_chooser_noncustom_activate_cb), @@ -891,8 +891,8 @@ presence_chooser_dialog_setup (CustomMessageDialog *dialog) gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, - COL_ICON, empathy_icon_name_for_presence_state (states[i]), - COL_LABEL, empathy_presence_state_get_default_status (states[i]), + COL_ICON, empathy_icon_name_for_presence (states[i]), + COL_LABEL, empathy_presence_get_default_message (states[i]), COL_PRESENCE, states[i], -1); } diff --git a/libempathy-gtk/empathy-presence-chooser.h b/libempathy-gtk/empathy-presence-chooser.h index 8a9349620..a04458d83 100644 --- a/libempathy-gtk/empathy-presence-chooser.h +++ b/libempathy-gtk/empathy-presence-chooser.h @@ -27,8 +27,6 @@ #include <gtk/gtk.h> -#include <libempathy/empathy-presence.h> - G_BEGIN_DECLS #define EMPATHY_TYPE_PRESENCE_CHOOSER (empathy_presence_chooser_get_type ()) diff --git a/libempathy-gtk/empathy-status-icon.c b/libempathy-gtk/empathy-status-icon.c index 9e62a1e18..0cffeb1b4 100644 --- a/libempathy-gtk/empathy-status-icon.c +++ b/libempathy-gtk/empathy-status-icon.c @@ -372,7 +372,7 @@ status_icon_idle_notify_cb (EmpathyStatusIcon *icon) if (flash_state != MC_PRESENCE_UNSET) { const gchar *icon_name; - icon_name = empathy_icon_name_for_presence_state (flash_state); + icon_name = empathy_icon_name_for_presence (flash_state); if (!priv->flash_state_event) { /* We are now flashing */ priv->flash_state_event = status_icon_event_new (icon, icon_name, NULL); @@ -429,7 +429,7 @@ status_icon_set_from_state (EmpathyStatusIcon *icon) priv = GET_PRIV (icon); state = empathy_idle_get_state (priv->idle); - icon_name = empathy_icon_name_for_presence_state (state); + icon_name = empathy_icon_name_for_presence (state); gtk_status_icon_set_from_icon_name (priv->icon, icon_name); } diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index 22a5fc2f7..0b29232bc 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -220,9 +220,9 @@ empathy_icon_name_from_account (McAccount *account) } const gchar * -empathy_icon_name_for_presence_state (McPresence state) +empathy_icon_name_for_presence (McPresence presence) { - switch (state) { + switch (presence) { case MC_PRESENCE_AVAILABLE: return EMPATHY_IMAGE_AVAILABLE; case MC_PRESENCE_DO_NOT_DISTURB: @@ -244,32 +244,15 @@ empathy_icon_name_for_presence_state (McPresence state) } const gchar * -empathy_icon_name_for_presence (EmpathyPresence *presence) -{ - McPresence state; - - g_return_val_if_fail (EMPATHY_IS_PRESENCE (presence), - EMPATHY_IMAGE_OFFLINE); - - state = empathy_presence_get_state (presence); - - return empathy_icon_name_for_presence_state (state); -} - -const gchar * empathy_icon_name_for_contact (EmpathyContact *contact) { - EmpathyPresence *presence; + McPresence presence; g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), EMPATHY_IMAGE_OFFLINE); presence = empathy_contact_get_presence (contact); - if (presence) { - return empathy_icon_name_for_presence (presence); - } - - return EMPATHY_IMAGE_UNKNOWN; + return empathy_icon_name_for_presence (presence); } GdkPixbuf * diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h index fd1f7c633..1fb29a97d 100644 --- a/libempathy-gtk/empathy-ui-utils.h +++ b/libempathy-gtk/empathy-ui-utils.h @@ -37,7 +37,6 @@ #include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-profile.h> -#include <libempathy/empathy-presence.h> #include <libempathy/empathy-contact.h> #include <libempathy/empathy-avatar.h> @@ -68,8 +67,7 @@ void empathy_glade_setup_size_group (GladeXML *gui, ...); /* Pixbufs */ const gchar * empathy_icon_name_from_account (McAccount *account); -const gchar * empathy_icon_name_for_presence_state (McPresence state); -const gchar * empathy_icon_name_for_presence (EmpathyPresence *presence); +const gchar * empathy_icon_name_for_presence (McPresence presence); const gchar * empathy_icon_name_for_contact (EmpathyContact *contact); GdkPixbuf * empathy_pixbuf_from_data (gchar *data, gsize data_size); |