aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-individual-view.c
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2010-08-24 19:57:37 +0800
committerPhilip Withnall <philip.withnall@collabora.co.uk>2010-08-27 17:23:48 +0800
commit5b5f330cef05c8ebaa5ded6c74992910d7d85999 (patch)
tree407e6bdc19124e7f6896dc5a269457977b3c887d /libempathy-gtk/empathy-individual-view.c
parenta1aea4b698a537c046e53215d2a64259b97cd935 (diff)
downloadgsoc2013-empathy-5b5f330cef05c8ebaa5ded6c74992910d7d85999.tar
gsoc2013-empathy-5b5f330cef05c8ebaa5ded6c74992910d7d85999.tar.gz
gsoc2013-empathy-5b5f330cef05c8ebaa5ded6c74992910d7d85999.tar.bz2
gsoc2013-empathy-5b5f330cef05c8ebaa5ded6c74992910d7d85999.tar.lz
gsoc2013-empathy-5b5f330cef05c8ebaa5ded6c74992910d7d85999.tar.xz
gsoc2013-empathy-5b5f330cef05c8ebaa5ded6c74992910d7d85999.tar.zst
gsoc2013-empathy-5b5f330cef05c8ebaa5ded6c74992910d7d85999.zip
Add an EmpathyIndividualView feature for changing Individuals' groups
This separates drag and drop support from changing groups, so that EmpathyIndividualView instances (such as the one in the linking dialogue) may support dragging and dropping Individuals to and from another tree view, but not support dragging them between groups inside the EmpathyIndividualView instance. Helps: bgo#627715
Diffstat (limited to 'libempathy-gtk/empathy-individual-view.c')
-rw-r--r--libempathy-gtk/empathy-individual-view.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index 926f4ddf7..245ea1643 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -293,8 +293,14 @@ individual_view_contact_drag_received (GtkWidget *self,
if (!group_can_be_modified (new_group, new_group_is_fake, TRUE))
goto finished;
- /* Get source group information. */
- if (priv->drag_row)
+ /* Get source group information iff the view has the FEATURE_GROUPS_CHANGE
+ * feature. Otherwise, we just add the dropped contact to whichever group
+ * they were dropped in, and don't remove them from their old group. This
+ * allows for Individual views which shouldn't allow Individuals to have
+ * their groups changed, and also for dragging Individuals between Individual
+ * views. */
+ if ((priv->view_features & EMPATHY_INDIVIDUAL_VIEW_FEATURE_GROUPS_CHANGE) &&
+ priv->drag_row != NULL)
{
source_path = gtk_tree_row_reference_get_path (priv->drag_row);
if (source_path)
@@ -304,13 +310,20 @@ individual_view_contact_drag_received (GtkWidget *self,
NULL, &old_group_is_fake);
gtk_tree_path_free (source_path);
}
- }
- if (!group_can_be_modified (old_group, old_group_is_fake, FALSE))
- goto finished;
+ if (!group_can_be_modified (old_group, old_group_is_fake, FALSE))
+ goto finished;
- if (!tp_strdiff (old_group, new_group))
- goto finished;
+ if (!tp_strdiff (old_group, new_group))
+ goto finished;
+ }
+ else if (priv->drag_row != NULL)
+ {
+ /* We don't allow changing Individuals' groups, and this Individual was
+ * dragged from another group in *this* Individual view, so we disallow
+ * the drop. */
+ goto finished;
+ }
/* XXX: for contacts, we used to ensure the account, create the contact
* factory, and then wait on the contacts. But they should already be
@@ -503,7 +516,9 @@ individual_view_drag_motion (GtkWidget *widget,
target = gtk_drag_dest_find_target (widget, context, priv->file_targets);
gtk_tree_model_get_iter (model, &iter, path);
- if (target == GDK_NONE)
+ if (target == GDK_NONE &&
+ (priv->view_features & EMPATHY_INDIVIDUAL_VIEW_FEATURE_GROUPS_CHANGE ||
+ priv->drag_row == NULL))
{
/* If target == GDK_NONE, then we don't have a target that can be
dropped on a contact. This means a contact drag. If we're
@@ -511,6 +526,11 @@ individual_view_drag_motion (GtkWidget *widget,
we're pointing to is in a group, highlight that. Otherwise,
set the drag position to before the first row for a drag into
the "non-group" at the top.
+ We only highlight things if the contact is from a different Individual
+ view, or if this Individual view has FEATURE_GROUPS_CHANGE. This
+ prevents highlighting in Individual views which don't have
+ FEATURE_GROUPS_CHANGE, but do have FEATURE_CONTACT_DRAG and
+ FEATURE_CONTACT_DROP.
*/
GtkTreeIter group_iter;
gboolean is_group;
@@ -543,7 +563,7 @@ individual_view_drag_motion (GtkWidget *widget,
group_path, GTK_TREE_VIEW_DROP_BEFORE);
}
}
- else
+ else if (target != GDK_NONE)
{
/* This is a file drag, and it can only be dropped on contacts,
* not groups.