keyboard: Update panel layout with descriptions for sections

Changes based on mockup by @aday:
https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1222#note_1017128
This commit is contained in:
Ian Douglas Scott 2021-01-26 12:05:27 -08:00 committed by Robert Ancell
parent 2e2b794b45
commit 3a50deb431
2 changed files with 94 additions and 45 deletions

View file

@ -43,13 +43,13 @@ struct _CcKeyboardPanel
GtkRadioButton *per_window_source; GtkRadioButton *per_window_source;
GtkRadioButton *same_source; GtkRadioButton *same_source;
GtkLabel *value_input_switch;
GSettings *keybindings_settings; GSettings *keybindings_settings;
/* "Type Special Characters" section */ /* "Type Special Characters" section */
CcXkbModifierDialog *alt_chars_dialog; CcXkbModifierDialog *alt_chars_dialog;
CcXkbModifierDialog *compose_dialog; CcXkbModifierDialog *compose_dialog;
GSettings *input_source_settings; GSettings *input_source_settings;
GtkLabel *input_switch_description;
GtkListBox *special_chars_list; GtkListBox *special_chars_list;
GtkListBoxRow *alt_chars_row; GtkListBoxRow *alt_chars_row;
GtkListBoxRow *compose_row; GtkListBoxRow *compose_row;
@ -201,6 +201,7 @@ cc_keyboard_panel_class_init (CcKeyboardPanelClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/keyboard/cc-keyboard-panel.ui"); gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/keyboard/cc-keyboard-panel.ui");
gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, input_source_list); gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, input_source_list);
gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, input_switch_description);
gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, per_window_source); gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, per_window_source);
gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, same_source); gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, same_source);
gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, special_chars_list); gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, special_chars_list);
@ -208,7 +209,6 @@ cc_keyboard_panel_class_init (CcKeyboardPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, compose_row); gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, compose_row);
gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, value_alternate_chars); gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, value_alternate_chars);
gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, value_compose); gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, value_compose);
gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, value_input_switch);
gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, common_shortcuts_row); gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, common_shortcuts_row);
gtk_widget_class_bind_template_callback (widget_class, special_chars_activated); gtk_widget_class_bind_template_callback (widget_class, special_chars_activated);
@ -221,13 +221,19 @@ translate_switch_input_source (GValue *value,
gpointer user_data) gpointer user_data)
{ {
g_autofree const gchar **strv = NULL; g_autofree const gchar **strv = NULL;
g_autofree gchar *accel_text = NULL;
g_autofree gchar *label = NULL; g_autofree gchar *label = NULL;
CcKeyCombo combo = { 0 }; CcKeyCombo combo = { 0 };
strv = g_variant_get_strv (variant, NULL); strv = g_variant_get_strv (variant, NULL);
gtk_accelerator_parse (strv[0] ? strv[0] : "", &combo.keyval, &combo.mask); gtk_accelerator_parse (strv[0] ? strv[0] : "", &combo.keyval, &combo.mask);
label = convert_keysym_state_to_string (&combo); accel_text = convert_keysym_state_to_string (&combo);
label = g_strdup_printf (_("Input sources can be switched using the %s "
"keyboard shortcut.\nThis can be changed in "
"the keyboard shortcut settings."),
accel_text);
g_value_set_string (value, label); g_value_set_string (value, label);
@ -265,10 +271,10 @@ cc_keyboard_panel_init (CcKeyboardPanel *self)
G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN); G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_INVERT_BOOLEAN);
self->keybindings_settings = g_settings_new ("org.gnome.desktop.wm.keybindings"); self->keybindings_settings = g_settings_new ("org.gnome.desktop.wm.keybindings");
g_settings_bind_with_mapping (self->keybindings_settings, "switch-input-source", g_settings_bind_with_mapping (self->keybindings_settings, "switch-input-source",
self->value_input_switch, "label", self->input_switch_description, "label",
G_SETTINGS_BIND_GET, G_SETTINGS_BIND_GET,
translate_switch_input_source, translate_switch_input_source,
NULL, NULL, NULL); NULL, NULL, NULL);
/* "Type Special Characters" section */ /* "Type Special Characters" section */
g_settings_bind_with_mapping (self->input_source_settings, g_settings_bind_with_mapping (self->input_source_settings,

View file

@ -36,14 +36,34 @@
<property name="spacing">12</property> <property name="spacing">12</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<child> <child>
<object class="GtkLabel"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="orientation">vertical</property>
<property name="xalign">0</property> <property name="spacing">6</property>
<property name="label" translatable="yes">Input Sources</property> <child>
<attributes> <object class="GtkLabel">
<attribute name="weight" value="bold"/> <property name="visible">True</property>
</attributes> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Input Sources</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Includes keyboard layouts and input methods.</property>
<property name="wrap">True</property>
<property name="max-width-chars">50</property>
<style>
<class name="dim-label" />
</style>
</object>
</child>
</object> </object>
</child> </child>
<child> <child>
@ -59,14 +79,33 @@
</object> </object>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="orientation">vertical</property>
<property name="xalign">0</property> <property name="spacing">6</property>
<property name="label" translatable="yes">Input Source Switching</property> <child>
<attributes> <object class="GtkLabel">
<attribute name="weight" value="bold"/> <property name="visible">True</property>
</attributes> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Input Source Switching</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel" id="input_switch_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
<property name="max-width-chars">50</property>
<style>
<class name="dim-label" />
</style>
</object>
</child>
</object> </object>
</child> </child>
<child> <child>
@ -130,34 +169,39 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="HdyActionRow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selectable">False</property>
<property name="title" translatable="yes">Keyboard Shortcut</property>
<property name="subtitle" translatable="yes">This can be changed in Customize Shortcuts</property>
<child>
<object class="GtkLabel" id="value_input_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="orientation">vertical</property>
<property name="xalign">0</property> <property name="spacing">6</property>
<property name="label" translatable="yes">Type Special Characters</property> <child>
<attributes> <object class="GtkLabel">
<attribute name="weight" value="bold"/> <property name="visible">True</property>
</attributes> <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Special Character Entry</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Methods for entering symbols and letter variants using the keyboard.</property>
<property name="wrap">True</property>
<property name="max-width-chars">50</property>
<style>
<class name="dim-label" />
</style>
</object>
</child>
</object> </object>
</child> </child>
<child> <child>
@ -177,7 +221,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="title" translatable="yes">Alternate Characters Key</property> <property name="title" translatable="yes">Alternate Characters Key</property>
<property name="subtitle" translatable="yes">Hold down and type to enter different characters</property>
<property name="activatable">True</property> <property name="activatable">True</property>
<child> <child>
<object class="GtkLabel" id="value_alternate_chars"> <object class="GtkLabel" id="value_alternate_chars">
@ -250,7 +293,7 @@
<object class="HdyActionRow" id="common_shortcuts_row"> <object class="HdyActionRow" id="common_shortcuts_row">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="title" translatable="yes">Customize Shortcuts</property> <property name="title" translatable="yes">View and Customize Shortcuts</property>
<property name="activatable">True</property> <property name="activatable">True</property>
<child> <child>
<object class="GtkImage"> <object class="GtkImage">