]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-menu.c
Merge branch 'sasl'
[empathy.git] / libempathy-gtk / empathy-contact-menu.c
index 54bb4b28617a96c1b5a5f27896d109557412cf65..c7fd19b09218a4d5fdd42d3e40bb613a74cf807b 100644 (file)
 
 #include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
-#ifdef ENABLE_TPL
 #include <telepathy-logger/log-manager.h>
-#else
 
-#include <libempathy/empathy-log-manager.h>
-#endif /* ENABLE_TPL */
 #include <libempathy/empathy-call-factory.h>
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-dispatcher.h>
@@ -114,7 +110,8 @@ empathy_contact_menu_new (EmpathyContact             *contact,
 
        /* Separator */
        if (features & (EMPATHY_CONTACT_FEATURE_EDIT |
-                       EMPATHY_CONTACT_FEATURE_INFO)) {
+                       EMPATHY_CONTACT_FEATURE_INFO |
+                       EMPATHY_CONTACT_FEATURE_FAVOURITE)) {
                item = gtk_separator_menu_item_new ();
                gtk_menu_shell_append (shell, item);
                gtk_widget_show (item);
@@ -134,6 +131,13 @@ empathy_contact_menu_new (EmpathyContact             *contact,
                gtk_widget_show (item);
        }
 
+       /* Favorite checkbox */
+       if (features & EMPATHY_CONTACT_FEATURE_FAVOURITE) {
+               item = empathy_contact_favourite_menu_item_new (contact);
+               gtk_menu_shell_append (shell, item);
+               gtk_widget_show (item);
+       }
+
        return menu;
 }
 
@@ -212,7 +216,7 @@ static void
 empathy_contact_chat_menu_item_activated (GtkMenuItem *item,
        EmpathyContact *contact)
 {
-  empathy_dispatcher_chat_with_contact (contact, NULL, NULL);
+  empathy_dispatcher_chat_with_contact (contact, gtk_get_current_event_time ());
 }
 
 GtkWidget *
@@ -227,6 +231,7 @@ empathy_contact_chat_menu_item_new (EmpathyContact *contact)
        image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_MESSAGE,
                                              GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+       gtk_widget_set_sensitive (item, !empathy_contact_is_user (contact));
        gtk_widget_show (image);
 
        g_signal_connect (item, "activate",
@@ -240,10 +245,9 @@ static void
 empathy_contact_audio_call_menu_item_activated (GtkMenuItem *item,
        EmpathyContact *contact)
 {
-       EmpathyCallFactory *factory;
 
-       factory = empathy_call_factory_get ();
-       empathy_call_factory_new_call_with_streams (factory, contact, TRUE, FALSE);
+       empathy_call_factory_new_call_with_streams (contact, TRUE, FALSE,
+               gtk_get_current_event_time (), NULL);
 }
 
 GtkWidget *
@@ -258,7 +262,8 @@ empathy_contact_audio_call_menu_item_new (EmpathyContact *contact)
        image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VOIP,
                                              GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-       gtk_widget_set_sensitive (item, empathy_contact_can_voip_audio (contact));
+       gtk_widget_set_sensitive (item, empathy_contact_can_voip_audio (contact) &&
+                                       !empathy_contact_is_user (contact));
        gtk_widget_show (image);
 
        g_signal_connect (item, "activate",
@@ -272,10 +277,8 @@ static void
 empathy_contact_video_call_menu_item_activated (GtkMenuItem *item,
        EmpathyContact *contact)
 {
-       EmpathyCallFactory *factory;
-
-       factory = empathy_call_factory_get ();
-       empathy_call_factory_new_call_with_streams (factory, contact, TRUE, TRUE);
+       empathy_call_factory_new_call_with_streams (contact, TRUE, TRUE,
+               gtk_get_current_event_time (), NULL);
 }
 
 GtkWidget *
@@ -290,7 +293,8 @@ empathy_contact_video_call_menu_item_new (EmpathyContact *contact)
        image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_VIDEO_CALL,
                                              GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-       gtk_widget_set_sensitive (item, empathy_contact_can_voip_video (contact));
+       gtk_widget_set_sensitive (item, empathy_contact_can_voip_video (contact) &&
+                                       !empathy_contact_is_user (contact));
        gtk_widget_show (image);
 
        g_signal_connect (item, "activate",
@@ -311,30 +315,19 @@ contact_log_menu_item_activate_cb (EmpathyContact *contact)
 GtkWidget *
 empathy_contact_log_menu_item_new (EmpathyContact *contact)
 {
-#ifndef ENABLE_TPL
-       EmpathyLogManager *manager;
-#else
        TplLogManager     *manager;
-#endif /* ENABLE_TPL */
        gboolean           have_log;
        GtkWidget         *item;
        GtkWidget         *image;
 
        g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
 
-#ifndef ENABLE_TPL
-       manager = empathy_log_manager_dup_singleton ();
-       have_log = empathy_log_manager_exists (manager,
-                                              empathy_contact_get_account (contact),
-                                              empathy_contact_get_id (contact),
-                                              FALSE);
-#else
        manager = tpl_log_manager_dup_singleton ();
        have_log = tpl_log_manager_exists (manager,
                                               empathy_contact_get_account (contact),
                                               empathy_contact_get_id (contact),
                                               FALSE);
-#endif /* ENABLE_TPL */
+
        g_object_unref (manager);
 
        item = gtk_image_menu_item_new_with_mnemonic (_("_Previous Conversations"));
@@ -359,10 +352,11 @@ empathy_contact_file_transfer_menu_item_new (EmpathyContact *contact)
 
        g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
 
-       item = gtk_image_menu_item_new_with_mnemonic (_("Send file"));
+       item = gtk_image_menu_item_new_with_mnemonic (_("Send File"));
        image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_DOCUMENT_SEND,
                                              GTK_ICON_SIZE_MENU);
-       gtk_widget_set_sensitive (item, empathy_contact_can_send_files (contact));
+       gtk_widget_set_sensitive (item, empathy_contact_can_send_files (contact) &&
+                                       !empathy_contact_is_user (contact));
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
        gtk_widget_show (image);
 
@@ -373,7 +367,6 @@ empathy_contact_file_transfer_menu_item_new (EmpathyContact *contact)
        return item;
 }
 
-/* FIXME  we should check if the contact supports vnc stream tube */
 GtkWidget *
 empathy_contact_share_my_desktop_menu_item_new (EmpathyContact *contact)
 {
@@ -382,10 +375,11 @@ empathy_contact_share_my_desktop_menu_item_new (EmpathyContact *contact)
 
        g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
 
-       item = gtk_image_menu_item_new_with_mnemonic (_("Share my desktop"));
+       item = gtk_image_menu_item_new_with_mnemonic (_("Share My Desktop"));
        image = gtk_image_new_from_icon_name (GTK_STOCK_NETWORK,
                                              GTK_ICON_SIZE_MENU);
-       gtk_widget_set_sensitive (item, empathy_contact_can_use_stream_tube (contact));
+       gtk_widget_set_sensitive (item, empathy_contact_can_use_rfb_stream_tube (
+               contact));
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
        gtk_widget_show (image);
 
@@ -396,6 +390,46 @@ empathy_contact_share_my_desktop_menu_item_new (EmpathyContact *contact)
        return item;
 }
 
+static void
+favourite_menu_item_toggled_cb (GtkCheckMenuItem *item,
+       EmpathyContact *contact)
+{
+       EmpathyContactManager *manager;
+       EmpathyContactList *list;
+
+       manager = empathy_contact_manager_dup_singleton ();
+       list = EMPATHY_CONTACT_LIST (manager);
+
+       if (gtk_check_menu_item_get_active (item)) {
+               empathy_contact_list_add_to_favourites (list, contact);
+       } else {
+               empathy_contact_list_remove_from_favourites (list, contact);
+       }
+
+       g_object_unref (manager);
+}
+
+GtkWidget *
+empathy_contact_favourite_menu_item_new (EmpathyContact *contact)
+{
+       GtkWidget *item;
+       EmpathyContactManager *manager;
+
+       item = gtk_check_menu_item_new_with_label (_("Favorite"));
+
+       manager = empathy_contact_manager_dup_singleton ();
+       gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
+               empathy_contact_list_is_favourite (EMPATHY_CONTACT_LIST (manager),
+                                                  contact));
+
+       g_signal_connect (item, "toggled",
+                         G_CALLBACK (favourite_menu_item_toggled_cb),
+                         contact);
+
+       g_object_unref (manager);
+       return item;
+}
+
 static void
 contact_info_menu_item_activate_cb (EmpathyContact *contact)
 {
@@ -541,11 +575,17 @@ empathy_contact_invite_menu_item_new (EmpathyContact *contact)
 
        g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
 
-       item = gtk_image_menu_item_new_with_mnemonic (_("_Invite to chat room"));
+       item = gtk_image_menu_item_new_with_mnemonic (_("_Invite to Chat Room"));
        image = gtk_image_new_from_icon_name (EMPATHY_IMAGE_GROUP_MESSAGE,
                                              GTK_ICON_SIZE_MENU);
        gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
 
+       if (empathy_contact_is_user (contact)) {
+               gtk_widget_set_sensitive (item, FALSE);
+               gtk_widget_show (image);
+               return item;
+       }
+
        mgr = empathy_chatroom_manager_dup_singleton (NULL);
        rooms = empathy_chatroom_manager_get_chatrooms (mgr,
                empathy_contact_get_account (contact));