]> git.0d.be Git - empathy.git/commitdiff
Insert smileys at the cursor position
authorVeena Katiyar <veenakatiyar0509@gmail.com>
Sun, 17 Nov 2013 19:09:18 +0000 (00:39 +0530)
committerChandni Verma <chandniverma2112@gmail.com>
Sun, 17 Nov 2013 19:14:50 +0000 (00:44 +0530)
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=685899
libempathy-gtk/empathy-chat.c
libempathy-gtk/empathy-chat.h
src/empathy-chat-window.c

index c6cc8e081742170353f47626a9a3d8d840d279c1..35f908b7b9420385274af259715f6597b10e75af 100644 (file)
@@ -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 {
index 2a983622b9e17902b1d758ebc9f67daaf8d889fa..c73f5c1f96a5d13d39404556a10f3d0b4ed047e7 100644 (file)
@@ -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
 
index f7c8707eb7f73dfe09c4b984ba4d9547a0fcb994..b496356290bba217485b5ac9de5b63325e074b5c 100644 (file)
@@ -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