diff options
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/Makefile.am | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-roster-item.c | 149 | ||||
-rw-r--r-- | libempathy-gtk/empathy-roster-item.h | 56 |
3 files changed, 207 insertions, 0 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index d681b6d6c..ee33a60ca 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -78,6 +78,7 @@ libempathy_gtk_handwritten_source = \ empathy-password-dialog.c \ empathy-presence-chooser.c \ empathy-protocol-chooser.c \ + empathy-roster-item.c \ empathy-roster-view.c \ empathy-search-bar.c \ empathy-share-my-desktop.c \ @@ -147,6 +148,7 @@ libempathy_gtk_headers = \ empathy-password-dialog.h \ empathy-presence-chooser.h \ empathy-protocol-chooser.h \ + empathy-roster-item.h \ empathy-roster-view.h \ empathy-search-bar.h \ empathy-share-my-desktop.h \ diff --git a/libempathy-gtk/empathy-roster-item.c b/libempathy-gtk/empathy-roster-item.c new file mode 100644 index 000000000..827c1dab7 --- /dev/null +++ b/libempathy-gtk/empathy-roster-item.c @@ -0,0 +1,149 @@ +#include "config.h" + +#include "empathy-roster-item.h" + +G_DEFINE_TYPE (EmpathyRosterItem, empathy_roster_item, GTK_TYPE_BOX) + +enum +{ + PROP_INDIVIDIUAL = 1, + N_PROPS +}; + +/* +enum +{ + LAST_SIGNAL +}; + +static guint signals[LAST_SIGNAL]; +*/ + +struct _EmpathyRosterItemPriv +{ + FolksIndividual *individual; +}; + +static void +empathy_roster_item_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + EmpathyRosterItem *self = EMPATHY_ROSTER_ITEM (object); + + switch (property_id) + { + case PROP_INDIVIDIUAL: + g_value_set_object (value, self->priv->individual); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +empathy_roster_item_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + EmpathyRosterItem *self = EMPATHY_ROSTER_ITEM (object); + + switch (property_id) + { + case PROP_INDIVIDIUAL: + g_assert (self->priv->individual == NULL); /* construct only */ + self->priv->individual = g_value_dup_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +empathy_roster_item_constructed (GObject *object) +{ + EmpathyRosterItem *self = EMPATHY_ROSTER_ITEM (object); + void (*chain_up) (GObject *) = + ((GObjectClass *) empathy_roster_item_parent_class)->constructed; + + if (chain_up != NULL) + chain_up (object); + + g_assert (FOLKS_IS_INDIVIDUAL (self->priv->individual)); +} + +static void +empathy_roster_item_dispose (GObject *object) +{ + EmpathyRosterItem *self = EMPATHY_ROSTER_ITEM (object); + void (*chain_up) (GObject *) = + ((GObjectClass *) empathy_roster_item_parent_class)->dispose; + + g_clear_object (&self->priv->individual); + + if (chain_up != NULL) + chain_up (object); +} + +static void +empathy_roster_item_finalize (GObject *object) +{ + //EmpathyRosterItem *self = EMPATHY_ROSTER_ITEM (object); + void (*chain_up) (GObject *) = + ((GObjectClass *) empathy_roster_item_parent_class)->finalize; + + if (chain_up != NULL) + chain_up (object); +} + +static void +empathy_roster_item_class_init ( + EmpathyRosterItemClass *klass) +{ + GObjectClass *oclass = G_OBJECT_CLASS (klass); + GParamSpec *spec; + + oclass->get_property = empathy_roster_item_get_property; + oclass->set_property = empathy_roster_item_set_property; + oclass->constructed = empathy_roster_item_constructed; + oclass->dispose = empathy_roster_item_dispose; + oclass->finalize = empathy_roster_item_finalize; + + spec = g_param_spec_object ("individual", "Individual", + "FolksIndividual", + FOLKS_TYPE_INDIVIDUAL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (oclass, PROP_INDIVIDIUAL, spec); + + g_type_class_add_private (klass, sizeof (EmpathyRosterItemPriv)); +} + +static void +empathy_roster_item_init (EmpathyRosterItem *self) +{ + self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, + EMPATHY_TYPE_ROSTER_ITEM, EmpathyRosterItemPriv); + + gtk_widget_set_size_request (GTK_WIDGET (self), 300, 64); +} + +GtkWidget * +empathy_roster_item_new (FolksIndividual *individual) +{ + g_return_val_if_fail (FOLKS_IS_INDIVIDUAL (individual), NULL); + + return g_object_new (EMPATHY_TYPE_ROSTER_ITEM, + "individual", individual, + "spacing", 8, + NULL); +} + +FolksIndividual * +empathy_roster_item_get_individual (EmpathyRosterItem *self) +{ + return self->priv->individual; +} diff --git a/libempathy-gtk/empathy-roster-item.h b/libempathy-gtk/empathy-roster-item.h new file mode 100644 index 000000000..16923a81c --- /dev/null +++ b/libempathy-gtk/empathy-roster-item.h @@ -0,0 +1,56 @@ +#ifndef __EMPATHY_ROSTER_ITEM_H__ +#define __EMPATHY_ROSTER_ITEM_H__ + +#include <gtk/gtk.h> +#include <folks/folks.h> + +G_BEGIN_DECLS + +typedef struct _EmpathyRosterItem EmpathyRosterItem; +typedef struct _EmpathyRosterItemClass EmpathyRosterItemClass; +typedef struct _EmpathyRosterItemPriv EmpathyRosterItemPriv; + +struct _EmpathyRosterItemClass +{ + /*<private>*/ + GtkBoxClass parent_class; +}; + +struct _EmpathyRosterItem +{ + /*<private>*/ + GtkBox parent; + EmpathyRosterItemPriv *priv; +}; + +GType empathy_roster_item_get_type (void); + +/* TYPE MACROS */ +#define EMPATHY_TYPE_ROSTER_ITEM \ + (empathy_roster_item_get_type ()) +#define EMPATHY_ROSTER_ITEM(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + EMPATHY_TYPE_ROSTER_ITEM, \ + EmpathyRosterItem)) +#define EMPATHY_ROSTER_ITEM_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + EMPATHY_TYPE_ROSTER_ITEM, \ + EmpathyRosterItemClass)) +#define EMPATHY_IS_ROSTER_ITEM(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj), \ + EMPATHY_TYPE_ROSTER_ITEM)) +#define EMPATHY_IS_ROSTER_ITEM_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass), \ + EMPATHY_TYPE_ROSTER_ITEM)) +#define EMPATHY_ROSTER_ITEM_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), \ + EMPATHY_TYPE_ROSTER_ITEM, \ + EmpathyRosterItemClass)) + +GtkWidget * empathy_roster_item_new (FolksIndividual *individual); + +FolksIndividual * empathy_roster_item_get_individual (EmpathyRosterItem *self); + +G_END_DECLS + +#endif /* #ifndef __EMPATHY_ROSTER_ITEM_H__*/ |