#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-contact-list.h>
+#include <libempathy/empathy-log-manager.h>
#include <libempathy/gossip-debug.h>
#include <libempathy/gossip-utils.h>
#include <libempathy/empathy-marshal.h>
#include "gossip-cell-renderer-expander.h"
#include "gossip-cell-renderer-text.h"
#include "gossip-ui-utils.h"
+#include "empathy-contact-dialogs.h"
//#include "gossip-chat-invite.h"
-//#include "gossip-contact-info-dialog.h"
-//#include "gossip-edit-contact-dialog.h"
//#include "gossip-ft-window.h"
-//#include "gossip-log-window.h"
+#include "gossip-log-window.h"
#define DEBUG_DOMAIN "ContactListView"
gint y,
GtkSelectionData *selection,
guint info,
- guint time,
- gpointer user_data);
+ guint time);
static gboolean contact_list_view_drag_motion (GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
- guint time,
- gpointer data);
+ guint time);
static gboolean contact_list_view_drag_motion_cb (DragMotionData *data);
static void contact_list_view_drag_begin (GtkWidget *widget,
- GdkDragContext *context,
- gpointer user_data);
+ GdkDragContext *context);
static void contact_list_view_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection,
guint info,
- guint time,
- gpointer user_data);
+ guint time);
static void contact_list_view_drag_end (GtkWidget *widget,
- GdkDragContext *context,
- gpointer user_data);
+ GdkDragContext *context);
+static gboolean contact_list_view_drag_drop (GtkWidget *widget,
+ GdkDragContext *drag_context,
+ gint x,
+ gint y,
+ guint time);
static void contact_list_view_cell_set_background (GossipContactListView *view,
GtkCellRenderer *cell,
gboolean is_group,
static void
gossip_contact_list_view_class_init (GossipContactListViewClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = contact_list_view_finalize;
object_class->get_property = contact_list_view_get_property;
object_class->set_property = contact_list_view_set_property;
+ widget_class->drag_data_received = contact_list_view_drag_data_received;
+ widget_class->drag_drop = contact_list_view_drag_drop;
+ widget_class->drag_begin = contact_list_view_drag_begin;
+ widget_class->drag_data_get = contact_list_view_drag_data_get;
+ widget_class->drag_end = contact_list_view_drag_end;
+ /* FIXME: noticed but when you drag the row over the treeview
+ * fast, it seems to stop redrawing itself, if we don't
+ * connect this signal, all is fine.
+ */
+ widget_class->drag_motion = contact_list_view_drag_motion;
+
signals[DRAG_CONTACT_RECEIVED] =
g_signal_new ("drag-contact-received",
G_OBJECT_CLASS_TYPE (klass),
gossip_contact_list_view_get_contact_menu (GossipContactListView *view,
GossipContact *contact)
{
- gboolean can_show_log;
- gboolean can_send_file;
+ EmpathyLogManager *log_manager;
+ gboolean can_show_log;
+ gboolean can_send_file;
g_return_val_if_fail (GOSSIP_IS_CONTACT_LIST_VIEW (view), NULL);
g_return_val_if_fail (GOSSIP_IS_CONTACT (contact), NULL);
- can_show_log = FALSE; /* FIXME: gossip_log_exists_for_contact (contact); */
+ log_manager = empathy_log_manager_new ();
+ can_show_log = empathy_log_manager_exists (log_manager,
+ gossip_contact_get_account (contact),
+ gossip_contact_get_id (contact),
+ FALSE);
can_send_file = FALSE;
+ g_object_unref (log_manager);
return contact_list_view_get_contact_menu (view,
can_send_file,
drag_types_dest,
G_N_ELEMENTS (drag_types_dest),
GDK_ACTION_MOVE | GDK_ACTION_LINK);
-
- g_signal_connect (GTK_WIDGET (view),
- "drag-data-received",
- G_CALLBACK (contact_list_view_drag_data_received),
- NULL);
-
- /* FIXME: noticed but when you drag the row over the treeview
- * fast, it seems to stop redrawing itself, if we don't
- * connect this signal, all is fine.
- */
- g_signal_connect (view,
- "drag-motion",
- G_CALLBACK (contact_list_view_drag_motion),
- NULL);
-
- g_signal_connect (view,
- "drag-begin",
- G_CALLBACK (contact_list_view_drag_begin),
- NULL);
- g_signal_connect (view,
- "drag-data-get",
- G_CALLBACK (contact_list_view_drag_data_get),
- NULL);
- g_signal_connect (view,
- "drag-end",
- G_CALLBACK (contact_list_view_drag_end),
- NULL);
}
static void
gint y,
GtkSelectionData *selection,
guint info,
- guint time,
- gpointer user_data)
+ guint time)
{
GossipContactListViewPriv *priv;
- EmpathyContactManager *manager;
+ EmpathyContactList *list;
GtkTreeModel *model;
GtkTreePath *path;
GtkTreeViewDropPosition position;
id);
/* FIXME: This is ambigous, an id can come from multiple accounts */
- manager = empathy_contact_manager_new ();
- contact = empathy_contact_list_find (EMPATHY_CONTACT_LIST (manager), id);
- g_object_unref (manager);
+ list = gossip_contact_list_store_get_list_iface (priv->store);
+ contact = empathy_contact_list_find (list, id);
if (!contact) {
gossip_debug (DEBUG_DOMAIN, "No contact found associated with drag & drop");
GdkDragContext *context,
gint x,
gint y,
- guint time,
- gpointer data)
+ guint time)
{
static DragMotionData *dm = NULL;
GtkTreePath *path;
static void
contact_list_view_drag_begin (GtkWidget *widget,
- GdkDragContext *context,
- gpointer user_data)
+ GdkDragContext *context)
{
GossipContactListViewPriv *priv;
GtkTreeSelection *selection;
priv = GET_PRIV (widget);
+ GTK_WIDGET_CLASS (gossip_contact_list_view_parent_class)->drag_begin (widget,
+ context);
+
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
return;
GdkDragContext *context,
GtkSelectionData *selection,
guint info,
- guint time,
- gpointer user_data)
+ guint time)
{
GossipContactListViewPriv *priv;
GtkTreePath *src_path;
static void
contact_list_view_drag_end (GtkWidget *widget,
- GdkDragContext *context,
- gpointer user_data)
+ GdkDragContext *context)
{
GossipContactListViewPriv *priv;
priv = GET_PRIV (widget);
+ GTK_WIDGET_CLASS (gossip_contact_list_view_parent_class)->drag_end (widget,
+ context);
+
if (priv->drag_row) {
gtk_tree_row_reference_free (priv->drag_row);
priv->drag_row = NULL;
}
}
+static gboolean
+contact_list_view_drag_drop (GtkWidget *widget,
+ GdkDragContext *drag_context,
+ gint x,
+ gint y,
+ guint time)
+{
+ return FALSE;
+}
+
static void
contact_list_view_cell_set_background (GossipContactListView *view,
GtkCellRenderer *cell,
contacts = empathy_contact_list_get_members (list);
for (l = contacts; l && !show_group; l = l->next) {
if (!gossip_contact_is_in_group (l->data, group)) {
+ g_object_unref (l->data);
continue;
}
if (contact_list_view_filter_show_contact (l->data, filter)) {
show_group = TRUE;
}
+ g_object_unref (l->data);
}
- g_list_foreach (contacts, (GFunc) g_object_unref, NULL);
g_list_free (contacts);
g_free (str);
contact_list_view_action_cb (GtkAction *action,
GossipContactListView *view)
{
- GossipContact *contact;
- const gchar *name;
- gchar *group;
+ GossipContactListViewPriv *priv;
+ GossipContact *contact;
+ const gchar *name;
+ gchar *group;
+ GtkWindow *parent;
+
+ priv = GET_PRIV (view);
name = gtk_action_get_name (action);
if (!name) {
contact = gossip_contact_list_view_get_selected (view);
group = gossip_contact_list_view_get_selected_group (view);
+ parent = gossip_get_toplevel_window (GTK_WIDGET (view));
if (contact && strcmp (name, "Chat") == 0) {
contact_list_view_action_activated (view, contact);
}
else if (contact && strcmp (name, "Information") == 0) {
+ empathy_contact_information_dialog_show (contact, parent, FALSE);
}
else if (contact && strcmp (name, "Edit") == 0) {
+ empathy_contact_information_dialog_show (contact, parent, TRUE);
}
else if (contact && strcmp (name, "Remove") == 0) {
+ /* FIXME: Ask for confirmation */
+ EmpathyContactList *list;
+
+ list = gossip_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."));
}
else if (contact && strcmp (name, "Invite") == 0) {
}
else if (contact && strcmp (name, "SendFile") == 0) {
}
else if (contact && strcmp (name, "Log") == 0) {
+ gossip_log_window_show (gossip_contact_get_account (contact),
+ gossip_contact_get_id (contact),
+ FALSE,
+ parent);
}
else if (group && strcmp (name, "Rename") == 0) {
}