From da8b4378e882ecfc5d0706e046ece816867309f8 Mon Sep 17 00:00:00 2001 From: Ivan Dmitrievich Yartsev Date: Mon, 30 Mar 2026 17:54:08 +0600 Subject: [PATCH] Added debug menu item --- source/libublsettingsui-gtk3-password.c | 24 +++++++++++++--------- source/libublsettingsui-gtk3.c | 27 +++++++++++++++++++++++++ source/libublsettingsui-gtk3.h | 5 +++++ 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/source/libublsettingsui-gtk3-password.c b/source/libublsettingsui-gtk3-password.c index 3015e83..fda1e6a 100644 --- a/source/libublsettingsui-gtk3-password.c +++ b/source/libublsettingsui-gtk3-password.c @@ -46,7 +46,14 @@ gboolean on_password_tooltip_out_event(GtkWidget *self, GdkEvent *, yon_password char *yon_password_unencrypted_password_get(yon_password_window *window){ const char *password = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); const char *password_repeat = gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); - if (strpbrk(password,"!@#%^&*\'")){ + + if (window->strength_func){ + double password_strength = ((double(*)(yon_password_window *,const char*))window->strength_func)(window,password); + if (password_strength<0.3){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),_WEAK_PASSWORD_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return NULL; + } + } else if (strpbrk(password,"!@#%^&*\'")){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),_PASSWORD_RESTRICTED_SYMBOL_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->PasswordEntry); return NULL; @@ -103,7 +110,13 @@ char *yon_password_hash_get(yon_password_window *window){ } else { const char *password = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); const char *password_repeat = gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); - if (strpbrk(password,"!@#%^&*\'")){ + if (window->strength_func){ + double password_strength = ((double(*)(yon_password_window *,const char*))window->strength_func)(window,password); + if (password_strength<0.3){ + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),_WEAK_PASSWORD_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); + return NULL; + } + } else if (strpbrk(password,"!@#%^&*\'")){ yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),_PASSWORD_RESTRICTED_SYMBOL_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); yon_ubl_status_highlight_incorrect(window->PasswordEntry); return NULL; @@ -207,13 +220,6 @@ void on_password_accept(GtkWidget *,dictionary *dict){ if (encription_active <1||gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){ final = yon_password_unencrypted_password_get(window); - if (window->strength_func){ - double password_strength = ((double(*)(yon_password_window *,const char*))window->strength_func)(window,final); - if (password_strength<0.3){ - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),_WEAK_PASSWORD_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); - return; - } - } if (!final) return; } else { final = yon_password_hash_get(window); diff --git a/source/libublsettingsui-gtk3.c b/source/libublsettingsui-gtk3.c index b318bcd..f493c5d 100644 --- a/source/libublsettingsui-gtk3.c +++ b/source/libublsettingsui-gtk3.c @@ -570,6 +570,33 @@ GtkWidget *yon_root_button_new(config_str args, int args_size){ return root_item; } +void on_debug_switch(GtkWidget *self, GtkWidget *check){ + template_config->debug_mode = !template_config->debug_mode; + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),template_config->debug_mode); +} + +GtkWidget *yon_debug_button_new(){ + textdomain(template_ui_LocaleName); + GtkWidget *debug_item = gtk_menu_item_new(); + gtk_style_context_add_class(gtk_widget_get_style_context(debug_item),"menuitemtop"); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + GtkWidget *debug_label = gtk_label_new(DEBUG_CHECK_LABEL); + GtkWidget *debug_check = gtk_check_button_new(); + g_object_set_data(G_OBJECT(debug_item),"Label",debug_label); + gtk_box_pack_start(GTK_BOX(box),debug_check,0,0,0); + gtk_box_pack_start(GTK_BOX(box),debug_label,1,1,0); + gtk_container_add(GTK_CONTAINER(debug_item),box); + gtk_label_set_xalign(GTK_LABEL(debug_label),0); + gtk_widget_show_all(debug_item); + if (template_config->debug_mode) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(debug_check),1); + } + textdomain(template_app_information.app_locale); + g_signal_connect(G_OBJECT(debug_item),"activate", G_CALLBACK(on_debug_switch),debug_check); + gtk_widget_show_all(debug_item); + return debug_item; +} + void yon_root_button_setup(template_main_window *widgets, config_str args, int args_size){ GtkWidget *root_item = yon_root_button_new(args,args_size); gtk_style_context_add_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemmiddle"); diff --git a/source/libublsettingsui-gtk3.h b/source/libublsettingsui-gtk3.h index 04c7f58..25d6a2c 100644 --- a/source/libublsettingsui-gtk3.h +++ b/source/libublsettingsui-gtk3.h @@ -318,6 +318,10 @@ void yon_root_button_setup(template_main_window *widgets, config_str args, int a /// @return Type: GtkWidget. A newly created root menu item GtkWidget *yon_root_button_new(config_str args, int args_size); +/// @brief Create new debug button +/// @return Type: GtkWidget. A newly created debug menu item; +GtkWidget *yon_debug_button_new(); + /// @brief Setup all callbacks for root button /// @param root_item Target root menu item /// @param window Main application window @@ -691,6 +695,7 @@ yon_window *yon_window_new(); #define SAVE_MODE_HDD_HOME_LABEL yon_char_get_localised_from_lib("HDD sandbox with profile saving") #define CUSTOM_CONFIG_CREATION_ERROR_LABEL yon_char_get_localised_from_lib("New configuration file creation failed") #define ROOT_CHECK_LABEL yon_char_get_localised_from_lib("Grant root access") + #define DEBUG_CHECK_LABEL yon_char_get_localised_from_lib("Debug mode") #define SETTINGS_TITLE_LABEL yon_char_get_localised_from_lib("Settings") #define CONFIG_WINDOW_MENU_LABEL yon_char_get_localised_from_lib("Settigs") -- 2.35.1