diff --git a/source/libublsettings-gtk3-menu.c b/source/libublsettings-gtk3-menu.c index 03e9ed4..a5115b8 100644 --- a/source/libublsettings-gtk3-menu.c +++ b/source/libublsettings-gtk3-menu.c @@ -3,10 +3,9 @@ // rmb menu section typedef int (*RmbCheck)(void*); -gboolean on_rmb_menu_open(GtkWidget *self,GdkEventButton *event, rmb_menu_window *window){ +gboolean on_rmb_menu_open(GtkWidget *,GdkEventButton *event, rmb_menu_window *window){ int (*func)(void*) = (RmbCheck)(window->show_function); if (!func||func(window->show_data)){ - if (self){}; if (event->button==3){ gtk_widget_show_all(window->menu); diff --git a/source/libublsettings-gtk3-misc.c b/source/libublsettings-gtk3-misc.c index 993539f..ccf2968 100644 --- a/source/libublsettings-gtk3-misc.c +++ b/source/libublsettings-gtk3-misc.c @@ -301,6 +301,32 @@ void yon_gtk_entry_block_restricted_symbols(GtkEntry *target){ g_signal_connect(G_OBJECT(target),"insert-text",G_CALLBACK(yon_on_insert_restricted_check),NULL); } +void yon_on_insert_languages(GtkEditable *editable, const gchar *text, gint length, gint *position, gpointer){ + gchar *new_text = g_new(gchar, length + 1); + gint i, j = 0; + + for (i = 0; i < length; i++) { + if (text[i]>=0) { + new_text[j] = text[i]; + j++; + } + } + + if (j < length) { + g_signal_handlers_block_by_func(editable, G_CALLBACK(yon_on_insert_restricted_check), NULL); + gtk_editable_insert_text(editable, new_text, j, position); + g_signal_handlers_unblock_by_func(editable, G_CALLBACK(yon_on_insert_restricted_check), NULL); + g_signal_stop_emission_by_name(editable, "insert-text"); + } + + g_free(new_text); +} + +void yon_gtk_entry_block_languages(GtkEntry *target){ + g_return_if_fail(GTK_IS_ENTRY(target)); + g_signal_connect(G_OBJECT(target),"insert-text",G_CALLBACK(yon_on_insert_languages),NULL); +} + void yon_on_insert_custom_restricted_check(GtkEditable *editable, const gchar *text, gint length, gint *position, char *symbols){ gchar *new_text = g_new(gchar, length + 1); gint i, j = 0; diff --git a/source/libublsettings-gtk3.h b/source/libublsettings-gtk3.h index 61a5e94..9c5527b 100644 --- a/source/libublsettings-gtk3.h +++ b/source/libublsettings-gtk3.h @@ -499,6 +499,8 @@ void yon_on_text_insert_only_digits(GtkEditable *editable, const gchar *text, gi void yon_gtk_entry_block_restricted_symbols(GtkEntry *target); +void yon_gtk_entry_block_languages(GtkEntry *target); + void yon_gtk_entry_block_symbols(GtkEntry *target, char *symbols); // GtkTreeStore section