empathy r1675 - trunk/libempathy-gtk



Author: xclaesse
Date: Tue Nov 11 15:26:02 2008
New Revision: 1675
URL: http://svn.gnome.org/viewvc/empathy?rev=1675&view=rev

Log:
AvatarChooser: Add McAccount and EmpathyContactFactory properties

Modified:
   trunk/libempathy-gtk/empathy-avatar-chooser.c
   trunk/libempathy-gtk/empathy-avatar-chooser.h
   trunk/libempathy-gtk/empathy-contact-widget.c

Modified: trunk/libempathy-gtk/empathy-avatar-chooser.c
==============================================================================
--- trunk/libempathy-gtk/empathy-avatar-chooser.c	(original)
+++ trunk/libempathy-gtk/empathy-avatar-chooser.c	Tue Nov 11 15:26:02 2008
@@ -43,6 +43,9 @@
 
 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAvatarChooser)
 typedef struct {
+	EmpathyContactFactory *contact_factory;
+	McAccount             *account;
+
 	gchar *image_data;
 	gsize  image_data_size;
 	gchar *mime_type;
@@ -84,6 +87,12 @@
 	LAST_SIGNAL
 };
 
+enum {
+	PROP_0,
+	PROP_CONTACT_FACTORY,
+	PROP_ACCOUNT
+};
+
 static guint signals [LAST_SIGNAL];
 
 G_DEFINE_TYPE (EmpathyAvatarChooser, empathy_avatar_chooser, GTK_TYPE_BUTTON);
@@ -102,11 +111,67 @@
 };
 
 static void
+empathy_avatar_chooser_get_property (GObject    *object,
+				     guint       param_id,
+				     GValue     *value,
+				     GParamSpec *pspec)
+{
+	EmpathyAvatarChooserPriv *priv = GET_PRIV (object);
+
+	switch (param_id) {
+	case PROP_CONTACT_FACTORY:
+		g_assert (priv->contact_factory != NULL);
+		g_value_set_object (value, priv->contact_factory);
+		break;
+	case PROP_ACCOUNT:
+		g_value_set_object (value, priv->account);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	}
+}
+
+static void
+empathy_avatar_chooser_set_property (GObject      *object,
+				     guint         param_id,
+				     const GValue *value,
+				     GParamSpec   *pspec)
+{
+	EmpathyAvatarChooser *self = EMPATHY_AVATAR_CHOOSER (object);
+	EmpathyAvatarChooserPriv *priv = GET_PRIV (self);
+
+	switch (param_id) {
+	case PROP_CONTACT_FACTORY:
+		priv->contact_factory = g_value_get_object (value);
+
+		g_assert (priv->contact_factory != NULL);
+		g_object_ref (priv->contact_factory);
+
+		break;
+	case PROP_ACCOUNT:
+		if (priv->account)
+			g_object_unref (priv->account);
+
+		priv->account = g_value_get_object (value);
+		if (priv->account)
+			g_object_ref (priv->account);
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+		break;
+	}
+}
+
+static void
 empathy_avatar_chooser_class_init (EmpathyAvatarChooserClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	GParamSpec *param_spec;
 
 	object_class->finalize = avatar_chooser_finalize;
+	object_class->get_property = empathy_avatar_chooser_get_property;
+	object_class->set_property = empathy_avatar_chooser_set_property;
 
 	signals[CHANGED] =
 		g_signal_new ("changed",
@@ -117,6 +182,29 @@
 			      g_cclosure_marshal_VOID__VOID,
 			      G_TYPE_NONE, 0);
 
+	param_spec = g_param_spec_object ("contact-factory",
+					  "EmpathyContactFactory instance",
+					  "EmpathyContactFactory instance "
+					  "(may not be NULL)",
+					  EMPATHY_TYPE_CONTACT_FACTORY,
+					  G_PARAM_CONSTRUCT_ONLY |
+					  G_PARAM_READWRITE |
+					  G_PARAM_STATIC_STRINGS);
+	g_object_class_install_property (object_class,
+					 PROP_CONTACT_FACTORY,
+					 param_spec);
+
+	param_spec = g_param_spec_object ("account",
+					  "McAccount",
+					  "McAccount whose avatar should be "
+					  "shown and modified by this widget",
+					  MC_TYPE_ACCOUNT,
+					  G_PARAM_READWRITE |
+					  G_PARAM_STATIC_STRINGS);
+	g_object_class_install_property (object_class,
+					 PROP_ACCOUNT,
+					 param_spec);
+
 	g_type_class_add_private (object_class, sizeof (EmpathyAvatarChooserPriv));
 }
 
@@ -159,6 +247,10 @@
 
 	priv = GET_PRIV (object);
 
+	g_object_unref (priv->contact_factory);
+	if (priv->account)
+		g_object_unref (priv->account);
+
 	g_free (priv->image_data);
 	g_free (priv->mime_type);
 
@@ -542,9 +634,11 @@
 }
 
 GtkWidget *
-empathy_avatar_chooser_new (void)
+empathy_avatar_chooser_new (EmpathyContactFactory *contact_factory)
 {
-	return g_object_new (EMPATHY_TYPE_AVATAR_CHOOSER, NULL);
+	return g_object_new (EMPATHY_TYPE_AVATAR_CHOOSER,
+			     "contact-factory", contact_factory,
+			     NULL);
 }
 
 void

Modified: trunk/libempathy-gtk/empathy-avatar-chooser.h
==============================================================================
--- trunk/libempathy-gtk/empathy-avatar-chooser.h	(original)
+++ trunk/libempathy-gtk/empathy-avatar-chooser.h	Tue Nov 11 15:26:02 2008
@@ -27,6 +27,7 @@
 #include <gtk/gtkbutton.h>
 
 #include <libempathy/empathy-contact.h>
+#include <libempathy/empathy-contact-factory.h>
 
 G_BEGIN_DECLS
 
@@ -49,7 +50,7 @@
 };
 
 GType      empathy_avatar_chooser_get_type       (void);
-GtkWidget *empathy_avatar_chooser_new            (void);
+GtkWidget *empathy_avatar_chooser_new            (EmpathyContactFactory *contact_factory);
 void       empathy_avatar_chooser_set            (EmpathyAvatarChooser *chooser,
 						  EmpathyAvatar        *avatar);
 void       empathy_avatar_chooser_get_image_data (EmpathyAvatarChooser *chooser,

Modified: trunk/libempathy-gtk/empathy-contact-widget.c
==============================================================================
--- trunk/libempathy-gtk/empathy-contact-widget.c	(original)
+++ trunk/libempathy-gtk/empathy-contact-widget.c	Tue Nov 11 15:26:02 2008
@@ -497,7 +497,8 @@
 {
   if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR)
     {
-      information->widget_avatar = empathy_avatar_chooser_new ();
+      information->widget_avatar = empathy_avatar_chooser_new (
+          information->factory);
       g_signal_connect (information->widget_avatar, "changed",
             G_CALLBACK (contact_widget_avatar_changed_cb),
             information);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]