region: Move show layout button inside each row

This matches the new designs in
https://gitlab.gnome.org/Teams/Design/settings-mockups/blob/master/region-and-language/region-and-language.png
This commit is contained in:
Robert Ancell 2018-11-19 11:08:07 +13:00 committed by Georges Basile Stavracas Neto
parent d4683a9ddd
commit 7a9d2b83df
7 changed files with 128 additions and 53 deletions

View file

@ -34,12 +34,21 @@ G_DEFINE_TYPE (CcInputRow, cc_input_row, GTK_TYPE_LIST_BOX_ROW)
enum enum
{ {
SIGNAL_SHOW_LAYOUT,
SIGNAL_REMOVE_ROW, SIGNAL_REMOVE_ROW,
SIGNAL_LAST SIGNAL_LAST
}; };
static guint signals[SIGNAL_LAST] = { 0, }; static guint signals[SIGNAL_LAST] = { 0, };
static void
layout_button_clicked_cb (CcInputRow *self)
{
g_signal_emit (self,
signals[SIGNAL_SHOW_LAYOUT],
0);
}
static void static void
remove_button_clicked_cb (CcInputRow *self) remove_button_clicked_cb (CcInputRow *self)
{ {
@ -72,8 +81,19 @@ cc_input_row_class_init (CcInputRowClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcInputRow, name_label); gtk_widget_class_bind_template_child (widget_class, CcInputRow, name_label);
gtk_widget_class_bind_template_child (widget_class, CcInputRow, icon_image); gtk_widget_class_bind_template_child (widget_class, CcInputRow, icon_image);
gtk_widget_class_bind_template_callback (widget_class, layout_button_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, remove_button_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, remove_button_clicked_cb);
signals[SIGNAL_SHOW_LAYOUT] =
g_signal_new ("show-layout",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
NULL,
G_TYPE_NONE,
0);
signals[SIGNAL_REMOVE_ROW] = signals[SIGNAL_REMOVE_ROW] =
g_signal_new ("remove-row", g_signal_new ("remove-row",
G_TYPE_FROM_CLASS (object_class), G_TYPE_FROM_CLASS (object_class),

View file

@ -4,7 +4,6 @@
<template class="CcInputRow" parent="GtkListBoxRow"> <template class="CcInputRow" parent="GtkListBoxRow">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="activatable">True</property>
<child> <child>
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
@ -28,6 +27,21 @@
</child> </child>
<child> <child>
<object class="GtkButton" id="remove_button"> <object class="GtkButton" id="remove_button">
<property name="visible">True</property>
<signal name="clicked" handler="layout_button_clicked_cb" object="CcInputRow" swapped="yes"/>
<style>
<class name="image-button"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon_name">view-layout-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="visible">True</property> <property name="visible">True</property>
<signal name="clicked" handler="remove_button_clicked_cb" object="CcInputRow" swapped="yes"/> <signal name="clicked" handler="remove_button_clicked_cb" object="CcInputRow" swapped="yes"/>
<style> <style>

View file

@ -84,7 +84,6 @@ struct _CcRegionPanel {
GtkRevealer *restart_revealer; GtkRevealer *restart_revealer;
GtkRadioButton *same_source; GtkRadioButton *same_source;
GtkButton *show_config_button; GtkButton *show_config_button;
GtkButton *show_layout_button;
gboolean login; gboolean login;
gboolean login_auto_apply; gboolean login_auto_apply;
@ -716,6 +715,29 @@ maybe_start_ibus (void)
#endif #endif
static void
row_layout_cb (CcRegionPanel *self,
CcInputRow *row)
{
CcInputSource *source;
const gchar *layout, *layout_variant;
g_autofree gchar *commandline = NULL;
source = cc_input_row_get_source (row);
layout = cc_input_source_get_layout (source);
layout_variant = cc_input_source_get_layout_variant (source);
if (layout_variant && layout_variant[0])
commandline = g_strdup_printf ("gkbd-keyboard-display -l \"%s\t%s\"",
layout, layout_variant);
else
commandline = g_strdup_printf ("gkbd-keyboard-display -l %s",
layout);
g_spawn_command_line_async (commandline, NULL);
}
static void remove_input (CcRegionPanel *self, CcInputRow *row); static void remove_input (CcRegionPanel *self, CcInputRow *row);
static void static void
@ -756,6 +778,7 @@ add_input_row (CcRegionPanel *self, CcInputSource *source)
row = cc_input_row_new (source); row = cc_input_row_new (source);
gtk_widget_show (GTK_WIDGET (row)); gtk_widget_show (GTK_WIDGET (row));
g_signal_connect_object (row, "show-layout", G_CALLBACK (row_layout_cb), self, G_CONNECT_SWAPPED);
g_signal_connect_object (row, "remove-row", G_CALLBACK (row_removed_cb), self, G_CONNECT_SWAPPED); g_signal_connect_object (row, "remove-row", G_CALLBACK (row_removed_cb), self, G_CONNECT_SWAPPED);
gtk_container_add (GTK_CONTAINER (self->input_list), GTK_WIDGET (row)); gtk_container_add (GTK_CONTAINER (self->input_list), GTK_WIDGET (row));
update_input_rows (self); update_input_rows (self);
@ -875,7 +898,6 @@ update_buttons (CcRegionPanel *self)
selected = CC_INPUT_ROW (gtk_list_box_get_selected_row (self->input_list)); selected = CC_INPUT_ROW (gtk_list_box_get_selected_row (self->input_list));
if (selected == NULL) { if (selected == NULL) {
gtk_widget_set_visible (GTK_WIDGET (self->show_config_button), FALSE); gtk_widget_set_visible (GTK_WIDGET (self->show_config_button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (self->show_layout_button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (self->move_up_input_button), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (self->move_up_input_button), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (self->move_down_input_button), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (self->move_down_input_button), FALSE);
} else { } else {
@ -884,7 +906,6 @@ update_buttons (CcRegionPanel *self)
index = gtk_list_box_row_get_index (GTK_LIST_BOX_ROW (selected)); index = gtk_list_box_row_get_index (GTK_LIST_BOX_ROW (selected));
gtk_widget_set_visible (GTK_WIDGET (self->show_config_button), CC_IS_INPUT_SOURCE_IBUS (cc_input_row_get_source (selected))); gtk_widget_set_visible (GTK_WIDGET (self->show_config_button), CC_IS_INPUT_SOURCE_IBUS (cc_input_row_get_source (selected)));
gtk_widget_set_sensitive (GTK_WIDGET (self->show_layout_button), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (self->move_up_input_button), index > 1); gtk_widget_set_sensitive (GTK_WIDGET (self->move_up_input_button), index > 1);
gtk_widget_set_sensitive (GTK_WIDGET (self->move_down_input_button), index < n_rows - 1); gtk_widget_set_sensitive (GTK_WIDGET (self->move_down_input_button), index < n_rows - 1);
} }
@ -1155,32 +1176,6 @@ show_selected_settings (CcRegionPanel *self)
g_warning ("Failed to launch input source setup: %s", error->message); g_warning ("Failed to launch input source setup: %s", error->message);
} }
static void
show_selected_layout (CcRegionPanel *self)
{
CcInputRow *selected;
CcInputSource *source;
const gchar *layout, *layout_variant;
g_autofree gchar *commandline = NULL;
selected = CC_INPUT_ROW (gtk_list_box_get_selected_row (self->input_list));
if (selected == NULL)
return;
source = cc_input_row_get_source (selected);
layout = cc_input_source_get_layout (source);
layout_variant = cc_input_source_get_layout_variant (source);
if (layout_variant && layout_variant[0])
commandline = g_strdup_printf ("gkbd-keyboard-display -l \"%s\t%s\"",
layout, layout_variant);
else
commandline = g_strdup_printf ("gkbd-keyboard-display -l %s",
layout);
g_spawn_command_line_async (commandline, NULL);
}
static void static void
update_shortcut_label (GtkLabel *label, update_shortcut_label (GtkLabel *label,
const gchar *value) const gchar *value)
@ -1635,14 +1630,12 @@ cc_region_panel_class_init (CcRegionPanelClass * klass)
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, restart_revealer); gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, restart_revealer);
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, same_source); gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, same_source);
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, show_config_button); gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, show_config_button);
gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, show_layout_button);
gtk_widget_class_bind_template_callback (widget_class, restart_now); gtk_widget_class_bind_template_callback (widget_class, restart_now);
gtk_widget_class_bind_template_callback (widget_class, add_input); gtk_widget_class_bind_template_callback (widget_class, add_input);
gtk_widget_class_bind_template_callback (widget_class, move_selected_input_up); gtk_widget_class_bind_template_callback (widget_class, move_selected_input_up);
gtk_widget_class_bind_template_callback (widget_class, move_selected_input_down); gtk_widget_class_bind_template_callback (widget_class, move_selected_input_down);
gtk_widget_class_bind_template_callback (widget_class, show_selected_settings); gtk_widget_class_bind_template_callback (widget_class, show_selected_settings);
gtk_widget_class_bind_template_callback (widget_class, show_selected_layout);
} }
static void static void

View file

@ -422,27 +422,6 @@
</child> </child>
</object> </object>
</child> </child>
<child>
<object class="GtkButton" id="show_layout_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="show_selected_layout" object="CcRegionPanel" swapped="yes"/>
<child internal-child="accessible">
<object class="AtkObject">
<property name="accessible-name" translatable="yes">Show input source keyboard layout</property>
</object>
</child>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">input-keyboard-symbolic</property>
<property name="icon-size">1</property>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>

View file

@ -32,6 +32,7 @@ resource_data = files(
'cc-format-chooser.ui', 'cc-format-chooser.ui',
'cc-input-chooser.ui', 'cc-input-chooser.ui',
'cc-region-panel.ui', 'cc-region-panel.ui',
'view-layout-symbolic.svg',
) )
sources += gnome.compile_resources( sources += gnome.compile_resources(

View file

@ -6,4 +6,7 @@
<file preprocess="xml-stripblanks">cc-input-row.ui</file> <file preprocess="xml-stripblanks">cc-input-row.ui</file>
<file preprocess="xml-stripblanks">cc-region-panel.ui</file> <file preprocess="xml-stripblanks">cc-region-panel.ui</file>
</gresource> </gresource>
<gresource prefix="/org/gnome/ControlCenter/icons/scalable/actions">
<file>view-layout-symbolic.svg</file>
</gresource>
</gresources> </gresources>

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="16"
viewBox="0 0 16 16"
version="1.1"
id="svg7384"
height="16">
<metadata
id="metadata90">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Gnome Symbolic Icon Theme</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<title
id="title9167">Gnome Symbolic Icon Theme</title>
<defs
id="defs7386">
<linearGradient
osb:paint="solid"
id="linearGradient7212">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop7214" />
</linearGradient>
</defs>
<g
transform="translate(-341.0002,-13.000323)"
style="display:inline"
id="layer9" />
<g
transform="translate(-100,-380.00032)"
id="layer1" />
<g
transform="translate(-100,-380.00032)"
style="display:inline"
id="layer10">
<path
d="m 108,382 a 8,8 0 0 0 -7.73828,6.00977 A 8,8 0 0 0 108,394 8,8 0 0 0 115.73828,387.99023 8,8 0 0 0 108,382 Z m 0,2 a 4,4 0 0 1 4,4 4,4 0 0 1 -4,4 4,4 0 0 1 -4,-4 4,4 0 0 1 4,-4 z"
id="path2314"
style="opacity:1;vector-effect:none;fill:#2e3436;fill-opacity:1;stroke:none;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;marker-start:none;marker-mid:none;marker-end:none;paint-order:normal" />
<path
id="path2318"
d="m 110,388.00003 a 2,2 0 0 1 -2,2 2,2 0 0 1 -2,-2 2,2 0 0 1 2,-2 2,2 0 0 1 2,2 z"
style="vector-effect:none;fill:#2e3436;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
transform="translate(-100,-380.00032)"
id="g6387" />
<g
transform="translate(-100,-380.00032)"
id="layer11" />
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB