From ec34069693214c2a2876b2c24b680b86e9cac20c Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 14 Feb 2025 14:55:39 +0600 Subject: [PATCH] Added function --- source/libublsettings-gtk3-misc.c | 61 +++++++++++++++++++++++++++++ source/libublsettings-gtk3-status.c | 2 +- source/libublsettings-gtk3.h | 2 + 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/source/libublsettings-gtk3-misc.c b/source/libublsettings-gtk3-misc.c index 080e4af..8087a39 100644 --- a/source/libublsettings-gtk3-misc.c +++ b/source/libublsettings-gtk3-misc.c @@ -416,4 +416,65 @@ void yon_gtk_window_set_shrinking_from_revealer_resizing(GtkWindow *window, GtkR wrapped->height=height; wrapped->window=gtk_widget_get_toplevel(GTK_WIDGET(revealer)); g_signal_connect(G_OBJECT(wrapped->revealer),"notify::reveal-child",G_CALLBACK(_yon_on_revealer_switched),wrapped); +} + +// void on_entry_pattern_inserted(GtkEditable *self, const gchar *text, gint length, gint *position, char *pattern){ +// if (length!=1) { +// return; +// } +// const char *old = gtk_entry_get_text(GTK_ENTRY(self)); +// int old_size = strlen(old); + +// char *final = yon_char_append((char*)old,text); + +// switch(pattern[old_size]){ +// case '\1':{ +// if (text[0]>='0'&&text[0]<='9') +// } +// break; +// case '\2': +// break; +// default: +// break; +// } + +// if (strlen(new_text) < strlen(text)) { +// g_signal_handlers_block_by_func(editable, G_CALLBACK(yon_on_space_first_changed), NULL); +// gtk_entry_set_text(editable, new_text); +// g_signal_handlers_unblock_by_func(editable, G_CALLBACK(yon_on_space_first_changed), NULL); +// g_signal_stop_emission_by_name(editable, "changed"); +// } +// } + +// void yon_entry_set_pattern(GtkEntry *target, char *pattern){ +// char *pattern_copy = yon_char_new(pattern); +// g_signal_connect(G_OBJECT(target),"insert-text",G_CALLBACK(on_entry_pattern_inserted),pattern_copy) +// } + +void yon_on_insert_allowed_check(GtkEditable *editable, char *text, int length, int *position,char *symbols){ + + gchar *new_text = g_new(gchar, length + 1); + memset(new_text,0,length+1); + gint i, j = 0; + + for (i = 0; i < length; i++) { + if (strchr(symbols,text[i])) { + 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_on_entry_set_allowed_symbols(GtkEntry *target, char *symbols){ + g_return_if_fail(GTK_IS_ENTRY(target)); + g_signal_connect(G_OBJECT(target),"insert-text",G_CALLBACK(yon_on_insert_allowed_check),symbols); } \ No newline at end of file diff --git a/source/libublsettings-gtk3-status.c b/source/libublsettings-gtk3-status.c index ad521d4..ae91cc7 100644 --- a/source/libublsettings-gtk3-status.c +++ b/source/libublsettings-gtk3-status.c @@ -46,7 +46,7 @@ void yon_ubl_status_box_set(BACKGROUND_IMAGE_TYPE type, GtkWidget *box, GtkImage { gtk_style_context_remove_class(gtk_widget_get_style_context(box), "boxInfoMessError"); gtk_style_context_add_class(gtk_widget_get_style_context(box), "boxInfoMessOK"); - gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.libublsettingsui-gtk3.important", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); + gtk_image_set_from_pixbuf(GTK_IMAGE(icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.libublsettingsui-gtk3.important-symbolic", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, NULL)); } break; } diff --git a/source/libublsettings-gtk3.h b/source/libublsettings-gtk3.h index a6d98cf..4d1da3e 100644 --- a/source/libublsettings-gtk3.h +++ b/source/libublsettings-gtk3.h @@ -505,6 +505,8 @@ void yon_gtk_entry_block_symbols(GtkEntry *target, char *symbols); void yon_gtk_entry_block_lowercase(GtkEntry *target); +void yon_on_entry_set_allowed_symbols(GtkEntry *target, char *symbols); + // GtkTreeStore section dictionary *yon_gtk_tree_store_get_children(GtkTreeStore *tree, GtkTreeIter *parent,int column);