]> git.0d.be Git - empathy.git/commitdiff
Merge branch 'undo-close-tab'
authorJonny Lamb <jonnylamb@gnome.org>
Tue, 30 Mar 2010 13:48:31 +0000 (14:48 +0100)
committerJonny Lamb <jonnylamb@gnome.org>
Tue, 30 Mar 2010 13:48:31 +0000 (14:48 +0100)
1  2 
src/Makefile.am
src/empathy-chat-window.c
src/empathy-chat-window.ui
src/empathy-main-window.c
src/empathy.c

diff --combined src/Makefile.am
index a01b759a1948e233a4952a9a95146f81f9d1c750,ae92c675a7a71e7050c9f48e1e96991ff39f7c47..18edc7f3f652894367e07ae099d9716d0db16c21
@@@ -81,7 -81,6 +81,7 @@@ endi
  bin_PROGRAMS =                        \
        empathy                 \
        empathy-accounts        \
 +      empathy-debugger        \
        $(NULL)
  
  BUILT_SOURCES=
@@@ -95,26 -94,22 +95,27 @@@ empathy_accounts_LDADD =                                           
        libempathy-accounts-common.la                                   \
        $(NULL)
  
 +empathy_debugger_SOURCES =                                            \
 +      empathy-debug-window.c empathy-debug-window.h                   \
 +      empathy-debugger.c                                              \
 +      $(NULL)
 +
  empathy_handwritten_source = \
        empathy-about-dialog.c empathy-about-dialog.h                   \
        empathy-call-window-fullscreen.c empathy-call-window-fullscreen.h \
        empathy-call-window.c empathy-call-window.h                     \
        empathy-chat-window.c empathy-chat-window.h                     \
        empathy-chatrooms-window.c empathy-chatrooms-window.h           \
 -      empathy-debug-window.c empathy-debug-window.h                   \
        empathy-event-manager.c empathy-event-manager.h                 \
        empathy-ft-manager.c empathy-ft-manager.h                       \
        empathy-invite-participant-dialog.c empathy-invite-participant-dialog.h \
        empathy-main-window.c empathy-main-window.h                     \
 +      empathy-migrate-butterfly-logs.c empathy-migrate-butterfly-logs.h \
        empathy-new-chatroom-dialog.c empathy-new-chatroom-dialog.h     \
        empathy-preferences.c empathy-preferences.h                     \
        empathy-sidebar.c empathy-sidebar.h                             \
        empathy-status-icon.c empathy-status-icon.h                     \
+       empathy-chat-manager.c empathy-chat-manager.h                   \
        empathy.c
  
  empathy_SOURCES =                                                     \
index 302aa3ac35dd13ac5d8556ab228b7338ccb9045b,9748b61c6d6c3e708ea475c4901ff930f92a8b5f..e18ae2583437869caac8fc82db6ce4dd1bcf381a
@@@ -54,6 -54,7 +54,7 @@@
  #include <libempathy-gtk/empathy-ui-utils.h>
  #include <libempathy-gtk/empathy-notify-manager.h>
  
+ #include "empathy-chat-manager.h"
  #include "empathy-chat-window.h"
  #include "empathy-about-dialog.h"
  #include "empathy-invite-participant-dialog.h"
@@@ -84,6 -85,9 +85,9 @@@ typedef struct 
        GtkTargetList *contact_targets;
        GtkTargetList *file_targets;
  
+       EmpathyChatManager *chat_manager;
+       gulong chat_manager_chats_changed_id;
        /* Menu items. */
        GtkUIManager *ui_manager;
        GtkAction   *menu_conv_insert_smiley;
  
        GtkAction   *menu_tabs_next;
        GtkAction   *menu_tabs_prev;
+       GtkAction   *menu_tabs_undo_close_tab;
        GtkAction   *menu_tabs_left;
        GtkAction   *menu_tabs_right;
        GtkAction   *menu_tabs_detach;
@@@ -119,7 -124,6 +124,7 @@@ static const GtkTargetEntry drag_types_
        { "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[] = {
  };
  
  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 },
  };
  
@@@ -333,21 -334,18 +338,21 @@@ chat_window_menu_context_update (Empath
  {
        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);
@@@ -390,6 -388,8 +395,6 @@@ chat_window_contact_menu_update (Empath
                "/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,6 -488,8 +493,6 @@@ chat_window_title_update (EmpathyChatWi
  {
        gchar *name;
  
 -      DEBUG ("Update window : Title");
 -
        name = get_window_title_name (priv);
        gtk_window_set_title (GTK_WINDOW (priv->dialog), name);
        g_free (name);
@@@ -503,6 -505,8 +508,6 @@@ chat_window_icon_update (EmpathyChatWin
  
        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),
@@@ -534,6 -538,8 +539,6 @@@ chat_window_close_button_update (Empath
        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),
@@@ -557,6 -563,8 +562,6 @@@ chat_window_update (EmpathyChatWindow *
  
        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);
@@@ -872,7 -880,6 +877,7 @@@ chat_window_invite_participant_activate
        EmpathyTpChat         *tp_chat;
        TpChannel             *channel;
        int                    response;
 +      TpAccount             *account;
  
        priv = GET_PRIV (window);
  
  
        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));
@@@ -1020,18 -1026,14 +1025,18 @@@ chat_window_tabs_next_activate_cb (GtkA
        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;
        }
@@@ -1046,18 -1048,14 +1051,18 @@@ chat_window_tabs_previous_activate_cb (
        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;
        }
        gtk_notebook_prev_page (GTK_NOTEBOOK (priv->notebook));
  }
  
+ static void
+ chat_window_tabs_undo_close_tab_activate_cb (GtkAction         *action,
+                                            EmpathyChatWindow *window)
+ {
+       EmpathyChatWindowPriv *priv = GET_PRIV (window);
+       empathy_chat_manager_undo_closed_chat (priv->chat_manager);
+ }
  static void
  chat_window_tabs_left_activate_cb (GtkAction         *action,
                                   EmpathyChatWindow *window)
@@@ -1185,6 -1191,7 +1198,6 @@@ chat_window_set_urgency_hint (EmpathyCh
  
        priv = GET_PRIV (window);
  
 -      DEBUG ("Turning %s urgency hint", urgent ? "on" : "off");
        gtk_window_set_urgency_hint (GTK_WINDOW (priv->dialog), urgent);
  }
  
@@@ -1522,6 -1529,8 +1535,6 @@@ chat_window_focus_in_event_cb (GtkWidge
  {
        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);
@@@ -1541,18 -1550,15 +1554,18 @@@ chat_window_drag_drop (GtkWidge
                         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;
        }
@@@ -1570,11 -1576,14 +1583,11 @@@ chat_window_drag_motion (GtkWidge
  {
        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
                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
@@@ -1743,6 -1752,17 +1756,17 @@@ chat_window_drag_data_received (GtkWidg
        }
  }
  
+ static void
+ chat_window_chat_manager_chats_changed_cb (EmpathyChatManager *chat_manager,
+                                          guint num_chats_in_manager,
+                                          EmpathyChatWindow *window)
+ {
+       EmpathyChatWindowPriv *priv = GET_PRIV (window);
+       gtk_action_set_sensitive (priv->menu_tabs_undo_close_tab,
+                                 num_chats_in_manager > 0);
+ }
  static void
  chat_window_finalize (GObject *object)
  {
                gtk_target_list_unref (priv->file_targets);
        }
  
+       if (priv->chat_manager) {
+               g_signal_handler_disconnect (priv->chat_manager,
+                                            priv->chat_manager_chats_changed_id);
+               g_object_unref (priv->chat_manager);
+               priv->chat_manager = NULL;
+       }
        chat_windows = g_list_remove (chat_windows, window);
        gtk_widget_destroy (priv->dialog);
  
@@@ -1834,6 -1861,7 +1865,7 @@@ empathy_chat_window_init (EmpathyChatWi
                                       "menu_edit_find", &priv->menu_edit_find,
                                       "menu_tabs_next", &priv->menu_tabs_next,
                                       "menu_tabs_prev", &priv->menu_tabs_prev,
+                                      "menu_tabs_undo_close_tab", &priv->menu_tabs_undo_close_tab,
                                       "menu_tabs_left", &priv->menu_tabs_left,
                                       "menu_tabs_right", &priv->menu_tabs_right,
                                       "menu_tabs_detach", &priv->menu_tabs_detach,
                              "menu_edit_find", "activate", chat_window_find_activate_cb,
                              "menu_tabs_next", "activate", chat_window_tabs_next_activate_cb,
                              "menu_tabs_prev", "activate", chat_window_tabs_previous_activate_cb,
+                             "menu_tabs_undo_close_tab", "activate", chat_window_tabs_undo_close_tab_activate_cb,
                              "menu_tabs_left", "activate", chat_window_tabs_left_activate_cb,
                              "menu_tabs_right", "activate", chat_window_tabs_right_activate_cb,
                              "menu_tabs_detach", "activate", chat_window_detach_activate_cb,
        priv->current_chat = NULL;
  
        priv->notify_mgr = empathy_notify_manager_dup_singleton ();
+       priv->chat_manager = empathy_chat_manager_dup_singleton ();
+       priv->chat_manager_chats_changed_id =
+               g_signal_connect (priv->chat_manager, "chats-changed",
+                                 G_CALLBACK (chat_window_chat_manager_chats_changed_cb),
+                                 window);
+       chat_window_chat_manager_chats_changed_cb (priv->chat_manager,
+                                                  empathy_chat_manager_get_num_chats (priv->chat_manager),
+                                                  window);
  }
  
  EmpathyChatWindow *
@@@ -2103,6 -2142,7 +2146,7 @@@ empathy_chat_window_remove_chat (Empath
        EmpathyChatWindowPriv *priv;
        gint                   position;
        EmpathyContact        *remote_contact;
+       EmpathyChatManager    *chat_manager;
  
        g_return_if_fail (window != NULL);
        g_return_if_fail (EMPATHY_IS_CHAT (chat));
                                                      chat);
        }
  
+       chat_manager = empathy_chat_manager_dup_singleton ();
+       empathy_chat_manager_closed_chat (chat_manager, chat);
+       g_object_unref (chat_manager);
        position = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook),
                                          GTK_WIDGET (chat));
        gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), position);
@@@ -2244,7 -2288,7 +2292,7 @@@ empathy_chat_window_present_chat (Empat
  
        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);
  }
index 32bf89cc0848201f2026b2d5db2444e89c417444,076cedc94bda9c8458d49a0262a2901a6f4ceb4a..0c4aba0b407e4e9d69727972dd7486636dd27cf1
            </object>
            <accelerator key="Page_Down" modifiers="GDK_CONTROL_MASK"/>
          </child>
+         <child>
+           <object class="GtkAction" id="menu_tabs_undo_close_tab">
+             <property name="name">menu_tabs_undo_close_tab</property>
+             <property name="label" translatable="yes">_Undo Close Tab</property>
+           </object>
+           <accelerator key="t" modifiers="GDK_SHIFT_MASK | GDK_CONTROL_MASK"/>
+         </child>
          <child>
            <object class="GtkAction" id="menu_tabs_left">
              <property name="name">menu_tabs_left</property>
              <property name="label" translatable="yes">Move Tab _Left</property>
            </object>
 +          <accelerator key="Page_Down" modifiers="GDK_CONTROL_MASK|GDK_SHIFT_MASK"/>
          </child>
          <child>
            <object class="GtkAction" id="menu_tabs_right">
              <property name="name">menu_tabs_right</property>
              <property name="label" translatable="yes">Move Tab _Right</property>
            </object>
 +          <accelerator key="Page_Up" modifiers="GDK_CONTROL_MASK|GDK_SHIFT_MASK"/>
          </child>
          <child>
            <object class="GtkAction" id="menu_tabs_detach">
          <menu action="menu_tabs">
            <menuitem action="menu_tabs_prev"/>
            <menuitem action="menu_tabs_next"/>
+           <menuitem action="menu_tabs_undo_close_tab"/>
            <separator/>
            <menuitem action="menu_tabs_left"/>
            <menuitem action="menu_tabs_right"/>
index 635627e742c865a6240389858c99223ba67e71e1,a1544fa6db400530017d218ec22dd5d1f23ac08d..031e23d07f9ae0d39f0cef7c8308fd8df124e56d
@@@ -1,7 -1,7 +1,7 @@@
  /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
  /*
   * Copyright (C) 2002-2007 Imendio AB
 - * Copyright (C) 2007-2008 Collabora Ltd.
 + * Copyright (C) 2007-2010 Collabora Ltd.
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License as
@@@ -25,6 -25,7 +25,7 @@@
  
  #include <sys/stat.h>
  #include <gtk/gtk.h>
+ #include <gdk/gdkkeysyms.h>
  #include <glib/gi18n.h>
  
  #include <telepathy-glib/account-manager.h>
@@@ -53,6 -54,7 +54,7 @@@
  #include <libempathy-gtk/empathy-ui-utils.h>
  
  #include "empathy-accounts-dialog.h"
+ #include "empathy-chat-manager.h"
  #include "empathy-main-window.h"
  #include "ephy-spinner.h"
  #include "empathy-preferences.h"
@@@ -63,7 -65,6 +65,7 @@@
  #include "empathy-chatrooms-window.h"
  #include "empathy-event-manager.h"
  #include "empathy-ft-manager.h"
 +#include "empathy-migrate-butterfly-logs.h"
  
  #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
  #include <libempathy/empathy-debug.h>
@@@ -120,9 -121,6 +122,9 @@@ typedef struct 
  
        /* Actions that are enabled when there are connected accounts */
        GList                  *actions_connected;
 +
 +      /* The idle event source to migrate butterfly's logs */
 +      guint butterfly_log_migration_contact_added_id;
  } EmpathyMainWindow;
  
  static EmpathyMainWindow *main_window = NULL;
@@@ -362,7 -360,7 +364,7 @@@ main_window_error_edit_clicked_cb (GtkB
        account = g_object_get_data (G_OBJECT (button), "account");
  
        empathy_accounts_dialog_show_application (
 -                      gtk_widget_get_screen (GTK_WIDGET (button)), NULL, NULL,
 +                      gtk_widget_get_screen (GTK_WIDGET (button)),
                        account, FALSE, FALSE);
  
        main_window_remove_error (window, account);
@@@ -424,7 -422,6 +426,7 @@@ main_window_error_display (EmpathyMainW
        label = gtk_label_new (str);
        gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
        gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
 +      gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
        gtk_widget_show (label);
        g_free (str);
  
@@@ -657,11 -654,27 +659,28 @@@ main_window_destroy_cb (GtkWidge
                                              window);
        g_object_unref (window->event_manager);
        g_object_unref (window->ui_manager);
 +      g_object_unref (window->chatroom_manager);
  
        g_free (window);
  }
  
+ static gboolean
+ main_window_key_press_event_cb  (GtkWidget *window,
+                                GdkEventKey *event,
+                                gpointer user_data)
+ {
+       EmpathyChatManager *chat_manager;
+       if (event->keyval == GDK_T
+           && event->state & GDK_SHIFT_MASK
+           && event->state & GDK_CONTROL_MASK) {
+               chat_manager = empathy_chat_manager_dup_singleton ();
+               empathy_chat_manager_undo_closed_chat (chat_manager);
+               g_object_unref (chat_manager);
+       }
+       return FALSE;
+ }
  static void
  main_window_chat_quit_cb (GtkAction         *action,
                          EmpathyMainWindow *window)
@@@ -1069,7 -1082,7 +1088,7 @@@ main_window_edit_accounts_cb (GtkActio
                              EmpathyMainWindow *window)
  {
        empathy_accounts_dialog_show_application (gdk_screen_get_default (),
 -                      NULL, NULL, NULL, FALSE, FALSE);
 +                      NULL, FALSE, FALSE);
  }
  
  static void
@@@ -1097,35 -1110,7 +1116,35 @@@ static voi
  main_window_help_debug_cb (GtkAction         *action,
                           EmpathyMainWindow *window)
  {
 -      empathy_debug_window_new (NULL);
 +      GdkScreen *screen = gdk_screen_get_default ();
 +      GError *error = NULL;
 +      gchar *argv[2] = { NULL, };
 +      gint i = 0;
 +      gchar *path;
 +
 +      g_return_if_fail (GDK_IS_SCREEN (screen));
 +
 +      /* Try to run from source directory if possible */
 +      path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "src",
 +                      "empathy-debugger", NULL);
 +
 +      if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
 +              g_free (path);
 +              path = g_build_filename (BIN_DIR, "empathy-debugger", NULL);
 +      }
 +
 +      argv[i++] = path;
 +
 +      gdk_spawn_on_screen (screen, NULL, argv, NULL,
 +                      G_SPAWN_SEARCH_PATH,
 +                      NULL, NULL, NULL, &error);
 +
 +      if (error) {
 +              g_warning ("Failed to open debug window: %s", error->message);
 +              g_error_free (error);
 +      }
 +
 +      g_free (path);
  }
  
  static void
@@@ -1147,7 -1132,7 +1166,7 @@@ main_window_throbber_button_press_event
  
        empathy_accounts_dialog_show_application (
                        gtk_widget_get_screen (GTK_WIDGET (throbber_ebox)),
 -                      NULL, NULL, NULL, FALSE, FALSE);
 +                      NULL, FALSE, FALSE);
  
        return FALSE;
  }
@@@ -1277,18 -1262,6 +1296,18 @@@ account_manager_prepared_cb (GObject *s
        g_list_free (accounts);
  }
  
 +static void
 +main_window_contact_added_cb (EmpathyContactMonitor   *monitor,
 +                            EmpathyContact            *contact,
 +                            EmpathyMainWindow         *window)
 +{
 +      if (!empathy_migrate_butterfly_logs (contact)) {
 +              g_signal_handler_disconnect (monitor,
 +                                           window->butterfly_log_migration_contact_added_id);
 +              window->butterfly_log_migration_contact_added_id = 0;
 +      }
 +}
 +
  GtkWidget *
  empathy_main_window_show (void)
  {
        GSList                   *l;
  
        if (main_window) {
 -              empathy_window_present (GTK_WINDOW (main_window->window), TRUE);
 +              empathy_window_present (GTK_WINDOW (main_window->window));
                return main_window->window;
        }
  
  
        empathy_builder_connect (gui, window,
                              "main_window", "destroy", main_window_destroy_cb,
+                             "main_window", "key-press-event", main_window_key_press_event_cb,
                              "chat_quit", "activate", main_window_chat_quit_cb,
                              "chat_new_message", "activate", main_window_chat_new_message_cb,
                              "chat_new_call", "activate", main_window_chat_new_call_cb,
                                                           EMPATHY_CONTACT_FEATURE_ALL);
        g_signal_connect (monitor, "contact-presence-changed",
                          G_CALLBACK (main_window_contact_presence_changed_cb), window);
 +      window->butterfly_log_migration_contact_added_id =  g_signal_connect (monitor, "contact-added",
 +                        G_CALLBACK (main_window_contact_added_cb), window);
        g_object_unref (list_iface);
  
        gtk_widget_show (GTK_WIDGET (window->list_view));
diff --combined src/empathy.c
index b92f58d26b152f78c2cd2a5401519986adb232e2,d18e165b347803889105abe62a263a48410a6609..637778d4714e38a84adfbd966cc0828f191ce732
@@@ -72,6 -72,7 +72,7 @@@
  #include "empathy-import-mc4-accounts.h"
  #include "empathy-accounts-common.h"
  #include "empathy-accounts-dialog.h"
+ #include "empathy-chat-manager.h"
  #include "empathy-status-icon.h"
  #include "empathy-call-window.h"
  #include "empathy-chat-window.h"
@@@ -240,12 -241,24 +241,12 @@@ migrate_config_to_xdg_dir (void
    g_free (old_dir);
  }
  
 -static void
 -accounts_application_exited_cb (GPid pid,
 -    gint status,
 -    gpointer data)
 -{
 -  if (status)
 -    {
 -      g_warning ("accounts application exited with status %d: '%s'",
 -          status, g_strerror (status));
 -    }
 -}
 -
  static void
  show_accounts_ui (GdkScreen *screen,
      gboolean if_needed)
  {
    empathy_accounts_dialog_show_application (screen,
 -      accounts_application_exited_cb, NULL, NULL, if_needed, start_hidden);
 +      NULL, if_needed, start_hidden);
  }
  
  static UniqueResponse
@@@ -549,18 -562,6 +550,18 @@@ chatroom_manager_ready_cb (EmpathyChatr
        account_manager_chatroom_ready_cb, chatroom_manager);
  }
  
 +static void
 +empathy_idle_set_auto_away_cb (EmpathyConf *conf,
 +                              const gchar *key,
 +                              gpointer user_data)
 +{
 +      gboolean autoaway;
 +      EmpathyIdle *idle = user_data;
 +
 +      empathy_conf_get_bool (conf, key, &autoaway);
 +      empathy_idle_set_auto_away (idle, autoaway);
 +}
 +
  int
  main (int argc, char *argv[])
  {
    GtkWidget *window;
    EmpathyIdle *idle;
    EmpathyConnectivity *connectivity;
+   EmpathyChatManager *chat_manager;
    GError *error = NULL;
    UniqueApp *unique_app;
    gboolean chatroom_manager_ready;
 -
 +  gboolean autoaway = TRUE;
  #ifdef ENABLE_DEBUG
    TpDebugSender *debug_sender;
 -#endif /* ENABLE_TPL */
 +#endif
  
    GOptionContext *optcontext;
    GOptionEntry options[] = {
  
    /* Setting up Idle */
    idle = empathy_idle_dup_singleton ();
 -  empathy_idle_set_auto_away (idle, TRUE);
 +
 +  empathy_conf_get_bool (empathy_conf_get (),
 +      EMPATHY_PREFS_AUTOAWAY, &autoaway);
 +
 +  empathy_conf_notify_add (empathy_conf_get (),
 +                         EMPATHY_PREFS_AUTOAWAY,
 +                         empathy_idle_set_auto_away_cb,
 +                         idle);
 +
 +  empathy_idle_set_auto_away (idle, autoaway);
  
    /* Setting up Connectivity */
    connectivity = empathy_connectivity_dup_singleton ();
    window = empathy_main_window_show ();
    icon = empathy_status_icon_new (GTK_WINDOW (window), start_hidden);
  
+   /* Chat manager */
+   chat_manager = empathy_chat_manager_dup_singleton ();
    g_signal_connect (unique_app, "message-received",
        G_CALLBACK (unique_app_message_cb), window);
  
    g_object_unref (debug_sender);
  #endif
  
+   g_object_unref (chat_manager);
    g_object_unref (idle);
    g_object_unref (connectivity);
    g_object_unref (icon);