diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2018-11-19 11:22:29 +1300 |
---|---|---|
committer | Georges Basile Stavracas Neto <georges.stavracas@gmail.com> | 2019-02-04 13:56:41 +0000 |
commit | 4d5626d066e8794351a879bc63f3b0a819b363f6 (patch) | |
tree | ad925975d21192a3fb71f6c83c93c98c42a7f343 | |
parent | a193417b32c3f4dd707d60c59193115b9f97194d (diff) | |
download | gnome-control-center-4d5626d066e8794351a879bc63f3b0a819b363f6.tar.gz |
region: Convert add input button to a row
This matches the new designs in
https://gitlab.gnome.org/Teams/Design/settings-mockups/blob/master/region-and-language/region-and-language.png
-rw-r--r-- | panels/region/cc-region-panel.c | 16 | ||||
-rw-r--r-- | panels/region/cc-region-panel.ui | 51 |
2 files changed, 30 insertions, 37 deletions
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c index 45e886042..e4d6f1833 100644 --- a/panels/region/cc-region-panel.c +++ b/panels/region/cc-region-panel.c @@ -59,7 +59,7 @@ struct _CcRegionPanel { CcPanel parent_instance; - GtkButton *add_input_button; + GtkListBoxRow *add_input_row; GtkLabel *alt_next_source; GtkLabel *formats_label; GtkListBoxRow *formats_row; @@ -808,7 +808,7 @@ add_input_row (CcRegionPanel *self, CcInputSource *source) g_signal_connect_object (row, "show-settings", G_CALLBACK (row_settings_cb), self, G_CONNECT_SWAPPED); 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)); + gtk_list_box_insert (GTK_LIST_BOX (self->input_list), GTK_WIDGET (row), gtk_list_box_row_get_index (self->add_input_row)); update_input_rows (self); cc_list_box_adjust_scrolling (self->input_list); @@ -1150,6 +1150,14 @@ move_input (CcRegionPanel *self, } static void +input_row_activated_cb (CcRegionPanel *self, GtkListBoxRow *row) +{ + if (row == self->add_input_row) { + add_input (self); + } +} + +static void move_selected_input_up (CcRegionPanel *self) { GtkListBoxRow *selected; @@ -1603,7 +1611,7 @@ cc_region_panel_class_init (CcRegionPanelClass * klass) gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/region/cc-region-panel.ui"); - gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, add_input_button); + gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, add_input_row); gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, alt_next_source); gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, formats_label); gtk_widget_class_bind_template_child (widget_class, CcRegionPanel, formats_row); @@ -1628,8 +1636,8 @@ 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_callback (widget_class, input_row_activated_cb); 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); } diff --git a/panels/region/cc-region-panel.ui b/panels/region/cc-region-panel.ui index 740c1ac50..242793e1f 100644 --- a/panels/region/cc-region-panel.ui +++ b/panels/region/cc-region-panel.ui @@ -253,6 +253,8 @@ <object class="GtkListBox" id="input_list"> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="selection-mode">none</property> + <signal name="row_activated" handler="input_row_activated_cb" object="CcRegionPanel" swapped="yes"/> <accessibility> <relation target="input_heading_label" type="labelled-by"/> </accessibility> @@ -271,6 +273,22 @@ </child> </object> </child> + <child> + <object class="GtkListBoxRow" id="add_input_row"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="selectable">False</property> + <child> + <object class="GtkImage"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="margin">18</property> + <property name="icon-name">list-add-symbolic</property> + </object> + </child> + </object> + </child> </object> </child> </object> @@ -286,39 +304,6 @@ <class name="inline-toolbar"/> </style> <child> - <object class="GtkToolItem"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkButton" id="add_input_button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <signal name="clicked" handler="add_input" object="CcRegionPanel" swapped="yes"/> - <child internal-child="accessible"> - <object class="AtkObject"> - <property name="accessible-name" translatable="yes">Add input source</property> - </object> - </child> - <child> - <object class="GtkImage"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="icon_name">list-add-symbolic</property> - <property name="icon-size">1</property> - </object> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - <child> <object class="GtkSeparatorToolItem"> <property name="visible">True</property> <property name="can_focus">False</property> |