keyboard: Use AdwActionRow for input switch rows

This commit is contained in:
Christopher Davis 2022-02-12 15:00:05 -08:00 committed by Georges Basile Stavracas Neto
parent 84becfbd80
commit 485dd456bb
2 changed files with 19 additions and 62 deletions

View file

@ -38,8 +38,6 @@ struct _CcKeyboardPanel
{ {
CcPanel parent_instance; CcPanel parent_instance;
GtkListBox *input_source_list;
GtkCheckButton *per_window_source; GtkCheckButton *per_window_source;
GtkCheckButton *same_source; GtkCheckButton *same_source;
GSettings *keybindings_settings; GSettings *keybindings_settings;
@ -51,7 +49,7 @@ struct _CcKeyboardPanel
GtkWidget *value_alternate_chars; GtkWidget *value_alternate_chars;
GtkWidget *value_compose; GtkWidget *value_compose;
GtkListBoxRow *common_shortcuts_row; AdwActionRow *common_shortcuts_row;
}; };
CC_PANEL_REGISTER (CcKeyboardPanel, cc_keyboard_panel) CC_PANEL_REGISTER (CcKeyboardPanel, cc_keyboard_panel)
@ -98,14 +96,6 @@ static const CcXkbModifier COMPOSE_MODIFIER = {
NULL, NULL,
}; };
static const gchar *custom_css =
".keyboard-panel-radio-button {"
" padding-left: 6px;"
" padding-right: 12px;"
" padding-top: 12px;"
" padding-bottom: 12px;"
"}";
static void static void
special_chars_activated (AdwActionRow *row, special_chars_activated (AdwActionRow *row,
CcKeyboardPanel *self) CcKeyboardPanel *self)
@ -196,7 +186,6 @@ 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_switch_group); gtk_widget_class_bind_template_child (widget_class, CcKeyboardPanel, input_switch_group);
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);
@ -238,20 +227,10 @@ translate_switch_input_source (GValue *value,
static void static void
cc_keyboard_panel_init (CcKeyboardPanel *self) cc_keyboard_panel_init (CcKeyboardPanel *self)
{ {
GtkCssProvider *provider;
g_resources_register (cc_keyboard_get_resource ()); g_resources_register (cc_keyboard_get_resource ());
gtk_widget_init_template (GTK_WIDGET (self)); gtk_widget_init_template (GTK_WIDGET (self));
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, custom_css, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1);
g_object_unref (provider);
self->input_source_settings = g_settings_new ("org.gnome.desktop.input-sources"); self->input_source_settings = g_settings_new ("org.gnome.desktop.input-sources");
/* "Input Source Switching" section */ /* "Input Source Switching" section */

View file

@ -27,48 +27,26 @@
<object class="AdwPreferencesGroup" id="input_switch_group"> <object class="AdwPreferencesGroup" id="input_switch_group">
<property name="title" translatable="yes">Input Source Switching</property> <property name="title" translatable="yes">Input Source Switching</property>
<child> <child>
<object class="GtkListBox" id="input_source_list"> <object class="AdwActionRow">
<property name="margin-bottom">20</property> <property name="title" translatable="yes">Use the _same source for all windows</property>
<style> <property name="use-underline">True</property>
<class name="boxed-list"/> <property name="activatable-widget">same_source</property>
</style> <child type="prefix">
<child> <object class="GtkCheckButton" id="same_source">
<object class="GtkListBoxRow"> <property name="valign">center</property>
<child>
<object class="GtkCheckButton" id="same_source">
<property name="active">True</property>
<style>
<class name="keyboard-panel-radio-button" />
</style>
<child>
<object class="GtkLabel">
<property name="margin_start">6</property>
<property name="use_underline">True</property>
<property name="label" translatable="yes">Use the _same source for all windows</property>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
<child> </object>
<object class="GtkListBoxRow"> </child>
<child> <child>
<object class="GtkCheckButton" id="per_window_source"> <object class="AdwActionRow">
<property name="active">True</property> <property name="title" translatable="yes">Switch input sources _individually for each window</property>
<property name="group">same_source</property> <property name="use-underline">True</property>
<style> <property name="activatable-widget">per_window_source</property>
<class name="keyboard-panel-radio-button" /> <child type="prefix">
</style> <object class="GtkCheckButton" id="per_window_source">
<child> <property name="valign">center</property>
<object class="GtkLabel"> <property name="group">same_source</property>
<property name="margin_start">6</property>
<property name="use_underline">True</property>
<property name="label" translatable="yes">Switch input sources _individually for each window</property>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>