From 8771b15072c901d495c083fc2fb9a998660e9971 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Fri, 31 Oct 2025 17:57:14 +0600 Subject: [PATCH 1/6] WIP keyboard design changes --- source/ubl-settings-keyboard.c | 189 +++--- source/ubl-settings-keyboard.h | 45 +- ubl-settings-keyboard.glade | 1056 +++++++++++++++++++------------- 3 files changed, 754 insertions(+), 536 deletions(-) diff --git a/source/ubl-settings-keyboard.c b/source/ubl-settings-keyboard.c index e160240..e787546 100644 --- a/source/ubl-settings-keyboard.c +++ b/source/ubl-settings-keyboard.c @@ -106,42 +106,40 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ } gboolean yon_interface_update(main_window *widgets){ - g_signal_handlers_block_by_func(G_OBJECT(widgets->ModelCombo),G_CALLBACK(on_model_changed),widgets); - g_signal_handlers_block_by_func(G_OBJECT(widgets->MoveDownButton),G_CALLBACK(on_move_down),widgets); - g_signal_handlers_block_by_func(G_OBJECT(widgets->MoveUpButton),G_CALLBACK(on_move_up),widgets); - g_signal_handlers_block_by_func(G_OBJECT(widgets->OptionsButton),G_CALLBACK(on_options_open),widgets); - g_signal_handlers_block_by_func(G_OBJECT(widgets->NumLockCombo),G_CALLBACK(on_num_lock_changed),widgets); - gtk_list_store_clear(widgets->layoutsList); - - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ModelCombo),0); - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumLockCombo),0); + g_signal_handlers_block_by_func(G_OBJECT(widgets->SystemKeyboardModelCombo),G_CALLBACK(on_model_changed),widgets); + // g_signal_handlers_block_by_func(G_OBJECT(widgets->SystemKeyboardOptionsCombo),G_CALLBACK(on_options_open),widgets); + g_signal_handlers_block_by_func(G_OBJECT(widgets->NumlockCombo),G_CALLBACK(on_num_lock_changed),widgets); + gtk_list_store_clear(main_config.layouts_list); + + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->SystemKeyboardModelCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),0); GtkTreeIter iter; - gtk_entry_set_text(GTK_ENTRY(widgets->OptionsEntry),DEFAULT_LABEL); + gtk_entry_set_text(GTK_ENTRY(widgets->SystemKeyboardOptionsCombo),DEFAULT_LABEL); { char *name = yon_config_get_by_key(model_parameter); char *id; if (name) { - int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->modelsList),&iter); - for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->modelsList),&iter)){ - gtk_tree_model_get(GTK_TREE_MODEL(widgets->modelsList),&iter,1,&id,-1); + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(main_config.models_list),&iter); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.models_list),&iter)){ + gtk_tree_model_get(GTK_TREE_MODEL(main_config.models_list),&iter,1,&id,-1); if (!strcmp(name,id)){ - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->ModelCombo),&iter); + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->SystemKeyboardModelCombo),&iter); break; } } - } else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ModelCombo),0); + } else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->SystemKeyboardModelCombo),0); } { char *name = yon_config_get_by_key(options_parameter); if (name) { char *id, *rname; - gtk_entry_set_text(GTK_ENTRY(widgets->OptionsEntry),name); + gtk_entry_set_text(GTK_ENTRY(widgets->SystemKeyboardOptionsCombo),name); int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(main_config.options_list),&iter); for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.options_list),&iter)){ gtk_tree_model_get(GTK_TREE_MODEL(main_config.options_list),&iter,0,&id,1,&rname,-1); if (!strcmp(id,name)){ gtk_list_store_set(main_config.options_list,&iter,2,1,-1); - gtk_entry_set_text(GTK_ENTRY(widgets->OptionsEntry),rname); + gtk_entry_set_text(GTK_ENTRY(widgets->SystemKeyboardOptionsCombo),rname); break; } } @@ -155,34 +153,32 @@ gboolean yon_interface_update(main_window *widgets){ } char *name = yon_config_get_by_key(num_lock_boot_parameter); if (name) { - if (!strcmp(name,"yes")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumLockCombo),1); - else if (!strcmp(name,"no")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumLockCombo),2); + if (!strcmp(name,"yes")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),1); + else if (!strcmp(name,"no")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),2); } - else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumLockCombo),0); + else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),0); if (main_config.layouts_list){ int size=0; name = yon_config_get_by_key(keyboard_layout_parameter); config_str layouts = yon_char_parse(name,&size,","); GtkTreeIter iter, itar; char *rid,*rname; - gtk_list_store_clear(widgets->layoutsList); + gtk_list_store_clear(main_config.layouts_list); for (int i=0;ilayoutsList,&itar); - gtk_list_store_set(widgets->layoutsList,&itar,0,rname,1,rid,2,1,-1); + gtk_list_store_append(main_config.layouts_list,&itar); + gtk_list_store_set(main_config.layouts_list,&itar,0,rname,1,rid,2,1,-1); } } } } } - g_signal_handlers_unblock_by_func(G_OBJECT(widgets->ModelCombo),G_CALLBACK(on_model_changed),widgets); - g_signal_handlers_unblock_by_func(G_OBJECT(widgets->MoveDownButton),G_CALLBACK(on_move_down),widgets); - g_signal_handlers_unblock_by_func(G_OBJECT(widgets->MoveUpButton),G_CALLBACK(on_move_up),widgets); - g_signal_handlers_unblock_by_func(G_OBJECT(widgets->OptionsButton),G_CALLBACK(on_options_open),widgets); - g_signal_handlers_unblock_by_func(G_OBJECT(widgets->NumLockCombo),G_CALLBACK(on_num_lock_changed),widgets); + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->SystemKeyboardModelCombo),G_CALLBACK(on_model_changed),widgets); + // g_signal_handlers_unblock_by_func(G_OBJECT(widgets->OptionsButton),G_CALLBACK(on_options_open),widgets); + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->NumlockCombo),G_CALLBACK(on_num_lock_changed),widgets); return G_SOURCE_REMOVE; } @@ -206,8 +202,8 @@ void on_model_changed(GtkComboBoxText *self, main_window *widgets){ default: char *id; GtkTreeIter iter; - gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widgets->ModelCombo),&iter); - gtk_tree_model_get(GTK_TREE_MODEL(widgets->modelsList),&iter,1,&id,-1); + gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widgets->SystemKeyboardModelCombo),&iter); + gtk_tree_model_get(GTK_TREE_MODEL(main_config.models_list),&iter,1,&id,-1); yon_config_register(model_parameter,model_parameter_command,id); break; } @@ -222,7 +218,7 @@ void on_options_accept(GtkWidget *self, dictionary *dict){ char *name, *id; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model,&iter)){ gtk_tree_model_get(model,&iter,0,&id,1,&name,-1); - gtk_entry_set_text(GTK_ENTRY(widgets->OptionsEntry),name); + gtk_entry_set_text(GTK_ENTRY(widgets->SystemKeyboardOptionsCombo),name); yon_config_register(options_parameter,options_parameter_command,id); } @@ -237,7 +233,7 @@ void yon_layouts_save(main_window *widgets){ for_iter(widgets->layoutsFilter,&iter){ char *name, *id; gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(widgets->layoutsFilter),&child_iter,&iter); - gtk_tree_model_get(GTK_TREE_MODEL(widgets->layoutsList),&child_iter,0,&name,1,&id,-1); + gtk_tree_model_get(GTK_TREE_MODEL(main_config.layouts_list),&child_iter,0,&name,1,&id,-1); yon_char_parsed_add_or_create_if_exists(parsed,&size,id); } if (parsed&&size>0){ @@ -283,7 +279,7 @@ GList *yon_get_all_selected(GtkTreeView *tree, int column){ void on_layouts_accept(GtkWidget *self, dictionary *dict){ main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); layouts_window *window = yon_dictionary_get_data(dict->first->next,layouts_window*); - gtk_list_store_clear(widgets->layoutsList); + gtk_list_store_clear(main_config.layouts_list); GtkTreeModel *model = GTK_TREE_MODEL(window->list); GList *list = yon_get_all_selected(GTK_TREE_VIEW(window->MainTree),2); char *name; @@ -293,9 +289,9 @@ void on_layouts_accept(GtkWidget *self, dictionary *dict){ for (guint i=0;ilayoutsList,&iter); + gtk_list_store_append(main_config.layouts_list,&iter); gtk_tree_model_get(model,&lwiter,0,&name,1,&id,-1); - gtk_list_store_set(widgets->layoutsList,&iter,1,name,0,id,2,1,-1); + gtk_list_store_set(main_config.layouts_list,&iter,1,name,0,id,2,1,-1); } yon_layouts_save(widgets); on_subwindow_close(self); @@ -309,7 +305,11 @@ void on_layouts_chosen(GtkCellRenderer *, gchar *path, layouts_window *window){ gtk_list_store_set(window->list,&iter,2,!chosen,-1); } -void on_layouts_add(GtkWidget *, main_window *widgets){ +void on_system_layouts_add(GtkWidget *, main_window *widgets){ + yon_layouts_add(GTK_TREE_VIEW(widgets->SystemLayoutTree),widgets->SystemList,widgets); +} + +void yon_layouts_add(GtkTreeView *, GtkListStore *, main_window *widgets){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_layouts_path); layouts_window *window = malloc(sizeof(layouts_window)); window->Window = yon_gtk_builder_get_widget(builder,"Window"); @@ -351,87 +351,35 @@ void on_layouts_add(GtkWidget *, main_window *widgets){ } } -void on_layouts_remove(GtkWidget *, main_window *widgets){ - GtkTreeModel *model = GTK_TREE_MODEL(widgets->layoutsList); +void yon_layouts_remove(GtkTreeView *tree, GtkListStore *cur_list, main_window *widgets){ + GtkTreeModel *model = GTK_TREE_MODEL(cur_list); GtkTreeIter iter; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->LayoutsTree)),&model,&iter)){ + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(tree),&model,&iter)){ GtkTreeIter iter_converted; char *target; gtk_tree_model_get(model,&iter,1,&target,-1); gtk_tree_model_filter_convert_iter_to_child_iter(widgets->layoutsFilter,&iter_converted,&iter); - gtk_list_store_remove(widgets->layoutsList,&iter_converted); + gtk_list_store_remove(cur_list,&iter_converted); yon_config_remove_element(keyboard_layout_parameter,target,","); } } -void on_move_up(GtkWidget *, main_window *widgets){ - GtkTreeModel *model = GTK_TREE_MODEL(widgets->layoutsFilter); - GtkTreeIter iter,*previter; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->LayoutsTree)),&model,&iter)){ - previter = gtk_tree_iter_copy(&iter); - if (gtk_tree_model_iter_previous(model,previter)) - { - GtkTreeIter iter_converted, previter_converted; - gtk_tree_model_filter_convert_iter_to_child_iter(widgets->layoutsFilter,&iter_converted,&iter); - gtk_tree_model_filter_convert_iter_to_child_iter(widgets->layoutsFilter,&previter_converted,previter); - gtk_list_store_move_before(widgets->layoutsList,&iter_converted,&previter_converted); - yon_layouts_save(widgets); - } - } +void on_system_layouts_remove(GtkWidget *, main_window *widgets){ + yon_layouts_add(GTK_TREE_VIEW(widgets->ConsoleLayoutTree),widgets->ConsoleList,widgets); } -void on_move_down(GtkWidget *, main_window *widgets){ - GtkTreeModel *model = GTK_TREE_MODEL(widgets->layoutsFilter); - GtkTreeIter iter,*nextiter; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->LayoutsTree)),&model,&iter)){ - nextiter = gtk_tree_iter_copy(&iter); - if (gtk_tree_model_iter_next(model,nextiter)){ - GtkTreeIter iter_converted, nextiter_converted; - gtk_tree_model_filter_convert_iter_to_child_iter(widgets->layoutsFilter,&iter_converted,&iter); - gtk_tree_model_filter_convert_iter_to_child_iter(widgets->layoutsFilter,&nextiter_converted,nextiter); - gtk_list_store_move_after(widgets->layoutsList,&iter_converted,&nextiter_converted); - yon_layouts_save(widgets); - } - } - -} - - - // standard functions - -void yon_main_window_complete(main_window *widgets){ - widgets = yon_remalloc(widgets,sizeof(main_window)); - GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); - gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"BoxMain"),1,1,0); - // Custom widgets configuration - { - - widgets->NumLockCombo = yon_gtk_builder_get_widget(builder,"NumlockCombo"); - widgets->ModelCombo = yon_gtk_builder_get_widget(builder,"ModelCombo"); - widgets->keyboard = yon_gtk_builder_get_widget(builder,"keyboard"); - widgets->keytable = yon_gtk_builder_get_widget(builder,"keytable"); - widgets->grp_toggle = yon_gtk_builder_get_widget(builder,"grp_toggle"); - widgets->OptionsEntry = yon_gtk_builder_get_widget(builder,"OptionsEntry"); - widgets->OptionsButton = yon_gtk_builder_get_widget(builder,"OptionsButton"); - widgets->LayoutsTree = yon_gtk_builder_get_widget(builder,"LayoutsTree"); - widgets->MoveUpButton = yon_gtk_builder_get_widget(builder,"MoveUpButton"); - widgets->MoveDownButton = yon_gtk_builder_get_widget(builder,"MoveDownButton"); - widgets->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); - widgets->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); - widgets->layoutsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); - widgets->layoutsFilter = GTK_TREE_MODEL_FILTER(gtk_builder_get_object(builder,"LayoutsFilter")); - widgets->modelsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore2")); - +void yon_config_init(){ int size; + main_config.models_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_BOOLEAN); GtkTreeIter iter; config_str models = yon_config_load(get_models_command,&size); for (int i=0;imodelsList,&iter); - gtk_list_store_set(widgets->modelsList,&iter,1,models[i],0,_(models[i+1]),-1); + gtk_list_store_append(main_config.models_list,&iter); + gtk_list_store_set(main_config.models_list,&iter,1,models[i],0,_(models[i+1]),-1); } main_config.layouts_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_BOOLEAN); int laysize; @@ -451,19 +399,48 @@ void yon_main_window_complete(main_window *widgets){ gtk_list_store_append(main_config.options_list,&iter); gtk_list_store_set(main_config.options_list,&iter,0,option[0],1,_(option[1]),-1); } +} + +void yon_main_window_complete(main_window *widgets){ + widgets = yon_remalloc(widgets,sizeof(main_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); + gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"BoxMain"),1,1,0); + // Custom widgets configuration + { + + widgets->ConsoleNumlockCombo = yon_gtk_builder_get_widget(builder,"ConsoleNumlockCombo"); + widgets->ConsoleDefaultLayoutRadio = yon_gtk_builder_get_widget(builder,"ConsoleDefaultLayoutRadio"); + widgets->ConsoleManualLayoutRadio = yon_gtk_builder_get_widget(builder,"ConsoleManualLayoutRadio"); + widgets->ConsoleLayoutTree = yon_gtk_builder_get_widget(builder,"ConsoleLayoutTree"); + widgets->ConsoleLayoutAddButton = yon_gtk_builder_get_widget(builder,"ConsoleLayoutAddButton"); + widgets->ConsoleLayoutRemoveButton = yon_gtk_builder_get_widget(builder,"ConsoleLayoutRemoveButton"); + widgets->ConsoleScrollLockCheck = yon_gtk_builder_get_widget(builder,"ConsoleScrollLockCheck"); + widgets->ConsoleManualEntry = yon_gtk_builder_get_widget(builder,"ConsoleManualEntry"); + widgets->SystemKeyboardModelCombo = yon_gtk_builder_get_widget(builder,"SystemKeyboardModelCombo"); + widgets->SystemKeyboardOptionsCombo = yon_gtk_builder_get_widget(builder,"SystemKeyboardOptionsCombo"); + widgets->SystemDefaultLayoutRadio = yon_gtk_builder_get_widget(builder,"SystemDefaultLayoutRadio"); + widgets->SystemManualLayoutRadio = yon_gtk_builder_get_widget(builder,"SystemManualLayoutRadio"); + widgets->SystemLayoutTree = yon_gtk_builder_get_widget(builder,"SystemLayoutTree"); + widgets->SystemLayoutAddButton = yon_gtk_builder_get_widget(builder,"SystemLayoutAddButton"); + widgets->SystemLayoutRemoveButton = yon_gtk_builder_get_widget(builder,"SystemLayoutRemoveButton"); + widgets->SystemScrollLockCheck = yon_gtk_builder_get_widget(builder,"SystemScrollLockCheck"); + widgets->SystemComposeCheck = yon_gtk_builder_get_widget(builder,"SystemComposeCheck"); + widgets->SystemManualEntry = yon_gtk_builder_get_widget(builder,"SystemManualEntry"); + widgets->NumlockCombo = yon_gtk_builder_get_widget(builder,"NumlockCombo"); + widgets->ConsoleList = GTK_LIST_STORE(gtk_builder_get_object(builder,"ConsoleList")); + widgets->SystemList = GTK_LIST_STORE(gtk_builder_get_object(builder,"SystemList")); + /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ // yon_window_config_add_custom_parameter(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING); /* Signal connection | Присоединение сигналов */ - g_signal_connect(G_OBJECT(widgets->AddButton),"clicked",G_CALLBACK(on_layouts_add),widgets); - g_signal_connect(G_OBJECT(widgets->RemoveButton),"clicked",G_CALLBACK(on_layouts_remove),widgets); - g_signal_connect(G_OBJECT(widgets->ModelCombo),"changed",G_CALLBACK(on_model_changed),widgets); - g_signal_connect(G_OBJECT(widgets->MoveDownButton),"clicked",G_CALLBACK(on_move_down),widgets); - g_signal_connect(G_OBJECT(widgets->MoveUpButton),"clicked",G_CALLBACK(on_move_up),widgets); - g_signal_connect(G_OBJECT(widgets->OptionsButton),"clicked",G_CALLBACK(on_options_open),widgets); - g_signal_connect(G_OBJECT(widgets->NumLockCombo),"changed",G_CALLBACK(on_num_lock_changed),widgets); + g_signal_connect(G_OBJECT(widgets->SystemLayoutAddButton),"clicked",G_CALLBACK(on_system_layouts_add),widgets); + g_signal_connect(G_OBJECT(widgets->SystemLayoutRemoveButton),"clicked",G_CALLBACK(on_system_layouts_remove),widgets); + g_signal_connect(G_OBJECT(widgets->SystemKeyboardModelCombo),"changed",G_CALLBACK(on_model_changed),widgets); + // g_signal_connect(G_OBJECT(widgets->SystemKeyboardOptionsCombo),"clicked",G_CALLBACK(on_options_open),widgets); + g_signal_connect(G_OBJECT(widgets->NumlockCombo),"changed",G_CALLBACK(on_num_lock_changed),widgets); } g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_config_local_load),widgets); @@ -484,7 +461,7 @@ void yon_main_window_complete(main_window *widgets){ int main(int argc, char *argv[]){ setlocale(LC_ALL, ""); textdomain (LocaleName); - + yon_config_init(); yon_ubl_connect_config((_template_config*)&main_config); yon_ubl_window_init(TITLE_LABEL,TITLE_INFO_LABEL,LocaleName,CssPath,LocaleName,version_application,WIKI_LINK); config_str unfound = NULL; diff --git a/source/ubl-settings-keyboard.h b/source/ubl-settings-keyboard.h index e6a5eaf..77791a8 100644 --- a/source/ubl-settings-keyboard.h +++ b/source/ubl-settings-keyboard.h @@ -63,26 +63,34 @@ typedef struct { char *options; GtkListStore *layouts_list; GtkListStore *options_list; + GtkListStore *models_list; } config; typedef struct { template_window_fields - GtkWidget *NumLockCombo; - GtkWidget *ModelCombo; - GtkWidget *keyboard; - GtkWidget *keytable; - GtkWidget *grp_toggle; - GtkWidget *OptionsEntry; - GtkWidget *OptionsButton; - GtkWidget *LayoutsTree; - GtkWidget *MoveUpButton; - GtkWidget *MoveDownButton; - GtkWidget *AddButton; - GtkWidget *RemoveButton; + GtkWidget *ConsoleNumlockCombo; + GtkWidget *ConsoleDefaultLayoutRadio; + GtkWidget *ConsoleManualLayoutRadio; + GtkWidget *ConsoleLayoutTree; + GtkWidget *ConsoleLayoutAddButton; + GtkWidget *ConsoleLayoutRemoveButton; + GtkWidget *ConsoleScrollLockCheck; + GtkWidget *ConsoleManualEntry; + GtkWidget *SystemKeyboardModelCombo; + GtkWidget *SystemKeyboardOptionsCombo; + GtkWidget *SystemDefaultLayoutRadio; + GtkWidget *SystemManualLayoutRadio; + GtkWidget *SystemLayoutTree; + GtkWidget *SystemLayoutAddButton; + GtkWidget *SystemLayoutRemoveButton; + GtkWidget *SystemScrollLockCheck; + GtkWidget *SystemComposeCheck; + GtkWidget *SystemManualEntry; + GtkWidget *NumlockCombo; GtkTreeModelFilter *layoutsFilter; - GtkListStore *layoutsList; - GtkListStore *modelsList; + GtkListStore *ConsoleList; + GtkListStore *SystemList; } main_window; @@ -133,13 +141,16 @@ void config_init(); void yon_main_window_complete(main_window *widgets); void on_move_down(GtkWidget *self, main_window *widgets); void on_move_up(GtkWidget *self, main_window *widgets); -void on_layouts_add(GtkWidget *self, main_window *widgets); void on_layouts_accept(GtkWidget *self, dictionary *dict); void on_options_open(GtkWidget *self, main_window *widgets); void on_options_accept(GtkWidget *self, dictionary *dict); void on_model_changed(GtkComboBoxText *self, main_window *widgets); void on_num_lock_changed(GtkComboBox *self, main_window *widgets); -void on_layouts_remove(GtkWidget *, main_window *widgets); void yon_layouts_save(main_window *widgets); void on_layouts_chosen(GtkCellRenderer *self, gchar *path, layouts_window *window); -GList *yon_get_all_selected(GtkTreeView *tree, int column); \ No newline at end of file +GList *yon_get_all_selected(GtkTreeView *tree, int column); +void on_system_layouts_add(GtkWidget *, main_window *widgets); +void yon_layouts_add(GtkTreeView *tree, GtkListStore *cur_list, main_window *widgets); +void yon_layouts_remove(GtkTreeView *tree, GtkListStore *cur_list, main_window *widgets); +void on_system_layouts_remove(GtkWidget *, main_window *widgets); +void yon_config_init(); \ No newline at end of file diff --git a/ubl-settings-keyboard.glade b/ubl-settings-keyboard.glade index 3445b85..bad50e4 100644 --- a/ubl-settings-keyboard.glade +++ b/ubl-settings-keyboard.glade @@ -25,20 +25,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + + True False - user-trash-symbolic + com.ublinux.libublsettingsui-gtk3.increase-symbolic - + True False - value-increase-symbolic + com.ublinux.libublsettingsui-gtk3.trash-symbolic - + + True + False + com.ublinux.libublsettingsui-gtk3.increase-symbolic + + True False - document-edit-symbolic + com.ublinux.libublsettingsui-gtk3.trash-symbolic @@ -67,215 +73,274 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - True - False - False - - - True - False - Load global configuration - - - - - - True - False - Load local configuration - - - - - - True - False - False - False - - - True - False - False - - - True - False - Save configuration - - - - - - True - False - Save to global configuration - - - - - - True - False - Save to local configuration - - - - - - True - False - - - True - False - True False - 5 - 5 - 5 - 5 - 5 - 5 - True - True vertical - 5 - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - - - True - False - 5 - - - True - False - Num Lock on boot: - 0 - - - False - True - 0 - - - - - True - False - 0 - - Default - On - Off - - - - True - True - 1 - - - - - - - - - True - False - Console - - - - - False - True - 0 - - - + True - False - 0.019999999552965164 + True in - + True False - 5 - 5 - 5 True False + 5 + 5 + 5 + 5 + 5 + 5 + True + True vertical - 6 + 5 - + True False - 5 + 0.019999999552965164 + in - + True False - Keyboard model: - 0 + 5 + 5 + 5 + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Num Lock on boot: + 0 + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + vertical + 5 + + + Default layout + True + True + False + True + True + + + False + True + 0 + + + + + Manual + True + True + False + True + True + ConsoleDefaultLayoutRadio + + + False + True + 1 + + + + + False + True + 0 + + + + + True + True + in + 100 + 150 + + + True + True + + + + + True + True + 1 + + + + + True + False + vertical + 5 + + + True + True + True + image5 + + + + False + True + 0 + + + + + True + True + True + image4 + + + + False + True + 1 + + + + + False + True + 2 + + + + + False + True + 1 + + + + + Scroll Lock indication when switching layouts + True + True + False + True + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Manual input: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 3 + + + + - - False - True - 0 - - - + + True False - liststore2 - 0 - 1 - - - - 0 - - + Console - - True - True - 1 - @@ -285,30 +350,49 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True False - 5 + 0.019999999552965164 + in - + True False - vertical - 5 + 5 + 5 + 5 - + True - True - in + False + vertical + 6 - + True - True - LayoutsFilter - False + False + 5 + + + True + False + Keyboard model: + 0 + + + False + True + 0 + + - - column + + True + False + liststore2 + 0 + 1 @@ -316,272 +400,418 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + True + True + 1 + + + False + True + 0 + - - - True - True - 0 - - - - - True - True - 0 - - - - - True - False - vertical - 5 - - - True - True - True - Move layout up - + True - True - False - True - menu4 - up + False + 5 - + + True + False + Keyboard options: + + + False + True + 0 + + + + + True + False + 0 + + Default + + + + True + True + 1 + - + + False + True + 1 + - - - - False - True - 0 - - - - - True - True - True - Move layout down - + True - True - False - True - menu5 + False + 5 + + + True + False + vertical + 5 + + + Default layout + True + True + False + True + True + + + False + True + 0 + + + + + Manual + True + True + False + True + ConsoleDefaultLayoutRadio + + + False + True + 1 + + + + + False + True + 0 + + - + + True + True + in + 100 + 150 + + + True + True + + + + + True + True + 1 + + + + + True + False + vertical + 5 + + + True + True + True + image2 + + + + False + True + 0 + + + + + True + True + True + image6 + + + + False + True + 1 + + + + + False + True + 2 + - + + False + True + 2 + + + + + True + False + 5 + + + Scroll Lock indication when switching layouts + True + True + False + True + + + False + True + 0 + + + + + Set Compose (Multi_Key) to the right Win key + True + True + False + True + + + False + True + 1 + + + + + False + True + 3 + + + + + True + False + 5 + + + True + False + Manual input: + + + False + True + 0 + + + + + True + True + + + True + True + 1 + + + + + False + True + 4 + - - - - False - True - 1 - - - - - True - True - True - Добавить раскладку - image3 - - - - False - True - 2 - - - - - True - True - True - Удалить раскладку - image1 - - - False - True - 4 - - - False - True - 1 - - - - True - True - end - 2 - - - - - True - False - Keyboard layouts: - 0 - - - False - True - end - 4 - - - - - False - 5 - - + + True False - KEYBOARD: - 0 - - - False - True - 0 - - - - - True - True + System - - True - True - 1 - - False + True True - 4 + 1 - + True False - 5 + 0.019999999552965164 + in - + True False - Keyboard options: - 0 + 5 + 5 + 5 + + + True + False + 5 + + + True + False + Numlock: + + + False + True + 0 + + + + + True + False + 0 + + Default + + + + True + True + 1 + + + + - - False - True - 0 - - - + + True False + Additional - - True - True - 1 - - - - - True - True - True - Pick an option - image4 - - - - False - True - 2 - False True - 7 + 3 - - - True - False - Keyboard - - True True - 3 + 1 - - - - - - - + + True + False + False + + + True + False + Load global configuration + + + + + + True + False + Load local configuration + + + + + + True + False + False + False + + + True + False + False + + + True + False + Save configuration + + + + + + True + False + Save to global configuration + + + + + + True + False + Save to local configuration + + + + + + True + False + + + True + False From 1f46007544410fbbbeb585c6731d8b601b4f6856 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Sat, 1 Nov 2025 17:10:23 +0600 Subject: [PATCH 2/6] WIP keyboard remake --- source/ubl-settings-keyboard.c | 220 +++++----- source/ubl-settings-keyboard.h | 61 ++- ubl-settings-keyboard-layouts.glade | 12 +- ubl-settings-keyboard.glade | 595 ++++++++++++++-------------- 4 files changed, 446 insertions(+), 442 deletions(-) diff --git a/source/ubl-settings-keyboard.c b/source/ubl-settings-keyboard.c index e787546..1194b4d 100644 --- a/source/ubl-settings-keyboard.c +++ b/source/ubl-settings-keyboard.c @@ -106,15 +106,14 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ } gboolean yon_interface_update(main_window *widgets){ - g_signal_handlers_block_by_func(G_OBJECT(widgets->SystemKeyboardModelCombo),G_CALLBACK(on_model_changed),widgets); + g_signal_handlers_block_by_func(G_OBJECT(widgets->KeyboardModelCombo),G_CALLBACK(on_model_changed),widgets); // g_signal_handlers_block_by_func(G_OBJECT(widgets->SystemKeyboardOptionsCombo),G_CALLBACK(on_options_open),widgets); g_signal_handlers_block_by_func(G_OBJECT(widgets->NumlockCombo),G_CALLBACK(on_num_lock_changed),widgets); - gtk_list_store_clear(main_config.layouts_list); - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->SystemKeyboardModelCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->KeyboardModelCombo),0); gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),0); + // gtk_entry_set_text(GTK_ENTRY(widgets->SystemKeyboardOptionsCombo),DEFAULT_LABEL); GtkTreeIter iter; - gtk_entry_set_text(GTK_ENTRY(widgets->SystemKeyboardOptionsCombo),DEFAULT_LABEL); { char *name = yon_config_get_by_key(model_parameter); char *id; @@ -123,60 +122,44 @@ gboolean yon_interface_update(main_window *widgets){ for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.models_list),&iter)){ gtk_tree_model_get(GTK_TREE_MODEL(main_config.models_list),&iter,1,&id,-1); if (!strcmp(name,id)){ - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->SystemKeyboardModelCombo),&iter); + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->KeyboardModelCombo),&iter); break; } } - } else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->SystemKeyboardModelCombo),0); + } else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->KeyboardModelCombo),0); } { - char *name = yon_config_get_by_key(options_parameter); - if (name) { - char *id, *rname; - gtk_entry_set_text(GTK_ENTRY(widgets->SystemKeyboardOptionsCombo),name); - int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(main_config.options_list),&iter); - for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.options_list),&iter)){ - gtk_tree_model_get(GTK_TREE_MODEL(main_config.options_list),&iter,0,&id,1,&rname,-1); - if (!strcmp(id,name)){ - gtk_list_store_set(main_config.options_list,&iter,2,1,-1); - gtk_entry_set_text(GTK_ENTRY(widgets->SystemKeyboardOptionsCombo),rname); - break; - } - } - } - } - { - if (main_config.layouts_list){ - for_iter(main_config.layouts_list,&iter){ - gtk_list_store_set(main_config.layouts_list,&iter,2,0,-1); - } - } + // if (main_config.layouts_store){ + // for_iter(main_config.layouts_store,&iter){ + // gtk_tree_store_set(main_config.layouts_store,&iter,2,0,-1); + // } + // } char *name = yon_config_get_by_key(num_lock_boot_parameter); if (name) { if (!strcmp(name,"yes")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),1); else if (!strcmp(name,"no")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),2); } else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),0); - if (main_config.layouts_list){ - int size=0; - name = yon_config_get_by_key(keyboard_layout_parameter); - config_str layouts = yon_char_parse(name,&size,","); - GtkTreeIter iter, itar; - char *rid,*rname; - gtk_list_store_clear(main_config.layouts_list); - for (int i=0;iSystemKeyboardModelCombo),G_CALLBACK(on_model_changed),widgets); + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->KeyboardModelCombo),G_CALLBACK(on_model_changed),widgets); // g_signal_handlers_unblock_by_func(G_OBJECT(widgets->OptionsButton),G_CALLBACK(on_options_open),widgets); g_signal_handlers_unblock_by_func(G_OBJECT(widgets->NumlockCombo),G_CALLBACK(on_num_lock_changed),widgets); return G_SOURCE_REMOVE; @@ -202,9 +185,10 @@ void on_model_changed(GtkComboBoxText *self, main_window *widgets){ default: char *id; GtkTreeIter iter; - gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widgets->SystemKeyboardModelCombo),&iter); - gtk_tree_model_get(GTK_TREE_MODEL(main_config.models_list),&iter,1,&id,-1); - yon_config_register(model_parameter,model_parameter_command,id); + if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widgets->KeyboardModelCombo),&iter)){ + gtk_tree_model_get(GTK_TREE_MODEL(main_config.models_list),&iter,1,&id,-1); + yon_config_register(model_parameter,model_parameter_command,id); + } break; } @@ -218,7 +202,7 @@ void on_options_accept(GtkWidget *self, dictionary *dict){ char *name, *id; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model,&iter)){ gtk_tree_model_get(model,&iter,0,&id,1,&name,-1); - gtk_entry_set_text(GTK_ENTRY(widgets->SystemKeyboardOptionsCombo),name); + gtk_entry_set_text(GTK_ENTRY(widgets->OptionsTree),name); yon_config_register(options_parameter,options_parameter_command,id); } @@ -233,7 +217,7 @@ void yon_layouts_save(main_window *widgets){ for_iter(widgets->layoutsFilter,&iter){ char *name, *id; gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(widgets->layoutsFilter),&child_iter,&iter); - gtk_tree_model_get(GTK_TREE_MODEL(main_config.layouts_list),&child_iter,0,&name,1,&id,-1); + gtk_tree_model_get(GTK_TREE_MODEL(main_config.layouts_store),&child_iter,0,&name,1,&id,-1); yon_char_parsed_add_or_create_if_exists(parsed,&size,id); } if (parsed&&size>0){ @@ -279,21 +263,28 @@ GList *yon_get_all_selected(GtkTreeView *tree, int column){ void on_layouts_accept(GtkWidget *self, dictionary *dict){ main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); layouts_window *window = yon_dictionary_get_data(dict->first->next,layouts_window*); - gtk_list_store_clear(main_config.layouts_list); + gtk_list_store_clear(widgets->LayoutsList); GtkTreeModel *model = GTK_TREE_MODEL(window->list); - GList *list = yon_get_all_selected(GTK_TREE_VIEW(window->MainTree),2); - char *name; - char *id; - GtkTreeIter iter, lwiter; - GtkTreePath *pth; - for (guint i=0;ilist,&window_iter){ + char *id, *name; + int status; + gtk_tree_model_get(model,&window_iter,0,&id,1,&name,2,&status,-1); + if (status){ + gtk_list_store_append(widgets->LayoutsList,&main_iter); + gtk_list_store_set(widgets->LayoutsList,&main_iter,0,id,1,name,-1); + } + GtkTreeIter child_iter; + if (gtk_tree_model_iter_children(model,&child_iter,&window_iter)){ + for (int valid2=1;valid2;valid2=gtk_tree_model_iter_next(model,&child_iter)){ + gtk_tree_model_get(model,&child_iter,0,&id,1,&name,2,&status,-1); + if (status){ + gtk_list_store_append(widgets->LayoutsList,&main_iter); + gtk_list_store_set(widgets->LayoutsList,&main_iter,0,id,1,name,-1); + } + } + } } - yon_layouts_save(widgets); on_subwindow_close(self); } @@ -302,11 +293,11 @@ void on_layouts_chosen(GtkCellRenderer *, gchar *path, layouts_window *window){ gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),&iter,path); int chosen; gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,2,&chosen,-1); - gtk_list_store_set(window->list,&iter,2,!chosen,-1); + gtk_tree_store_set(GTK_TREE_STORE(window->list),&iter,2,!chosen,-1); } void on_system_layouts_add(GtkWidget *, main_window *widgets){ - yon_layouts_add(GTK_TREE_VIEW(widgets->SystemLayoutTree),widgets->SystemList,widgets); + yon_layouts_add(GTK_TREE_VIEW(widgets->LayoutTree),widgets->LayoutsList,widgets); } void yon_layouts_add(GtkTreeView *, GtkListStore *, main_window *widgets){ @@ -317,12 +308,14 @@ void yon_layouts_add(GtkTreeView *, GtkListStore *, main_window *widgets){ window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); window->ChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"ChosenCell")); window->MainTree = yon_gtk_builder_get_widget(builder,"LayoutsTree"); - window->list = main_config.layouts_list; - gtk_tree_view_set_model(GTK_TREE_VIEW(window->MainTree), GTK_TREE_MODEL(window->list)); + window->list = (GtkListStore*)main_config.layouts_store; + gtk_tree_view_set_model(GTK_TREE_VIEW(window->MainTree), GTK_TREE_MODEL(main_config.layouts_store)); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),GTK_SELECTION_MULTIPLE); yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),TITLE_LABEL,icon_path,"layout_window"); + gtk_tree_view_column_clicked(GTK_TREE_VIEW_COLUMN(gtk_tree_view_get_column(GTK_TREE_VIEW(window->MainTree),0))); + dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); @@ -340,13 +333,13 @@ void yon_layouts_add(GtkTreeView *, GtkListStore *, main_window *widgets){ gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&id,-1); for (int i=0;ilist,&iter,2,1,-1); + gtk_tree_store_set(GTK_TREE_STORE(window->list),&iter,2,1,-1); found=1; break; } } if (!found) { - gtk_list_store_set(window->list,&iter,2,0,-1); + gtk_tree_store_set(GTK_TREE_STORE(window->list),&iter,2,0,-1); } } } @@ -365,11 +358,25 @@ void yon_layouts_remove(GtkTreeView *tree, GtkListStore *cur_list, main_window * } void on_system_layouts_remove(GtkWidget *, main_window *widgets){ - yon_layouts_add(GTK_TREE_VIEW(widgets->ConsoleLayoutTree),widgets->ConsoleList,widgets); + yon_layouts_remove(GTK_TREE_VIEW(widgets->LayoutTree),widgets->LayoutsList,widgets); } // standard functions +void yon_layout_build(char *key, dictionary *value, main_window *){ + GtkTreeIter parent; + GtkTreeIter iter; + gtk_tree_store_append(main_config.layouts_store,&parent,NULL); + gtk_tree_store_set(main_config.layouts_store,&parent,0,key,1,"",2,(char*)value->first->data,-1); + dictionary *dict; + for_dictionaries(dict,value){ + if (yon_char_is_empty(dict->key)) continue; + gtk_tree_store_append(main_config.layouts_store,&iter,&parent); + char *key_full = yon_char_unite(key,"_",dict->key,NULL); + gtk_tree_store_set(main_config.layouts_store,&iter,0,key_full,1,dict->key,2,(char*)dict->data,-1); + } +} + void yon_config_init(){ int size; main_config.models_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_BOOLEAN); @@ -381,17 +388,29 @@ void yon_config_init(){ gtk_list_store_append(main_config.models_list,&iter); gtk_list_store_set(main_config.models_list,&iter,1,models[i],0,_(models[i+1]),-1); } - main_config.layouts_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_BOOLEAN); - int laysize; - config_str rtn = yon_resource_open_file(layouts_path,&size); - for (int i=0; iConsoleNumlockCombo = yon_gtk_builder_get_widget(builder,"ConsoleNumlockCombo"); - widgets->ConsoleDefaultLayoutRadio = yon_gtk_builder_get_widget(builder,"ConsoleDefaultLayoutRadio"); - widgets->ConsoleManualLayoutRadio = yon_gtk_builder_get_widget(builder,"ConsoleManualLayoutRadio"); - widgets->ConsoleLayoutTree = yon_gtk_builder_get_widget(builder,"ConsoleLayoutTree"); - widgets->ConsoleLayoutAddButton = yon_gtk_builder_get_widget(builder,"ConsoleLayoutAddButton"); - widgets->ConsoleLayoutRemoveButton = yon_gtk_builder_get_widget(builder,"ConsoleLayoutRemoveButton"); - widgets->ConsoleScrollLockCheck = yon_gtk_builder_get_widget(builder,"ConsoleScrollLockCheck"); - widgets->ConsoleManualEntry = yon_gtk_builder_get_widget(builder,"ConsoleManualEntry"); - widgets->SystemKeyboardModelCombo = yon_gtk_builder_get_widget(builder,"SystemKeyboardModelCombo"); - widgets->SystemKeyboardOptionsCombo = yon_gtk_builder_get_widget(builder,"SystemKeyboardOptionsCombo"); - widgets->SystemDefaultLayoutRadio = yon_gtk_builder_get_widget(builder,"SystemDefaultLayoutRadio"); - widgets->SystemManualLayoutRadio = yon_gtk_builder_get_widget(builder,"SystemManualLayoutRadio"); - widgets->SystemLayoutTree = yon_gtk_builder_get_widget(builder,"SystemLayoutTree"); - widgets->SystemLayoutAddButton = yon_gtk_builder_get_widget(builder,"SystemLayoutAddButton"); - widgets->SystemLayoutRemoveButton = yon_gtk_builder_get_widget(builder,"SystemLayoutRemoveButton"); - widgets->SystemScrollLockCheck = yon_gtk_builder_get_widget(builder,"SystemScrollLockCheck"); - widgets->SystemComposeCheck = yon_gtk_builder_get_widget(builder,"SystemComposeCheck"); - widgets->SystemManualEntry = yon_gtk_builder_get_widget(builder,"SystemManualEntry"); + widgets->KeyboardModelCombo = yon_gtk_builder_get_widget(builder,"KeyboardModelCombo"); + widgets->DefaultLayoutRadio = yon_gtk_builder_get_widget(builder,"DefaultLayoutRadio"); + widgets->ManualLayoutRadio = yon_gtk_builder_get_widget(builder,"ManualLayoutRadio"); + widgets->LayoutTree = yon_gtk_builder_get_widget(builder,"LayoutTree"); + widgets->LayoutAddButton = yon_gtk_builder_get_widget(builder,"LayoutAddButton"); + widgets->LayoutRemoveButton = yon_gtk_builder_get_widget(builder,"LayoutRemoveButton"); + widgets->LayoutChangingCombo = yon_gtk_builder_get_widget(builder,"LayoutChangingCombo"); + widgets->OptionsTree = yon_gtk_builder_get_widget(builder,"OptionsTree"); + widgets->OptionsEditButton = yon_gtk_builder_get_widget(builder,"OptionsEditButton"); + widgets->ScrollLockCheck = yon_gtk_builder_get_widget(builder,"ScrollLockCheck"); + widgets->ComposeCheck = yon_gtk_builder_get_widget(builder,"ComposeCheck"); + widgets->ManualEntry = yon_gtk_builder_get_widget(builder,"ManualEntry"); widgets->NumlockCombo = yon_gtk_builder_get_widget(builder,"NumlockCombo"); - widgets->ConsoleList = GTK_LIST_STORE(gtk_builder_get_object(builder,"ConsoleList")); - widgets->SystemList = GTK_LIST_STORE(gtk_builder_get_object(builder,"SystemList")); + widgets->TTYLayoutCombo = yon_gtk_builder_get_widget(builder,"TTYLayoutCombo"); + widgets->LayoutsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"LayoutsList")); /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ @@ -436,9 +450,9 @@ void yon_main_window_complete(main_window *widgets){ /* Signal connection | Присоединение сигналов */ - g_signal_connect(G_OBJECT(widgets->SystemLayoutAddButton),"clicked",G_CALLBACK(on_system_layouts_add),widgets); - g_signal_connect(G_OBJECT(widgets->SystemLayoutRemoveButton),"clicked",G_CALLBACK(on_system_layouts_remove),widgets); - g_signal_connect(G_OBJECT(widgets->SystemKeyboardModelCombo),"changed",G_CALLBACK(on_model_changed),widgets); + g_signal_connect(G_OBJECT(widgets->LayoutAddButton),"clicked",G_CALLBACK(on_system_layouts_add),widgets); + g_signal_connect(G_OBJECT(widgets->LayoutRemoveButton),"clicked",G_CALLBACK(on_system_layouts_remove),widgets); + g_signal_connect(G_OBJECT(widgets->KeyboardModelCombo),"changed",G_CALLBACK(on_model_changed),widgets); // g_signal_connect(G_OBJECT(widgets->SystemKeyboardOptionsCombo),"clicked",G_CALLBACK(on_options_open),widgets); g_signal_connect(G_OBJECT(widgets->NumlockCombo),"changed",G_CALLBACK(on_num_lock_changed),widgets); } @@ -454,6 +468,8 @@ void yon_main_window_complete(main_window *widgets){ yon_root_button_setup((template_main_window*)widgets,main_config.launch_arguments,main_config.launch_size); yon_save_window_set_postsave_function(on_save_done,widgets); + gtk_tree_view_column_clicked(GTK_TREE_VIEW_COLUMN(gtk_tree_view_get_column(GTK_TREE_VIEW(widgets->LayoutTree),0))); + g_hash_table_foreach(main_config.layouts,(GHFunc)yon_layout_build,widgets); on_config_local_load(NULL,widgets); } diff --git a/source/ubl-settings-keyboard.h b/source/ubl-settings-keyboard.h index 77791a8..c25895d 100644 --- a/source/ubl-settings-keyboard.h +++ b/source/ubl-settings-keyboard.h @@ -50,6 +50,25 @@ #define get_models_command "sed '/<\\/modelList>/q' /usr/share/X11/xkb/rules/base.xml | grep -E '^ {8,8}|^ {8,8}'|sed -e 's/ *//g' -e 's,,,g' -e 's/ *//g' -e 's,,,g'" #define layouts_path "resource:///com/ublinux/csv/layouts.csv" +#define layouts_command "xkbcli list --load-exotic | awk \"\ +layout && /description:/ {\ + match(\\$0, /: *(.*)/, matches);\ + description = matches[1];\ + printf \\\"%s|%s|%s\\\\n\\\", layout, variant, description;\ + layout = \\\"\\\"; variant = \\\"\\\";\ +}\ +/layout:/ {\ + match(\\$0, /: *'([^']+)'/, matches);\ + l = matches[1];\ + layout = layouts[l] = l;\ +}\ +/variant:/ {\ + match(\\$0, /: *'([^']+)'/, matches);\ + variant = matches[1];\ +}\ +\" | sort -u\ +" + typedef char* string; __attribute__((unused)) static \ @@ -61,36 +80,33 @@ typedef struct { config_str launch_arguments; int launch_size; char *options; - GtkListStore *layouts_list; + GtkTreeStore *layouts_store; GtkListStore *options_list; GtkListStore *models_list; + GHashTable *layouts; + int layouts_size; + config_str layouts_list; } config; typedef struct { template_window_fields - GtkWidget *ConsoleNumlockCombo; - GtkWidget *ConsoleDefaultLayoutRadio; - GtkWidget *ConsoleManualLayoutRadio; - GtkWidget *ConsoleLayoutTree; - GtkWidget *ConsoleLayoutAddButton; - GtkWidget *ConsoleLayoutRemoveButton; - GtkWidget *ConsoleScrollLockCheck; - GtkWidget *ConsoleManualEntry; - GtkWidget *SystemKeyboardModelCombo; - GtkWidget *SystemKeyboardOptionsCombo; - GtkWidget *SystemDefaultLayoutRadio; - GtkWidget *SystemManualLayoutRadio; - GtkWidget *SystemLayoutTree; - GtkWidget *SystemLayoutAddButton; - GtkWidget *SystemLayoutRemoveButton; - GtkWidget *SystemScrollLockCheck; - GtkWidget *SystemComposeCheck; - GtkWidget *SystemManualEntry; + GtkWidget *KeyboardModelCombo; + GtkWidget *DefaultLayoutRadio; + GtkWidget *ManualLayoutRadio; + GtkWidget *LayoutTree; + GtkWidget *LayoutAddButton; + GtkWidget *LayoutRemoveButton; + GtkWidget *LayoutChangingCombo; + GtkWidget *OptionsTree; + GtkWidget *OptionsEditButton; + GtkWidget *ScrollLockCheck; + GtkWidget *ComposeCheck; + GtkWidget *ManualEntry; GtkWidget *NumlockCombo; + GtkWidget *TTYLayoutCombo; GtkTreeModelFilter *layoutsFilter; - GtkListStore *ConsoleList; - GtkListStore *SystemList; + GtkListStore *LayoutsList; } main_window; @@ -153,4 +169,5 @@ void on_system_layouts_add(GtkWidget *, main_window *widgets); void yon_layouts_add(GtkTreeView *tree, GtkListStore *cur_list, main_window *widgets); void yon_layouts_remove(GtkTreeView *tree, GtkListStore *cur_list, main_window *widgets); void on_system_layouts_remove(GtkWidget *, main_window *widgets); -void yon_config_init(); \ No newline at end of file +void yon_config_init(); +void yon_layout_build(char *key, dictionary *value, main_window *widgets); \ No newline at end of file diff --git a/ubl-settings-keyboard-layouts.glade b/ubl-settings-keyboard-layouts.glade index f36fbe5..75ae4f3 100644 --- a/ubl-settings-keyboard-layouts.glade +++ b/ubl-settings-keyboard-layouts.glade @@ -12,16 +12,6 @@ False process-stop-symbolic - - - - - - - - - - 450 550 @@ -85,7 +75,6 @@ True True - liststore1 False 1 @@ -94,6 +83,7 @@ column + 0 diff --git a/ubl-settings-keyboard.glade b/ubl-settings-keyboard.glade index bad50e4..c0f53d3 100644 --- a/ubl-settings-keyboard.glade +++ b/ubl-settings-keyboard.glade @@ -1,5 +1,5 @@ - - - - True - False - com.ublinux.libublsettingsui-gtk3.increase-symbolic + + + + + + + + + - + True False - com.ublinux.libublsettingsui-gtk3.trash-symbolic + com.ublinux.libublsettingsui-gtk3.edit-symbolic - + True False com.ublinux.libublsettingsui-gtk3.increase-symbolic @@ -46,33 +50,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False com.ublinux.libublsettingsui-gtk3.trash-symbolic - - - - - - - - - - - - liststore1 - - - - - - - - - - - Default - - - - True False @@ -81,6 +58,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True True + never in @@ -118,18 +96,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False vertical - 5 + 6 True False 5 - + True False - Num Lock on boot: - 0 + Keyboard model: + 1 False @@ -138,15 +116,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True False + LayoutsList 0 - - Default - On - Off - + 1 + + + + 0 + + True @@ -167,42 +148,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False 5 - + True False - vertical - 5 - - - Default layout - True - True - False - True - True - - - False - True - 0 - - - - - Manual - True - True - False - True - True - ConsoleDefaultLayoutRadio - - - False - True - 1 - - + start + Keyboard model: + 1 False @@ -210,26 +161,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0 - - - True - True - in - 100 - 150 - - - True - True - - - - - True - True - 1 - - True @@ -237,14 +168,40 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. vertical 5 - + True - True - True - image5 - + False + 10 + + + Default layout + True + True + False + True + True + + + False + True + 0 + + + + + Manual + True + True + False + True + DefaultLayoutRadio + + + False + True + 1 + + False @@ -253,14 +210,111 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True - True - True - image4 - + False + 5 + + + True + True + in + 100 + 150 + + + True + True + LayoutsList + False + + + + + + column + 0 + + + + 0 + + + + + + + column + + + + + + + + column + + + + 1 + + + + + + + + + True + True + 0 + + + + + True + False + vertical + 5 + + + True + True + True + image2 + + + + False + True + 0 + + + + + True + True + True + image6 + + + + False + True + 1 + + + + + False + True + 1 + + False @@ -269,55 +323,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - False - True - 2 - - - - - False - True - 1 - - - - - Scroll Lock indication when switching layouts - True - True - False - True - - - False - True - 2 - - - - - True - False - 5 - - - True - False - Manual input: - - - False - True - 0 - - - - - True - True - True True @@ -328,57 +333,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 3 + 1 - - - - - - - True - False - Console - - - - - False - True - 0 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 - - - True - False - vertical - 6 True False 5 - + True False - Keyboard model: - 0 + Changing the layout: + 1 False @@ -387,18 +355,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True False - liststore2 0 - 1 - - - - 0 - - + + Default + True @@ -410,7 +373,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 0 + 2 @@ -419,10 +382,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False 5 - + True False - Keyboard options: + vertical + 5 + + + True + False + Additional options: + 1 + + + False + True + 0 + + False @@ -431,13 +408,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True - False - 0 - - Default - + True + in + + + True + True + + + + + True @@ -445,18 +428,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 1 - - - False - True - 1 - - - - - True - False - 5 True @@ -464,13 +435,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. vertical 5 - - Default layout + True True - False - True - True + True + image1 + False @@ -478,46 +450,36 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0 - - - Manual - True - True - False - True - ConsoleDefaultLayoutRadio - - - False - True - 1 - - False True - 0 + 2 + + + False + True + 3 + + + + + True + False + 5 - + True - True - in - 100 - 150 - - - True - True - - + False + start + 1 - True + False True - 1 + 0 @@ -527,14 +489,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. vertical 5 - + + Scroll Lock indication when switching layouts True True - True - image2 - + False + True False @@ -543,14 +503,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + + Set Compose (Multi_Key) to the right Win key True True - True - image6 - + False + True False @@ -562,14 +520,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 2 + 1 False True - 2 + 4 @@ -578,12 +536,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False 5 - - Scroll Lock indication when switching layouts + True - True - False - True + False + Manual input: + 1 False @@ -592,15 +549,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Set Compose (Multi_Key) to the right Win key + True True - False - True - False + True True 1 @@ -609,7 +563,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 3 + 5 @@ -618,10 +572,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False 5 - + True False - Manual input: + Numlock: + 1 False @@ -630,9 +585,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True - True + False + 0 + + Default + True @@ -644,7 +603,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 4 + 6 @@ -662,7 +621,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True True - 1 + 0 @@ -684,10 +643,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False 5 - + True False - Numlock: + Secondary layout: + 1 False @@ -696,13 +656,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True False - 0 - - Default - True @@ -718,7 +674,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False - Additional + TTY layout @@ -740,6 +696,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + + + + + + + + + + + + + + + + + + + + + + + liststore1 + True False From e3de124983b73cf77430d17cf35a0e88169daaa9 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Sat, 1 Nov 2025 18:08:51 +0600 Subject: [PATCH 3/6] Fixes --- source/CMakeLists.txt | 1 + source/ubl-settings-keyboard.c | 372 +++++---- source/ubl-settings-keyboard.h | 49 +- ubl-settings-keyboard-layouts.glade | 12 +- ubl-settings-keyboard.glade | 1107 +++++++++++---------------- 5 files changed, 708 insertions(+), 833 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 5cabe32..81cad36 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -84,6 +84,7 @@ set(LIBRARIES ${UTILS_LIBRARIES} ${VTE291_LIBRARIES} pthread + xml2 ublsettings ublsettings-gtk3 ublsettingsui-gtk3) diff --git a/source/ubl-settings-keyboard.c b/source/ubl-settings-keyboard.c index 1194b4d..e0698bb 100644 --- a/source/ubl-settings-keyboard.c +++ b/source/ubl-settings-keyboard.c @@ -2,6 +2,58 @@ config main_config; + +const char *get_localized_layout_name(const char *layout_code) { + static char name[128]; + name[0] = '\0'; + + setlocale(LC_ALL, ""); + const char *lang = yongetenv("LANG"); + if (!lang) lang = "en"; + char lang_short[8]; + sscanf(lang, "%2s", lang_short); + + xmlDoc *doc = xmlReadFile("/usr/share/X11/xkb/rules/base.xml", NULL, 0); + if (!doc) return layout_code; + + xmlNode *root = xmlDocGetRootElement(doc); + for (xmlNode *layout = root->children; layout; layout = layout->next) { + if (layout->type == XML_ELEMENT_NODE && strcmp((char *)layout->name, "layout") == 0) { + xmlNode *config = layout->children; + const char *found_name = NULL; + const char *found_desc = NULL; + + for (xmlNode *n = config; n; n = n->next) { + if (n->type == XML_ELEMENT_NODE && strcmp((char *)n->name, "configItem") == 0) { + for (xmlNode *m = n->children; m; m = m->next) { + if (m->type != XML_ELEMENT_NODE) continue; + if (strcmp((char *)m->name, "name") == 0) + found_name = (char *)xmlNodeGetContent(m); + else if (strcmp((char *)m->name, "description") == 0) { + xmlChar *langAttr = xmlGetProp(m, (const xmlChar *)"xml:lang"); + if (langAttr && strncmp((char *)langAttr, lang_short, 2) == 0) + found_desc = (char *)xmlNodeGetContent(m); + xmlFree(langAttr); + } + } + } + } + + if (found_name && strcmp(found_name, layout_code) == 0) { + if (found_desc) + snprintf(name, sizeof(name), "%s", found_desc); + else + snprintf(name, sizeof(name), "%s", layout_code); + break; + } + } + } + xmlFreeDoc(doc); + xmlCleanupParser(); + return name[0] ? name : layout_code; +} + + void on_save_done(main_window *, config_str output, int size){ char *final_output = yon_char_parsed_to_string(output,size,""); if (final_output){ @@ -106,62 +158,83 @@ void yon_load_proceed(YON_CONFIG_TYPE type){ } gboolean yon_interface_update(main_window *widgets){ - g_signal_handlers_block_by_func(G_OBJECT(widgets->KeyboardModelCombo),G_CALLBACK(on_model_changed),widgets); - // g_signal_handlers_block_by_func(G_OBJECT(widgets->SystemKeyboardOptionsCombo),G_CALLBACK(on_options_open),widgets); - g_signal_handlers_block_by_func(G_OBJECT(widgets->NumlockCombo),G_CALLBACK(on_num_lock_changed),widgets); - - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->KeyboardModelCombo),0); - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),0); - // gtk_entry_set_text(GTK_ENTRY(widgets->SystemKeyboardOptionsCombo),DEFAULT_LABEL); + g_signal_handlers_block_by_func(G_OBJECT(widgets->ModelCombo),G_CALLBACK(on_model_changed),widgets); + g_signal_handlers_block_by_func(G_OBJECT(widgets->MoveDownButton),G_CALLBACK(on_move_down),widgets); + g_signal_handlers_block_by_func(G_OBJECT(widgets->MoveUpButton),G_CALLBACK(on_move_up),widgets); + g_signal_handlers_block_by_func(G_OBJECT(widgets->OptionsButton),G_CALLBACK(on_options_open),widgets); + g_signal_handlers_block_by_func(G_OBJECT(widgets->NumLockCombo),G_CALLBACK(on_num_lock_changed),widgets); + gtk_list_store_clear(widgets->layoutsList); + + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ModelCombo),0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumLockCombo),0); GtkTreeIter iter; + gtk_entry_set_text(GTK_ENTRY(widgets->OptionsEntry),DEFAULT_LABEL); { char *name = yon_config_get_by_key(model_parameter); char *id; if (name) { - int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(main_config.models_list),&iter); - for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.models_list),&iter)){ - gtk_tree_model_get(GTK_TREE_MODEL(main_config.models_list),&iter,1,&id,-1); + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->modelsList),&iter); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->modelsList),&iter)){ + gtk_tree_model_get(GTK_TREE_MODEL(widgets->modelsList),&iter,1,&id,-1); if (!strcmp(name,id)){ - gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->KeyboardModelCombo),&iter); + gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->ModelCombo),&iter); break; } } - } else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->KeyboardModelCombo),0); + } else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ModelCombo),0); } { - // if (main_config.layouts_store){ - // for_iter(main_config.layouts_store,&iter){ - // gtk_tree_store_set(main_config.layouts_store,&iter,2,0,-1); - // } - // } + char *name = yon_config_get_by_key(options_parameter); + if (name) { + char *id, *rname; + gtk_entry_set_text(GTK_ENTRY(widgets->OptionsEntry),name); + int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(main_config.options_list),&iter); + for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.options_list),&iter)){ + gtk_tree_model_get(GTK_TREE_MODEL(main_config.options_list),&iter,0,&id,1,&rname,-1); + if (!strcmp(id,name)){ + gtk_list_store_set(main_config.options_list,&iter,2,1,-1); + gtk_entry_set_text(GTK_ENTRY(widgets->OptionsEntry),rname); + break; + } + } + } + } + { + if (main_config.layouts_list){ + for_iter(main_config.layouts_list,&iter){ + gtk_tree_store_set(main_config.layouts_list,&iter,2,0,-1); + } + } char *name = yon_config_get_by_key(num_lock_boot_parameter); if (name) { - if (!strcmp(name,"yes")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),1); - else if (!strcmp(name,"no")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),2); + if (!strcmp(name,"yes")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumLockCombo),1); + else if (!strcmp(name,"no")) gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumLockCombo),2); + } + else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumLockCombo),0); + if (main_config.layouts_list){ + int size=0; + name = yon_config_get_by_key(keyboard_layout_parameter); + config_str layouts = yon_char_parse(name,&size,","); + GtkTreeIter iter, itar; + char *rid,*rname; + gtk_list_store_clear(widgets->layoutsList); + for (int i=0;ilayoutsList,&itar); + gtk_list_store_set(widgets->layoutsList,&itar,0,rname,1,rid,2,1,-1); + } + } + } } - else gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->NumlockCombo),0); - // if (main_config.layouts_store){ - // int size=0; - // name = yon_config_get_by_key(keyboard_layout_parameter); - // config_str layouts = yon_char_parse(name,&size,","); - // GtkTreeIter iter, itar; - // char *rid,*rname; - // gtk_tree_store_clear(main_config.layouts_store); - // for (int i=0;iKeyboardModelCombo),G_CALLBACK(on_model_changed),widgets); - // g_signal_handlers_unblock_by_func(G_OBJECT(widgets->OptionsButton),G_CALLBACK(on_options_open),widgets); - g_signal_handlers_unblock_by_func(G_OBJECT(widgets->NumlockCombo),G_CALLBACK(on_num_lock_changed),widgets); + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->ModelCombo),G_CALLBACK(on_model_changed),widgets); + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->MoveDownButton),G_CALLBACK(on_move_down),widgets); + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->MoveUpButton),G_CALLBACK(on_move_up),widgets); + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->OptionsButton),G_CALLBACK(on_options_open),widgets); + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->NumLockCombo),G_CALLBACK(on_num_lock_changed),widgets); return G_SOURCE_REMOVE; } @@ -185,10 +258,9 @@ void on_model_changed(GtkComboBoxText *self, main_window *widgets){ default: char *id; GtkTreeIter iter; - if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widgets->KeyboardModelCombo),&iter)){ - gtk_tree_model_get(GTK_TREE_MODEL(main_config.models_list),&iter,1,&id,-1); - yon_config_register(model_parameter,model_parameter_command,id); - } + gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widgets->ModelCombo),&iter); + gtk_tree_model_get(GTK_TREE_MODEL(widgets->modelsList),&iter,1,&id,-1); + yon_config_register(model_parameter,model_parameter_command,id); break; } @@ -202,7 +274,7 @@ void on_options_accept(GtkWidget *self, dictionary *dict){ char *name, *id; if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),&model,&iter)){ gtk_tree_model_get(model,&iter,0,&id,1,&name,-1); - gtk_entry_set_text(GTK_ENTRY(widgets->OptionsTree),name); + gtk_entry_set_text(GTK_ENTRY(widgets->OptionsEntry),name); yon_config_register(options_parameter,options_parameter_command,id); } @@ -217,7 +289,7 @@ void yon_layouts_save(main_window *widgets){ for_iter(widgets->layoutsFilter,&iter){ char *name, *id; gtk_tree_model_filter_convert_iter_to_child_iter(GTK_TREE_MODEL_FILTER(widgets->layoutsFilter),&child_iter,&iter); - gtk_tree_model_get(GTK_TREE_MODEL(main_config.layouts_store),&child_iter,0,&name,1,&id,-1); + gtk_tree_model_get(GTK_TREE_MODEL(widgets->layoutsList),&child_iter,0,&name,1,&id,-1); yon_char_parsed_add_or_create_if_exists(parsed,&size,id); } if (parsed&&size>0){ @@ -263,28 +335,31 @@ GList *yon_get_all_selected(GtkTreeView *tree, int column){ void on_layouts_accept(GtkWidget *self, dictionary *dict){ main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); layouts_window *window = yon_dictionary_get_data(dict->first->next,layouts_window*); - gtk_list_store_clear(widgets->LayoutsList); + gtk_list_store_clear(widgets->layoutsList); GtkTreeModel *model = GTK_TREE_MODEL(window->list); - GtkTreeIter main_iter, window_iter; - for_iter(window->list,&window_iter){ - char *id, *name; + char *name; + char *id; + GtkTreeIter iter, lwiter, chiter; + for_iter(model,&lwiter){ int status; - gtk_tree_model_get(model,&window_iter,0,&id,1,&name,2,&status,-1); + gtk_tree_model_get(model,&lwiter,0,&name,1,&id,2,&status,-1); if (status){ - gtk_list_store_append(widgets->LayoutsList,&main_iter); - gtk_list_store_set(widgets->LayoutsList,&main_iter,0,id,1,name,-1); + gtk_list_store_append(widgets->layoutsList,&iter); + gtk_list_store_set(widgets->layoutsList,&iter,1,name,0,id,2,1,-1); } - GtkTreeIter child_iter; - if (gtk_tree_model_iter_children(model,&child_iter,&window_iter)){ - for (int valid2=1;valid2;valid2=gtk_tree_model_iter_next(model,&child_iter)){ - gtk_tree_model_get(model,&child_iter,0,&id,1,&name,2,&status,-1); - if (status){ - gtk_list_store_append(widgets->LayoutsList,&main_iter); - gtk_list_store_set(widgets->LayoutsList,&main_iter,0,id,1,name,-1); + if (gtk_tree_model_iter_children(model,&chiter,&lwiter)){ + for (int valid2 = 1; valid2; valid2 = gtk_tree_model_iter_next(model,&chiter)){ + char *chid, *chname; + int chstatus; + gtk_tree_model_get(model,&chiter,0,&chname,1,&chid,2,&chstatus,-1); + if (chstatus){ + gtk_list_store_append(widgets->layoutsList,&iter); + gtk_list_store_set(widgets->layoutsList,&iter,1,chname,0,chid,2,1,-1); } } } } + yon_layouts_save(widgets); on_subwindow_close(self); } @@ -296,11 +371,7 @@ void on_layouts_chosen(GtkCellRenderer *, gchar *path, layouts_window *window){ gtk_tree_store_set(GTK_TREE_STORE(window->list),&iter,2,!chosen,-1); } -void on_system_layouts_add(GtkWidget *, main_window *widgets){ - yon_layouts_add(GTK_TREE_VIEW(widgets->LayoutTree),widgets->LayoutsList,widgets); -} - -void yon_layouts_add(GtkTreeView *, GtkListStore *, main_window *widgets){ +void on_layouts_add(GtkWidget *, main_window *widgets){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_layouts_path); layouts_window *window = malloc(sizeof(layouts_window)); window->Window = yon_gtk_builder_get_widget(builder,"Window"); @@ -308,14 +379,12 @@ void yon_layouts_add(GtkTreeView *, GtkListStore *, main_window *widgets){ window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); window->ChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"ChosenCell")); window->MainTree = yon_gtk_builder_get_widget(builder,"LayoutsTree"); - window->list = (GtkListStore*)main_config.layouts_store; - gtk_tree_view_set_model(GTK_TREE_VIEW(window->MainTree), GTK_TREE_MODEL(main_config.layouts_store)); + window->list = (GtkListStore*)main_config.layouts_list; + gtk_tree_view_set_model(GTK_TREE_VIEW(window->MainTree), GTK_TREE_MODEL(window->list)); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),GTK_SELECTION_MULTIPLE); yon_gtk_window_setup(GTK_WINDOW(window->Window),GTK_WINDOW(widgets->Window),TITLE_LABEL,icon_path,"layout_window"); - gtk_tree_view_column_clicked(GTK_TREE_VIEW_COLUMN(gtk_tree_view_get_column(GTK_TREE_VIEW(window->MainTree),0))); - dictionary *dict = NULL; yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); @@ -344,73 +413,110 @@ void yon_layouts_add(GtkTreeView *, GtkListStore *, main_window *widgets){ } } -void yon_layouts_remove(GtkTreeView *tree, GtkListStore *cur_list, main_window *widgets){ - GtkTreeModel *model = GTK_TREE_MODEL(cur_list); +void on_layouts_remove(GtkWidget *, main_window *widgets){ + GtkTreeModel *model = GTK_TREE_MODEL(widgets->layoutsList); GtkTreeIter iter; - if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(tree),&model,&iter)){ + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->LayoutsTree)),&model,&iter)){ GtkTreeIter iter_converted; char *target; gtk_tree_model_get(model,&iter,1,&target,-1); gtk_tree_model_filter_convert_iter_to_child_iter(widgets->layoutsFilter,&iter_converted,&iter); - gtk_list_store_remove(cur_list,&iter_converted); + gtk_list_store_remove(widgets->layoutsList,&iter_converted); yon_config_remove_element(keyboard_layout_parameter,target,","); } } -void on_system_layouts_remove(GtkWidget *, main_window *widgets){ - yon_layouts_remove(GTK_TREE_VIEW(widgets->LayoutTree),widgets->LayoutsList,widgets); +void on_move_up(GtkWidget *, main_window *widgets){ + GtkTreeModel *model = GTK_TREE_MODEL(widgets->layoutsFilter); + GtkTreeIter iter,*previter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->LayoutsTree)),&model,&iter)){ + previter = gtk_tree_iter_copy(&iter); + if (gtk_tree_model_iter_previous(model,previter)) + { + GtkTreeIter iter_converted, previter_converted; + gtk_tree_model_filter_convert_iter_to_child_iter(widgets->layoutsFilter,&iter_converted,&iter); + gtk_tree_model_filter_convert_iter_to_child_iter(widgets->layoutsFilter,&previter_converted,previter); + gtk_list_store_move_before(widgets->layoutsList,&iter_converted,&previter_converted); + yon_layouts_save(widgets); + } + } } -// standard functions - -void yon_layout_build(char *key, dictionary *value, main_window *){ - GtkTreeIter parent; - GtkTreeIter iter; - gtk_tree_store_append(main_config.layouts_store,&parent,NULL); - gtk_tree_store_set(main_config.layouts_store,&parent,0,key,1,"",2,(char*)value->first->data,-1); - dictionary *dict; - for_dictionaries(dict,value){ - if (yon_char_is_empty(dict->key)) continue; - gtk_tree_store_append(main_config.layouts_store,&iter,&parent); - char *key_full = yon_char_unite(key,"_",dict->key,NULL); - gtk_tree_store_set(main_config.layouts_store,&iter,0,key_full,1,dict->key,2,(char*)dict->data,-1); +void on_move_down(GtkWidget *, main_window *widgets){ + GtkTreeModel *model = GTK_TREE_MODEL(widgets->layoutsFilter); + GtkTreeIter iter,*nextiter; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->LayoutsTree)),&model,&iter)){ + nextiter = gtk_tree_iter_copy(&iter); + if (gtk_tree_model_iter_next(model,nextiter)){ + GtkTreeIter iter_converted, nextiter_converted; + gtk_tree_model_filter_convert_iter_to_child_iter(widgets->layoutsFilter,&iter_converted,&iter); + gtk_tree_model_filter_convert_iter_to_child_iter(widgets->layoutsFilter,&nextiter_converted,nextiter); + gtk_list_store_move_after(widgets->layoutsList,&iter_converted,&nextiter_converted); + yon_layouts_save(widgets); + } } + } -void yon_config_init(){ + + +// standard functions + + +void yon_main_window_complete(main_window *widgets){ + widgets = yon_remalloc(widgets,sizeof(main_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); + gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"BoxMain"),1,1,0); + // Custom widgets configuration + { + + widgets->NumLockCombo = yon_gtk_builder_get_widget(builder,"NumlockCombo"); + widgets->ModelCombo = yon_gtk_builder_get_widget(builder,"ModelCombo"); + widgets->keyboard = yon_gtk_builder_get_widget(builder,"keyboard"); + widgets->keytable = yon_gtk_builder_get_widget(builder,"keytable"); + widgets->grp_toggle = yon_gtk_builder_get_widget(builder,"grp_toggle"); + widgets->OptionsEntry = yon_gtk_builder_get_widget(builder,"OptionsEntry"); + widgets->OptionsButton = yon_gtk_builder_get_widget(builder,"OptionsButton"); + widgets->LayoutsTree = yon_gtk_builder_get_widget(builder,"LayoutsTree"); + widgets->MoveUpButton = yon_gtk_builder_get_widget(builder,"MoveUpButton"); + widgets->MoveDownButton = yon_gtk_builder_get_widget(builder,"MoveDownButton"); + widgets->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); + widgets->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); + widgets->layoutsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore1")); + widgets->layoutsFilter = GTK_TREE_MODEL_FILTER(gtk_builder_get_object(builder,"LayoutsFilter")); + widgets->modelsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore2")); + int size; - main_config.models_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_BOOLEAN); - GtkTreeIter iter; + GtkTreeIter iter,chiter; config_str models = yon_config_load(get_models_command,&size); for (int i=0;imodelsList,&iter); + gtk_list_store_set(widgets->modelsList,&iter,1,models[i],0,_(models[i+1]),-1); } - yon_char_parsed_free(models,size); - - main_config.layouts_store = gtk_tree_store_new(4,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_BOOLEAN); - main_config.layouts_list = yon_config_load(layouts_command,&main_config.layouts_size); - main_config.layouts = g_hash_table_new(g_str_hash,g_str_equal); - for (int i=0; iInterfaceBox),yon_gtk_builder_get_widget(builder,"BoxMain"),1,1,0); - // Custom widgets configuration - { - - widgets->KeyboardModelCombo = yon_gtk_builder_get_widget(builder,"KeyboardModelCombo"); - widgets->DefaultLayoutRadio = yon_gtk_builder_get_widget(builder,"DefaultLayoutRadio"); - widgets->ManualLayoutRadio = yon_gtk_builder_get_widget(builder,"ManualLayoutRadio"); - widgets->LayoutTree = yon_gtk_builder_get_widget(builder,"LayoutTree"); - widgets->LayoutAddButton = yon_gtk_builder_get_widget(builder,"LayoutAddButton"); - widgets->LayoutRemoveButton = yon_gtk_builder_get_widget(builder,"LayoutRemoveButton"); - widgets->LayoutChangingCombo = yon_gtk_builder_get_widget(builder,"LayoutChangingCombo"); - widgets->OptionsTree = yon_gtk_builder_get_widget(builder,"OptionsTree"); - widgets->OptionsEditButton = yon_gtk_builder_get_widget(builder,"OptionsEditButton"); - widgets->ScrollLockCheck = yon_gtk_builder_get_widget(builder,"ScrollLockCheck"); - widgets->ComposeCheck = yon_gtk_builder_get_widget(builder,"ComposeCheck"); - widgets->ManualEntry = yon_gtk_builder_get_widget(builder,"ManualEntry"); - widgets->NumlockCombo = yon_gtk_builder_get_widget(builder,"NumlockCombo"); - widgets->TTYLayoutCombo = yon_gtk_builder_get_widget(builder,"TTYLayoutCombo"); - widgets->LayoutsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"LayoutsList")); - /* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */ // yon_window_config_add_custom_parameter(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING); /* Signal connection | Присоединение сигналов */ - g_signal_connect(G_OBJECT(widgets->LayoutAddButton),"clicked",G_CALLBACK(on_system_layouts_add),widgets); - g_signal_connect(G_OBJECT(widgets->LayoutRemoveButton),"clicked",G_CALLBACK(on_system_layouts_remove),widgets); - g_signal_connect(G_OBJECT(widgets->KeyboardModelCombo),"changed",G_CALLBACK(on_model_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->SystemKeyboardOptionsCombo),"clicked",G_CALLBACK(on_options_open),widgets); - g_signal_connect(G_OBJECT(widgets->NumlockCombo),"changed",G_CALLBACK(on_num_lock_changed),widgets); + g_signal_connect(G_OBJECT(widgets->AddButton),"clicked",G_CALLBACK(on_layouts_add),widgets); + g_signal_connect(G_OBJECT(widgets->RemoveButton),"clicked",G_CALLBACK(on_layouts_remove),widgets); + g_signal_connect(G_OBJECT(widgets->ModelCombo),"changed",G_CALLBACK(on_model_changed),widgets); + g_signal_connect(G_OBJECT(widgets->MoveDownButton),"clicked",G_CALLBACK(on_move_down),widgets); + g_signal_connect(G_OBJECT(widgets->MoveUpButton),"clicked",G_CALLBACK(on_move_up),widgets); + g_signal_connect(G_OBJECT(widgets->OptionsButton),"clicked",G_CALLBACK(on_options_open),widgets); + g_signal_connect(G_OBJECT(widgets->NumLockCombo),"changed",G_CALLBACK(on_num_lock_changed),widgets); } g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_config_local_load),widgets); @@ -468,8 +550,6 @@ void yon_main_window_complete(main_window *widgets){ yon_root_button_setup((template_main_window*)widgets,main_config.launch_arguments,main_config.launch_size); yon_save_window_set_postsave_function(on_save_done,widgets); - gtk_tree_view_column_clicked(GTK_TREE_VIEW_COLUMN(gtk_tree_view_get_column(GTK_TREE_VIEW(widgets->LayoutTree),0))); - g_hash_table_foreach(main_config.layouts,(GHFunc)yon_layout_build,widgets); on_config_local_load(NULL,widgets); } @@ -477,7 +557,7 @@ void yon_main_window_complete(main_window *widgets){ int main(int argc, char *argv[]){ setlocale(LC_ALL, ""); textdomain (LocaleName); - yon_config_init(); + yon_ubl_connect_config((_template_config*)&main_config); yon_ubl_window_init(TITLE_LABEL,TITLE_INFO_LABEL,LocaleName,CssPath,LocaleName,version_application,WIKI_LINK); config_str unfound = NULL; diff --git a/source/ubl-settings-keyboard.h b/source/ubl-settings-keyboard.h index c25895d..007e003 100644 --- a/source/ubl-settings-keyboard.h +++ b/source/ubl-settings-keyboard.h @@ -9,6 +9,9 @@ #include #include #include +#include +#include + #ifdef WEBKIT_FOUND #include #endif @@ -50,7 +53,7 @@ #define get_models_command "sed '/<\\/modelList>/q' /usr/share/X11/xkb/rules/base.xml | grep -E '^ {8,8}|^ {8,8}'|sed -e 's/ *//g' -e 's,,,g' -e 's/ *//g' -e 's,,,g'" #define layouts_path "resource:///com/ublinux/csv/layouts.csv" -#define layouts_command "xkbcli list --load-exotic | awk \"\ +#define get_layouts_command "xkbcli list --load-exotic | awk \"\ layout && /description:/ {\ match(\\$0, /: *(.*)/, matches);\ description = matches[1];\ @@ -80,33 +83,28 @@ typedef struct { config_str launch_arguments; int launch_size; char *options; - GtkTreeStore *layouts_store; + GtkTreeStore *layouts_list; GtkListStore *options_list; - GtkListStore *models_list; - GHashTable *layouts; - int layouts_size; - config_str layouts_list; } config; typedef struct { template_window_fields - GtkWidget *KeyboardModelCombo; - GtkWidget *DefaultLayoutRadio; - GtkWidget *ManualLayoutRadio; - GtkWidget *LayoutTree; - GtkWidget *LayoutAddButton; - GtkWidget *LayoutRemoveButton; - GtkWidget *LayoutChangingCombo; - GtkWidget *OptionsTree; - GtkWidget *OptionsEditButton; - GtkWidget *ScrollLockCheck; - GtkWidget *ComposeCheck; - GtkWidget *ManualEntry; - GtkWidget *NumlockCombo; - GtkWidget *TTYLayoutCombo; + GtkWidget *NumLockCombo; + GtkWidget *ModelCombo; + GtkWidget *keyboard; + GtkWidget *keytable; + GtkWidget *grp_toggle; + GtkWidget *OptionsEntry; + GtkWidget *OptionsButton; + GtkWidget *LayoutsTree; + GtkWidget *MoveUpButton; + GtkWidget *MoveDownButton; + GtkWidget *AddButton; + GtkWidget *RemoveButton; GtkTreeModelFilter *layoutsFilter; - GtkListStore *LayoutsList; + GtkListStore *layoutsList; + GtkListStore *modelsList; } main_window; @@ -157,17 +155,14 @@ void config_init(); void yon_main_window_complete(main_window *widgets); void on_move_down(GtkWidget *self, main_window *widgets); void on_move_up(GtkWidget *self, main_window *widgets); +void on_layouts_add(GtkWidget *self, main_window *widgets); void on_layouts_accept(GtkWidget *self, dictionary *dict); void on_options_open(GtkWidget *self, main_window *widgets); void on_options_accept(GtkWidget *self, dictionary *dict); void on_model_changed(GtkComboBoxText *self, main_window *widgets); void on_num_lock_changed(GtkComboBox *self, main_window *widgets); +void on_layouts_remove(GtkWidget *, main_window *widgets); void yon_layouts_save(main_window *widgets); void on_layouts_chosen(GtkCellRenderer *self, gchar *path, layouts_window *window); GList *yon_get_all_selected(GtkTreeView *tree, int column); -void on_system_layouts_add(GtkWidget *, main_window *widgets); -void yon_layouts_add(GtkTreeView *tree, GtkListStore *cur_list, main_window *widgets); -void yon_layouts_remove(GtkTreeView *tree, GtkListStore *cur_list, main_window *widgets); -void on_system_layouts_remove(GtkWidget *, main_window *widgets); -void yon_config_init(); -void yon_layout_build(char *key, dictionary *value, main_window *widgets); \ No newline at end of file +const char *get_localized_layout_name(const char *layout_code); \ No newline at end of file diff --git a/ubl-settings-keyboard-layouts.glade b/ubl-settings-keyboard-layouts.glade index 75ae4f3..f36fbe5 100644 --- a/ubl-settings-keyboard-layouts.glade +++ b/ubl-settings-keyboard-layouts.glade @@ -12,6 +12,16 @@ False process-stop-symbolic + + + + + + + + + + 450 550 @@ -75,6 +85,7 @@ True True + liststore1 False 1 @@ -83,7 +94,6 @@ column - 0 diff --git a/ubl-settings-keyboard.glade b/ubl-settings-keyboard.glade index c0f53d3..3445b85 100644 --- a/ubl-settings-keyboard.glade +++ b/ubl-settings-keyboard.glade @@ -1,5 +1,5 @@ - - + + True + False + user-trash-symbolic + + + True + False + value-increase-symbolic + + + True + False + document-edit-symbolic + + - + - + + + + + + + + liststore1 + + + + - + + + + Default + + + - + + True + False + False + + + True + False + Load global configuration + + + + + + True + False + Load local configuration + + + + + + True + False + False + False + + True False - com.ublinux.libublsettingsui-gtk3.edit-symbolic + False + + + True + False + Save configuration + + + + + + True + False + Save to global configuration + + + + + + True + False + Save to local configuration + + + - + True False - com.ublinux.libublsettingsui-gtk3.increase-symbolic - + True False - com.ublinux.libublsettingsui-gtk3.trash-symbolic True False + 5 + 5 + 5 + 5 + 5 + 5 + True + True vertical + 5 - + True - True - never + False + 0.019999999552965164 in - + True False + 5 + 5 + 5 True False - 5 - 5 - 5 - 5 - 5 - 5 - True - True - vertical 5 - + True False - 0.019999999552965164 - in + Num Lock on boot: + 0 + + + False + True + 0 + + + + + True + False + 0 + + Default + On + Off + + + + True + True + 1 + + + + + + + + + True + False + Console + + + + + False + True + 0 + + + + + True + False + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + + + True + False + vertical + 6 + + + True + False + 5 + + + True + False + Keyboard model: + 0 + + + False + True + 0 + + - + True False - 5 - 5 - 5 + liststore2 + 0 + 1 - + + + 0 + + + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + vertical + 5 + + True - False - vertical - 6 + True + in - + True - False - 5 - - - True - False - Keyboard model: - 1 - - - False - True - 0 - - + True + LayoutsFilter + False - - True - False - LayoutsList - 0 - 1 + + column @@ -129,670 +316,272 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - - - True - False - start - Keyboard model: - 1 - - - False - True - 0 - - - - - True - False - vertical - 5 - - - True - False - 10 - - - Default layout - True - True - False - True - True - - - False - True - 0 - - - - - Manual - True - True - False - True - DefaultLayoutRadio - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - - - True - True - in - 100 - 150 - - - True - True - LayoutsList - False - - - - - - column - 0 - - - - 0 - - - - - - - column - - - - - - - - column - - - - 1 - - - - - - - - - True - True - 0 - - - - - True - False - vertical - 5 - - - True - True - True - image2 - - - - False - True - 0 - - - - - True - True - True - image6 - - - - False - True - 1 - - - - - False - True - 1 - - - - - False - True - 1 - - - - - True - True - 1 - - - - - False - True - 1 - - - - - True - False - 5 - - - True - False - Changing the layout: - 1 - - - False - True - 0 - - - - - True - False - 0 - - Default - - - - True - True - 1 - - - - - False - True - 2 - - - - - True - False - 5 - - - True - False - vertical - 5 - - - True - False - Additional options: - 1 - - - False - True - 0 - - - - - False - True - 0 - - - - - True - True - in - - - True - True - - - - - - - - True - True - 1 - - - - - True - False - vertical - 5 - - - True - True - True - image1 - - - - False - True - 0 - - - - - False - True - 2 - - - - - False - True - 3 - - - - - True - False - 5 - - - True - False - start - 1 - - - False - True - 0 - - - - - True - False - vertical - 5 - - - Scroll Lock indication when switching layouts - True - True - False - True - - - False - True - 0 - - - - - Set Compose (Multi_Key) to the right Win key - True - True - False - True - - - False - True - 1 - - - - - False - True - 1 - - - False - True - 4 - + + + True + True + 0 + + + + + True + True + 0 + + + + + True + False + vertical + 5 + + + True + True + True + Move layout up - + True - False - 5 + True + False + True + menu4 + up - - True - False - Manual input: - 1 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - + + - - False - True - 5 - + + + + False + True + 0 + + + + + True + True + True + Move layout down - + True - False - 5 - - - True - False - Numlock: - 1 - - - False - True - 0 - - + True + False + True + menu5 - - True - False - 0 - - Default - - - - True - True - 1 - + + - - False - True - 6 - + + + False + True + 1 + + + + + True + True + True + Добавить раскладку + image3 + + + + False + True + 2 + + + + + True + True + True + Удалить раскладку + image1 + + + + False + True + 4 + + + False + True + 1 + - - + + + True + True + end + 2 + + + + + True + False + Keyboard layouts: + 0 + + + False + True + end + 4 + + + + + False + 5 + + True False - System + KEYBOARD: + 0 + + + False + True + 0 + + + + + True + True + + True + True + 1 + - True + False True - 0 + 4 - + True False - 0.019999999552965164 - in + 5 - + True False - 5 - 5 - 5 - - - True - False - 5 - - - True - False - Secondary layout: - 1 - - - False - True - 0 - - - - - True - False - - - True - True - 1 - - - - + Keyboard options: + 0 + + False + True + 0 + - - + + True False - TTY layout + + True + True + 1 + + + + + True + True + True + Pick an option + image4 + + + + False + True + 2 + False True - 3 + 7 + + + True + False + Keyboard + + True True - 1 + 3 - - - - - + - - - - - - - - - - - - liststore1 - - - True - False - False - - - True - False - Load global configuration - - - - - - True - False - Load local configuration - - - - - - True - False - False - False - - - True - False - False - - - True - False - Save configuration - - - - - - True - False - Save to global configuration - - - - - - True - False - Save to local configuration - - - - - - True - False - - - True - False - From 4dc891ab853440de21a72f8dc418228595103187 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Sat, 1 Nov 2025 18:09:21 +0600 Subject: [PATCH 4/6] Fixes --- source/ubl-settings-keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ubl-settings-keyboard.c b/source/ubl-settings-keyboard.c index e0698bb..4a59358 100644 --- a/source/ubl-settings-keyboard.c +++ b/source/ubl-settings-keyboard.c @@ -8,7 +8,7 @@ const char *get_localized_layout_name(const char *layout_code) { name[0] = '\0'; setlocale(LC_ALL, ""); - const char *lang = yongetenv("LANG"); + const char *lang = getenv("LANG"); if (!lang) lang = "en"; char lang_short[8]; sscanf(lang, "%2s", lang_short); From 3416043a67601333536baf76705d13983b929aab Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Sat, 1 Nov 2025 18:24:25 +0600 Subject: [PATCH 5/6] Fixes --- source/CMakeLists.txt | 1 - source/ubl-settings-keyboard.c | 67 +++++++--------------------------- source/ubl-settings-keyboard.h | 5 +-- 3 files changed, 15 insertions(+), 58 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 81cad36..5cabe32 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -84,7 +84,6 @@ set(LIBRARIES ${UTILS_LIBRARIES} ${VTE291_LIBRARIES} pthread - xml2 ublsettings ublsettings-gtk3 ublsettingsui-gtk3) diff --git a/source/ubl-settings-keyboard.c b/source/ubl-settings-keyboard.c index 4a59358..f0f1ba3 100644 --- a/source/ubl-settings-keyboard.c +++ b/source/ubl-settings-keyboard.c @@ -3,55 +3,6 @@ config main_config; -const char *get_localized_layout_name(const char *layout_code) { - static char name[128]; - name[0] = '\0'; - - setlocale(LC_ALL, ""); - const char *lang = getenv("LANG"); - if (!lang) lang = "en"; - char lang_short[8]; - sscanf(lang, "%2s", lang_short); - - xmlDoc *doc = xmlReadFile("/usr/share/X11/xkb/rules/base.xml", NULL, 0); - if (!doc) return layout_code; - - xmlNode *root = xmlDocGetRootElement(doc); - for (xmlNode *layout = root->children; layout; layout = layout->next) { - if (layout->type == XML_ELEMENT_NODE && strcmp((char *)layout->name, "layout") == 0) { - xmlNode *config = layout->children; - const char *found_name = NULL; - const char *found_desc = NULL; - - for (xmlNode *n = config; n; n = n->next) { - if (n->type == XML_ELEMENT_NODE && strcmp((char *)n->name, "configItem") == 0) { - for (xmlNode *m = n->children; m; m = m->next) { - if (m->type != XML_ELEMENT_NODE) continue; - if (strcmp((char *)m->name, "name") == 0) - found_name = (char *)xmlNodeGetContent(m); - else if (strcmp((char *)m->name, "description") == 0) { - xmlChar *langAttr = xmlGetProp(m, (const xmlChar *)"xml:lang"); - if (langAttr && strncmp((char *)langAttr, lang_short, 2) == 0) - found_desc = (char *)xmlNodeGetContent(m); - xmlFree(langAttr); - } - } - } - } - - if (found_name && strcmp(found_name, layout_code) == 0) { - if (found_desc) - snprintf(name, sizeof(name), "%s", found_desc); - else - snprintf(name, sizeof(name), "%s", layout_code); - break; - } - } - } - xmlFreeDoc(doc); - xmlCleanupParser(); - return name[0] ? name : layout_code; -} void on_save_done(main_window *, config_str output, int size){ @@ -215,7 +166,7 @@ gboolean yon_interface_update(main_window *widgets){ int size=0; name = yon_config_get_by_key(keyboard_layout_parameter); config_str layouts = yon_char_parse(name,&size,","); - GtkTreeIter iter, itar; + GtkTreeIter iter, itar,itor; char *rid,*rname; gtk_list_store_clear(widgets->layoutsList); for (int i=0;ilayoutsList,&itar); gtk_list_store_set(widgets->layoutsList,&itar,0,rname,1,rid,2,1,-1); } + for(int valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(main_config.layouts_list),&itor,&iter);valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.layouts_list),&itor)){ + gtk_tree_model_get(GTK_TREE_MODEL(main_config.layouts_list),&itor,0,&rid,1,&rname,-1); + + if (!strcmp(layouts[i],rid)){ + gtk_list_store_append(widgets->layoutsList,&itar); + gtk_list_store_set(widgets->layoutsList,&itar,0,rname,1,rid,2,1,-1); + } + } } } } @@ -503,13 +462,15 @@ void yon_main_window_complete(main_window *widgets){ config_str layout = yon_char_parse(rtn[i],&laysize,"|"); if (yon_char_is_empty(layout[1])){ gtk_tree_store_append(main_config.layouts_list,&iter,NULL); - gtk_tree_store_set(main_config.layouts_list,&iter,0,layout[0],1,get_localized_layout_name(layout[2]),-1); + textdomain("iso_639"); + gtk_tree_store_set(main_config.layouts_list,&iter,0,layout[0],1,_(layout[2]),-1); + textdomain(LocaleName); } else { char *full_layout = yon_char_unite(layout[0],"_",layout[1],NULL); gtk_tree_store_append(main_config.layouts_list,&chiter,&iter); - textdomain("iso639"); - gtk_tree_store_set(main_config.layouts_list,&chiter,0,full_layout,1,get_localized_layout_name(layout[2]),-1); + textdomain("iso_639"); + gtk_tree_store_set(main_config.layouts_list,&chiter,0,full_layout,1,_(layout[2]),-1); textdomain(LocaleName); free(full_layout); diff --git a/source/ubl-settings-keyboard.h b/source/ubl-settings-keyboard.h index 007e003..c6501c0 100644 --- a/source/ubl-settings-keyboard.h +++ b/source/ubl-settings-keyboard.h @@ -9,8 +9,6 @@ #include #include #include -#include -#include #ifdef WEBKIT_FOUND #include @@ -164,5 +162,4 @@ void on_num_lock_changed(GtkComboBox *self, main_window *widgets); void on_layouts_remove(GtkWidget *, main_window *widgets); void yon_layouts_save(main_window *widgets); void on_layouts_chosen(GtkCellRenderer *self, gchar *path, layouts_window *window); -GList *yon_get_all_selected(GtkTreeView *tree, int column); -const char *get_localized_layout_name(const char *layout_code); \ No newline at end of file +GList *yon_get_all_selected(GtkTreeView *tree, int column); \ No newline at end of file From 92bd8e47a3456525a040d7a1818394a6bf78d75d Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Sat, 1 Nov 2025 19:10:00 +0600 Subject: [PATCH 6/6] Layout list fixes --- layouts.csv | 132 ++++++++++++++++++++------------- source/ubl-settings-keyboard.c | 77 ++++++------------- source/ubl-settings-keyboard.h | 22 +----- 3 files changed, 104 insertions(+), 127 deletions(-) diff --git a/layouts.csv b/layouts.csv index 4a59bcb..c0b9210 100644 --- a/layouts.csv +++ b/layouts.csv @@ -1,68 +1,98 @@ -af;Afrikaans -ar;Arabic -as;Assamese +al;Albanian +et;Amharic +am;Armenian +ara;Arabic +eg;Arabic (Egypt) +iq;Arabic (Iraq) +ma;Arabic (Morocco) +sy;Arabic (Syria) az;Azerbaijani -be;Belarusian +ml;Bambara +bd;Bangla +by;Belarusian +be;Belgian +dz;Berber (Algeria, Latin) +ba;Bosnian +brai;Braille bg;Bulgarian -bn;Bengali -bs;Bosnian -ca;Catalan -cs;Czech -da;Danish -de;German -el;Greek -en;English -es;Spanish -et;Estonian +mm;Burmese +cn;Chinese +hr;Croatian +cz;Czech +dk;Danish +af;Dari +mv;Dhivehi +nl;Dutch +bt;Dzongkha +au;English (Australia) +cm;English (Cameroon) +gh;English (Ghana) +nz;English (New Zealand) +ng;English (Nigeria) +za;English (South Africa) +gb;English (UK) +us;English (US) +epo;Esperanto +ee;Estonian +fo;Faroese +ph;Filipino fi;Finnish fr;French -gu;Gujarati -he;Hebrew -hi;Hindi -hr;Croatian +ca;French (Canada) +cd;French (Democratic Republic of the Congo) +tg;French (Togo) +ge;Georgian +de;German +at;German (Austria) +ch;German (Switzerland) +gr;Greek +il;Hebrew hu;Hungarian -hy;Armenian -id;Indonesian is;Icelandic +in;Indian +id;Indonesian (Latin) +ie;Irish it;Italian -ja;Japanese -ka;Georgian -kk;Kazakh -kn;Kannada -ko;Korean -ks;Kashmiri -ku;Kurdish -ky;Kirghiz -lt;Lithuanian +jp;Japanese +kz;Kazakh +kh;Khmer (Cambodia) +kr;Korean +kg;Kyrgyz +la;Lao lv;Latvian +lt;Lithuanian mk;Macedonian -ml;Malayalam -mr;Marathi -ms;Malay +my;Malay (Jawi, Arabic Keyboard) mt;Maltese -nb;Bokmal -nl;Dutch -nn;Nynorsk -or;Oriya -pa;Punjabi +md;Moldavian +mn;Mongolian +me;Montenegrin +np;Nepali +gn;N'Ko (AZERTY) +no;Norwegian +ir;Persian pl;Polish pt;Portuguese +br;Portuguese (Brazil) ro;Romanian ru;Russian -sa;Sanskrit +rs;Serbian +lk;Sinhala (phonetic) sk;Slovak -sl;Slovenian -sq;Albanian -sr;Serbian -sv;Swedish -ta;Tamil -te;Telugu +si;Slovenian +es;Spanish +latam;Spanish (Latin American) +ke;Swahili (Kenya) +tz;Swahili (Tanzania) +se;Swedish +tw;Taiwanese +tj;Tajik th;Thai +bw;Tswana +tm;Turkmen tr;Turkish -uk;Ukrainian -us;American -vi;Vietnamese -zh;Simplified Chinese -zh;Traditional Chinese -zh;Chinese -zh;Traditional Chinese \ No newline at end of file +ua;Ukrainian +pk;Urdu (Pakistan) +uz;Uzbek +vn;Vietnamese +sn;Wolof \ No newline at end of file diff --git a/source/ubl-settings-keyboard.c b/source/ubl-settings-keyboard.c index f0f1ba3..873b37b 100644 --- a/source/ubl-settings-keyboard.c +++ b/source/ubl-settings-keyboard.c @@ -2,9 +2,6 @@ config main_config; - - - void on_save_done(main_window *, config_str output, int size){ char *final_output = yon_char_parsed_to_string(output,size,""); if (final_output){ @@ -153,7 +150,7 @@ gboolean yon_interface_update(main_window *widgets){ { if (main_config.layouts_list){ for_iter(main_config.layouts_list,&iter){ - gtk_tree_store_set(main_config.layouts_list,&iter,2,0,-1); + gtk_list_store_set(main_config.layouts_list,&iter,2,0,-1); } } char *name = yon_config_get_by_key(num_lock_boot_parameter); @@ -166,7 +163,7 @@ gboolean yon_interface_update(main_window *widgets){ int size=0; name = yon_config_get_by_key(keyboard_layout_parameter); config_str layouts = yon_char_parse(name,&size,","); - GtkTreeIter iter, itar,itor; + GtkTreeIter iter, itar; char *rid,*rname; gtk_list_store_clear(widgets->layoutsList); for (int i=0;ilayoutsList,&itar); gtk_list_store_set(widgets->layoutsList,&itar,0,rname,1,rid,2,1,-1); } - for(int valid = gtk_tree_model_iter_children(GTK_TREE_MODEL(main_config.layouts_list),&itor,&iter);valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(main_config.layouts_list),&itor)){ - gtk_tree_model_get(GTK_TREE_MODEL(main_config.layouts_list),&itor,0,&rid,1,&rname,-1); - - if (!strcmp(layouts[i],rid)){ - gtk_list_store_append(widgets->layoutsList,&itar); - gtk_list_store_set(widgets->layoutsList,&itar,0,rname,1,rid,2,1,-1); - } - } } } } @@ -296,27 +285,17 @@ void on_layouts_accept(GtkWidget *self, dictionary *dict){ layouts_window *window = yon_dictionary_get_data(dict->first->next,layouts_window*); gtk_list_store_clear(widgets->layoutsList); GtkTreeModel *model = GTK_TREE_MODEL(window->list); + GList *list = yon_get_all_selected(GTK_TREE_VIEW(window->MainTree),2); char *name; char *id; - GtkTreeIter iter, lwiter, chiter; - for_iter(model,&lwiter){ - int status; - gtk_tree_model_get(model,&lwiter,0,&name,1,&id,2,&status,-1); - if (status){ - gtk_list_store_append(widgets->layoutsList,&iter); - gtk_list_store_set(widgets->layoutsList,&iter,1,name,0,id,2,1,-1); - } - if (gtk_tree_model_iter_children(model,&chiter,&lwiter)){ - for (int valid2 = 1; valid2; valid2 = gtk_tree_model_iter_next(model,&chiter)){ - char *chid, *chname; - int chstatus; - gtk_tree_model_get(model,&chiter,0,&chname,1,&chid,2,&chstatus,-1); - if (chstatus){ - gtk_list_store_append(widgets->layoutsList,&iter); - gtk_list_store_set(widgets->layoutsList,&iter,1,chname,0,chid,2,1,-1); - } - } - } + GtkTreeIter iter, lwiter; + GtkTreePath *pth; + for (guint i=0;ilayoutsList,&iter); + gtk_tree_model_get(model,&lwiter,0,&name,1,&id,-1); + gtk_list_store_set(widgets->layoutsList,&iter,1,name,0,id,2,1,-1); } yon_layouts_save(widgets); on_subwindow_close(self); @@ -327,7 +306,7 @@ void on_layouts_chosen(GtkCellRenderer *, gchar *path, layouts_window *window){ gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),&iter,path); int chosen; gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,2,&chosen,-1); - gtk_tree_store_set(GTK_TREE_STORE(window->list),&iter,2,!chosen,-1); + gtk_list_store_set(window->list,&iter,2,!chosen,-1); } void on_layouts_add(GtkWidget *, main_window *widgets){ @@ -338,7 +317,7 @@ void on_layouts_add(GtkWidget *, main_window *widgets){ window->CancelButton = yon_gtk_builder_get_widget(builder,"CancelButton"); window->ChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"ChosenCell")); window->MainTree = yon_gtk_builder_get_widget(builder,"LayoutsTree"); - window->list = (GtkListStore*)main_config.layouts_list; + window->list = main_config.layouts_list; gtk_tree_view_set_model(GTK_TREE_VIEW(window->MainTree), GTK_TREE_MODEL(window->list)); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(window->MainTree)),GTK_SELECTION_MULTIPLE); @@ -361,13 +340,13 @@ void on_layouts_add(GtkWidget *, main_window *widgets){ gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&id,-1); for (int i=0;ilist),&iter,2,1,-1); + gtk_list_store_set(window->list,&iter,2,1,-1); found=1; break; } } if (!found) { - gtk_tree_store_set(GTK_TREE_STORE(window->list),&iter,2,0,-1); + gtk_list_store_set(window->list,&iter,2,0,-1); } } } @@ -446,7 +425,7 @@ void yon_main_window_complete(main_window *widgets){ widgets->modelsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore2")); int size; - GtkTreeIter iter,chiter; + GtkTreeIter iter; config_str models = yon_config_load(get_models_command,&size); for (int i=0;imodelsList,&iter); gtk_list_store_set(widgets->modelsList,&iter,1,models[i],0,_(models[i+1]),-1); } - main_config.layouts_list = gtk_tree_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_BOOLEAN); + main_config.layouts_list = gtk_list_store_new(3,G_TYPE_STRING,G_TYPE_STRING,G_TYPE_BOOLEAN); int laysize; - config_str rtn = yon_config_load(get_layouts_command,&size); + config_str rtn = yon_resource_open_file(layouts_path,&size); for (int i=0; i #include #include - #ifdef WEBKIT_FOUND #include #endif @@ -51,25 +50,6 @@ #define get_models_command "sed '/<\\/modelList>/q' /usr/share/X11/xkb/rules/base.xml | grep -E '^ {8,8}|^ {8,8}'|sed -e 's/ *//g' -e 's,,,g' -e 's/ *//g' -e 's,,,g'" #define layouts_path "resource:///com/ublinux/csv/layouts.csv" -#define get_layouts_command "xkbcli list --load-exotic | awk \"\ -layout && /description:/ {\ - match(\\$0, /: *(.*)/, matches);\ - description = matches[1];\ - printf \\\"%s|%s|%s\\\\n\\\", layout, variant, description;\ - layout = \\\"\\\"; variant = \\\"\\\";\ -}\ -/layout:/ {\ - match(\\$0, /: *'([^']+)'/, matches);\ - l = matches[1];\ - layout = layouts[l] = l;\ -}\ -/variant:/ {\ - match(\\$0, /: *'([^']+)'/, matches);\ - variant = matches[1];\ -}\ -\" | sort -u\ -" - typedef char* string; __attribute__((unused)) static \ @@ -81,7 +61,7 @@ typedef struct { config_str launch_arguments; int launch_size; char *options; - GtkTreeStore *layouts_list; + GtkListStore *layouts_list; GtkListStore *options_list; } config;