Added debug menu item #86

Merged
asmeron merged 2 commits from YanTheKaller/libublsettingsui-gtk3:master into master 1 month ago

@ -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){ char *yon_password_unencrypted_password_get(yon_password_window *window){
const char *password = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); const char *password = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry));
const char *password_repeat = gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); 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_box_spawn(GTK_CONTAINER(window->StatusBox),_PASSWORD_RESTRICTED_SYMBOL_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
yon_ubl_status_highlight_incorrect(window->PasswordEntry); yon_ubl_status_highlight_incorrect(window->PasswordEntry);
return NULL; return NULL;
@ -103,7 +110,13 @@ char *yon_password_hash_get(yon_password_window *window){
} else { } else {
const char *password = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry)); const char *password = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry));
const char *password_repeat = gtk_entry_get_text(GTK_ENTRY(window->RepeatPasswordEntry)); 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_box_spawn(GTK_CONTAINER(window->StatusBox),_PASSWORD_RESTRICTED_SYMBOL_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
yon_ubl_status_highlight_incorrect(window->PasswordEntry); yon_ubl_status_highlight_incorrect(window->PasswordEntry);
return NULL; 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))){ if (encription_active <1||gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){
final = yon_password_unencrypted_password_get(window); 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; if (!final) return;
} else { } else {
final = yon_password_hash_get(window); final = yon_password_hash_get(window);

@ -570,6 +570,33 @@ GtkWidget *yon_root_button_new(config_str args, int args_size){
return root_item; 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){ 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); GtkWidget *root_item = yon_root_button_new(args,args_size);
gtk_style_context_add_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemmiddle"); gtk_style_context_add_class(gtk_widget_get_style_context(widgets->DocumentationMenuItem),"menuitemmiddle");

@ -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 /// @return Type: GtkWidget. A newly created root menu item
GtkWidget *yon_root_button_new(config_str args, int args_size); 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 /// @brief Setup all callbacks for root button
/// @param root_item Target root menu item /// @param root_item Target root menu item
/// @param window Main application window /// @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 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 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 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 SETTINGS_TITLE_LABEL yon_char_get_localised_from_lib("Settings")
#define CONFIG_WINDOW_MENU_LABEL yon_char_get_localised_from_lib("Settigs") #define CONFIG_WINDOW_MENU_LABEL yon_char_get_localised_from_lib("Settigs")

Loading…
Cancel
Save