diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-08-24 21:34:00 +0800 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2010-08-27 17:23:48 +0800 |
commit | 9bee6ee28d745736a6c5c9b0cd26041575da9b73 (patch) | |
tree | ca82524e672f03fc9698133624e70de312502ded /libempathy-gtk | |
parent | 3f23b6d1c7a04cf288872cf975cdb81da1325289 (diff) | |
download | gsoc2013-empathy-9bee6ee28d745736a6c5c9b0cd26041575da9b73.tar gsoc2013-empathy-9bee6ee28d745736a6c5c9b0cd26041575da9b73.tar.gz gsoc2013-empathy-9bee6ee28d745736a6c5c9b0cd26041575da9b73.tar.bz2 gsoc2013-empathy-9bee6ee28d745736a6c5c9b0cd26041575da9b73.tar.lz gsoc2013-empathy-9bee6ee28d745736a6c5c9b0cd26041575da9b73.tar.xz gsoc2013-empathy-9bee6ee28d745736a6c5c9b0cd26041575da9b73.tar.zst gsoc2013-empathy-9bee6ee28d745736a6c5c9b0cd26041575da9b73.zip |
Add an EmpathyIndividualView::drag-individual-received signal
Subclasses or users of the widget can then override this and stop the signal
emission to do new and interesting things with dropped Individuals, rather
than just changing their groups.
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-individual-view.c | 84 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-view.h | 6 |
2 files changed, 55 insertions, 35 deletions
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c index 63b689687..7899acce8 100644 --- a/libempathy-gtk/empathy-individual-view.c +++ b/libempathy-gtk/empathy-individual-view.c @@ -141,7 +141,7 @@ static GdkAtom drag_atoms_source[G_N_ELEMENTS (drag_types_source)]; enum { - DRAG_CONTACT_RECEIVED, + DRAG_INDIVIDUAL_RECEIVED, LAST_SIGNAL }; @@ -341,6 +341,29 @@ individual_view_contact_drag_received (GtkWidget *self, /* FIXME: We should probably wait for the cb before calling * gtk_drag_finish */ + /* Emit a signal notifying of the drag. We change the Individual's groups in + * the default signal handler. */ + g_signal_emit (self, signals[DRAG_INDIVIDUAL_RECEIVED], 0, + gdk_drag_context_get_selected_action (context), individual, new_group, + old_group); + + retval = TRUE; + +finished: + tp_clear_object (&manager); + g_free (old_group); + g_free (new_group); + + return retval; +} + +static void +real_drag_individual_received_cb (EmpathyIndividualView *self, + GdkDragAction action, + FolksIndividual *individual, + const gchar *new_group, + const gchar *old_group) +{ DEBUG ("individual %s dragged from '%s' to '%s'", folks_individual_get_id (individual), old_group, new_group); @@ -348,41 +371,29 @@ individual_view_contact_drag_received (GtkWidget *self, { /* Mark contact as favourite */ folks_favourite_set_is_favourite (FOLKS_FAVOURITE (individual), TRUE); + return; } - else - { - if (!tp_strdiff (old_group, EMPATHY_INDIVIDUAL_STORE_FAVORITE)) - { - /* Remove contact as favourite */ - folks_favourite_set_is_favourite (FOLKS_FAVOURITE (individual), - FALSE); - /* Don't try to remove it */ - old_group = NULL; - } - - if (new_group != NULL) - { - folks_groups_change_group (FOLKS_GROUPS (individual), new_group, TRUE, - groups_change_group_cb, NULL); - } + if (!tp_strdiff (old_group, EMPATHY_INDIVIDUAL_STORE_FAVORITE)) + { + /* Remove contact as favourite */ + folks_favourite_set_is_favourite (FOLKS_FAVOURITE (individual), FALSE); - if (old_group != NULL && - gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE) - { - folks_groups_change_group (FOLKS_GROUPS (individual), old_group, - FALSE, groups_change_group_cb, NULL); - } + /* Don't try to remove it */ + old_group = NULL; } - retval = TRUE; - -finished: - tp_clear_object (&manager); - g_free (old_group); - g_free (new_group); + if (new_group != NULL) + { + folks_groups_change_group (FOLKS_GROUPS (individual), new_group, TRUE, + groups_change_group_cb, NULL); + } - return retval; + if (old_group != NULL && action == GDK_ACTION_MOVE) + { + folks_groups_change_group (FOLKS_GROUPS (individual), old_group, + FALSE, groups_change_group_cb, NULL); + } } static gboolean @@ -1893,14 +1904,17 @@ empathy_individual_view_class_init (EmpathyIndividualViewClass *klass) * won't be called. */ tree_view_class->row_activated = individual_view_row_activated; - signals[DRAG_CONTACT_RECEIVED] = - g_signal_new ("drag-contact-received", + klass->drag_individual_received = real_drag_individual_received_cb; + + signals[DRAG_INDIVIDUAL_RECEIVED] = + g_signal_new ("drag-individual-received", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, - 0, + G_STRUCT_OFFSET (EmpathyIndividualViewClass, drag_individual_received), NULL, NULL, - _empathy_gtk_marshal_VOID__OBJECT_STRING_STRING, - G_TYPE_NONE, 3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_STRING); + _empathy_gtk_marshal_VOID__UINT_OBJECT_STRING_STRING, + G_TYPE_NONE, 4, G_TYPE_UINT, FOLKS_TYPE_INDIVIDUAL, + G_TYPE_STRING, G_TYPE_STRING); g_object_class_install_property (object_class, PROP_STORE, diff --git a/libempathy-gtk/empathy-individual-view.h b/libempathy-gtk/empathy-individual-view.h index a87848408..babe0a939 100644 --- a/libempathy-gtk/empathy-individual-view.h +++ b/libempathy-gtk/empathy-individual-view.h @@ -73,6 +73,12 @@ struct _EmpathyIndividualView struct _EmpathyIndividualViewClass { GtkTreeViewClass parent_class; + + void (* drag_individual_received) (EmpathyIndividualView *self, + GdkDragAction action, + FolksIndividual *individual, + const gchar *new_group, + const gchar *old_group); }; GType empathy_individual_view_get_type (void) G_GNUC_CONST; |