diff --git a/source/ubl-settings-keyboard-layouts.c b/source/ubl-settings-keyboard-layouts.c index 0fa9e99..a81eec0 100644 --- a/source/ubl-settings-keyboard-layouts.c +++ b/source/ubl-settings-keyboard-layouts.c @@ -2,35 +2,8 @@ void on_layouts_accept(GtkWidget *self, layouts_window *window){ main_window *widgets = g_object_get_data(G_OBJECT(window->Window),"widgets"); - gtk_list_store_clear(widgets->LayoutsList); - GtkTreeModel *model = GTK_TREE_MODEL(window->list); - GtkTreeIter window_iter; - char *save_string = NULL; - for_iter(window->list,&window_iter){ - char *id, *variant, *name; - int status; - gtk_tree_model_get(model,&window_iter,0,&id,2,&name,3,&status,-1); - if (status){ - char *temp = yon_char_append_element(save_string,id,","); - if (!yon_char_is_empty(save_string)) free(save_string); - save_string = temp; - } - 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,&variant,2,&name,3,&status,-1); - if (status){ - char *full_id = yon_char_unite(id,"_",variant,NULL); - char *temp = yon_char_append_element(save_string,full_id,","); - if (!yon_char_is_empty(save_string)) free(save_string); - save_string = temp; - free(full_id); - } - } - } - } - if (!yon_char_is_empty(save_string)){ - yon_config_register(keyboard_layout_parameter,keyboard_layout_parameter_command,save_string); + if (!yon_char_is_empty(window->parameters)){ + yon_config_register(keyboard_layout_parameter,keyboard_layout_parameter_command,window->parameters); } else { yon_config_remove_by_key(keyboard_layout_parameter); } @@ -42,8 +15,27 @@ void on_layouts_chosen(GtkCellRenderer *, gchar *path, layouts_window *window){ GtkTreeIter iter; 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,3,&chosen,-1); + char *layout, *variant; + gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&layout,1,&variant,3,&chosen,-1); gtk_tree_store_set(GTK_TREE_STORE(window->list),&iter,3,!chosen,-1); + + + char *full_layout = NULL; + if (!yon_char_is_empty(variant)){ + yon_char_unite(layout,"_",variant,NULL); + } else { + full_layout = layout; + } + if (!chosen){ + char *temp = yon_char_append_element(window->parameters,full_layout,","); + free(window->parameters); + window->parameters = temp; + } else { + char *temp = yon_char_remove_element(window->parameters,full_layout,","); + free(window->parameters); + window->parameters = temp; + } + free(full_layout); } void on_system_layouts_add(GtkWidget *, main_window *widgets){ @@ -59,6 +51,7 @@ layouts_window *yon_layouts_window_new(){ 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->parameters = yon_char_new(config(keyboard_layout_parameter)); g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); g_signal_connect(G_OBJECT(window->ChosenCell),"toggled",G_CALLBACK(on_layouts_chosen),window); @@ -183,7 +176,7 @@ void yon_layout_build(layouts_window *window){ yon_char_parsed_free(variants,variants_size); } - yon_char_parsed_free(layouts,size); + yon_char_parsed_free(layouts,size); } diff --git a/source/ubl-settings-keyboard-options.c b/source/ubl-settings-keyboard-options.c index 08e4261..3825691 100644 --- a/source/ubl-settings-keyboard-options.c +++ b/source/ubl-settings-keyboard-options.c @@ -76,7 +76,7 @@ void yon_options_setup(layouts_window *window){ int parsed_size; config_str parsed = yon_char_parse(options[i],&parsed_size,"|"); gtk_list_store_append(window->OptionsList,&iter); - gtk_list_store_set(window->OptionsList,&iter,0,parsed[0],1,parsed[1],2,yon_char_check_element(config_options,parsed[0],","),-1); + gtk_list_store_set(window->OptionsList,&iter,0,parsed[0],1,_(parsed[1]),2,yon_char_check_element(config_options,parsed[0],","),-1); char *str = yon_char_new(parsed[0]); char *type = yon_char_divide_search(str,":",-1); if (yon_char_parsed_check_exist(filter,filter_size,type)==-1){ @@ -98,31 +98,14 @@ void on_options_filter_changed(GtkWidget *, layouts_window *window){ void on_options_accept(GtkWidget *self, layouts_window *window){ main_window *widgets = g_object_get_data(G_OBJECT(window->Window),"widgets"); - // char *main_option = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->LayoutChangingCombo)); char *options = (char*)gtk_entry_get_text(GTK_ENTRY(window->OptionsEntry)); if (!yon_char_is_empty(options)){ - // char *full_options = yon_char_unite(!yon_char_is_empty(main_option)?main_option:"",",",options,NULL); yon_config_register(options_parameter,options_parameter_command,options); - // free(full_options); - // } else if (!yon_char_is_empty(main_option)){ - // yon_config_register(options_parameter,options_parameter_command,main_option); } else { yon_config_remove_by_key(options_parameter); } - // GtkTreeModel *model = GTK_TREE_MODEL(window->OptionsList); - // GtkTreeIter iter, itar; - // char *name, *id; - // int status; - // for_iter(model,&iter){ - // gtk_tree_model_get(model,&iter,0,&id,1,&name,2,&status,-1); - // if (status){ - // gtk_list_store_append(widgets->OptionsList,&itar); - // gtk_list_store_set(widgets->OptionsList,&itar,0,id,1,_(name),-1); - // } - // } on_subwindow_close(self); yon_interface_update(widgets); - // on_options_save(NULL, widgets); } void on_options_save(GtkWidget *,main_window *widgets){ @@ -173,7 +156,6 @@ layouts_window *yon_options_window_new(){ void on_options_open(GtkWidget *, main_window *widgets){ layouts_window *window = yon_options_window_new(); - // window->list = main_config.options_list; g_object_set_data(G_OBJECT(window->Window),"widgets",widgets); g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_options_accept),window); } diff --git a/source/ubl-settings-keyboard.c b/source/ubl-settings-keyboard.c index 36a8454..2695140 100644 --- a/source/ubl-settings-keyboard.c +++ b/source/ubl-settings-keyboard.c @@ -12,7 +12,6 @@ gboolean yon_interface_update(main_window *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); { char *kbmodel = yon_config_get_by_key(model_parameter); if (kbmodel) { @@ -52,6 +51,18 @@ gboolean yon_interface_update(main_window *widgets){ } else { gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->TTYLayoutCombo),0); } + char *tty_keymap_change = config(console_keymap_toggle_parameter); + if (!yon_char_is_empty(tty_keymap_change)){ + gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->TTYKeymapCombo),tty_keymap_change); + } else { + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->TTYKeymapCombo),0); + } + char *tty_font = config(console_font_parameter); + if (!yon_char_is_empty(tty_font)){ + gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->TTYFontCombo),tty_font); + } else { + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->TTYFontCombo),0); + } } { gtk_list_store_clear(widgets->OptionsList); @@ -215,6 +226,24 @@ void on_tty_changed(GtkWidget *, main_window *widgets){ } } +void on_tty_keymap_changed(GtkWidget *, main_window *widgets){ + char *tty_layout = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->TTYKeymapCombo)); + if (!yon_char_is_empty(tty_layout)){ + yon_config_register(console_keymap_toggle_parameter,console_keymap_toggle_parameter_command,tty_layout); + } else { + yon_config_remove_by_key(console_keymap_toggle_parameter); + } +} + +void on_tty_font_changed(GtkWidget *, main_window *widgets){ + char *tty_layout = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->TTYFontCombo)); + if (!yon_char_is_empty(tty_layout)){ + yon_config_register(console_font_parameter,console_font_parameter_command,tty_layout); + } else { + yon_config_remove_by_key(console_font_parameter); + } +} + void yon_main_window_complete(main_window *widgets){ widgets = yon_remalloc(widgets,sizeof(main_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); @@ -237,6 +266,8 @@ void yon_main_window_complete(main_window *widgets){ widgets->ScrollLockSwitch = yon_gtk_builder_get_widget(builder,"ScrollLockSwitch"); widgets->NumLockCombo = yon_gtk_builder_get_widget(builder,"NumLockCombo"); widgets->TTYLayoutCombo = yon_gtk_builder_get_widget(builder,"TTYLayoutCombo"); + widgets->TTYKeymapCombo = yon_gtk_builder_get_widget(builder,"TTYKeymapCombo"); + widgets->TTYFontCombo = yon_gtk_builder_get_widget(builder,"TTYFontCombo"); widgets->LayoutsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"LayoutsList")); widgets->OptionsList = GTK_LIST_STORE(gtk_builder_get_object(builder,"OptionsList")); @@ -248,6 +279,8 @@ void yon_main_window_complete(main_window *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->TTYLayoutCombo),"changed",G_CALLBACK(on_tty_changed),widgets); + g_signal_connect(G_OBJECT(widgets->TTYKeymapCombo),"changed",G_CALLBACK(on_tty_keymap_changed),widgets); + g_signal_connect(G_OBJECT(widgets->TTYFontCombo),"changed",G_CALLBACK(on_tty_font_changed),widgets); g_signal_connect(G_OBJECT(widgets->KeyboardModelCombo),"changed",G_CALLBACK(on_model_changed),widgets); g_signal_connect(G_OBJECT(widgets->OptionsEditButton),"clicked",G_CALLBACK(on_options_open),widgets); g_signal_connect(G_OBJECT(widgets->OptionsRemoveButton),"clicked",G_CALLBACK(on_option_remove),widgets); @@ -302,6 +335,13 @@ void yon_main_window_complete(main_window *widgets){ } yon_char_parsed_free(models,size); + { + config_str parsed = yon_config_load(tty_keymaps_command,&size); + for (int i=0;iTTYKeymapCombo),parsed[i],parsed[i]); + } + } 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))); diff --git a/source/ubl-settings-keyboard.h b/source/ubl-settings-keyboard.h index fbe1dd3..066d0b9 100644 --- a/source/ubl-settings-keyboard.h +++ b/source/ubl-settings-keyboard.h @@ -38,6 +38,10 @@ #define num_lock_boot_parameter_command "ubconfig --source global get keyboard NUMLOCK" #define console_keymap_parameter "CONSOLE_KEYMAP" #define console_keymap_parameter_command "ubconfig --source global get keyboard CONSOLE_KEYMAP" +#define console_keymap_toggle_parameter "CONSOLE_KEYMAP_TOGGLE" +#define console_keymap_toggle_parameter_command "ubconfig --source global get keyboard CONSOLE_KEYMAP_TOGGLE" +#define console_font_parameter "CONSOLE_FONT" +#define console_font_parameter_command "ubconfig --source global get keyboard CONSOLE_FONT" #define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get keyboard XKBMODEL XKBLAYOUT XKBOPTIONS NUMLOCK",NULL) #define config_get_local_command "ubconfig --source system get keyboard XKBMODEL XKBLAYOUT XKBOPTIONS NUMLOCK" @@ -115,6 +119,8 @@ // terminate : Key sequence to kill the X server #define terminate_options_command "sed -En '/^! option$/,/^ *$/!d;s/[[:blank:]]+(terminate:[^ ]+)[[:blank:]]+(.*)/\\1|\\2/p' /usr/share/X11/xkb/rules/evdev.lst" +#define tty_keymaps_command "find /usr/share/kbd/keymaps/ -type f -name \"*.map.*\" | sed -E \"s:.*/(.*)\\..*\\..*:\\1:g\" | sort -u" + typedef char* string; __attribute__((unused)) static \ @@ -155,6 +161,8 @@ typedef struct { GtkWidget *ScrollLockSwitch; GtkWidget *NumLockCombo; GtkWidget *TTYLayoutCombo; + GtkWidget *TTYKeymapCombo; + GtkWidget *TTYFontCombo; GtkListStore *LayoutsList; GtkListStore *OptionsList; } main_window; @@ -183,6 +191,7 @@ typedef struct { GtkTreeStore *list; GtkListStore *OptionsList; GtkTreeModel *OptionsFilter; + char *parameters; } layouts_window; typedef struct { @@ -241,4 +250,6 @@ void on_layout_move_down(GtkWidget *, main_window *widgets); void on_layout_move_up(GtkWidget *, main_window *widgets); void on_layout_dnd_inserted(GtkTreeModel *, GtkTreePath* path, GtkTreeIter* iter, main_window *widgets); void on_layout_dnd_deleted(GtkTreeModel *, GtkTreePath* path, GtkTreeIter* iter, main_window *widgets); -void on_tty_changed(GtkWidget *, main_window *widgets); \ No newline at end of file +void on_tty_changed(GtkWidget *, main_window *widgets); +void on_tty_keymap_changed(GtkWidget *, main_window *widgets); +void on_tty_font_changed(GtkWidget *, main_window *widgets); \ No newline at end of file diff --git a/ubl-settings-keyboard-layouts.glade b/ubl-settings-keyboard-layouts.glade index 71f15cf..7a0cb5a 100644 --- a/ubl-settings-keyboard-layouts.glade +++ b/ubl-settings-keyboard-layouts.glade @@ -5,114 +5,54 @@ True False - emblem-ok-symbolic + com.ublinux.libublsettingsui-gtk3.accept-symbolic True False - process-stop-symbolic + com.ublinux.libublsettingsui-gtk3.cancel-uncolored-symbolic - + 450 550 True False - dialog - - - False - 3 - 3 - 3 - 3 - vertical - 5 - - - False - end - - - Cancel - True - True - True - image2 - - - True - True - 0 - - - - - Accept - True - True - True - image1 - - - True - True - 1 - - - - - False - False - 0 - - + com.ublinux.ubl-settings-keyboard + + + True + True + in - + True True - in + False + 1 - - True - True - False - 1 - - - none - - + + column - - column - - - - 3 - - - + + + 3 + + + + + + column + 0 - - column - 0 - - - - 2 - - - + + + 2 + - - True - True - 1 - @@ -120,7 +60,6 @@ True False - True True @@ -150,6 +89,31 @@ com.ublinux.ubl-settings-keyboard + + + Cancel + True + True + True + image2 + + + 1 + + + + + Accept + True + True + True + image1 + + + end + 2 + + diff --git a/ubl-settings-keyboard.glade b/ubl-settings-keyboard.glade index 0b0b231..8f52c9c 100644 --- a/ubl-settings-keyboard.glade +++ b/ubl-settings-keyboard.glade @@ -43,6 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + True False @@ -162,20 +163,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False 5 - - - True - False - start - Layouts: - 1 - - - False - True - 0 - - True @@ -187,6 +174,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False 10 + + + True + False + Layouts: + 1 + + + False + True + 0 + + True @@ -196,7 +196,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 0 + 1 @@ -208,7 +208,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True - 1 + 2 @@ -295,6 +295,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. False True True + Move layout up image4 + + + False + True + 0 + + - - - 1 - + + True + True + True + image3 + + + + False + True + 1 + + + False + True + 1 + - - - - True - True - 1 - - - - - True - False - vertical - 5 - - - True - True - True - image1 - - - False - True - 0 - - - - - True - True - True - image3 - - - - False + True True 1 - False + True True - 2 + 0 @@ -736,13 +749,46 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False + vertical 5 - + True False - Secondary layout: - 1 + 5 + + + True + False + Secondary layout: + 1 + + + False + True + 0 + + + + + True + False + LayoutsList + 0 + 0 + + + + 2 + + + + + True + True + 1 + + False @@ -751,25 +797,85 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - + True False - LayoutsList - 0 - 0 + 5 + + + True + False + Keymap and layout change: + 1 + + + False + True + 0 + + - - - 2 - + + True + False + 0 + + Default + + + + True + True + 1 + - True + False True 1 + + + True + False + 5 + + + True + False + Font: + 1 + + + False + True + 0 + + + + + True + False + 0 + + Default + + + + True + True + 1 + + + + + False + True + 2 + + @@ -778,7 +884,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False - TTY layout + Setting up TTY VT @@ -800,17 +906,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - - - - - - - - - -