]> git.0d.be Git - empathy.git/commitdiff
Add feature support for EmpathyPersonaView
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Tue, 24 Aug 2010 13:57:56 +0000 (14:57 +0100)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Fri, 27 Aug 2010 09:23:49 +0000 (10:23 +0100)
libempathy-gtk/empathy-individual-linker.c
libempathy-gtk/empathy-persona-view.c
libempathy-gtk/empathy-persona-view.h

index 9ebb4718b4fcadb1b0e6fcfb3e8190bdb2581c26..2729790465e549599c5d88ee7a40280dc27517f8 100644 (file)
@@ -322,7 +322,8 @@ set_up (EmpathyIndividualLinker *self)
 
   priv->persona_store = empathy_persona_store_new (priv->new_individual);
   empathy_persona_store_set_show_protocols (priv->persona_store, TRUE);
-  persona_view = empathy_persona_view_new (priv->persona_store);
+  persona_view = empathy_persona_view_new (priv->persona_store,
+      EMPATHY_PERSONA_VIEW_FEATURE_NONE);
   empathy_persona_view_set_show_offline (persona_view, TRUE);
 
   gtk_container_add (GTK_CONTAINER (scrolled_window),
index 04777b1b6c2e5d1b41b92c9c0e7b308fec5df0b3..44ea8256ad2b275d04920f137a356b06b5698fcb 100644 (file)
@@ -44,6 +44,7 @@
 #include "empathy-images.h"
 #include "empathy-cell-renderer-text.h"
 #include "empathy-cell-renderer-activatable.h"
+#include "empathy-gtk-enum-types.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
 #include <libempathy/empathy-debug.h>
@@ -69,6 +70,7 @@ typedef struct
   GtkTreeModelFilter *filter;
   GtkWidget *tooltip_widget;
   gboolean show_offline;
+  EmpathyPersonaViewFeatureFlags features;
 } EmpathyPersonaViewPriv;
 
 enum
@@ -76,6 +78,7 @@ enum
   PROP_0,
   PROP_MODEL,
   PROP_SHOW_OFFLINE,
+  PROP_FEATURES,
 };
 
 G_DEFINE_TYPE (EmpathyPersonaView, empathy_persona_view, GTK_TYPE_TREE_VIEW);
@@ -311,6 +314,17 @@ text_cell_data_func (GtkTreeViewColumn *tree_column,
   cell_set_background (self, cell, is_active);
 }
 
+static void
+set_features (EmpathyPersonaView *self,
+    EmpathyPersonaViewFeatureFlags features)
+{
+  EmpathyPersonaViewPriv *priv = GET_PRIV (self);
+
+  priv->features = features;
+
+  g_object_notify (G_OBJECT (self), "features");
+}
+
 static void
 empathy_persona_view_init (EmpathyPersonaView *self)
 {
@@ -411,6 +425,9 @@ get_property (GObject *object,
       case PROP_SHOW_OFFLINE:
         g_value_set_boolean (value, priv->show_offline);
         break;
+      case PROP_FEATURES:
+        g_value_set_flags (value, priv->features);
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
         break;
@@ -434,6 +451,9 @@ set_property (GObject *object,
         empathy_persona_view_set_show_offline (self,
             g_value_get_boolean (value));
         break;
+      case PROP_FEATURES:
+        set_features (self, g_value_get_flags (value));
+        break;
       default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
         break;
@@ -481,12 +501,27 @@ empathy_persona_view_class_init (EmpathyPersonaViewClass *klass)
           FALSE,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  /**
+   * EmpathyPersonaStore:features:
+   *
+   * Features of the view, such as whether drag and drop is enabled.
+   */
+  g_object_class_install_property (object_class, PROP_FEATURES,
+      g_param_spec_flags ("features",
+          "Features",
+          "Flags for all enabled features.",
+          EMPATHY_TYPE_PERSONA_VIEW_FEATURE_FLAGS,
+          EMPATHY_PERSONA_VIEW_FEATURE_NONE,
+          G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
   g_type_class_add_private (object_class, sizeof (EmpathyPersonaViewPriv));
 }
 
 /**
  * empathy_persona_view_new:
  * @store: an #EmpathyPersonaStore
+ * @features: a set of flags specifying the view's functionality, or
+ * %EMPATHY_PERSONA_VIEW_FEATURE_NONE
  *
  * Create a new #EmpathyPersonaView displaying the personas in
  * #EmpathyPersonaStore.
@@ -494,11 +529,15 @@ empathy_persona_view_class_init (EmpathyPersonaViewClass *klass)
  * Return value: a new #EmpathyPersonaView
  */
 EmpathyPersonaView *
-empathy_persona_view_new (EmpathyPersonaStore *store)
+empathy_persona_view_new (EmpathyPersonaStore *store,
+    EmpathyPersonaViewFeatureFlags features)
 {
   g_return_val_if_fail (EMPATHY_IS_PERSONA_STORE (store), NULL);
 
-  return g_object_new (EMPATHY_TYPE_PERSONA_VIEW, "model", store, NULL);
+  return g_object_new (EMPATHY_TYPE_PERSONA_VIEW,
+      "model", store,
+      "features", features,
+      NULL);
 }
 
 /**
index 11fe039eb81fed122e80102336a7a29801254503..c7ba61d051d2c325b053735bba1f2104c0a00726 100644 (file)
 
 G_BEGIN_DECLS
 
+typedef enum
+{
+  EMPATHY_PERSONA_VIEW_FEATURE_NONE = 0,
+  EMPATHY_PERSONA_VIEW_FEATURE_ALL = (1 << 0) - 1,
+} EmpathyPersonaViewFeatureFlags;
+
 #define EMPATHY_TYPE_PERSONA_VIEW (empathy_persona_view_get_type ())
 #define EMPATHY_PERSONA_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
     EMPATHY_TYPE_PERSONA_VIEW, EmpathyPersonaView))
@@ -61,7 +67,8 @@ typedef struct
 
 GType empathy_persona_view_get_type (void) G_GNUC_CONST;
 
-EmpathyPersonaView *empathy_persona_view_new (EmpathyPersonaStore *store);
+EmpathyPersonaView *empathy_persona_view_new (EmpathyPersonaStore *store,
+    EmpathyPersonaViewFeatureFlags features);
 
 FolksPersona *empathy_persona_view_dup_selected (EmpathyPersonaView *self);