summaryrefslogtreecommitdiff
path: root/liszt/factory.c
diff options
context:
space:
mode:
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;
+}