Skip to main content
Topic: gtk3: Get rid of insert_emoji feature^H^H^H^H^H^H^Hbug (Read 1018 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

gtk3: Get rid of insert_emoji feature^H^H^H^H^H^H^Hbug

Anybody else having trouble with the breakage caused by the recent insert_emoji
bullshit? There's a patch in extra, but it didn't work for me. So until this gets
fixed properly, here's how to lose it entirely:
Code: [Select]
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 8f3aa8e748..52f8fea0af 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -322,7 +322,6 @@ enum {
   ICON_PRESS,
   ICON_RELEASE,
   PREEDIT_CHANGED,
-  INSERT_EMOJI,
   LAST_SIGNAL
 };
 
@@ -547,7 +546,6 @@ static void gtk_entry_cut_clipboard      (GtkEntry        *entry);
 static void gtk_entry_copy_clipboard     (GtkEntry        *entry);
 static void gtk_entry_paste_clipboard    (GtkEntry        *entry);
 static void gtk_entry_toggle_overwrite   (GtkEntry        *entry);
-static void gtk_entry_insert_emoji       (GtkEntry        *entry);
 static void gtk_entry_select_all         (GtkEntry        *entry);
 static void gtk_entry_real_activate      (GtkEntry        *entry);
 static gboolean gtk_entry_popup_menu     (GtkWidget       *widget);
@@ -814,7 +812,6 @@ gtk_entry_class_init (GtkEntryClass *class)
   class->copy_clipboard = gtk_entry_copy_clipboard;
   class->paste_clipboard = gtk_entry_paste_clipboard;
   class->toggle_overwrite = gtk_entry_toggle_overwrite;
-  class->insert_emoji = gtk_entry_insert_emoji;
   class->activate = gtk_entry_real_activate;
   class->get_text_area_size = gtk_entry_get_text_area_size;
   class->get_frame_size = gtk_entry_get_frame_size;
@@ -1902,28 +1899,6 @@ gtk_entry_class_init (GtkEntryClass *class)
                                 G_TYPE_NONE, 1,
                                 G_TYPE_STRING);
 
-
-  /**
-   * GtkEntry::insert-emoji:
-   * @entry: the object which received the signal
-   *
-   * The ::insert-emoji signal is a
-   * [keybinding signal][GtkBindingSignal]
-   * which gets emitted to present the Emoji chooser for the @entry.
-   *
-   * The default bindings for this signal are Ctrl-. and Ctrl-;
-   *
-   * Since: 3.22.27
-   */
-  signals[INSERT_EMOJI] =
-    g_signal_new (I_("insert-emoji"),
-   G_OBJECT_CLASS_TYPE (gobject_class),
-   G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-   G_STRUCT_OFFSET (GtkEntryClass, insert_emoji),
-   NULL, NULL,
-   NULL,
-   G_TYPE_NONE, 0);
-
   /*
    * Key bindings
    */
@@ -9615,8 +9590,6 @@ popup_targets_received (GtkClipboard     *clipboard,
           gtk_widget_set_sensitive (menuitem,
                                     mode == DISPLAY_NORMAL &&
                                     info_entry_priv->editable);
-          g_signal_connect_swapped (menuitem, "activate",
-                                    G_CALLBACK (gtk_entry_insert_emoji), entry);
           gtk_widget_show (menuitem);
           gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
         }
@@ -11074,43 +11047,6 @@ gtk_entry_get_tabs (GtkEntry *entry)
   return entry->priv->tabs;
 }
 
-static void
-gtk_entry_insert_emoji (GtkEntry *entry)
-{
-  GtkWidget *chooser;
-  GdkRectangle rect;
-
-  if (gtk_widget_get_ancestor (GTK_WIDGET (entry), GTK_TYPE_EMOJI_CHOOSER) != NULL)
-    return;
-
-  chooser = GTK_WIDGET (g_object_get_data (G_OBJECT (entry), "gtk-emoji-chooser"));
-  if (!chooser)
-    {
-      chooser = gtk_emoji_chooser_new ();
-      g_object_set_data (G_OBJECT (entry), "gtk-emoji-chooser", chooser);
-
-      gtk_popover_set_relative_to (GTK_POPOVER (chooser), GTK_WIDGET (entry));
-      if (entry->priv->show_emoji_icon)
-        {
-          gtk_entry_get_icon_area (entry, GTK_ENTRY_ICON_SECONDARY, &rect);
-          gtk_popover_set_pointing_to (GTK_POPOVER (chooser), &rect);
-        }
-      g_signal_connect_swapped (chooser, "emoji-picked", G_CALLBACK (gtk_entry_enter_text), entry);
-    }
-
-  gtk_popover_popup (GTK_POPOVER (chooser));
-}
-
-static void
-pick_emoji (GtkEntry *entry,
-            int       icon,
-            GdkEvent *event,
-            gpointer  data)
-{
-  if (icon == GTK_ENTRY_ICON_SECONDARY)
-    gtk_entry_insert_emoji (entry);
-}
-
 static void
 set_show_emoji_icon (GtkEntry *entry,
                      gboolean  value)
@@ -11139,12 +11075,9 @@ set_show_emoji_icon (GtkEntry *entry,
       gtk_entry_set_icon_tooltip_text (entry,
                                        GTK_ENTRY_ICON_SECONDARY,
                                        _("Insert Emoji"));
-
-      g_signal_connect (entry, "icon-press", G_CALLBACK (pick_emoji), NULL);
     }
   else
     {
-      g_signal_handlers_disconnect_by_func (entry, pick_emoji, NULL);
 
       gtk_entry_set_icon_from_icon_name (entry,
                                          GTK_ENTRY_ICON_SECONDARY,
diff --git a/gtk/gtkentry.h b/gtk/gtkentry.h
index 073e703d0d..bed0ede96f 100644
--- a/gtk/gtkentry.h
+++ b/gtk/gtkentry.h
@@ -146,7 +146,6 @@ struct _GtkEntryClass
   void (* copy_clipboard)     (GtkEntry             *entry);
   void (* paste_clipboard)    (GtkEntry             *entry);
   void (* toggle_overwrite)   (GtkEntry             *entry);
-  void (* insert_emoji)       (GtkEntry             *entry);
 
   /* hooks to add other objects beside the entry (like in GtkSpinButton) */
   void (* get_text_area_size) (GtkEntry       *entry,
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 1b001bb68b..04a6a92826 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -333,7 +333,6 @@ enum
   TOGGLE_CURSOR_VISIBLE,
   PREEDIT_CHANGED,
   EXTEND_SELECTION,
-  INSERT_EMOJI,
   LAST_SIGNAL
 };
 
@@ -586,7 +585,6 @@ static void     gtk_text_view_set_hadjustment_values (GtkTextView   *text_view);
 static void     gtk_text_view_set_vadjustment_values (GtkTextView   *text_view);
 
 static void gtk_text_view_update_im_spot_location (GtkTextView *text_view);
-static void gtk_text_view_insert_emoji (GtkTextView *text_view);
 
 /* Container methods */
 static void gtk_text_view_add    (GtkContainer *container,
@@ -788,7 +786,6 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
   klass->toggle_overwrite = gtk_text_view_toggle_overwrite;
   klass->create_buffer = gtk_text_view_create_buffer;
   klass->extend_selection = gtk_text_view_extend_selection;
-  klass->insert_emoji = gtk_text_view_insert_emoji;
 
   /*
    * Properties
@@ -1448,27 +1445,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
                   GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE,
                   GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE);
 
-  /**
-   * GtkTextView::insert-emoji:
-   * @text_view: the object which received the signal
-   *
-   * The ::insert-emoji signal is a
-   * [keybinding signal][GtkBindingSignal]
-   * which gets emitted to present the Emoji chooser for the @text_view.
-   *
-   * The default bindings for this signal are Ctrl-. and Ctrl-;
-   *
-   * Since: 3.22.27
-   */
-  signals[INSERT_EMOJI] =
-    g_signal_new (I_("insert-emoji"),
-                  G_OBJECT_CLASS_TYPE (gobject_class),
-                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
-                  G_STRUCT_OFFSET (GtkTextViewClass, insert_emoji),
-                  NULL, NULL,
-                  NULL,
-                  G_TYPE_NONE, 0);
-
   /*
    * Key bindings
    */
@@ -9519,8 +9495,6 @@ popup_targets_received (GtkClipboard     *clipboard,
         {
           menuitem = gtk_menu_item_new_with_mnemonic (_("Insert _Emoji"));
           gtk_widget_set_sensitive (menuitem, can_insert);
-          g_signal_connect_swapped (menuitem, "activate",
-                                    G_CALLBACK (gtk_text_view_insert_emoji), text_view);
           gtk_widget_show (menuitem);
           gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), menuitem);
         }
@@ -11443,39 +11417,3 @@ gtk_text_view_get_monospace (GtkTextView *text_view)
 
   return gtk_style_context_has_class (context, GTK_STYLE_CLASS_MONOSPACE);
 }
-
-static void
-gtk_text_view_insert_emoji (GtkTextView *text_view)
-{
-  GtkWidget *chooser;
-  GtkTextIter iter;
-  GdkRectangle rect;
-  GtkTextBuffer *buffer;
-
-  if (gtk_widget_get_ancestor (GTK_WIDGET (text_view), GTK_TYPE_EMOJI_CHOOSER) != NULL)
-    return;
-
-  chooser = GTK_WIDGET (g_object_get_data (G_OBJECT (text_view), "gtk-emoji-chooser"));
-  if (!chooser)
-    {
-      chooser = gtk_emoji_chooser_new ();
-      g_object_set_data (G_OBJECT (text_view), "gtk-emoji-chooser", chooser);
-
-      gtk_popover_set_relative_to (GTK_POPOVER (chooser), GTK_WIDGET (text_view));
-      g_signal_connect_swapped (chooser, "emoji-picked",
-                                G_CALLBACK (gtk_text_view_insert_at_cursor), text_view);
-    }
-
-  buffer = get_buffer (text_view);
-  gtk_text_buffer_get_iter_at_mark (buffer, &iter,
-                                    gtk_text_buffer_get_insert (buffer));
-
-  gtk_text_view_get_iter_location (text_view, &iter, (GdkRectangle *) &rect);
-  gtk_text_view_buffer_to_window_coords (text_view, GTK_TEXT_WINDOW_TEXT,
-                                         rect.x, rect.y, &rect.x, &rect.y);
-  _text_window_to_widget_coords (text_view, &rect.x, &rect.y);
-
-  gtk_popover_set_pointing_to (GTK_POPOVER (chooser), &rect);
-
-  gtk_popover_popup (GTK_POPOVER (chooser));
-}
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index f70dc490f6..5ba548fc1f 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -191,7 +191,6 @@ struct _GtkTextViewClass
                                   const GtkTextIter      *location,
                                   GtkTextIter            *start,
                                   GtkTextIter            *end);
-  void (* insert_emoji)          (GtkTextView      *text_view);
 
   /*< private >*/
 
The sha256sum of this patch is f32404f24c3507d78cd8d1e3494cd1e88db96bc9a5fc849f2224355dcbac35b9
(including the single space in the last line). Tested to build with extra/gtk3 (instead of the supplied patch).

Re: gtk3: Get rid of insert_emoji feature^H^H^H^H^H^H^Hbug

Reply #1
So you're saying that the 0001-entry-Undo-ABI-breakage-from-addition-of-insert_emoj.patch didn't fix the problem for you? Hmm, that's strange; it works for me. I maintain the gtk3-patched-filechooser-icon-view package in AUR and of course I included that new patch when I updated to follow upstream. Building the package without that patch leads to the emoji bug, but it works when I build with it.

Re: gtk3: Get rid of insert_emoji feature^H^H^H^H^H^H^Hbug

Reply #2
It didn't work for me. The feature breaks a custom keyboard shortcut for pluma to switch between tabs (the standard
shortcut uses both hands and is too acrobatic for me). The patch I posted restores that function.