]> git.0d.be Git - empathy.git/commitdiff
Merge branch 'spelling-578399'
authorDavyd Madeley <davyd@madeley.id.au>
Fri, 24 Apr 2009 01:07:25 +0000 (09:07 +0800)
committerDavyd Madeley <davyd@madeley.id.au>
Fri, 24 Apr 2009 01:07:25 +0000 (09:07 +0800)
1  2 
libempathy-gtk/Makefile.am
libempathy-gtk/empathy-chat.c
po/POTFILES.in
python/pyempathygtk/pyempathygtk.defs
python/update-binding.sh

index 63bcf5ae35a91655e26d83d20e0b70dd15097fe2,470d44ea5684184a4d00052a3a89202a30cab07d..2065589e3594b19d11419d9f2318e1bcfcb7fbe9
@@@ -49,8 -49,6 +49,7 @@@ libempathy_gtk_la_SOURCES 
        empathy-profile-chooser.c               \
        empathy-smiley-manager.c                \
        empathy-spell.c                         \
-       empathy-spell-dialog.c                  \
 +      empathy-status-preset-dialog.c          \
        empathy-theme-boxes.c                   \
        empathy-theme-irc.c                     \
        empathy-theme-manager.c                 \
@@@ -103,8 -101,6 +102,7 @@@ libempathy_gtk_headers =                   
        empathy-profile-chooser.h               \
        empathy-smiley-manager.h                \
        empathy-spell.h                         \
-       empathy-spell-dialog.h                  \
 +      empathy-status-preset-dialog.h          \
        empathy-theme-boxes.h                   \
        empathy-theme-irc.h                     \
        empathy-theme-manager.h                 \
@@@ -119,6 -115,7 +117,6 @@@ uidir = $(datadir)/empath
  ui_DATA =                                     \
        empathy-contact-widget.ui               \
        empathy-contact-dialogs.ui              \
 -      empathy-presence-chooser.ui             \
        empathy-account-widget-generic.ui       \
        empathy-account-widget-jabber.ui        \
        empathy-account-widget-msn.ui           \
        empathy-account-widget-yahoo.ui         \
        empathy-account-widget-groupwise.ui     \
        empathy-account-widget-aim.ui           \
-       empathy-spell-dialog.ui                 \
 +      empathy-status-preset-dialog.ui         \
        empathy-log-window.ui                   \
        empathy-chat.ui                         \
        empathy-new-message-dialog.ui
index 985eaa4cf6f3dc57a8e8682a276d55e0a734974f,c8ec59f1be98d823266093fa46da31da38d2ef59..425a1c555a4c41036c6bc40726e849e5886faff9
@@@ -45,7 -45,6 +45,6 @@@
  #include "empathy-chat.h"
  #include "empathy-conf.h"
  #include "empathy-spell.h"
- #include "empathy-spell-dialog.h"
  #include "empathy-contact-list-store.h"
  #include "empathy-contact-list-view.h"
  #include "empathy-contact-menu.h"
@@@ -65,6 -64,7 +64,6 @@@
  #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChat)
  typedef struct {
        EmpathyTpChat     *tp_chat;
 -      gulong            tp_chat_destroy_handler;
        McAccount         *account;
        gchar             *id;
        gchar             *name;
@@@ -189,15 -189,17 +188,15 @@@ chat_connect_channel_reconnected (Empat
  }
  
  static void
 -chat_connection_changed_cb (EmpathyAccountManager *manager,
 -                          McAccount *account,
 -                          TpConnectionStatusReason reason,
 -                          TpConnectionStatus current,
 -                          TpConnectionStatus previous,
 -                          EmpathyChat *chat)
 +chat_new_connection_cb (EmpathyAccountManager *manager,
 +                      TpConnection *connection,
 +                      EmpathyChat *chat)
  {
        EmpathyChatPriv *priv = GET_PRIV (chat);
 +      McAccount *account;
  
 -      if (current == TP_CONNECTION_STATUS_CONNECTED && !priv->tp_chat &&
 -          empathy_account_equal (account, priv->account) &&
 +      account = empathy_account_manager_get_account (manager, connection);
 +      if (!priv->tp_chat && empathy_account_equal (account, priv->account) &&
            priv->handle_type != TP_HANDLE_TYPE_NONE &&
            !EMP_STR_EMPTY (priv->id)) {
                
  
                switch (priv->handle_type) {
                        case TP_HANDLE_TYPE_CONTACT:
 -                              empathy_dispatcher_chat_with_contact_id (account, priv->id,
 +                              empathy_dispatcher_chat_with_contact_id (
 +                                      connection, priv->id,
                                        chat_connect_channel_reconnected,
                                        chat);
                                break;
                        case TP_HANDLE_TYPE_ROOM:
 -                              empathy_dispatcher_join_muc (account, priv->id,
 +                              empathy_dispatcher_join_muc (connection,
 +                                      priv->id,
                                        chat_connect_channel_reconnected,
                                        chat);
                                break;
@@@ -595,7 -595,7 +594,7 @@@ chat_property_changed_cb (EmpathyTpCha
  
  static void
  chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer,
-                                  EmpathyChat    *chat)
+                                    EmpathyChat    *chat)
  {
        EmpathyChatPriv *priv;
        GtkTextIter     start, end;
        }
  
        empathy_conf_get_bool (empathy_conf_get (),
-                             EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
-                             &spell_checker);
+                            EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
+                            &spell_checker);
  
        gtk_text_buffer_get_start_iter (buffer, &start);
  
@@@ -931,13 -931,42 +930,42 @@@ chat_spell_free (EmpathyChatSpell *chat
  }
  
  static void
- chat_text_check_word_spelling_cb (GtkMenuItem     *menuitem,
-                                 EmpathyChatSpell *chat_spell)
+ chat_spelling_menu_activate_cb (GtkMenuItem     *menu_item,
+                                               EmpathyChatSpell *chat_spell)
  {
-       empathy_spell_dialog_show (chat_spell->chat,
-                                 &chat_spell->start,
-                                 &chat_spell->end,
-                                 chat_spell->word);
+     empathy_chat_correct_word (chat_spell->chat,
+                                &(chat_spell->start),
+                                &(chat_spell->end),
+                                gtk_menu_item_get_label (menu_item));
+ }
+ static GtkWidget*
+ chat_spelling_build_menu (EmpathyChatSpell *chat_spell)
+ {
+     GtkWidget *menu, *menu_item;
+     GList     *suggestions, *l;
+     menu = gtk_menu_new ();
+     suggestions = empathy_spell_get_suggestions (chat_spell->word);
+     if (suggestions == NULL) {
+         menu_item = gtk_menu_item_new_with_label (_("(No Suggestions)"));
+       gtk_widget_set_sensitive (menu_item, FALSE);
+         gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+     } else {
+         for (l = suggestions; l; l = l->next) {
+             menu_item = gtk_menu_item_new_with_label (l->data);
+             g_signal_connect (G_OBJECT (menu_item),
+                           "activate",
+                           G_CALLBACK (chat_spelling_menu_activate_cb),
+                           chat_spell);
+             gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+         }
+     }
+     empathy_spell_free_suggestions (suggestions);
+     gtk_widget_show_all (menu);
+     return menu;
  }
  
  static void
@@@ -960,7 -989,8 +988,8 @@@ chat_input_populate_popup_cb (GtkTextVi
        GtkTextIter           iter, start, end;
        GtkWidget            *item;
        gchar                *str = NULL;
-       EmpathyChatSpell      *chat_spell;
+       EmpathyChatSpell     *chat_spell;
+       GtkWidget            *spell_menu;
        EmpathySmileyManager *smiley_manager;
        GtkWidget            *smiley_menu;
        GtkWidget            *image;
                gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
                gtk_widget_show (item);
  
-               item = gtk_image_menu_item_new_with_mnemonic (_("_Check Word Spelling..."));
+               item = gtk_image_menu_item_new_with_mnemonic (_("_Spelling Suggestions"));
                image = gtk_image_new_from_icon_name (GTK_STOCK_SPELL_CHECK,
                                                      GTK_ICON_SIZE_MENU);
                gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
-               g_signal_connect (item,
-                                 "activate",
-                                 G_CALLBACK (chat_text_check_word_spelling_cb),
-                                 chat_spell);
+               spell_menu = chat_spelling_build_menu (chat_spell);
+               gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), spell_menu);
                gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
                gtk_widget_show (item);
        }
@@@ -1138,6 -1168,10 +1167,6 @@@ chat_members_changed_cb (EmpathyTpCha
        if (priv->block_events_timeout_id == 0) {
                gchar *str;
  
 -              empathy_contact_run_until_ready (contact,
 -                                               EMPATHY_CONTACT_READY_NAME,
 -                                               NULL);
 -
                if (is_member) {
                        str = g_strdup_printf (_("%s has joined the room"),
                                               empathy_contact_get_name (contact));
@@@ -1429,26 -1463,13 +1458,26 @@@ chat_finalize (GObject *object
        chat_composing_remove_timeout (chat);
  
        g_signal_handlers_disconnect_by_func (priv->account_manager,
 -                                            chat_connection_changed_cb, object);
 +                                            chat_new_connection_cb, object);
  
        g_object_unref (priv->account_manager);
        g_object_unref (priv->log_manager);
  
        if (priv->tp_chat) {
 -              g_signal_handler_disconnect (priv->tp_chat, priv->tp_chat_destroy_handler);
 +              g_signal_handlers_disconnect_by_func (priv->tp_chat,
 +                      chat_destroy_cb, chat);
 +              g_signal_handlers_disconnect_by_func (priv->tp_chat,
 +                      chat_message_received_cb, chat);
 +              g_signal_handlers_disconnect_by_func (priv->tp_chat,
 +                      chat_send_error_cb, chat);
 +              g_signal_handlers_disconnect_by_func (priv->tp_chat,
 +                      chat_state_changed_cb, chat);
 +              g_signal_handlers_disconnect_by_func (priv->tp_chat,
 +                      chat_property_changed_cb, chat);
 +              g_signal_handlers_disconnect_by_func (priv->tp_chat,
 +                      chat_members_changed_cb, chat);
 +              g_signal_handlers_disconnect_by_func (priv->tp_chat,
 +                      chat_remote_contact_changed_cb, chat);
                empathy_tp_chat_close (priv->tp_chat);
                g_object_unref (priv->tp_chat);
        }
@@@ -1586,8 -1607,8 +1615,8 @@@ empathy_chat_init (EmpathyChat *chat
        priv->account_manager = empathy_account_manager_dup_singleton ();
  
        g_signal_connect (priv->account_manager,
 -                        "account-connection-changed",
 -                        G_CALLBACK (chat_connection_changed_cb),
 +                        "new-connection",
 +                        G_CALLBACK (chat_new_connection_cb),
                          chat);
  
        /* Block events for some time to avoid having "has come online" or
@@@ -1621,7 -1642,6 +1650,7 @@@ empathy_chat_set_tp_chat (EmpathyCha
                          EmpathyTpChat *tp_chat)
  {
        EmpathyChatPriv *priv = GET_PRIV (chat);
 +      TpConnection    *connection;
  
        g_return_if_fail (EMPATHY_IS_CHAT (chat));
        g_return_if_fail (EMPATHY_IS_TP_CHAT (tp_chat));
        }
  
        priv->tp_chat = g_object_ref (tp_chat);
 -      priv->account = g_object_ref (empathy_tp_chat_get_account (tp_chat));
 +      connection = empathy_tp_chat_get_connection (priv->tp_chat);
 +      priv->account = empathy_account_manager_get_account (priv->account_manager,
 +                                                           connection);
 +      g_object_ref (priv->account);
  
 +      g_signal_connect (tp_chat, "destroy",
 +                        G_CALLBACK (chat_destroy_cb),
 +                        chat);
        g_signal_connect (tp_chat, "message-received",
                          G_CALLBACK (chat_message_received_cb),
                          chat);
        g_signal_connect_swapped (tp_chat, "notify::remote-contact",
                                  G_CALLBACK (chat_remote_contact_changed_cb),
                                  chat);
 -      priv->tp_chat_destroy_handler =
 -              g_signal_connect (tp_chat, "destroy",
 -                        G_CALLBACK (chat_destroy_cb),
 -                        chat);
  
        chat_remote_contact_changed_cb (chat);
  
@@@ -1741,6 -1759,20 +1770,6 @@@ empathy_chat_get_remote_contact (Empath
        return priv->remote_contact;
  }
  
 -guint
 -empathy_chat_get_members_count (EmpathyChat *chat)
 -{
 -      EmpathyChatPriv *priv = GET_PRIV (chat);
 -
 -      g_return_val_if_fail (EMPATHY_IS_CHAT (chat), 0);
 -
 -      if (priv->tp_chat) {
 -              return empathy_tp_chat_get_members_count (priv->tp_chat);
 -      }
 -
 -      return 0;
 -}
 -
  GtkWidget *
  empathy_chat_get_contact_menu (EmpathyChat *chat)
  {
diff --combined po/POTFILES.in
index 623a23e6534e9bdb1cb4a179a80f8723016d1bc2,1fbad0bc68e91aa4525c1ad036c17b6479cf3ab6..c29bb60c77db85e62216432958a7340666198d80
@@@ -37,10 -37,7 +37,8 @@@ libempathy-gtk/empathy-log-window.
  [type: gettext/glade]libempathy-gtk/empathy-log-window.ui
  [type: gettext/glade]libempathy-gtk/empathy-new-message-dialog.ui
  libempathy-gtk/empathy-presence-chooser.c
- libempathy-gtk/empathy-spell-dialog.c
- [type: gettext/glade]libempathy-gtk/empathy-spell-dialog.ui
 -[type: gettext/glade]libempathy-gtk/empathy-presence-chooser.ui
 +libempathy-gtk/empathy-status-preset-dialog.c
 +[type: gettext/glade]libempathy-gtk/empathy-status-preset-dialog.ui
  libempathy-gtk/empathy-theme-boxes.c
  libempathy-gtk/empathy-theme-irc.c
  libempathy-gtk/empathy-theme-manager.c
index 01b65f7a1e39d8f7ede6123aeabf96a2e423774a,e12da48596fea67abc881c17b23210822b2aaa8c..df829a0313eaaf5391a9caa64908c0f32a113da0
    (return-type "McAccount*")
  )
  
 +(define-method get_connection
 +  (of-object "EmpathyAccountChooser")
 +  (c-name "empathy_account_chooser_get_connection")
 +  (return-type "TpConnection*")
 +)
 +
  (define-method set_account
    (of-object "EmpathyAccountChooser")
    (c-name "empathy_account_chooser_set_account")
    (return-type "EmpathyContact*")
  )
  
 -(define-method get_members_count
 -  (of-object "EmpathyChat")
 -  (c-name "empathy_chat_get_members_count")
 -  (return-type "guint")
 -)
 -
  (define-method get_contact_menu
    (of-object "EmpathyChat")
    (c-name "empathy_chat_get_contact_menu")
    (return-type "none")
    (parameters
      '("GtkWindow*" "parent")
 -    '("gboolean" "edit")
 -    '("gboolean" "is_user")
 +  )
 +)
 +
 +(define-method edit_dialog_show
 +  (of-object "EmpathyContact")
 +  (c-name "empathy_contact_edit_dialog_show")
 +  (return-type "none")
 +  (parameters
 +    '("GtkWindow*" "parent")
 +  )
 +)
 +
 +(define-function contact_personal_dialog_show
 +  (c-name "empathy_contact_personal_dialog_show")
 +  (return-type "none")
 +  (parameters
 +    '("GtkWindow*" "parent")
    )
  )
  
  
  
  
- ;; From empathy-spell-dialog.h
- (define-function spell_dialog_show
-   (c-name "empathy_spell_dialog_show")
-   (return-type "none")
-   (parameters
-     '("EmpathyChat*" "chat")
-     '("GtkTextIter*" "start")
-     '("GtkTextIter*" "end")
-     '("const-gchar*" "word")
-   )
- )
  ;; From empathy-theme-boxes.h
  
  (define-function theme_boxes_get_type
diff --combined python/update-binding.sh
index 16a879faf215141b25a0defd7039ae2d3da7d88e,9023be21a9b2c5d9a8d71501ea2a23c6aed037d8..14a5ddec335882558101e022892b99267a4532be
@@@ -11,6 -11,7 +11,6 @@@ python /usr/share/pygobject/2.0/codegen
        empathy-call-factory.h                  \
        empathy-call-handler.h                  \
        empathy-contact.h                       \
 -      empathy-contact-factory.h               \
        empathy-contact-groups.h                \
        empathy-contact-list.h                  \
        empathy-contact-manager.h               \
@@@ -33,6 -34,7 +33,6 @@@
        empathy-tp-contact-factory.h            \
        empathy-tp-contact-list.h               \
        empathy-tp-file.h                       \
 -      empathy-tp-group.h                      \
        empathy-tp-roomlist.h                   \
        empathy-tp-tube.h                       \
        empathy-tube-handler.h                  \
@@@ -76,7 -78,6 +76,6 @@@ python /usr/share/pygobject/2.0/codegen
        empathy-profile-chooser.h               \
        empathy-smiley-manager.h                \
        empathy-spell.h                         \
-       empathy-spell-dialog.h                  \
        empathy-theme-boxes.h                   \
        empathy-theme-irc.h                     \
        empathy-theme-manager.h                 \