]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-chat-window.c
Move empathy-conf to libempathy-gtk. libempathy do not depend directly on gconf anymore.
[empathy.git] / libempathy-gtk / empathy-chat-window.c
index a4d29b258b112cf2f01bf7e4fdf752ca01bec079..5acddc1e6c0e0d8ec27692a9a254cf3e4dda41df 100644 (file)
@@ -34,6 +34,8 @@
 #include <glade/glade.h>
 #include <glib/gi18n.h>
 
+#include <libmissioncontrol/mission-control.h>
+
 #include <libempathy/empathy-contact-factory.h>
 #include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-log-manager.h>
@@ -41,7 +43,6 @@
 #include <libempathy/empathy-contact.h>
 #include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-message.h>
-#include <libempathy/empathy-conf.h>
 #include <libempathy/empathy-utils.h>
 
 #include "empathy-chat-window.h"
 #include "empathy-contact-dialogs.h"
 #include "empathy-log-window.h"
 #include "empathy-new-chatroom-dialog.h"
+#include "empathy-conf.h"
 #include "empathy-preferences.h"
 #include "empathy-private-chat.h"
 #include "empathy-group-chat.h"
 //#include "empathy-sound.h"
 #include "empathy-ui-utils.h"
+#include "empathy-about-dialog.h"
 
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CHAT_WINDOW, EmpathyChatWindowPriv))
 
@@ -101,6 +104,9 @@ struct _EmpathyChatWindowPriv {
        GtkWidget             *menu_tabs_left;
        GtkWidget             *menu_tabs_right;
        GtkWidget             *menu_tabs_detach;
+       
+       GtkWidget             *menu_help_contents;
+       GtkWidget             *menu_help_about;
 
        guint                  save_geometry_id;
 };
@@ -166,6 +172,10 @@ static void       chat_window_tabs_right_activate_cb    (GtkWidget             *
                                                         EmpathyChatWindow      *window);
 static void       chat_window_detach_activate_cb        (GtkWidget             *menuitem,
                                                         EmpathyChatWindow      *window);
+static void       chat_window_help_contents_cb          (GtkWidget             *menuitem,
+                                                        EmpathyChatWindow      *window);
+static void       chat_window_help_about_cb             (GtkWidget             *menuitem,
+                                                        EmpathyChatWindow      *window);
 static gboolean   chat_window_delete_event_cb           (GtkWidget             *dialog,
                                                         GdkEvent              *event,
                                                         EmpathyChatWindow      *window);
@@ -304,6 +314,8 @@ empathy_chat_window_init (EmpathyChatWindow *window)
                                       "menu_tabs_left", &priv->menu_tabs_left,
                                       "menu_tabs_right", &priv->menu_tabs_right,
                                       "menu_tabs_detach", &priv->menu_tabs_detach,
+                                      "menu_help_contents", &priv->menu_help_contents,
+                                      "menu_help_about", &priv->menu_help_about,
                                       NULL);
 
        empathy_glade_connect (glade,
@@ -327,6 +339,8 @@ empathy_chat_window_init (EmpathyChatWindow *window)
                              "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,
+                             "menu_help_contents", "activate", chat_window_help_contents_cb,
+                             "menu_help_about", "activate", chat_window_help_about_cb,
                              NULL);
 
        g_object_unref (glade);
@@ -462,22 +476,12 @@ empathy_chat_window_get_default (void)
 
        for (l = chat_windows; l; l = l->next) {
                EmpathyChatWindow *chat_window;
-               GtkWidget        *dialog;
-               GdkWindow        *window;
-               gboolean          visible;
+               GtkWidget         *dialog;
 
                chat_window = l->data;
 
                dialog = empathy_chat_window_get_dialog (chat_window);
-               window = dialog->window;
-
-               g_object_get (dialog,
-                             "visible", &visible,
-                             NULL);
-
-               visible = visible && !(gdk_window_get_state (window) & GDK_WINDOW_STATE_ICONIFIED);
-
-               if (visible) {
+               if (empathy_window_get_is_visible (GTK_WINDOW (GTK_WINDOW (dialog)))) {
                        /* Found a visible window on this desktop */
                        return chat_window;
                }
@@ -749,8 +753,8 @@ chat_window_update_menu (EmpathyChatWindow *window)
                 * connected to the room?
                 */
                chatroom = empathy_chatroom_manager_find (priv->chatroom_manager,
-                                                        priv->current_chat->account,
-                                                        empathy_chat_get_id (priv->current_chat));
+                                                         empathy_chat_get_account (priv->current_chat),
+                                                         empathy_chat_get_id (priv->current_chat));
 
                gtk_widget_set_sensitive (priv->menu_room_add, chatroom == NULL);
                gtk_widget_set_sensitive (priv->menu_conv_insert_smiley, is_connected);
@@ -881,10 +885,10 @@ chat_window_log_activate_cb (GtkWidget        *menuitem,
 
        priv = GET_PRIV (window);
 
-       empathy_log_window_show (priv->current_chat->account,
-                               empathy_chat_get_id (priv->current_chat),
-                               empathy_chat_is_group_chat (priv->current_chat),
-                               GTK_WINDOW (priv->dialog));
+       empathy_log_window_show (empathy_chat_get_account (priv->current_chat),
+                                empathy_chat_get_id (priv->current_chat),
+                                empathy_chat_is_group_chat (priv->current_chat),
+                                GTK_WINDOW (priv->dialog));
 }
 
 static void
@@ -960,7 +964,7 @@ chat_window_conv_activate_cb (GtkWidget         *menuitem,
 
        manager = empathy_log_manager_new ();
        log_exists = empathy_log_manager_exists (manager,
-                                                priv->current_chat->account,
+                                                empathy_chat_get_account (priv->current_chat),
                                                 empathy_chat_get_id (priv->current_chat),
                                                 empathy_chat_is_group_chat (priv->current_chat));
        g_object_unref (manager);
@@ -1077,10 +1081,10 @@ chat_window_room_add_activate_cb (GtkWidget        *menuitem,
                return;
        }
 
-       chatroom = empathy_chatroom_new_full (priv->current_chat->account,
-                                            empathy_chat_get_id (priv->current_chat),
-                                            empathy_chat_get_name (priv->current_chat),
-                                            FALSE);
+       chatroom = empathy_chatroom_new_full (empathy_chat_get_account (priv->current_chat),
+                                             empathy_chat_get_id (priv->current_chat),
+                                             empathy_chat_get_name (priv->current_chat),
+                                             FALSE);
 
        manager = empathy_chatroom_manager_new ();
        empathy_chatroom_manager_add (manager, chatroom);
@@ -1232,6 +1236,20 @@ chat_window_detach_activate_cb (GtkWidget        *menuitem,
        gtk_widget_show (priv->dialog);
 }
 
+static void
+chat_window_help_contents_cb (GtkWidget         *menuitem,
+                             EmpathyChatWindow *window)
+{
+       //empathy_help_show ();
+}
+
+static void
+chat_window_help_about_cb (GtkWidget         *menuitem,
+                          EmpathyChatWindow *window)
+{
+       empathy_about_dialog_new (GTK_WINDOW (window));
+}
+
 static gboolean
 chat_window_delete_event_cb (GtkWidget        *dialog,
                             GdkEvent         *event,
@@ -1571,7 +1589,6 @@ chat_window_drag_data_received (GtkWidget        *widget,
                                guint             time,
                                EmpathyChatWindow *window)
 {
-       /* FIXME: DnD of contact do not seems to work... */
        if (info == DND_DRAG_TYPE_CONTACT_ID) {
                EmpathyContactFactory *factory;
                EmpathyContact        *contact = NULL;
@@ -1607,8 +1624,13 @@ chat_window_drag_data_received (GtkWidget        *widget,
                
                account = empathy_contact_get_account (contact);
                chat = empathy_chat_window_find_chat (account, id);
-               old_window = empathy_chat_get_window (chat);
-               
+
+               if (!chat) {
+                       empathy_chat_with_contact_id (account, id);
+                       return;
+               }
+
+               old_window = empathy_chat_get_window (chat);            
                if (old_window) {
                        if (old_window == window) {
                                gtk_drag_finish (context, TRUE, FALSE, time);
@@ -1866,7 +1888,7 @@ empathy_chat_window_find_chat (McAccount   *account,
 
                        chat = ll->data;
 
-                       if (empathy_account_equal (account, chat->account) &&
+                       if (empathy_account_equal (account, empathy_chat_get_account (chat)) &&
                            strcmp (id, empathy_chat_get_id (chat)) == 0) {
                                return chat;
                        }