Commit e2908ad8 authored by Xavier Claessens's avatar Xavier Claessens

add a favorite and tp-channel property to EmpathyChatroom

svn path=/trunk/; revision=1533
parent 209589bd
......@@ -34,6 +34,11 @@ typedef struct {
gchar *room;
gchar *name;
gboolean auto_connect;
gboolean favorite;
/* FIXME: This is crack. We should store EmapthyTpChat but can't
* as it's not created in the dispatcher. At some point it should be
* automatically created by tp-glib */
TpChannel *tp_channel;
} EmpathyChatroomPriv;
......@@ -53,6 +58,8 @@ enum {
PROP_ROOM,
PROP_NAME,
PROP_AUTO_CONNECT,
PROP_FAVORITE,
PROP_TP_CHANNEL
};
G_DEFINE_TYPE (EmpathyChatroom, empathy_chatroom, G_TYPE_OBJECT);
......@@ -98,6 +105,30 @@ empathy_chatroom_class_init (EmpathyChatroomClass *klass)
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_FAVORITE,
g_param_spec_boolean ("favorite",
"Favorite",
"TRUE if the chatroom is in user's favorite list",
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB));
g_object_class_install_property (object_class,
PROP_TP_CHANNEL,
g_param_spec_object ("tp-channel",
"TpChannel object",
"The TpChannel associated with this chatroom if we are in the"
" room. NULL otherwise.",
TP_TYPE_CHANNEL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB));
g_type_class_add_private (object_class, sizeof (EmpathyChatroomPriv));
}
......@@ -118,6 +149,12 @@ chatroom_finalize (GObject *object)
priv = GET_PRIV (object);
if (priv->tp_channel != NULL)
{
g_object_unref (priv->tp_channel);
priv->tp_channel = NULL;
}
g_object_unref (priv->account);
g_free (priv->room);
g_free (priv->name);
......@@ -148,6 +185,12 @@ chatroom_get_property (GObject *object,
case PROP_AUTO_CONNECT:
g_value_set_boolean (value, priv->auto_connect);
break;
case PROP_FAVORITE:
g_value_set_boolean (value, priv->favorite);
break;
case PROP_TP_CHANNEL:
g_value_set_object (value, priv->tp_channel);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
......@@ -181,6 +224,17 @@ chatroom_set_property (GObject *object,
empathy_chatroom_set_auto_connect (EMPATHY_CHATROOM (object),
g_value_get_boolean (value));
break;
case PROP_FAVORITE:
priv->favorite = g_value_get_boolean (value);
break;
case PROP_TP_CHANNEL:
if (priv->tp_channel != NULL)
{
g_object_unref (priv->tp_channel);
}
priv->tp_channel = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment