aboutsummaryrefslogtreecommitdiff
path: root/patches/no-emojis.c
blob: dc7dd892b57b1bea7d1bfef5009197703118e1a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* No Emojis:
 * (from gtk3-classic patch 'other__hide-insert-emoji.patch')
 *
 * Hides the 'Insert Emoji' menu item found at the bottom of the context menus
 * for GtkEntry and GtkTextView widgets.
 *
 * Set the environment variable GTKM_INSERT_EMOJI=1 to restore the menu items.
 */


#include <gtk/gtk.h>
#include <glib.h>

#include <stdlib.h>
#include <string.h>

#include <gtk3-classic.h>


#undef  G_LOG_DOMAIN
#define G_LOG_DOMAIN	"Gtk3-Classic::No-Emojis"


INTERCEPTED_CLASS_METHOD (gtk_menu_item, show,
			  (GtkWidget *	widget),
			  void)


void no_emojis_init ()
{
	GtkMenuItemClass * gtk_menu_item_class =
	 g_type_class_ref (GTK_TYPE_MENU_ITEM);

	INTERCEPT_CLASS_METHOD (
	 gtk_menu_item, GTK_WIDGET_CLASS, show)

	g_type_class_unref (gtk_menu_item_class);
}


static void
new_gtk_menu_item_show
(GtkWidget *	widget)

{
	const char *	gtkm_insert_emoji;
	const char *	label;


	CALL_ORIGINAL_CLASS_METHOD (gtk_menu_item, show,
				    (widget));


	gtkm_insert_emoji = getenv ("GTKM_INSERT_EMOJI");
	if (gtkm_insert_emoji != NULL && strcmp (gtkm_insert_emoji, "1") == 0)
		return;

	label = gtk_menu_item_get_label (GTK_MENU_ITEM (widget));
	if (label != NULL && strcmp (label, _("Insert _Emoji")) == 0)
		gtk_widget_hide (widget);
}
bgstack15