#include <string.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <libmissioncontrol/mc-account.h>
+#include <libempathy/empathy-call-factory.h>
#include <libempathy/empathy-contact-factory.h>
#include <libempathy/empathy-contact-list.h>
#include <libempathy/empathy-contact-groups.h>
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);
+
+ if (priv->tooltip_widget) {
+ DEBUG ("Tooltip destroyed");
+ priv->tooltip_widget = NULL;
+ g_object_unref (widget);
+ }
+}
+
static gboolean
contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
gint x,
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreePath *path;
+ static gint running = 0;
+ gboolean ret = FALSE;
- /* FIXME: We need GTK version >= 2.12.10. See GNOME bug #504087 */
- if (gtk_check_version (2, 12, 10)) {
+ /* Avoid an infinite loop. See GNOME bug #574377 */
+ if (running > 0) {
return FALSE;
}
+ running++;
if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view), &x, &y,
keyboard_mode,
&model, &path, &iter)) {
- return FALSE;
+ goto OUT;
}
gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (view), tooltip, path);
EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
-1);
if (!contact) {
- return FALSE;
+ goto OUT;
}
if (!priv->tooltip_widget) {
priv->tooltip_widget = empathy_contact_widget_new (contact,
- EMPATHY_CONTACT_WIDGET_EDIT_NONE);
- g_object_add_weak_pointer (G_OBJECT (priv->tooltip_widget),
- (gpointer) &priv->tooltip_widget);
+ EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP);
+ g_object_ref (priv->tooltip_widget);
+ g_signal_connect (priv->tooltip_widget, "destroy",
+ G_CALLBACK (contact_list_view_tooltip_destroy_cb),
+ view);
} else {
empathy_contact_widget_set_contact (priv->tooltip_widget,
contact);
}
gtk_tooltip_set_custom (tooltip, priv->tooltip_widget);
+ ret = TRUE;
g_object_unref (contact);
+OUT:
+ running--;
- return TRUE;
+ return ret;
}
static void
id);
strv = g_strsplit (id, "/", 2);
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
account = mc_account_lookup (strv[0]);
if (account) {
contact = empathy_contact_factory_get_from_id (factory,
GtkTreeModel *model;
GtkTreeIter iter;
+ if (!(priv->contact_features & EMPATHY_CONTACT_FEATURE_CHAT)) {
+ return;
+ }
+
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) {
- return;
- }
-
- /* There is no event for the contact, default action is starting a chat */
- if (priv->contact_features & EMPATHY_CONTACT_FEATURE_CHAT) {
+ if (contact) {
DEBUG ("Starting a chat");
- empathy_dispatcher_chat_with_contact (contact);
+ empathy_dispatcher_chat_with_contact (contact, NULL, NULL);
+ g_object_unref (contact);
}
-
- g_object_unref (contact);
}
static void
-1);
if (contact) {
- empathy_dispatcher_call_with_contact (contact);
+ EmpathyCallFactory *factory;
+
+ factory = empathy_call_factory_get ();
+ empathy_call_factory_new_call (factory, contact);
+
g_object_unref (contact);
}
}
EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
-1);
- if (!is_group || G_STR_EMPTY (name)) {
+ if (!is_group || EMP_STR_EMPTY (name)) {
g_free (name);
return;
}
if (priv->store) {
g_object_unref (priv->store);
}
+ if (priv->tooltip_widget) {
+ gtk_widget_destroy (priv->tooltip_widget);
+ }
G_OBJECT_CLASS (empathy_contact_list_view_parent_class)->finalize (object);
}
widget_class->drag_end = contact_list_view_drag_end;
widget_class->drag_motion = contact_list_view_drag_motion;
+ /* We use the class method to let user of this widget to connect to
+ * the signal and stop emission of the signal so the default handler
+ * won't be called. */
tree_view_class->row_activated = contact_list_view_row_activated;
signals[DRAG_CONTACT_RECEIVED] =
static gboolean
contact_list_view_remove_dialog_show (GtkWindow *parent,
- const gchar *window_title,
- const gchar *text)
+ const gchar *message,
+ const gchar *secondary_text)
{
- GtkWidget *dialog, *label, *image, *hbox;
+ GtkWidget *dialog;
gboolean res;
- dialog = gtk_dialog_new_with_buttons (window_title, parent,
- GTK_DIALOG_MODAL,
- GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
- GTK_STOCK_DELETE, GTK_RESPONSE_YES,
- NULL);
- gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE);
-
- label = gtk_label_new (text);
- image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
+ dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
+ "%s", message);
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
+ GTK_STOCK_DELETE, GTK_RESPONSE_YES,
+ NULL);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ "%s", secondary_text);
- hbox = gtk_hbox_new (FALSE, 5);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
- gtk_box_pack_start_defaults (GTK_BOX (hbox), image);
- gtk_box_pack_start_defaults (GTK_BOX (hbox), label);
- gtk_box_pack_start_defaults (GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox);
-
- gtk_widget_show (image);
- gtk_widget_show (label);
- gtk_widget_show (hbox);
gtk_widget_show (dialog);
res = gtk_dialog_run (GTK_DIALOG (dialog));