]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-list-view.c
Move the event manager to src/
[empathy.git] / libempathy-gtk / empathy-contact-list-view.c
index 3443950de52a503a4ff16e7fc0ff57a80dc68a27..dd3dc54a6d5d5d682189711a42c6cd85e490c2fe 100644 (file)
@@ -53,9 +53,6 @@
 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
 #include <libempathy/empathy-debug.h>
 
-/* Flashing delay for icons (milliseconds). */
-#define FLASH_TIMEOUT 500
-
 /* Active users are those which have recently changed state
  * (e.g. online, offline or from normal to a busy state).
  */
@@ -117,19 +114,6 @@ static guint signals[LAST_SIGNAL];
 
 G_DEFINE_TYPE (EmpathyContactListView, empathy_contact_list_view, GTK_TYPE_TREE_VIEW);
 
-static void
-contact_list_view_tooltip_destroy_cb (GtkWidget              *widget,
-                                     EmpathyContactListView *view)
-{
-       EmpathyContactListViewPriv *priv = GET_PRIV (view);
-
-       DEBUG ("Tooltip destroyed");
-       if (priv->tooltip_widget) {
-               g_object_unref (priv->tooltip_widget);
-               priv->tooltip_widget = NULL;
-       }
-}
-
 static gboolean
 contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
                                    gint                    x,
@@ -144,6 +128,11 @@ contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
        GtkTreeIter                 iter;
        GtkTreePath                *path;
 
+       /* FIXME: We need GTK version >= 2.12.10. See GNOME bug #504087 */
+       if (gtk_check_version (2, 12, 10)) {
+               return FALSE;
+       }
+
        if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view), &x, &y,
                                                keyboard_mode,
                                                &model, &path, &iter)) {
@@ -162,15 +151,14 @@ contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
 
        if (!priv->tooltip_widget) {
                priv->tooltip_widget = empathy_contact_widget_new (contact,
-                                               EMPATHY_CONTACT_WIDGET_EDIT_NONE);
-               g_object_ref (priv->tooltip_widget);
-               g_signal_connect (priv->tooltip_widget, "destroy",
-                                 G_CALLBACK (contact_list_view_tooltip_destroy_cb),
-                                 view);
-
+                       EMPATHY_CONTACT_WIDGET_EDIT_NONE);
+               g_object_add_weak_pointer (G_OBJECT (priv->tooltip_widget),
+                                          (gpointer) &priv->tooltip_widget);
        } else {
-               empathy_contact_widget_set_contact (priv->tooltip_widget, contact);
+               empathy_contact_widget_set_contact (priv->tooltip_widget,
+                                                   contact);
        }
+
        gtk_tooltip_set_custom (tooltip, priv->tooltip_widget);
 
        g_object_unref (contact);
@@ -528,21 +516,22 @@ contact_list_view_row_activated_cb (EmpathyContactListView *view,
        GtkTreeModel               *model;
        GtkTreeIter                 iter;
 
-       if (!(priv->contact_features & EMPATHY_CONTACT_FEATURE_CHAT)) {
-               return;
-       }
-
-       model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
-
+       model = GTK_TREE_MODEL (priv->store);
        gtk_tree_model_get_iter (model, &iter, path);
        gtk_tree_model_get (model, &iter,
                            EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
                            -1);
 
-       if (contact) {
+       if (!contact) {
+               return;
+       }
+
+       /* There is no event for the contact, default action is starting a chat */
+       if (priv->contact_features & EMPATHY_CONTACT_FEATURE_CHAT) {
                empathy_dispatcher_chat_with_contact (contact);
-               g_object_unref (contact);
        }
+
+       g_object_unref (contact);
 }
 
 static void
@@ -935,6 +924,7 @@ contact_list_view_set_list_features (EmpathyContactListView         *view,
                                     EmpathyContactListFeatureFlags  features)
 {
        EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       gboolean                    has_tooltip;
 
        g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view));
 
@@ -959,13 +949,13 @@ contact_list_view_set_list_features (EmpathyContactListView         *view,
                                   G_N_ELEMENTS (drag_types_dest),
                                   GDK_ACTION_MOVE | GDK_ACTION_COPY);
        } else {
-               /* FIXME: URI could still be  droped depending on FT feature */
+               /* FIXME: URI could still be droped depending on FT feature */
                gtk_drag_dest_unset (GTK_WIDGET (view));
        }
 
        /* Update has-tooltip */
-       gtk_widget_set_has_tooltip (GTK_WIDGET (view),
-                                   features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_TOOLTIP);
+       has_tooltip = (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_TOOLTIP) != 0;
+       gtk_widget_set_has_tooltip (GTK_WIDGET (view), has_tooltip);
 }
 
 static void
@@ -979,10 +969,6 @@ contact_list_view_finalize (GObject *object)
                g_object_unref (priv->store);
        }
 
-       if (priv->tooltip_widget) {
-               g_object_unref (priv->tooltip_widget);
-       }
-
        G_OBJECT_CLASS (empathy_contact_list_view_parent_class)->finalize (object);
 }
 
@@ -1212,8 +1198,8 @@ contact_list_view_remove_dialog_show (GtkWindow   *parent,
        
        dialog = gtk_dialog_new_with_buttons (window_title, parent,
                                              GTK_DIALOG_MODAL,
+                                             GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
                                              GTK_STOCK_DELETE, GTK_RESPONSE_YES,
-                                             GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
                                              NULL);
        gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE);