aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-05-31 03:15:31 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-05-31 04:15:42 +0800
commit327b8e56ecbaca67d550802f2fac741a78d81eb8 (patch)
tree62b8a9f51ecdcbfeae7dcdef81c4420d65a7aedc /libempathy-gtk
parentf93b95e549591cc8302d894e44641f42751b7f67 (diff)
downloadgsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar.gz
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar.bz2
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar.lz
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar.xz
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.tar.zst
gsoc2013-empathy-327b8e56ecbaca67d550802f2fac741a78d81eb8.zip
Remove usage of McPresence as much as possible
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-contact-list-store.c36
-rw-r--r--libempathy-gtk/empathy-presence-chooser.c95
-rw-r--r--libempathy-gtk/empathy-status-preset-dialog.c20
-rw-r--r--libempathy-gtk/empathy-ui-utils.c23
-rw-r--r--libempathy-gtk/empathy-ui-utils.h2
5 files changed, 73 insertions, 103 deletions
diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c
index a264d9ff7..8e3b7b34c 100644
--- a/libempathy-gtk/empathy-contact-list-store.c
+++ b/libempathy-gtk/empathy-contact-list-store.c
@@ -1309,28 +1309,6 @@ contact_list_store_get_group (EmpathyContactListStore *store,
}
}
-static guint
-contact_list_store_ordered_presence (McPresence state)
-{
- switch (state) {
- case MC_PRESENCE_UNSET:
- case MC_PRESENCE_OFFLINE:
- return 5;
- case MC_PRESENCE_AVAILABLE:
- return 0;
- case MC_PRESENCE_AWAY:
- return 2;
- case MC_PRESENCE_EXTENDED_AWAY:
- return 3;
- case MC_PRESENCE_HIDDEN:
- return 4;
- case MC_PRESENCE_DO_NOT_DISTURB:
- return 1;
- default:
- g_return_val_if_reached (6);
- }
-}
-
static gint
contact_list_store_state_sort_func (GtkTreeModel *model,
GtkTreeIter *iter_a,
@@ -1341,7 +1319,6 @@ contact_list_store_state_sort_func (GtkTreeModel *model,
gchar *name_a, *name_b;
gboolean is_separator_a, is_separator_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,
@@ -1377,16 +1354,11 @@ contact_list_store_state_sort_func (GtkTreeModel *model,
/* If we managed to get this far, we can start looking at
* 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);
+ ret_val = tp_connection_presence_type_cmp_availability (
+ empathy_contact_get_presence (EMPATHY_CONTACT (contact_a)),
+ empathy_contact_get_presence (EMPATHY_CONTACT (contact_b)));
- if (presence_a < presence_b) {
- ret_val = -1;
- } else if (presence_a > presence_b) {
- ret_val = 1;
- } else {
+ if (ret_val == 0) {
/* Fallback: compare by name */
ret_val = g_utf8_collate (name_a, name_b);
}
diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c
index 17b39c07f..4fd524e64 100644
--- a/libempathy-gtk/empathy-presence-chooser.c
+++ b/libempathy-gtk/empathy-presence-chooser.c
@@ -34,7 +34,6 @@
#include <gdk/gdkkeysyms.h>
#include <telepathy-glib/util.h>
-#include <libmissioncontrol/mc-enum-types.h>
#include <libempathy/empathy-idle.h>
#include <libempathy/empathy-utils.h>
@@ -105,36 +104,40 @@ typedef struct {
int block_changed;
guint focus_out_idle_source;
- McPresence state;
+ TpConnectionPresenceType state;
PresenceChooserEntryType previous_type;
- McPresence flash_state_1;
- McPresence flash_state_2;
+ TpConnectionPresenceType flash_state_1;
+ TpConnectionPresenceType flash_state_2;
guint flash_timeout_id;
} EmpathyPresenceChooserPriv;
/* States to be listed in the menu.
* Each state has a boolean telling if it can have custom message */
-static guint states[] = {MC_PRESENCE_AVAILABLE, TRUE,
- MC_PRESENCE_DO_NOT_DISTURB, TRUE,
- MC_PRESENCE_AWAY, TRUE,
- MC_PRESENCE_HIDDEN, FALSE,
- MC_PRESENCE_OFFLINE, FALSE};
+static struct { TpConnectionPresenceType state;
+ gboolean customisable;
+} states[] = { { TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, TRUE } ,
+ { TP_CONNECTION_PRESENCE_TYPE_BUSY, TRUE },
+ { TP_CONNECTION_PRESENCE_TYPE_AWAY, TRUE },
+ { TP_CONNECTION_PRESENCE_TYPE_HIDDEN, FALSE },
+ { TP_CONNECTION_PRESENCE_TYPE_OFFLINE, FALSE},
+ { TP_CONNECTION_PRESENCE_TYPE_UNSET, },
+ };
static void presence_chooser_finalize (GObject *object);
static void presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser);
static gboolean presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser);
static void presence_chooser_flash_start (EmpathyPresenceChooser *chooser,
- McPresence state_1,
- McPresence state_2);
+ TpConnectionPresenceType state_1,
+ TpConnectionPresenceType state_2);
static void presence_chooser_flash_stop (EmpathyPresenceChooser *chooser,
- McPresence state);
+ TpConnectionPresenceType state);
static void presence_chooser_menu_add_item (GtkWidget *menu,
const gchar *str,
- McPresence state);
+ TpConnectionPresenceType state);
static void presence_chooser_noncustom_activate_cb (GtkWidget *item,
gpointer user_data);
-static void presence_chooser_set_state (McPresence state,
+static void presence_chooser_set_state (TpConnectionPresenceType state,
const gchar *status);
static void presence_chooser_custom_activate_cb (GtkWidget *item,
gpointer user_data);
@@ -160,7 +163,7 @@ presence_chooser_create_model (EmpathyPresenceChooser *self)
store = gtk_list_store_new (N_COLUMNS,
G_TYPE_STRING, /* COL_STATE_ICON_NAME */
- MC_TYPE_PRESENCE, /* COL_STATE */
+ G_TYPE_UINT, /* COL_STATE */
G_TYPE_STRING, /* COL_STATUS_TEXT */
G_TYPE_STRING, /* COL_DISPLAY_MARKUP */
G_TYPE_BOOLEAN, /* COL_STATUS_CUSTOMISABLE */
@@ -168,26 +171,25 @@ presence_chooser_create_model (EmpathyPresenceChooser *self)
custom_message = g_strdup_printf ("<i>%s</i>", _("Custom Message..."));
- for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
+ for (i = 0; states[i].state != TP_CONNECTION_PRESENCE_TYPE_UNSET; i++) {
GList *list, *l;
const char *status, *icon_name;
- status = empathy_presence_get_default_message (states[i]);
- icon_name = empathy_icon_name_for_presence (states[i]);
+ status = empathy_presence_get_default_message (states[i].state);
+ icon_name = empathy_icon_name_for_presence (states[i].state);
gtk_list_store_insert_with_values (store, NULL, -1,
COL_STATE_ICON_NAME, icon_name,
- COL_STATE, states[i],
+ COL_STATE, states[i].state,
COL_STATUS_TEXT, status,
COL_DISPLAY_MARKUP, status,
- COL_STATUS_CUSTOMISABLE, states[i+1],
+ COL_STATUS_CUSTOMISABLE, states[i].customisable,
COL_TYPE, ENTRY_TYPE_BUILTIN,
-1);
- if (states[i+1]) {
-
+ if (states[i].customisable) {
/* Set custom messages if wanted */
- list = empathy_status_presets_get (states[i], -1);
+ list = empathy_status_presets_get (states[i].state, -1);
list = g_list_sort (list, (GCompareFunc) g_utf8_collate);
for (l = list; l; l = l->next) {
gtk_list_store_insert_with_values (store,
@@ -279,7 +281,7 @@ static gboolean
presence_chooser_is_preset (EmpathyPresenceChooser *self)
{
EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
- McPresence state;
+ TpConnectionPresenceType state;
const char *status;
GList *presets, *l;
gboolean match = FALSE;
@@ -407,17 +409,14 @@ mc_set_custom_state (EmpathyPresenceChooser *self)
/* update the status with MC */
status = gtk_entry_get_text (GTK_ENTRY (entry));
- DEBUG ("Sending state to MC-> %s (%s)\n",
- g_enum_get_value (g_type_class_peek (MC_TYPE_PRESENCE),
- priv->state)->value_name,
- status);
+ DEBUG ("Sending state to MC-> %d (%s)\n", priv->state, status);
empathy_idle_set_presence (priv->idle, priv->state, status);
}
static void
ui_set_custom_state (EmpathyPresenceChooser *self,
- McPresence state,
+ TpConnectionPresenceType state,
const char *status)
{
EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
@@ -462,7 +461,7 @@ presence_chooser_entry_icon_release_cb (EmpathyPresenceChooser *self,
}
else {
PresenceChooserEntryType type;
- McPresence state;
+ TpConnectionPresenceType state;
const char *status;
type = presence_chooser_get_entry_type (self);
@@ -554,7 +553,7 @@ presence_chooser_changed_cb (GtkComboBox *self, gpointer user_data)
EmpathyPresenceChooserPriv *priv = GET_PRIV (self);
GtkTreeIter iter;
char *icon_name;
- McPresence new_state;
+ TpConnectionPresenceType new_state;
gboolean customisable = TRUE;
PresenceChooserEntryType type = -1;
GtkWidget *entry;
@@ -823,8 +822,8 @@ static void
presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser)
{
EmpathyPresenceChooserPriv *priv;
- McPresence state;
- McPresence flash_state;
+ TpConnectionPresenceType state;
+ TpConnectionPresenceType flash_state;
const gchar *status;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -846,7 +845,7 @@ presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser)
valid;
valid = gtk_tree_model_iter_next (model, &iter)) {
int m_type;
- McPresence m_state;
+ TpConnectionPresenceType m_state;
char *m_status;
gtk_tree_model_get (model, &iter,
@@ -892,7 +891,7 @@ presence_chooser_presence_changed_cb (EmpathyPresenceChooser *chooser)
ui_set_custom_state (chooser, state, status);
}
- if (flash_state != MC_PRESENCE_UNSET) {
+ if (flash_state != TP_CONNECTION_PRESENCE_TYPE_UNSET) {
presence_chooser_flash_start (chooser, state, flash_state);
}
else {
@@ -904,7 +903,7 @@ static gboolean
presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser)
{
EmpathyPresenceChooserPriv *priv;
- McPresence state;
+ TpConnectionPresenceType state;
static gboolean on = FALSE;
GtkWidget *entry;
@@ -929,8 +928,8 @@ presence_chooser_flash_timeout_cb (EmpathyPresenceChooser *chooser)
static void
presence_chooser_flash_start (EmpathyPresenceChooser *chooser,
- McPresence state_1,
- McPresence state_2)
+ TpConnectionPresenceType state_1,
+ TpConnectionPresenceType state_2)
{
EmpathyPresenceChooserPriv *priv;
@@ -950,7 +949,7 @@ presence_chooser_flash_start (EmpathyPresenceChooser *chooser,
static void
presence_chooser_flash_stop (EmpathyPresenceChooser *chooser,
- McPresence state)
+ TpConnectionPresenceType state)
{
EmpathyPresenceChooserPriv *priv = GET_PRIV (chooser);
GtkWidget *entry;
@@ -984,21 +983,21 @@ empathy_presence_chooser_create_menu (void)
menu = gtk_menu_new ();
- for (i = 0; i < G_N_ELEMENTS (states); i += 2) {
+ for (i = 0; states[i].state != TP_CONNECTION_PRESENCE_TYPE_UNSET; i++) {
GList *list, *l;
- status = empathy_presence_get_default_message (states[i]);
+ status = empathy_presence_get_default_message (states[i].state);
presence_chooser_menu_add_item (menu,
status,
- states[i]);
+ states[i].state);
- if (states[i+1]) {
+ if (states[i].customisable) {
/* Set custom messages if wanted */
- list = empathy_status_presets_get (states[i], 5);
+ list = empathy_status_presets_get (states[i].state, 5);
for (l = list; l; l = l->next) {
presence_chooser_menu_add_item (menu,
l->data,
- states[i]);
+ states[i].state);
}
g_list_free (list);
}
@@ -1029,7 +1028,7 @@ empathy_presence_chooser_create_menu (void)
static void
presence_chooser_menu_add_item (GtkWidget *menu,
const gchar *str,
- McPresence state)
+ TpConnectionPresenceType state)
{
GtkWidget *item;
GtkWidget *image;
@@ -1061,7 +1060,7 @@ static void
presence_chooser_noncustom_activate_cb (GtkWidget *item,
gpointer user_data)
{
- McPresence state;
+ TpConnectionPresenceType state;
const gchar *status;
status = g_object_get_data (G_OBJECT (item), "status");
@@ -1071,7 +1070,7 @@ presence_chooser_noncustom_activate_cb (GtkWidget *item,
}
static void
-presence_chooser_set_state (McPresence state,
+presence_chooser_set_state (TpConnectionPresenceType state,
const gchar *status)
{
EmpathyIdle *idle;
diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c
index b011b5db3..7ac13ad38 100644
--- a/libempathy-gtk/empathy-status-preset-dialog.c
+++ b/libempathy-gtk/empathy-status-preset-dialog.c
@@ -39,8 +39,6 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include <libmissioncontrol/mc-enum-types.h>
-
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-status-presets.h>
@@ -54,10 +52,10 @@
G_DEFINE_TYPE (EmpathyStatusPresetDialog, empathy_status_preset_dialog, GTK_TYPE_DIALOG);
-static McPresence states[] = {
- MC_PRESENCE_AVAILABLE,
- MC_PRESENCE_DO_NOT_DISTURB,
- MC_PRESENCE_AWAY
+static TpConnectionPresenceType states[] = {
+ TP_CONNECTION_PRESENCE_TYPE_AVAILABLE,
+ TP_CONNECTION_PRESENCE_TYPE_BUSY,
+ TP_CONNECTION_PRESENCE_TYPE_AWAY,
};
typedef struct _EmpathyStatusPresetDialogPriv EmpathyStatusPresetDialogPriv;
@@ -172,7 +170,7 @@ status_preset_dialog_setup_add_combobox (EmpathyStatusPresetDialog *self)
int i;
store = gtk_list_store_new (ADD_COMBO_N_COLS,
- MC_TYPE_PRESENCE, /* ADD_COMBO_STATE */
+ G_TYPE_UINT, /* ADD_COMBO_STATE */
G_TYPE_STRING, /* ADD_COMBO_ICON_NAME */
G_TYPE_STRING, /* ADD_COMBO_STATUS */
G_TYPE_STRING); /* ADD_COMBO_DEFAULT_TEXT */
@@ -222,7 +220,7 @@ status_preset_dialog_status_edited (GtkCellRendererText *renderer,
GtkTreeModel *model;
GtkTreePath *path;
GtkTreeIter iter;
- McPresence state;
+ TpConnectionPresenceType state;
char *old_status;
gboolean valid;
@@ -269,7 +267,7 @@ status_preset_dialog_setup_presets_treeview (EmpathyStatusPresetDialog *self)
GtkCellRenderer *renderer;
store = gtk_list_store_new (PRESETS_STORE_N_COLS,
- MC_TYPE_PRESENCE, /* PRESETS_STORE_STATE */
+ G_TYPE_UINT, /* PRESETS_STORE_STATE */
G_TYPE_STRING, /* PRESETS_STORE_ICON_NAME */
G_TYPE_STRING); /* PRESETS_STORE_STATUS */
@@ -315,7 +313,7 @@ status_preset_dialog_preset_remove (GtkButton *button,
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter;
- McPresence state;
+ TpConnectionPresenceType state;
char *status;
selection = gtk_tree_view_get_selection (
@@ -418,7 +416,7 @@ status_preset_dialog_add_preset (GtkWidget *widget,
GtkTreeModel *model;
GtkTreeIter iter;
GtkWidget *entry;
- McPresence state, cstate;
+ TpConnectionPresenceType state, cstate;
const char *status;
char *cstatus;
gboolean valid, match = FALSE;
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index d9f4ae0dd..3f3961fea 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -194,24 +194,25 @@ empathy_icon_name_from_account (McAccount *account)
}
const gchar *
-empathy_icon_name_for_presence (McPresence presence)
+empathy_icon_name_for_presence (TpConnectionPresenceType presence)
{
switch (presence) {
- case MC_PRESENCE_AVAILABLE:
+ case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE:
return EMPATHY_IMAGE_AVAILABLE;
- case MC_PRESENCE_DO_NOT_DISTURB:
+ case TP_CONNECTION_PRESENCE_TYPE_BUSY:
return EMPATHY_IMAGE_BUSY;
- case MC_PRESENCE_AWAY:
+ case TP_CONNECTION_PRESENCE_TYPE_AWAY:
return EMPATHY_IMAGE_AWAY;
- case MC_PRESENCE_EXTENDED_AWAY:
+ case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY:
return EMPATHY_IMAGE_EXT_AWAY;
- case MC_PRESENCE_HIDDEN:
+ case TP_CONNECTION_PRESENCE_TYPE_HIDDEN:
return EMPATHY_IMAGE_HIDDEN;
- case MC_PRESENCE_OFFLINE:
- case MC_PRESENCE_UNSET:
+ case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
+ case TP_CONNECTION_PRESENCE_TYPE_ERROR:
+ case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
return EMPATHY_IMAGE_OFFLINE;
- default:
- g_assert_not_reached ();
+ case TP_CONNECTION_PRESENCE_TYPE_UNSET:
+ return NULL;
}
return NULL;
@@ -220,7 +221,7 @@ empathy_icon_name_for_presence (McPresence presence)
const gchar *
empathy_icon_name_for_contact (EmpathyContact *contact)
{
- McPresence presence;
+ TpConnectionPresenceType presence;
g_return_val_if_fail (EMPATHY_IS_CONTACT (contact),
EMPATHY_IMAGE_OFFLINE);
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index c80c79e8c..0b5b17f28 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -77,7 +77,7 @@ GtkWidget *empathy_builder_unref_and_keep_widget (GtkBuilder *gui,
/* Pixbufs */
const gchar * empathy_icon_name_from_account (McAccount *account);
-const gchar * empathy_icon_name_for_presence (McPresence presence);
+const gchar * empathy_icon_name_for_presence (TpConnectionPresenceType presence);
const gchar * empathy_icon_name_for_contact (EmpathyContact *contact);
GdkPixbuf * empathy_pixbuf_from_data (gchar *data,
gsize data_size);