static void contact_list_view_group_remove_activate_cb (GtkMenuItem *menuitem, EmpathyContactListView *view) { EmpathyContactListViewPriv *priv = GET_PRIV (view); gchar *group; group = empathy_contact_list_view_get_selected_group (view); if (group) { gchar *text; GtkWindow *parent; text = g_strdup_printf (_("Do you really want to remove the group '%s'?"), group); parent = empathy_get_toplevel_window (GTK_WIDGET (view)); if (contact_list_view_remove_dialog_show (parent, _("Removing group"), text)) { EmpathyContactList *list; list = empathy_contact_list_store_get_list_iface (priv->store); empathy_contact_list_remove_group (list, group); } g_free (text); } g_free (group); }
static void contact_list_view_remove_activate_cb (GtkMenuItem *menuitem, EmpathyContactListView *view) { EmpathyContactListViewPriv *priv = GET_PRIV (view); EmpathyContact *contact; contact = empathy_contact_list_view_get_selected (view); if (contact) { gchar *text; GtkWindow *parent; parent = empathy_get_toplevel_window (GTK_WIDGET (view)); text = g_strdup_printf (_("Do you really want to remove the contact '%s'?"), empathy_contact_get_name (contact)); if (contact_list_view_remove_dialog_show (parent, _("Removing contact"), text)) { EmpathyContactList *list; list = empathy_contact_list_store_get_list_iface (priv->store); empathy_contact_list_remove (list, contact, _("Sorry, I don't want you in my contact list anymore.")); } g_free (text); g_object_unref (contact); } }
static void contact_list_view_drag_got_contact (EmpathyTpContactFactory *factory, EmpathyContact *contact, const GError *error, gpointer user_data, GObject *view) { EmpathyContactListViewPriv *priv = GET_PRIV (view); DndGetContactData *data = user_data; EmpathyContactList *list; if (error != NULL) { DEBUG ("Error: %s", error->message); return; } DEBUG ("contact %s (%d) dragged from '%s' to '%s'", empathy_contact_get_id (contact), empathy_contact_get_handle (contact), data->old_group, data->new_group); list = empathy_contact_list_store_get_list_iface (priv->store); if (data->new_group) { empathy_contact_list_add_to_group (list, contact, data->new_group); } if (data->old_group && data->action == GDK_ACTION_MOVE) { empathy_contact_list_remove_from_group (list, contact, data->old_group); } }
static void contact_list_view_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection, guint info, guint time) { EmpathyContactListViewPriv *priv; EmpathyContactList *list; EmpathyContactFactory *factory; McAccount *account; GtkTreeModel *model; GtkTreePath *path; GtkTreeViewDropPosition position; EmpathyContact *contact = NULL; const gchar *id; gchar **strv; gchar *new_group = NULL; gchar *old_group = NULL; gboolean is_row; priv = GET_PRIV (widget); id = (const gchar*) selection->data; DEBUG ("Received %s%s drag & drop contact from roster with id:'%s'", context->action == GDK_ACTION_MOVE ? "move" : "", context->action == GDK_ACTION_COPY ? "copy" : "", id); strv = g_strsplit (id, "/", 2); factory = empathy_contact_factory_new (); account = mc_account_lookup (strv[0]); if (account) { contact = empathy_contact_factory_get_from_id (factory, account, strv[1]); g_object_unref (account); } g_object_unref (factory); g_strfreev (strv); if (!contact) { DEBUG ("No contact found associated with drag & drop"); return; } empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_HANDLE, NULL); model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); /* Get source group information. */ if (priv->drag_row) { path = gtk_tree_row_reference_get_path (priv->drag_row); if (path) { old_group = empathy_contact_list_store_get_parent_group (model, path, NULL); gtk_tree_path_free (path); } } /* Get destination group information. */ is_row = gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), x, y, &path, &position); if (is_row) { new_group = empathy_contact_list_store_get_parent_group (model, path, NULL); gtk_tree_path_free (path); } DEBUG ("contact %s (%d) dragged from '%s' to '%s'", empathy_contact_get_id (contact), empathy_contact_get_handle (contact), old_group, new_group); list = empathy_contact_list_store_get_list_iface (priv->store); if (new_group) { empathy_contact_list_add_to_group (list, contact, new_group); } if (old_group && context->action == GDK_ACTION_MOVE) { empathy_contact_list_remove_from_group (list, contact, old_group); } g_free (old_group); g_free (new_group); gtk_drag_finish (context, TRUE, FALSE, GDK_CURRENT_TIME); }