summaryrefslogtreecommitdiff
path: root/liszt/factory.c
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2010-12-14 12:52:28 +0000
committerJonny Lamb <jonnylamb@gnome.org>2010-12-15 09:30:47 +0000
commitec163cb6457b5b5162f12a6a3405e63f71b671a1 (patch)
treea8c725592b5ecfbeb19fc3feb505804d5d554455 /liszt/factory.c
parent275aa2505465bd2f1c5cf02427219a6ae54dfe93 (diff)
liszt: add
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'liszt/factory.c')
-rw-r--r--liszt/factory.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/liszt/factory.c b/liszt/factory.c
new file mode 100644
index 000000000..9b17f6201
--- /dev/null
+++ b/liszt/factory.c
@@ -0,0 +1,85 @@
+#include "factory.h"
+#include "contact-view.h"
+
+static void item_factory_init (gpointer g_iface, gpointer data);
+
+G_DEFINE_TYPE_WITH_CODE (LolFactory, lol_factory, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (MX_TYPE_ITEM_FACTORY, item_factory_init))
+
+struct _LolFactoryPrivate
+{
+ LolContactView *selected;
+};
+
+static void
+lol_factory_init (LolFactory *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, LOL_TYPE_FACTORY,
+ LolFactoryPrivate);
+}
+
+static void
+lol_factory_class_init (LolFactoryClass *cls)
+{
+ g_type_class_add_private (cls, sizeof (LolFactoryPrivate));
+}
+
+LolFactory *
+lol_factory_new (void)
+{
+ return g_object_new (LOL_TYPE_FACTORY,
+ NULL);
+}
+
+static void
+selected_cb (LolContactView *view,
+ gboolean status,
+ LolFactory *self)
+{
+ LolFactoryPrivate *priv = self->priv;
+
+ /* current selected contact has been de-selected */
+ if (priv->selected == view && !status)
+ {
+ priv->selected = NULL;
+ return;
+ }
+
+ /* unselect the curently selected contact */
+ if (priv->selected != NULL)
+ lol_contact_view_toggle_selected (LOL_CONTACT_VIEW (priv->selected));
+
+ priv->selected = view;
+}
+
+static gboolean
+button_press_event_cb (ClutterActor *actor,
+ ClutterEvent *event,
+ LolFactory *self)
+{
+ lol_contact_view_toggle_selected (LOL_CONTACT_VIEW (actor));
+
+ return TRUE;
+}
+
+static ClutterActor *
+create (MxItemFactory *factory)
+{
+ ClutterActor *out = CLUTTER_ACTOR (lol_contact_view_new ());
+
+ g_signal_connect (out, "button-press-event",
+ G_CALLBACK (button_press_event_cb), factory);
+ g_signal_connect (out, "selected",
+ G_CALLBACK (selected_cb), factory);
+
+ return out;
+}
+
+static void
+item_factory_init (gpointer g_iface,
+ gpointer data G_GNUC_UNUSED)
+{
+ MxItemFactoryIface *iface = g_iface;
+
+ iface->create = create;
+}