]> git.0d.be Git - empathy.git/blobdiff - src/empathy-chat-window.c
Merge branch 'undo-close-tab'
[empathy.git] / src / empathy-chat-window.c
index 9748b61c6d6c3e708ea475c4901ff930f92a8b5f..e18ae2583437869caac8fc82db6ce4dd1bcf381a 100644 (file)
@@ -124,6 +124,7 @@ static const GtkTargetEntry drag_types_dest[] = {
        { "text/contact-id", 0, DND_DRAG_TYPE_CONTACT_ID },
        { "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, DND_DRAG_TYPE_TAB },
        { "text/uri-list", 0, DND_DRAG_TYPE_URI_LIST },
+       { "text/path-list", 0, DND_DRAG_TYPE_URI_LIST },
 };
 
 static const GtkTargetEntry drag_types_dest_contact[] = {
@@ -131,6 +132,9 @@ static const GtkTargetEntry drag_types_dest_contact[] = {
 };
 
 static const GtkTargetEntry drag_types_dest_file[] = {
+       /* must be first to be prioritized, in order to receive the
+        * note's file path from Tomboy instead of an URI */
+       { "text/path-list", 0, DND_DRAG_TYPE_URI_LIST },
        { "text/uri-list", 0, DND_DRAG_TYPE_URI_LIST },
 };
 
@@ -334,18 +338,21 @@ chat_window_menu_context_update (EmpathyChatWindowPriv *priv,
 {
        gboolean first_page;
        gboolean last_page;
+       gboolean wrap_around;
        gboolean is_connected;
        gint     page_num;
 
        page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
        first_page = (page_num == 0);
        last_page = (page_num == (num_pages - 1));
+       g_object_get (gtk_settings_get_default (), "gtk-keynav-wrap-around",
+                     &wrap_around, NULL);
        is_connected = empathy_chat_get_tp_chat (priv->current_chat) != NULL;
 
-       DEBUG ("Update window : Menu Contexts (Tabs & Conv)");
-
-       gtk_action_set_sensitive (priv->menu_tabs_next, TRUE);
-       gtk_action_set_sensitive (priv->menu_tabs_prev, TRUE);
+       gtk_action_set_sensitive (priv->menu_tabs_next, (!last_page ||
+                                                        wrap_around));
+       gtk_action_set_sensitive (priv->menu_tabs_prev, (!first_page ||
+                                                        wrap_around));
        gtk_action_set_sensitive (priv->menu_tabs_detach, num_pages > 1);
        gtk_action_set_sensitive (priv->menu_tabs_left, !first_page);
        gtk_action_set_sensitive (priv->menu_tabs_right, !last_page);
@@ -388,8 +395,6 @@ chat_window_contact_menu_update (EmpathyChatWindowPriv *priv,
                "/chats_menubar/menu_contact");
        orig_submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menu));
 
-       DEBUG ("Update window : Contact Menu");
-
        if (orig_submenu == NULL || !GTK_WIDGET_VISIBLE (orig_submenu)) {
                submenu = empathy_chat_get_contact_menu (priv->current_chat);
                gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu), submenu);
@@ -488,8 +493,6 @@ chat_window_title_update (EmpathyChatWindowPriv *priv)
 {
        gchar *name;
 
-       DEBUG ("Update window : Title");
-
        name = get_window_title_name (priv);
        gtk_window_set_title (GTK_WINDOW (priv->dialog), name);
        g_free (name);
@@ -505,8 +508,6 @@ chat_window_icon_update (EmpathyChatWindowPriv *priv)
 
        n_chats = g_list_length (priv->chats);
 
-       DEBUG ("Update window : Icon");
-
        /* Update window icon */
        if (priv->chats_new_msg) {
                gtk_window_set_icon_name (GTK_WINDOW (priv->dialog),
@@ -538,8 +539,6 @@ chat_window_close_button_update (EmpathyChatWindowPriv *priv,
        GtkWidget *chat_close_button;
        gint       i;
 
-       DEBUG ("Update window : Close Button");
-
        if (num_pages == 1) {
                chat = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), 0);
                chat_close_button = g_object_get_data (G_OBJECT (chat),
@@ -563,8 +562,6 @@ chat_window_update (EmpathyChatWindow *window)
 
        num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
 
-       DEBUG ("Update window");
-
        /* Update Tab menu */
        chat_window_menu_context_update (priv,
                                         num_pages);
@@ -880,6 +877,7 @@ chat_window_invite_participant_activate_cb (GtkAction         *action,
        EmpathyTpChat         *tp_chat;
        TpChannel             *channel;
        int                    response;
+       TpAccount             *account;
 
        priv = GET_PRIV (window);
 
@@ -887,9 +885,10 @@ chat_window_invite_participant_activate_cb (GtkAction         *action,
 
        tp_chat = empathy_chat_get_tp_chat (priv->current_chat);
        channel = empathy_tp_chat_get_channel (tp_chat);
+       account = empathy_chat_get_account (priv->current_chat);
 
        dialog = empathy_invite_participant_dialog_new (
-                       GTK_WINDOW (priv->dialog));
+                       GTK_WINDOW (priv->dialog), account);
        gtk_widget_show (dialog);
 
        response = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -1026,14 +1025,18 @@ chat_window_tabs_next_activate_cb (GtkAction         *action,
        EmpathyChatWindowPriv *priv;
        EmpathyChat           *chat;
        gint                  index_, numPages;
+       gboolean              wrap_around;
 
        priv = GET_PRIV (window);
 
+       g_object_get (gtk_settings_get_default (), "gtk-keynav-wrap-around",
+                      &wrap_around, NULL);
+
        chat = priv->current_chat;
        index_ = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
        numPages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
 
-       if (index_ == (numPages - 1)) {
+       if (index_ == (numPages - 1) && wrap_around) {
                gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), 0);
                return;
        }
@@ -1048,14 +1051,18 @@ chat_window_tabs_previous_activate_cb (GtkAction         *action,
        EmpathyChatWindowPriv *priv;
        EmpathyChat           *chat;
        gint                  index_, numPages;
+       gboolean              wrap_around;
 
        priv = GET_PRIV (window);
 
+       g_object_get (gtk_settings_get_default (), "gtk-keynav-wrap-around",
+                      &wrap_around, NULL);
+
        chat = priv->current_chat;
        index_ = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
        numPages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
 
-       if (index_ <= 0) {
+       if (index_ <= 0 && wrap_around) {
                gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), numPages - 1);
                return;
        }
@@ -1191,7 +1198,6 @@ chat_window_set_urgency_hint (EmpathyChatWindow *window,
 
        priv = GET_PRIV (window);
 
-       DEBUG ("Turning %s urgency hint", urgent ? "on" : "off");
        gtk_window_set_urgency_hint (GTK_WINDOW (priv->dialog), urgent);
 }
 
@@ -1529,8 +1535,6 @@ chat_window_focus_in_event_cb (GtkWidget        *widget,
 {
        EmpathyChatWindowPriv *priv;
 
-       DEBUG ("Focus in event, updating title");
-
        priv = GET_PRIV (window);
 
        priv->chats_new_msg = g_list_remove (priv->chats_new_msg, priv->current_chat);
@@ -1550,15 +1554,18 @@ chat_window_drag_drop (GtkWidget        *widget,
                         int               x,
                         int               y,
                         guint             time_,
-                        gpointer          user_data)
+                        EmpathyChatWindow *window)
 {
-       GdkAtom target, uri_target, contact_target;
+       GdkAtom target;
+       EmpathyChatWindowPriv *priv;
+
+       priv = GET_PRIV (window);
 
-       target = gtk_drag_dest_find_target (widget, context, NULL);
-       uri_target = gdk_atom_intern_static_string ("text/uri-list");
-       contact_target = gdk_atom_intern_static_string ("text/contact-id");
+       target = gtk_drag_dest_find_target (widget, context, priv->file_targets);
+       if (target == GDK_NONE)
+               target = gtk_drag_dest_find_target (widget, context, priv->contact_targets);
 
-       if (target == uri_target || target == contact_target) {
+       if (target != GDK_NONE) {
                gtk_drag_get_data (widget, context, target, time_);
                return TRUE;
        }
@@ -1576,14 +1583,11 @@ chat_window_drag_motion (GtkWidget        *widget,
 {
        GdkAtom target;
        EmpathyChatWindowPriv *priv;
-       GdkAtom dest_target;
 
        priv = GET_PRIV (window);
 
-       target = gtk_drag_dest_find_target (widget, context, NULL);
-
-       dest_target = gdk_atom_intern_static_string ("text/uri-list");
-       if (target == dest_target) {
+       target = gtk_drag_dest_find_target (widget, context, priv->file_targets);
+       if (target != GDK_NONE) {
                /* This is a file drag.  Ensure the contact is online and set the
                   drag type to COPY.  Note that it's possible that the tab will
                   be switched by GTK+ after a timeout from drag_motion without
@@ -1612,8 +1616,8 @@ chat_window_drag_motion (GtkWidget        *widget,
                return TRUE;
        }
 
-       dest_target = gdk_atom_intern_static_string ("text/contact-id");
-       if (target == dest_target) {
+       target = gtk_drag_dest_find_target (widget, context, priv->contact_targets);
+       if (target != GDK_NONE) {
                /* This is a drag of a contact from a contact list.  Set to COPY.
                   FIXME: If this drag is to a MUC window, it invites the user.
                   Otherwise, it opens a chat.  Should we use a different drag
@@ -2288,7 +2292,7 @@ empathy_chat_window_present_chat (EmpathyChat *chat)
 
        priv = GET_PRIV (window);
        empathy_chat_window_switch_to_chat (window, chat);
-       empathy_window_present (GTK_WINDOW (priv->dialog), TRUE);
+       empathy_window_present (GTK_WINDOW (priv->dialog));
 
        gtk_widget_grab_focus (chat->input_text_view);
 }