[empathy] Add feature support for EmpathyPersonaView



commit 1337c4e6f42da41d1da84f32586f33812b8ec2b5
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Tue Aug 24 14:57:56 2010 +0100

    Add feature support for EmpathyPersonaView

 libempathy-gtk/empathy-individual-linker.c |    3 +-
 libempathy-gtk/empathy-persona-view.c      |   43 ++++++++++++++++++++++++++-
 libempathy-gtk/empathy-persona-view.h      |    9 +++++-
 3 files changed, 51 insertions(+), 4 deletions(-)
---
diff --git a/libempathy-gtk/empathy-individual-linker.c b/libempathy-gtk/empathy-individual-linker.c
index 9ebb471..2729790 100644
--- a/libempathy-gtk/empathy-individual-linker.c
+++ b/libempathy-gtk/empathy-individual-linker.c
@@ -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),
diff --git a/libempathy-gtk/empathy-persona-view.c b/libempathy-gtk/empathy-persona-view.c
index 04777b1..44ea825 100644
--- a/libempathy-gtk/empathy-persona-view.c
+++ b/libempathy-gtk/empathy-persona-view.c
@@ -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);
@@ -312,6 +315,17 @@ text_cell_data_func (GtkTreeViewColumn *tree_column,
 }
 
 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)
 {
   EmpathyPersonaViewPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (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);
 }
 
 /**
diff --git a/libempathy-gtk/empathy-persona-view.h b/libempathy-gtk/empathy-persona-view.h
index 11fe039..c7ba61d 100644
--- a/libempathy-gtk/empathy-persona-view.h
+++ b/libempathy-gtk/empathy-persona-view.h
@@ -36,6 +36,12 @@
 
 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);
 



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