]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-chat-window.c
Updatre python binding
[empathy.git] / libempathy-gtk / empathy-chat-window.c
index b4475ff7ab64aea3c73f43add9ed6ae479f4af8f..5e5a854c52d035eda7e909cd3283e57d6b4c8c98 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * Copyright (C) 2003-2007 Imendio AB
- * Copyright (C) 2007 Collabora Ltd.
+ * Copyright (C) 2007-2008 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
@@ -43,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))
 
@@ -103,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;
 };
@@ -168,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);
@@ -306,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,
@@ -329,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);
@@ -464,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;
                }
@@ -779,21 +781,21 @@ chat_window_update_menu (EmpathyChatWindow *window)
                                                   chat_window_show_contacts_toggled_cb,
                                                   window);
        } else {
-               EmpathyPrivateChat  *chat;
-               EmpathyContact      *contact;
-               EmpathyPresence     *presence;
+               EmpathyPrivateChat *chat;
+               EmpathyContact     *contact;
+               McPresence          presence;
 
                chat = EMPATHY_PRIVATE_CHAT (priv->current_chat);
 
                /* Show / Hide widgets */
                gtk_widget_hide (priv->menu_room);
 
-               /* presence==NULL means this contact refuses to send us his
+               /* Unset presence means this contact refuses to send us his
                 * presence. By adding the contact we ask the contact to accept
                 * to send his presence. */
                contact = empathy_private_chat_get_contact (chat);
                presence = empathy_contact_get_presence (contact);
-               if (!presence) {
+               if (presence == MC_PRESENCE_UNSET) {
                        gtk_widget_show (priv->menu_conv_add_contact);
                } else {
                        gtk_widget_hide (priv->menu_conv_add_contact);
@@ -871,7 +873,7 @@ chat_window_call_activate_cb (GtkWidget         *menuitem,
                chat = EMPATHY_PRIVATE_CHAT (priv->current_chat);
                contact = empathy_private_chat_get_contact (chat);
 
-               empathy_call_contact (contact);
+               empathy_call_with_contact (contact);
        }
 }
 
@@ -932,11 +934,6 @@ chat_window_configure_event_cb (GtkWidget         *widget,
 
        priv = GET_PRIV (window);
 
-       /* Only save geometry information if there is ONE chat visible. */
-       if (g_list_length (priv->chats) > 1) {
-               return FALSE;
-       }
-
        if (priv->save_geometry_id != 0) {
                g_source_remove (priv->save_geometry_id);
        }
@@ -1234,6 +1231,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,
@@ -1610,16 +1621,7 @@ chat_window_drag_data_received (GtkWidget        *widget,
                chat = empathy_chat_window_find_chat (account, id);
 
                if (!chat) {
-                       MissionControl *mc;
-
-                       mc = empathy_mission_control_new ();
-                       mission_control_request_channel (mc,
-                                                        empathy_contact_get_account (contact),
-                                                        TP_IFACE_CHANNEL_TYPE_TEXT,
-                                                        empathy_contact_get_handle (contact),
-                                                        TP_HANDLE_TYPE_CONTACT,
-                                                        NULL, NULL);
-                       g_object_unref (mc);
+                       empathy_chat_with_contact_id (account, id);
                        return;
                }
 
@@ -1724,8 +1726,9 @@ empathy_chat_window_add_chat (EmpathyChatWindow *window,
                              EmpathyChat       *chat)
 {
        EmpathyChatWindowPriv *priv;
-       GtkWidget            *label;
-       GtkWidget            *child;
+       GtkWidget             *label;
+       GtkWidget             *child;
+       gint                   x, y, w, h;
 
        g_return_if_fail (window != NULL);
        g_return_if_fail (EMPATHY_IS_CHAT (chat));
@@ -1738,24 +1741,20 @@ empathy_chat_window_add_chat (EmpathyChatWindow *window,
        /* Set the chat window */
        empathy_chat_set_window (chat, window);
 
-       if (g_list_length (priv->chats) == 0) {
-               gint x, y, w, h;
-
-               empathy_chat_load_geometry (chat, &x, &y, &w, &h);
+       empathy_chat_load_geometry (chat, &x, &y, &w, &h);
 
-               if (x >= 0 && y >= 0) {
-                       /* Let the window manager position it if we don't have
-                        * good x, y coordinates.
-                        */
-                       gtk_window_move (GTK_WINDOW (priv->dialog), x, y);
-               }
+       if (x >= 0 && y >= 0) {
+               /* Let the window manager position it if we don't have
+                * good x, y coordinates.
+                */
+               gtk_window_move (GTK_WINDOW (priv->dialog), x, y);
+       }
 
-               if (w > 0 && h > 0) {
-                       /* Use the defaults from the glade file if we don't have
-                        * good w, h geometry.
-                        */
-                       gtk_window_resize (GTK_WINDOW (priv->dialog), w, h);
-               }
+       if (w > 0 && h > 0) {
+               /* Use the defaults from the glade file if we don't have
+                * good w, h geometry.
+                */
+               gtk_window_resize (GTK_WINDOW (priv->dialog), w, h);
        }
 
        child = empathy_chat_get_widget (chat);