diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-08-24 19:57:37 +0800 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-08-27 17:23:48 +0800 |
commit | 5b5f330cef05c8ebaa5ded6c74992910d7d85999 (patch) | |
tree | 407e6bdc19124e7f6896dc5a269457977b3c887d | |
parent | a1aea4b698a537c046e53215d2a64259b97cd935 (diff) | |
download | gsoc2013-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
-rw-r--r-- | libempathy-gtk/empathy-individual-view.c | 38 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-view.h | 15 |
2 files changed, 38 insertions, 15 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. diff --git a/libempathy-gtk/empathy-individual-view.h b/libempathy-gtk/empathy-individual-view.h index 4a581c35c..6a65c7efa 100644 --- a/libempathy-gtk/empathy-individual-view.h +++ b/libempathy-gtk/empathy-individual-view.h @@ -53,12 +53,15 @@ typedef enum EMPATHY_INDIVIDUAL_VIEW_FEATURE_GROUPS_SAVE = 1 << 0, EMPATHY_INDIVIDUAL_VIEW_FEATURE_GROUPS_RENAME = 1 << 1, EMPATHY_INDIVIDUAL_VIEW_FEATURE_GROUPS_REMOVE = 1 << 2, - EMPATHY_INDIVIDUAL_VIEW_FEATURE_CONTACT_REMOVE = 1 << 3, - EMPATHY_INDIVIDUAL_VIEW_FEATURE_CONTACT_DROP = 1 << 4, - EMPATHY_INDIVIDUAL_VIEW_FEATURE_CONTACT_DRAG = 1 << 5, - EMPATHY_INDIVIDUAL_VIEW_FEATURE_CONTACT_TOOLTIP = 1 << 6, - EMPATHY_INDIVIDUAL_VIEW_FEATURE_FILE_DROP = 1 << 7, - EMPATHY_INDIVIDUAL_VIEW_FEATURE_ALL = (1 << 8) - 1, + /* NOTE: For this to behave as expected, FEATURE_CONTACT_DRAG and + * FEATURE_CONTACT_DROP should also be specified. */ + EMPATHY_INDIVIDUAL_VIEW_FEATURE_GROUPS_CHANGE = 1 << 3, + EMPATHY_INDIVIDUAL_VIEW_FEATURE_CONTACT_REMOVE = 1 << 4, + EMPATHY_INDIVIDUAL_VIEW_FEATURE_CONTACT_DROP = 1 << 5, + EMPATHY_INDIVIDUAL_VIEW_FEATURE_CONTACT_DRAG = 1 << 6, + EMPATHY_INDIVIDUAL_VIEW_FEATURE_CONTACT_TOOLTIP = 1 << 7, + EMPATHY_INDIVIDUAL_VIEW_FEATURE_FILE_DROP = 1 << 8, + EMPATHY_INDIVIDUAL_VIEW_FEATURE_ALL = (1 << 9) - 1, } EmpathyIndividualViewFeatureFlags; struct _EmpathyIndividualView |