[empathy] Insert smileys at the cursor position



commit 25b40bf1b21a7c73a5b87649e3fb3536d64d0a97
Author: Veena Katiyar <veenakatiyar0509 gmail com>
Date:   Mon Nov 18 00:39:18 2013 +0530

    Insert smileys at the cursor position
    
    Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=685899

 libempathy-gtk/empathy-chat.c |   15 ++++++++-------
 libempathy-gtk/empathy-chat.h |    3 +++
 src/empathy-chat-window.c     |    7 ++-----
 3 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index c6cc8e0..35f908b 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -46,7 +46,6 @@
 #include "empathy-input-text-view.h"
 #include "empathy-request-util.h"
 #include "empathy-search-bar.h"
-#include "empathy-smiley-manager.h"
 #include "empathy-spell.h"
 #include "empathy-string-parser.h"
 #include "empathy-theme-manager.h"
@@ -2095,6 +2094,13 @@ chat_input_has_focus_notify_cb (GtkWidget   *widget,
        empathy_theme_adium_focus_toggled (chat->view, gtk_widget_has_focus (widget));
 }
 
+void
+empathy_chat_insert_smiley (GtkTextBuffer *buffer,
+                               EmpathySmiley        *smiley)
+{
+       gtk_text_buffer_insert_at_cursor (buffer, smiley->str, -1);
+}
+
 static void
 chat_insert_smiley_activate_cb (EmpathySmileyManager *manager,
                                EmpathySmiley        *smiley,
@@ -2102,15 +2108,10 @@ chat_insert_smiley_activate_cb (EmpathySmileyManager *manager,
 {
        EmpathyChat   *chat = EMPATHY_CHAT (user_data);
        GtkTextBuffer *buffer;
-       GtkTextIter    iter;
 
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view));
 
-       gtk_text_buffer_get_end_iter (buffer, &iter);
-       gtk_text_buffer_insert (buffer, &iter, smiley->str, -1);
-
-       gtk_text_buffer_get_end_iter (buffer, &iter);
-       gtk_text_buffer_insert (buffer, &iter, " ", -1);
+       empathy_chat_insert_smiley (buffer, smiley);
 }
 
 typedef struct {
diff --git a/libempathy-gtk/empathy-chat.h b/libempathy-gtk/empathy-chat.h
index 2a98362..c73f5c1 100644
--- a/libempathy-gtk/empathy-chat.h
+++ b/libempathy-gtk/empathy-chat.h
@@ -33,6 +33,7 @@
 #include "empathy-contact.h"
 #include "empathy-theme-adium.h"
 #include "empathy-tp-chat.h"
+#include "empathy-smiley-manager.h"
 
 G_BEGIN_DECLS
 
@@ -98,6 +99,8 @@ guint              empathy_chat_get_n_messages_sending (EmpathyChat *self);
 gchar *            empathy_chat_dup_text             (EmpathyChat *self);
 void               empathy_chat_set_text             (EmpathyChat *self,
                                                       const gchar *text);
+void               empathy_chat_insert_smiley        (GtkTextBuffer *buffer,
+                                                      EmpathySmiley *smiley);
 
 G_END_DECLS
 
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index f7c8707..b496356 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -42,7 +42,6 @@
 #include "empathy-invite-participant-dialog.h"
 #include "empathy-notify-manager.h"
 #include "empathy-request-util.h"
-#include "empathy-smiley-manager.h"
 #include "empathy-sound-manager.h"
 #include "empathy-ui-utils.h"
 #include "empathy-utils.h"
@@ -1075,13 +1074,11 @@ chat_window_insert_smiley_activate_cb (EmpathySmileyManager *manager,
   EmpathyChatWindow *self = user_data;
   EmpathyChat *chat;
   GtkTextBuffer *buffer;
-  GtkTextIter iter;
 
   chat = self->priv->current_chat;
-
   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view));
-  gtk_text_buffer_get_end_iter (buffer, &iter);
-  gtk_text_buffer_insert (buffer, &iter, smiley->str, -1);
+
+  empathy_chat_insert_smiley (buffer, smiley);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]