]> git.0d.be Git - empathy.git/blobdiff - src/empathy-main-window.c
Remove useless mission-control includes
[empathy.git] / src / empathy-main-window.c
index b9993a8f543edc65dbefc9b49119506f91658f20..0d04153a31698bcb4921090e84842d5438e3d02f 100644 (file)
@@ -15,9 +15,9 @@
  *
  * You should have received a copy of the GNU General Public
  * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- * 
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301  USA
+ *
  * Authors: Xavier Claessens <xclaesse@gmail.com>
  */
 
 #include <libempathy/empathy-contact-manager.h>
 #include <libempathy/empathy-status-presets.h>
 
+#include <libempathy-gtk/empathy-conf.h>
 #include <libempathy-gtk/empathy-contact-dialogs.h>
 #include <libempathy-gtk/empathy-contact-list-store.h>
 #include <libempathy-gtk/empathy-contact-list-view.h>
-#include <libempathy-gtk/empathy-presence-chooser.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
 #include <libempathy-gtk/empathy-geometry.h>
-#include <libempathy-gtk/empathy-conf.h>
-#include <libempathy-gtk/empathy-log-window.h>
-#include <libempathy-gtk/empathy-new-message-dialog.h>
 #include <libempathy-gtk/empathy-gtk-enum-types.h>
-
-#include <libmissioncontrol/mission-control.h>
+#include <libempathy-gtk/empathy-new-message-dialog.h>
+#include <libempathy-gtk/empathy-log-window.h>
+#include <libempathy-gtk/empathy-presence-chooser.h>
+#include <libempathy-gtk/empathy-sound.h>
+#include <libempathy-gtk/empathy-ui-utils.h>
 
 #include "empathy-accounts-dialog.h"
 #include "empathy-main-window.h"
 #include "ephy-spinner.h"
 #include "empathy-preferences.h"
 #include "empathy-about-dialog.h"
+#include "empathy-debug-dialog.h"
 #include "empathy-new-chatroom-dialog.h"
+#include "empathy-map-view.h"
 #include "empathy-chatrooms-window.h"
 #include "empathy-event-manager.h"
+#include "empathy-ft-manager.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
 #include <libempathy/empathy-debug.h>
@@ -92,7 +94,7 @@ typedef struct {
        GtkWidget              *errors_vbox;
 
        GtkUIManager           *ui_manager;
-       GtkAction              *chat_history;
+       GtkAction              *view_history;
        GtkAction              *room_join_favorites;
        GtkWidget              *room_menu;
        GtkWidget              *room_separator;
@@ -132,7 +134,7 @@ main_window_flash_foreach (GtkTreeModel *model,
                           GtkTreeIter  *iter,
                           gpointer      user_data)
 {
-       FlashForeachData *data = (FlashForeachData*) user_data;
+       FlashForeachData *data = (FlashForeachData *) user_data;
        EmpathyContact   *contact;
        const gchar      *icon_name;
        GtkTreePath      *parent_path = NULL;
@@ -164,7 +166,7 @@ main_window_flash_foreach (GtkTreeModel *model,
 
        /* To make sure the parent is shown correctly, we emit
         * the row-changed signal on the parent so it prompts
-        * it to be refreshed by the filter func. 
+        * it to be refreshed by the filter func.
         */
        if (gtk_tree_model_iter_parent (model, &parent_iter, iter)) {
                parent_path = gtk_tree_model_get_path (model, &parent_iter);
@@ -194,7 +196,7 @@ main_window_flash_cb (EmpathyMainWindow *window)
        events = empathy_event_manager_get_events (window->event_manager);
        for (l = events; l; l = l->next) {
                data.event = l->data;
-               if (!data.event->contact) {
+               if (!data.event->contact || !data.event->must_ack) {
                        continue;
                }
 
@@ -298,7 +300,7 @@ static void
 main_window_error_edit_clicked_cb (GtkButton         *button,
                                   EmpathyMainWindow *window)
 {
-       McAccount *account;
+       EmpathyAccount *account;
        GtkWidget *error_widget;
 
        account = g_object_get_data (G_OBJECT (button), "account");
@@ -313,7 +315,7 @@ static void
 main_window_error_clear_clicked_cb (GtkButton         *button,
                                    EmpathyMainWindow *window)
 {
-       McAccount *account;
+       EmpathyAccount *account;
        GtkWidget *error_widget;
 
        account = g_object_get_data (G_OBJECT (button), "account");
@@ -324,7 +326,7 @@ main_window_error_clear_clicked_cb (GtkButton         *button,
 
 static void
 main_window_error_display (EmpathyMainWindow *window,
-                          McAccount         *account,
+                          EmpathyAccount    *account,
                           const gchar       *message)
 {
        GtkWidget *child;
@@ -345,7 +347,7 @@ main_window_error_display (EmpathyMainWindow *window,
 
                /* Just set the latest error and return */
                str = g_markup_printf_escaped ("<b>%s</b>\n%s",
-                                              mc_account_get_display_name (account),
+                                              empathy_account_get_display_name (account),
                                               message);
                gtk_label_set_markup (GTK_LABEL (label), str);
                g_free (str);
@@ -426,7 +428,7 @@ main_window_error_display (EmpathyMainWindow *window,
        gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
 
        str = g_markup_printf_escaped ("<b>%s</b>\n%s",
-                                      mc_account_get_display_name (account),
+                                      empathy_account_get_display_name (account),
                                       message);
        gtk_label_set_markup (GTK_LABEL (label), str);
        g_free (str);
@@ -478,7 +480,7 @@ main_window_update_status (EmpathyMainWindow *window, EmpathyAccountManager *man
 
 static void
 main_window_connection_changed_cb (EmpathyAccountManager *manager,
-                                  McAccount *account,
+                                  EmpathyAccount *account,
                                   TpConnectionStatusReason reason,
                                   TpConnectionStatus current,
                                   TpConnectionStatus previous,
@@ -561,32 +563,39 @@ main_window_connection_changed_cb (EmpathyAccountManager *manager,
 static void
 main_window_contact_presence_changed_cb (EmpathyContactMonitor *monitor,
                                         EmpathyContact *contact,
-                                        McPresence current,
-                                        McPresence previous,
+                                        TpConnectionPresenceType current,
+                                        TpConnectionPresenceType previous,
                                         EmpathyMainWindow *window)
 {
-       McAccount *account;
+       EmpathyAccount *account;
        gboolean should_play;
 
        account = empathy_contact_get_account (contact);
-       should_play = !empathy_account_manager_is_account_just_connected (window->account_manager, account);
+       should_play = !empathy_account_is_just_connected (account);
 
        if (!should_play) {
                return;
        }
 
-       if (previous < MC_PRESENCE_AVAILABLE && current > MC_PRESENCE_OFFLINE) {
-               /* someone is logging in */
-               empathy_sound_play (GTK_WIDGET (window->window),
-                                   EMPATHY_SOUND_CONTACT_CONNECTED);
-               return;
-       }
-
-       if (previous > MC_PRESENCE_OFFLINE && current < MC_PRESENCE_AVAILABLE) {
-               /* someone is logging off */
-               empathy_sound_play (GTK_WIDGET (window->window),
-                                   EMPATHY_SOUND_CONTACT_DISCONNECTED);
-       }
+  if (tp_connection_presence_type_cmp_availability (previous,
+     TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
+    {
+      /* contact was online */
+      if (tp_connection_presence_type_cmp_availability (current,
+          TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0)
+        /* someone is logging off */
+        empathy_sound_play (GTK_WIDGET (window->window),
+          EMPATHY_SOUND_CONTACT_DISCONNECTED);
+    }
+  else
+    {
+      /* contact was offline */
+      if (tp_connection_presence_type_cmp_availability (current,
+          TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
+        /* someone is logging in */
+        empathy_sound_play (GTK_WIDGET (window->window),
+          EMPATHY_SOUND_CONTACT_CONNECTED);
+    }
 }
 
 static void
@@ -662,7 +671,7 @@ main_window_chat_quit_cb (GtkAction         *action,
 }
 
 static void
-main_window_chat_history_cb (GtkAction         *action,
+main_window_view_history_cb (GtkAction         *action,
                             EmpathyMainWindow *window)
 {
        empathy_log_window_show (NULL, NULL, FALSE, GTK_WINDOW (window->window));
@@ -683,7 +692,14 @@ main_window_chat_add_contact_cb (GtkAction         *action,
 }
 
 static void
-main_window_chat_show_offline_cb (GtkToggleAction   *action,
+main_window_view_show_ft_manager (GtkAction         *action,
+                                 EmpathyMainWindow *window)
+{
+       empathy_ft_manager_show ();
+}
+
+static void
+main_window_view_show_offline_cb (GtkToggleAction   *action,
                                  EmpathyMainWindow *window)
 {
        gboolean current;
@@ -699,19 +715,25 @@ main_window_chat_show_offline_cb (GtkToggleAction   *action,
        //empathy_sound_set_enabled (TRUE);
 }
 
+static void
+main_window_view_show_map_cb (GtkCheckMenuItem  *item,
+                             EmpathyMainWindow *window)
+{
+#if HAVE_LIBCHAMPLAIN
+       empathy_map_view_show ();
+#endif
+}
+
 static void
 main_window_favorite_chatroom_join (EmpathyChatroom *chatroom)
 {
-       EmpathyAccountManager *manager;
-       McAccount      *account;
+       EmpathyAccount *account;
        TpConnection   *connection;
        const gchar    *room;
 
-       manager = empathy_account_manager_dup_singleton ();
        account = empathy_chatroom_get_account (chatroom);
-       connection = empathy_account_manager_get_connection (manager, account);
+       connection = empathy_account_get_connection (account);
        room = empathy_chatroom_get_room (chatroom);
-       g_object_unref (manager);
 
        if (connection != NULL) {
                DEBUG ("Requesting channel for '%s'", room);
@@ -920,6 +942,13 @@ main_window_help_about_cb (GtkAction         *action,
        empathy_about_dialog_new (GTK_WINDOW (window->window));
 }
 
+static void
+main_window_help_debug_cb (GtkAction         *action,
+                          EmpathyMainWindow *window)
+{
+       empathy_debug_dialog_new (GTK_WINDOW (window->window));
+}
+
 static void
 main_window_help_contents_cb (GtkAction         *action,
                              EmpathyMainWindow *window)
@@ -975,10 +1004,10 @@ main_window_configure_event_cb (GtkWidget         *widget,
 
 static void
 main_window_account_created_or_deleted_cb (EmpathyAccountManager  *manager,
-                                          McAccount              *account,
+                                          EmpathyAccount         *account,
                                           EmpathyMainWindow      *window)
 {
-       gtk_action_set_sensitive (window->chat_history,
+       gtk_action_set_sensitive (window->view_history,
                empathy_account_manager_get_count (manager) > 0);
 }
 
@@ -1038,7 +1067,7 @@ main_window_notify_sort_criterium_cb (EmpathyConf       *conf,
                g_free (str);
 
                if (enum_value) {
-                       empathy_contact_list_store_set_sort_criterium (window->list_store, 
+                       empathy_contact_list_store_set_sort_criterium (window->list_store,
                                                                       enum_value->value);
                }
        }
@@ -1082,6 +1111,7 @@ empathy_main_window_show (void)
        GtkWidget                *sw;
        GtkToggleAction          *show_offline_widget;
        GtkWidget                *ebox;
+       GtkAction                *show_map_widget;
        GtkToolItem              *item;
        gboolean                  show_offline;
        gboolean                  show_avatars;
@@ -1104,8 +1134,9 @@ empathy_main_window_show (void)
                                       "main_vbox", &window->main_vbox,
                                       "errors_vbox", &window->errors_vbox,
                                       "ui_manager", &window->ui_manager,
-                                      "chat_show_offline", &show_offline_widget,
-                                      "chat_history", &window->chat_history,
+                                      "view_show_offline", &show_offline_widget,
+                                      "view_history", &window->view_history,
+                                      "view_show_map", &show_map_widget,
                                       "room_join_favorites", &window->room_join_favorites,
                                       "presence_toolbar", &window->presence_toolbar,
                                       "roster_scrolledwindow", &sw,
@@ -1117,17 +1148,20 @@ empathy_main_window_show (void)
                              "main_window", "configure_event", main_window_configure_event_cb,
                              "chat_quit", "activate", main_window_chat_quit_cb,
                              "chat_new_message", "activate", main_window_chat_new_message_cb,
-                             "chat_history", "activate", main_window_chat_history_cb,
+                             "view_history", "activate", main_window_view_history_cb,
                              "room_join_new", "activate", main_window_room_join_new_cb,
                              "room_join_favorites", "activate", main_window_room_join_favorites_cb,
                              "room_manage_favorites", "activate", main_window_room_manage_favorites_cb,
                              "chat_add_contact", "activate", main_window_chat_add_contact_cb,
-                             "chat_show_offline", "toggled", main_window_chat_show_offline_cb,
+                             "view_show_ft_manager", "activate", main_window_view_show_ft_manager,
+                             "view_show_offline", "toggled", main_window_view_show_offline_cb,
+                             "view_show_map", "activate", main_window_view_show_map_cb,
                              "edit", "activate", main_window_edit_cb,
                              "edit_accounts", "activate", main_window_edit_accounts_cb,
                              "edit_personal_information", "activate", main_window_edit_personal_information_cb,
                              "edit_preferences", "activate", main_window_edit_preferences_cb,
                              "help_about", "activate", main_window_help_about_cb,
+                             "help_debug", "activate", main_window_help_debug_cb,
                              "help_contents", "activate", main_window_help_contents_cb,
                              NULL);
 
@@ -1137,6 +1171,10 @@ empathy_main_window_show (void)
        g_object_ref (window->ui_manager);
        g_object_unref (gui);
 
+#if !HAVE_LIBCHAMPLAIN
+       gtk_action_set_visible (show_map_widget, FALSE);
+#endif
+
        window->mc = empathy_mission_control_dup_singleton ();
        window->account_manager = empathy_account_manager_dup_singleton ();