[gnome-control-center] region: Move show layout button inside each row



commit 7a9d2b83dfb7313492e40222d3075132bee560d2
Author: Robert Ancell <robert ancell canonical com>
Date:   Mon Nov 19 11:08:07 2018 +1300

    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

 panels/region/cc-input-row.c           | 20 +++++++++++
 panels/region/cc-input-row.ui          | 16 ++++++++-
 panels/region/cc-region-panel.c        | 55 +++++++++++++---------------
 panels/region/cc-region-panel.ui       | 21 -----------
 panels/region/meson.build              |  1 +
 panels/region/region.gresource.xml     |  3 ++
 panels/region/view-layout-symbolic.svg | 65 ++++++++++++++++++++++++++++++++++
 7 files changed, 128 insertions(+), 53 deletions(-)
---
diff --git a/panels/region/cc-input-row.c b/panels/region/cc-input-row.c
index cb6587a9b..341f4c7e5 100644
--- a/panels/region/cc-input-row.c
+++ b/panels/region/cc-input-row.c
@@ -34,12 +34,21 @@ G_DEFINE_TYPE (CcInputRow, cc_input_row, GTK_TYPE_LIST_BOX_ROW)
 
 enum
 {
+  SIGNAL_SHOW_LAYOUT,
   SIGNAL_REMOVE_ROW,
   SIGNAL_LAST
 };
 
 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
 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, 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);
 
+  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] =
     g_signal_new ("remove-row",
                   G_TYPE_FROM_CLASS (object_class),
diff --git a/panels/region/cc-input-row.ui b/panels/region/cc-input-row.ui
index a6dab8555..d932ede74 100644
--- a/panels/region/cc-input-row.ui
+++ b/panels/region/cc-input-row.ui
@@ -4,7 +4,6 @@
   <template class="CcInputRow" parent="GtkListBoxRow">
     <property name="visible">True</property>
     <property name="can-focus">False</property>
-    <property name="activatable">True</property>
     <child>
       <object class="GtkBox">
         <property name="visible">True</property>
@@ -28,6 +27,21 @@
         </child>
         <child>
           <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>
             <signal name="clicked" handler="remove_button_clicked_cb" object="CcInputRow" swapped="yes"/>
             <style>
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index e182bb3fa..3a2ee1c68 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -84,7 +84,6 @@ struct _CcRegionPanel {
         GtkRevealer     *restart_revealer;
         GtkRadioButton  *same_source;
         GtkButton       *show_config_button;
-        GtkButton       *show_layout_button;
 
         gboolean     login;
         gboolean     login_auto_apply;
@@ -716,6 +715,29 @@ maybe_start_ibus (void)
 
 #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
@@ -756,6 +778,7 @@ add_input_row (CcRegionPanel *self, CcInputSource *source)
 
         row = cc_input_row_new (source);
         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);
         gtk_container_add (GTK_CONTAINER (self->input_list), GTK_WIDGET (row));
         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));
         if (selected == NULL) {
                 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_down_input_button), FALSE);
         } else {
@@ -884,7 +906,6 @@ update_buttons (CcRegionPanel *self)
                 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_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_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);
 }
 
-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
 update_shortcut_label (GtkLabel    *label,
                        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, same_source);
         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, 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_down);
         gtk_widget_class_bind_template_callback (widget_class, show_selected_settings);
-        gtk_widget_class_bind_template_callback (widget_class, show_selected_layout);
 }
 
 static void
diff --git a/panels/region/cc-region-panel.ui b/panels/region/cc-region-panel.ui
index 7d798c43e..2aeedfc88 100644
--- a/panels/region/cc-region-panel.ui
+++ b/panels/region/cc-region-panel.ui
@@ -422,27 +422,6 @@
                                 </child>
                               </object>
                             </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>
                         </child>
                       </object>
diff --git a/panels/region/meson.build b/panels/region/meson.build
index c0b886dd4..e709eb620 100644
--- a/panels/region/meson.build
+++ b/panels/region/meson.build
@@ -32,6 +32,7 @@ resource_data = files(
   'cc-format-chooser.ui',
   'cc-input-chooser.ui',
   'cc-region-panel.ui',
+  'view-layout-symbolic.svg',
 )
 
 sources += gnome.compile_resources(
diff --git a/panels/region/region.gresource.xml b/panels/region/region.gresource.xml
index 47b787e7d..5b57ddeb5 100644
--- a/panels/region/region.gresource.xml
+++ b/panels/region/region.gresource.xml
@@ -6,4 +6,7 @@
     <file preprocess="xml-stripblanks">cc-input-row.ui</file>
     <file preprocess="xml-stripblanks">cc-region-panel.ui</file>
   </gresource>
+  <gresource prefix="/org/gnome/ControlCenter/icons/scalable/actions">
+    <file>view-layout-symbolic.svg</file>
+  </gresource>
 </gresources>
diff --git a/panels/region/view-layout-symbolic.svg b/panels/region/view-layout-symbolic.svg
new file mode 100644
index 000000000..dc8b5d009
--- /dev/null
+++ b/panels/region/view-layout-symbolic.svg
@@ -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>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]