]> git.0d.be Git - empathy.git/commitdiff
"interactive" property on EmpathyContactListView to enable/disable contect
authorXavier Claessens <xclaesse@gmail.com>
Tue, 11 Sep 2007 09:26:52 +0000 (09:26 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Tue, 11 Sep 2007 09:26:52 +0000 (09:26 +0000)
2007-09-11  Xavier Claessens  <xclaesse@gmail.com>

* libempathy-gtk/empathy-main-window.c:
* libempathy-gtk/empathy-group-chat.c:
* libempathy-gtk/empathy-contact-list-view.c:
* libempathy-gtk/empathy-contact-list-view.h:
* doc/libempathy-gtk/tmpl/empathy-contact-list-view.sgml: "interactive"
property on EmpathyContactListView to enable/disable contect menu and
action when double-click on a contact.

svn path=/trunk/; revision=297

doc/libempathy-gtk/tmpl/empathy-contact-list-view.sgml
libempathy-gtk/empathy-contact-list-view.c
libempathy-gtk/empathy-contact-list-view.h
libempathy-gtk/empathy-group-chat.c
libempathy-gtk/empathy-main-window.c

index 188033ebf619a5a4f2af9c006295fac3298c3b29..9c3aefc753d48afb13aaa04959af57fa4b572e80 100644 (file)
@@ -39,6 +39,11 @@ EmpathyContactListView
 @arg2: 
 @arg3: 
 
+<!-- ##### ARG EmpathyContactListView:interactive ##### -->
+<para>
+
+</para>
+
 <!-- ##### FUNCTION empathy_contact_list_view_new ##### -->
 <para>
 
index 8e6b2cf0981ef4cdb9e26133fd15c410d87826cb..d4b222e4d2a8448160c217addf0bf5c018bcddb8 100644 (file)
@@ -69,6 +69,7 @@ struct _EmpathyContactListViewPriv {
        EmpathyContactListStore *store;
        GtkUIManager            *ui;
        GtkTreeRowReference     *drag_row;
+       gboolean                 interactive;
 };
 
 typedef struct {
@@ -182,6 +183,7 @@ static void        contact_list_view_voip_activated            (EmpathyContactLi
 
 enum {
        PROP_0,
+       PROP_INTERACTIVE
 };
 
 static const GtkActionEntry entries[] = {
@@ -313,6 +315,14 @@ empathy_contact_list_view_class_init (EmpathyContactListViewClass *klass)
                              G_TYPE_NONE,
                              3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_STRING);
 
+       g_object_class_install_property (object_class,
+                                        PROP_INTERACTIVE,
+                                        g_param_spec_boolean ("interactive",
+                                                              "View is interactive",
+                                                              "Is the view interactive",
+                                                              FALSE,
+                                                              G_PARAM_READWRITE));
+
        g_type_class_add_private (object_class, sizeof (EmpathyContactListViewPriv));
 }
 
@@ -394,6 +404,9 @@ contact_list_view_get_property (GObject    *object,
        priv = GET_PRIV (object);
 
        switch (param_id) {
+       case PROP_INTERACTIVE:
+               g_value_set_boolean (value, priv->interactive);
+               break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
                break;
@@ -406,11 +419,15 @@ contact_list_view_set_property (GObject      *object,
                                const GValue *value,
                                GParamSpec   *pspec)
 {
+       EmpathyContactListView     *view = EMPATHY_CONTACT_LIST_VIEW (object);
        EmpathyContactListViewPriv *priv;
 
        priv = GET_PRIV (object);
 
        switch (param_id) {
+       case PROP_INTERACTIVE:
+               empathy_contact_list_view_set_interactive (view, g_value_get_boolean (value));
+               break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
                break;
@@ -432,6 +449,28 @@ empathy_contact_list_view_new (EmpathyContactListStore *store)
        return view;
 }
 
+void
+empathy_contact_list_view_set_interactive (EmpathyContactListView  *view,
+                                          gboolean                 interactive)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+
+       g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view));
+
+       priv->interactive = interactive;
+       g_object_notify (G_OBJECT (view), "interactive");
+}
+
+gboolean
+empathy_contact_list_view_get_interactive (EmpathyContactListView  *view)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), FALSE);
+
+       return priv->interactive;
+}
+
 EmpathyContact *
 empathy_contact_list_view_get_selected (EmpathyContactListView *view)
 {
@@ -1192,12 +1231,12 @@ contact_list_view_button_press_event_cb (EmpathyContactListView *view,
        gboolean                   row_exists;
        GtkWidget                 *menu;
 
-       if (event->button != 3) {
+       priv = GET_PRIV (view);
+
+       if (!priv->interactive || event->button != 3) {
                return FALSE;
        }
 
-       priv = GET_PRIV (view);
-
        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
 
@@ -1241,13 +1280,18 @@ contact_list_view_button_press_event_cb (EmpathyContactListView *view,
 
 static void
 contact_list_view_row_activated_cb (EmpathyContactListView *view,
-                                   GtkTreePath           *path,
-                                   GtkTreeViewColumn     *col,
-                                   gpointer               user_data)
+                                   GtkTreePath            *path,
+                                   GtkTreeViewColumn      *col,
+                                   gpointer                user_data)
 {
-       EmpathyContact *contact;
-       GtkTreeModel  *model;
-       GtkTreeIter    iter;
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       EmpathyContact             *contact;
+       GtkTreeModel               *model;
+       GtkTreeIter                 iter;
+
+       if (!priv->interactive) {
+               return;
+       }
 
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
 
@@ -1265,9 +1309,14 @@ contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell,
                                     const gchar                    *path_string,
                                     EmpathyContactListView         *view)
 {
-       GtkTreeModel   *model;
-       GtkTreeIter     iter;
-       EmpathyContact *contact;
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       GtkTreeModel               *model;
+       GtkTreeIter                 iter;
+       EmpathyContact             *contact;
+
+       if (!priv->interactive) {
+               return;
+       }
 
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
        if (!gtk_tree_model_get_iter_from_string (model, &iter, path_string)) {
index b9de24357229cf6992c1df88f735f52eb20fc751..c37e5c71636d887c16ad068011b62115675c0930 100644 (file)
@@ -55,6 +55,9 @@ struct _EmpathyContactListViewClass {
 
 GType                   empathy_contact_list_view_get_type           (void) G_GNUC_CONST;
 EmpathyContactListView *empathy_contact_list_view_new                (EmpathyContactListStore *store);
+void                    empathy_contact_list_view_set_interactive    (EmpathyContactListView  *view,
+                                                                     gboolean                 interactive);
+gboolean                empathy_contact_list_view_get_interactive    (EmpathyContactListView  *view);
 EmpathyContact *        empathy_contact_list_view_get_selected       (EmpathyContactListView  *view);
 gchar *                 empathy_contact_list_view_get_selected_group (EmpathyContactListView  *view);
 GtkWidget *             empathy_contact_list_view_get_contact_menu   (EmpathyContactListView  *view,
index 48439302d30cd8725d044a5a9dbf5999e6cae1a3..f3c8e8a2061c103693a189eb8d5fdc9657cefa7d 100644 (file)
@@ -529,6 +529,7 @@ group_chat_set_tp_chat (EmpathyChat    *chat,
        /* Create contact list */
        priv->store = empathy_contact_list_store_new (EMPATHY_CONTACT_LIST (priv->tp_chat));
        priv->view = empathy_contact_list_view_new (priv->store);
+       empathy_contact_list_view_set_interactive (priv->view, TRUE);
        gtk_container_add (GTK_CONTAINER (priv->scrolled_window_contacts),
                           GTK_WIDGET (priv->view));
        gtk_widget_show (GTK_WIDGET (priv->view));
index 4b89c4e67632d023cc635519c3e2413e730639a0..c021df7dd90f204ab41a853c3dbc817fd3aaeeef 100644 (file)
@@ -290,6 +290,7 @@ empathy_main_window_show (void)
        list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ());
        window->list_store = empathy_contact_list_store_new (list_iface);
        window->list_view = empathy_contact_list_view_new (window->list_store);
+       empathy_contact_list_view_set_interactive (window->list_view, TRUE);
        g_object_unref (list_iface);
 
        gtk_widget_show (GTK_WIDGET (window->list_view));