diff --git a/panels/keyboard/cc-input-chooser.c b/panels/keyboard/cc-input-chooser.c index f9aaff69a..6adc4c262 100644 --- a/panels/keyboard/cc-input-chooser.c +++ b/panels/keyboard/cc-input-chooser.c @@ -22,7 +22,6 @@ #define GNOME_DESKTOP_USE_UNSTABLE_API #include -#include "list-box-helper.h" #include "cc-common-language.h" #include "cc-util.h" #include "cc-input-chooser.h" @@ -139,26 +138,23 @@ padded_label_new (const gchar *text, if (direction == ROW_TRAVEL_DIRECTION_BACKWARD) { - arrow = gtk_image_new_from_icon_name ("go-previous-symbolic", GTK_ICON_SIZE_MENU); - gtk_widget_show (arrow); - gtk_container_add (GTK_CONTAINER (widget), arrow); + arrow = gtk_image_new_from_icon_name ("go-previous-symbolic"); + gtk_box_append (GTK_BOX (widget), arrow); } label = gtk_label_new (text); - gtk_widget_show (label); gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_MIDDLE); gtk_widget_set_hexpand (label, TRUE); gtk_widget_set_halign (label, alignment); set_row_widget_margins (label); - gtk_container_add (GTK_CONTAINER (widget), label); + gtk_box_append (GTK_BOX (widget), label); if (dim_label) gtk_style_context_add_class (gtk_widget_get_style_context (label), "dim-label"); if (direction == ROW_TRAVEL_DIRECTION_FORWARD) { - arrow = gtk_image_new_from_icon_name ("go-next-symbolic", GTK_ICON_SIZE_MENU); - gtk_widget_show (arrow); - gtk_container_add (GTK_CONTAINER (widget), arrow); + arrow = gtk_image_new_from_icon_name ("go-next-symbolic"); + gtk_box_append (GTK_BOX (widget), arrow); } return widget; @@ -173,16 +169,14 @@ more_row_new (void) row = gtk_list_box_row_new (); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); - gtk_widget_show (box); - gtk_container_add (GTK_CONTAINER (row), box); + gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box); gtk_widget_set_tooltip_text (row, _("More…")); - arrow = gtk_image_new_from_icon_name ("view-more-symbolic", GTK_ICON_SIZE_MENU); - gtk_widget_show (arrow); - gtk_style_context_add_class (gtk_widget_get_style_context (arrow), "dim-label"); + arrow = gtk_image_new_from_icon_name ("view-more-symbolic"); + gtk_widget_add_css_class (arrow, "dim-label"); gtk_widget_set_hexpand (arrow, TRUE); set_row_widget_margins (arrow); - gtk_container_add (GTK_CONTAINER (box), arrow); + gtk_box_append (GTK_BOX (box), arrow); return GTK_LIST_BOX_ROW (row); } @@ -201,8 +195,7 @@ back_row_new (const gchar *text) row = gtk_list_box_row_new (); widget = padded_label_new (text, ROW_LABEL_POSITION_CENTER, ROW_TRAVEL_DIRECTION_BACKWARD, TRUE); - gtk_widget_show (widget); - gtk_container_add (GTK_CONTAINER (row), widget); + gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), widget); return GTK_LIST_BOX_ROW (row); } @@ -215,8 +208,7 @@ locale_row_new (const gchar *text) row = gtk_list_box_row_new (); widget = padded_label_new (text, ROW_LABEL_POSITION_CENTER, ROW_TRAVEL_DIRECTION_NONE, FALSE); - gtk_widget_show (widget); - gtk_container_add (GTK_CONTAINER (row), widget); + gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), widget); return GTK_LIST_BOX_ROW (row); } @@ -240,8 +232,7 @@ input_source_row_new (CcInputChooser *self, ROW_LABEL_POSITION_START, ROW_TRAVEL_DIRECTION_NONE, FALSE); - gtk_widget_show (widget); - gtk_container_add (GTK_CONTAINER (row), widget); + gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), widget); g_object_set_data (G_OBJECT (row), "name", (gpointer) display_name); g_object_set_data_full (G_OBJECT (row), "unaccented-name", cc_util_normalize_casefold_and_unaccent (display_name), g_free); @@ -259,13 +250,12 @@ input_source_row_new (CcInputChooser *self, ROW_LABEL_POSITION_START, ROW_TRAVEL_DIRECTION_NONE, FALSE); - gtk_widget_show (widget); - gtk_container_add (GTK_CONTAINER (row), widget); - image = gtk_image_new_from_icon_name ("system-run-symbolic", GTK_ICON_SIZE_MENU); - gtk_widget_show (image); + gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), widget); + + image = gtk_image_new_from_icon_name ("system-run-symbolic"); set_row_widget_margins (image); gtk_style_context_add_class (gtk_widget_get_style_context (image), "dim-label"); - gtk_container_add (GTK_CONTAINER (widget), image); + gtk_box_append (GTK_BOX (widget), image); g_object_set_data_full (G_OBJECT (row), "name", display_name, g_free); g_object_set_data_full (G_OBJECT (row), "unaccented-name", @@ -287,14 +277,12 @@ input_source_row_new (CcInputChooser *self, } static void -remove_all_children (GtkContainer *container) +remove_all_rows (GtkListBox *listbox) { - g_autoptr(GList) list = NULL; - GList *l; + GtkWidget *child; - list = gtk_container_get_children (container); - for (l = list; l; l = l->next) - gtk_container_remove (container, (GtkWidget *) l->data); + while ((child = gtk_widget_get_first_child (GTK_WIDGET (listbox))) != NULL) + gtk_list_box_remove (listbox, child); } static void @@ -306,22 +294,22 @@ add_input_source_rows_for_locale (CcInputChooser *self, const gchar *id; if (info->default_input_source_row) - gtk_container_add (GTK_CONTAINER (self->input_sources_listbox), GTK_WIDGET (info->default_input_source_row)); + gtk_list_box_append (self->input_sources_listbox, GTK_WIDGET (info->default_input_source_row)); g_hash_table_iter_init (&iter, info->layout_rows_by_id); while (g_hash_table_iter_next (&iter, (gpointer *) &id, (gpointer *) &row)) - gtk_container_add (GTK_CONTAINER (self->input_sources_listbox), row); + gtk_list_box_append (self->input_sources_listbox, row); g_hash_table_iter_init (&iter, info->engine_rows_by_id); while (g_hash_table_iter_next (&iter, (gpointer *) &id, (gpointer *) &row)) - gtk_container_add (GTK_CONTAINER (self->input_sources_listbox), row); + gtk_list_box_append (self->input_sources_listbox, row); } static void show_input_sources_for_locale (CcInputChooser *self, LocaleInfo *info) { - remove_all_children (GTK_CONTAINER (self->input_sources_listbox)); + remove_all_rows (self->input_sources_listbox); if (!info->back_row) { @@ -330,13 +318,12 @@ show_input_sources_for_locale (CcInputChooser *self, g_object_set_data (G_OBJECT (info->back_row), "back", GINT_TO_POINTER (TRUE)); g_object_set_data (G_OBJECT (info->back_row), "locale-info", info); } - gtk_container_add (GTK_CONTAINER (self->input_sources_listbox), GTK_WIDGET (info->back_row)); + gtk_list_box_append (self->input_sources_listbox, GTK_WIDGET (info->back_row)); add_input_source_rows_for_locale (self, info); gtk_adjustment_set_value (self->scroll_adjustment, gtk_adjustment_get_lower (self->scroll_adjustment)); - gtk_list_box_set_header_func (self->input_sources_listbox, cc_list_box_update_header_func, NULL, NULL); gtk_list_box_invalidate_filter (self->input_sources_listbox); gtk_list_box_set_selection_mode (self->input_sources_listbox, GTK_SELECTION_SINGLE); gtk_list_box_set_activate_on_single_click (self->input_sources_listbox, FALSE); @@ -360,7 +347,7 @@ show_locale_rows (CcInputChooser *self) LocaleInfo *info; GHashTableIter iter; - remove_all_children (GTK_CONTAINER (self->input_sources_listbox)); + remove_all_rows (self->input_sources_listbox); if (!self->showing_extra) initial = cc_common_language_get_initial_languages (); @@ -384,14 +371,13 @@ show_locale_rows (CcInputChooser *self) !is_current_locale (info->id)) g_object_set_data (G_OBJECT (info->locale_row), "is-extra", GINT_TO_POINTER (TRUE)); } - gtk_container_add (GTK_CONTAINER (self->input_sources_listbox), GTK_WIDGET (info->locale_row)); + gtk_list_box_append (self->input_sources_listbox, GTK_WIDGET (info->locale_row)); } - gtk_container_add (GTK_CONTAINER (self->input_sources_listbox), GTK_WIDGET (self->more_row)); + gtk_list_box_append (self->input_sources_listbox, GTK_WIDGET (self->more_row)); gtk_adjustment_set_value (self->scroll_adjustment, gtk_adjustment_get_lower (self->scroll_adjustment)); - gtk_list_box_set_header_func (self->input_sources_listbox, cc_list_box_update_header_func, NULL, NULL); gtk_list_box_invalidate_filter (self->input_sources_listbox); gtk_list_box_set_selection_mode (self->input_sources_listbox, GTK_SELECTION_NONE); gtk_list_box_set_activate_on_single_click (self->input_sources_listbox, TRUE); @@ -573,7 +559,7 @@ do_filter (CcInputChooser *self) self->filter_timeout_id = 0; filter_contents = - cc_util_normalize_casefold_and_unaccent (gtk_entry_get_text (GTK_ENTRY (self->filter_entry))); + cc_util_normalize_casefold_and_unaccent (gtk_editable_get_text (GTK_EDITABLE (self->filter_entry))); previous_words = self->filter_words; self->filter_words = g_strsplit_set (g_strstrip (filter_contents), " ", 0); @@ -662,23 +648,6 @@ on_input_sources_listbox_selected_rows_changed_cb (CcInputChooser *self) gtk_widget_set_sensitive (GTK_WIDGET (self->add_button), sensitive); } -static gboolean -on_input_sources_listbox_button_release_event_cb (CcInputChooser *self, GdkEvent *event) -{ - gdouble x, y; - GtkListBoxRow *row; - - gdk_event_get_coords (event, &x, &y); - row = gtk_list_box_get_row_at_y (self->input_sources_listbox, y); - if (row && g_object_get_data (G_OBJECT (row), "back")) - { - g_signal_emit_by_name (row, "activate", NULL); - return TRUE; - } - - return FALSE; -} - static void add_default_row (CcInputChooser *self, LocaleInfo *info, @@ -977,6 +946,7 @@ get_locale_infos (CcInputChooser *self) add_row_other (self, INPUT_SOURCE_TYPE_XKB, l->data); } +/* static gboolean on_filter_entry_key_release_event_cb (CcInputChooser *self, GdkEventKey *event) { @@ -990,6 +960,7 @@ on_filter_entry_key_release_event_cb (CcInputChooser *self, GdkEventKey *event) return FALSE; } + */ static void cc_input_chooser_dispose (GObject *object) @@ -1026,15 +997,16 @@ cc_input_chooser_class_init (CcInputChooserClass *klass) gtk_widget_class_bind_template_callback (widget_class, on_input_sources_listbox_row_activated_cb); gtk_widget_class_bind_template_callback (widget_class, on_input_sources_listbox_selected_rows_changed_cb); - gtk_widget_class_bind_template_callback (widget_class, on_input_sources_listbox_button_release_event_cb); gtk_widget_class_bind_template_callback (widget_class, on_filter_entry_search_changed_cb); - gtk_widget_class_bind_template_callback (widget_class, on_filter_entry_key_release_event_cb); + //gtk_widget_class_bind_template_callback (widget_class, on_filter_entry_key_release_event_cb); } void cc_input_chooser_init (CcInputChooser *self) { gtk_widget_init_template (GTK_WIDGET (self)); + + gtk_search_entry_set_key_capture_widget (self->filter_entry, GTK_WIDGET (self)); } CcInputChooser * @@ -1043,7 +1015,6 @@ cc_input_chooser_new (gboolean is_login, GHashTable *ibus_engines) { CcInputChooser *self; - g_autoptr(GError) error = NULL; self = g_object_new (CC_TYPE_INPUT_CHOOSER, "use-header-bar", 1, diff --git a/panels/keyboard/cc-input-chooser.ui b/panels/keyboard/cc-input-chooser.ui index 8d72357e2..ff98a8a02 100644 --- a/panels/keyboard/cc-input-chooser.ui +++ b/panels/keyboard/cc-input-chooser.ui @@ -9,8 +9,6 @@ _Cancel - True - True True center @@ -18,26 +16,20 @@ _Add - True - True - True False True center - + - True vertical 0 - True never automatic True - in 6 6 6 @@ -46,14 +38,14 @@ scroll_adjustment - True - True True fill fill - + @@ -67,7 +59,6 @@ 6 6 - diff --git a/panels/keyboard/cc-input-list-box.c b/panels/keyboard/cc-input-list-box.c index 191207490..c03a26d69 100644 --- a/panels/keyboard/cc-input-list-box.c +++ b/panels/keyboard/cc-input-list-box.c @@ -25,7 +25,6 @@ #define GNOME_DESKTOP_USE_UNSTABLE_API #include -#include "list-box-helper.h" #include "cc-input-list-box.h" #include "cc-input-chooser.h" #include "cc-input-row.h" @@ -40,10 +39,11 @@ #define KEY_INPUT_SOURCES "sources" struct _CcInputListBox { - GtkListBox parent_instance; + AdwBin parent_instance; GtkListBoxRow *add_input_row; GtkSizeGroup *input_size_group; + GtkListBox *listbox; GtkListBoxRow *no_inputs_row; GCancellable *cancellable; @@ -61,7 +61,7 @@ struct _CcInputListBox { #endif }; -G_DEFINE_TYPE (CcInputListBox, cc_input_list_box, GTK_TYPE_LIST_BOX) +G_DEFINE_TYPE (CcInputListBox, cc_input_list_box, ADW_TYPE_BIN) typedef struct { @@ -97,18 +97,18 @@ static void show_input_chooser (CcInputListBox *self); static void update_ibus_active_sources (CcInputListBox *self) { - g_autoptr(GList) rows = NULL; - GList *l; + GtkWidget *child; - rows = gtk_container_get_children (GTK_CONTAINER (self)); - for (l = rows; l; l = l->next) { + for (child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox)); + child; + child = gtk_widget_get_next_sibling (child)) { CcInputRow *row; CcInputSourceIBus *source; IBusEngineDesc *engine_desc; - if (!CC_IS_INPUT_ROW (l->data)) + if (!CC_IS_INPUT_ROW (child)) continue; - row = CC_INPUT_ROW (l->data); + row = CC_INPUT_ROW (child); if (!CC_IS_INPUT_SOURCE_IBUS (cc_input_row_get_source (row))) continue; @@ -200,7 +200,7 @@ row_settings_cb (CcInputListBox *self, return; ctx = gdk_display_get_app_launch_context (gdk_display_get_default ()); - gdk_app_launch_context_set_timestamp (ctx, gtk_get_current_event_time ()); + gdk_app_launch_context_set_timestamp (ctx, GDK_CURRENT_TIME); g_app_launch_context_setenv (G_APP_LAUNCH_CONTEXT (ctx), "IBUS_ENGINE_NAME", cc_input_source_ibus_get_engine_name (source)); @@ -254,20 +254,22 @@ row_removed_cb (CcInputListBox *self, static void update_input_rows (CcInputListBox *self) { - g_autoptr(GList) rows = NULL; - GList *l; + GtkWidget *child; guint n_input_rows = 0; - rows = gtk_container_get_children (GTK_CONTAINER (self)); - for (l = rows; l; l = l->next) - if (CC_IS_INPUT_ROW (l->data)) + child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox)); + while ((child = gtk_widget_get_next_sibling (child)) != NULL) + if (CC_IS_INPUT_ROW (child)) n_input_rows++; - for (l = rows; l; l = l->next) { + + for (child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox)); + child; + child = gtk_widget_get_next_sibling (child)) { CcInputRow *row; - if (!CC_IS_INPUT_ROW (l->data)) + if (!CC_IS_INPUT_ROW (child)) continue; - row = CC_INPUT_ROW (l->data); + row = CC_INPUT_ROW (child); cc_input_row_set_removable (row, n_input_rows > 1); cc_input_row_set_draggable (row, n_input_rows > 1); @@ -288,7 +290,7 @@ add_input_row (CcInputListBox *self, CcInputSource *source) g_signal_connect_object (row, "show-layout", G_CALLBACK (row_layout_cb), self, G_CONNECT_SWAPPED); g_signal_connect_object (row, "move-row", G_CALLBACK (row_moved_cb), self, G_CONNECT_SWAPPED); g_signal_connect_object (row, "remove-row", G_CALLBACK (row_removed_cb), self, G_CONNECT_SWAPPED); - gtk_list_box_insert (GTK_LIST_BOX (self), GTK_WIDGET (row), gtk_list_box_row_get_index (self->add_input_row)); + gtk_list_box_insert (self->listbox, GTK_WIDGET (row), gtk_list_box_row_get_index (self->add_input_row)); update_input_rows (self); } @@ -339,31 +341,32 @@ add_input_sources_from_settings (CcInputListBox *self) static void clear_input_sources (CcInputListBox *self) { - g_autoptr(GList) list = NULL; - GList *l; + GtkWidget *child; - list = gtk_container_get_children (GTK_CONTAINER (self)); - for (l = list; l; l = l->next) { - if (CC_IS_INPUT_ROW (l->data)) - gtk_container_remove (GTK_CONTAINER (self), GTK_WIDGET (l->data)); + child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox)); + while (child) { + GtkWidget *next = gtk_widget_get_next_sibling (child); + + if (CC_IS_INPUT_ROW (child)) + gtk_list_box_remove (self->listbox, GTK_WIDGET (child)); + + child = next; } - - cc_list_box_adjust_scrolling (GTK_LIST_BOX (self)); } static CcInputRow * get_row_by_source (CcInputListBox *self, CcInputSource *source) { - g_autoptr(GList) list = NULL; - GList *l; + GtkWidget *child; - list = gtk_container_get_children (GTK_CONTAINER (self)); - for (l = list; l; l = l->next) { + for (child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox)); + child; + child = gtk_widget_get_next_sibling (child)) { CcInputRow *row; - if (!CC_IS_INPUT_ROW (l->data)) + if (!CC_IS_INPUT_ROW (child)) continue; - row = CC_INPUT_ROW (l->data); + row = CC_INPUT_ROW (child); if (cc_input_source_matches (source, cc_input_row_get_source (row))) return row; @@ -379,7 +382,7 @@ input_sources_changed (CcInputListBox *self, CcInputRow *selected; g_autoptr(CcInputSource) source = NULL; - selected = CC_INPUT_ROW (gtk_list_box_get_selected_row (GTK_LIST_BOX (self))); + selected = CC_INPUT_ROW (gtk_list_box_get_selected_row (self->listbox)); if (selected) source = g_object_ref (cc_input_row_get_source (selected)); clear_input_sources (self); @@ -387,7 +390,7 @@ input_sources_changed (CcInputListBox *self, if (source != NULL) { CcInputRow *row = get_row_by_source (self, source); if (row != NULL) - gtk_list_box_select_row (GTK_LIST_BOX (self), GTK_LIST_BOX_ROW (row)); + gtk_list_box_select_row (self->listbox, GTK_LIST_BOX_ROW (row)); } } @@ -395,18 +398,19 @@ static void set_input_settings (CcInputListBox *self) { GVariantBuilder builder; - g_autoptr(GList) list = NULL; - GList *l; + GtkWidget *child; g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ss)")); - list = gtk_container_get_children (GTK_CONTAINER (self)); - for (l = list; l; l = l->next) { + + for (child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox)); + child; + child = gtk_widget_get_next_sibling (child)) { CcInputRow *row; CcInputSource *source; - if (!CC_IS_INPUT_ROW (l->data)) + if (!CC_IS_INPUT_ROW (child)) continue; - row = CC_INPUT_ROW (l->data); + row = CC_INPUT_ROW (child); source = cc_input_row_get_source (row); if (CC_IS_INPUT_SOURCE_XKB (source)) { @@ -435,6 +439,24 @@ update_input (CcInputListBox *self) } } +static void +on_chooser_response_cb (GtkDialog *dialog, + gint response, + CcInputListBox *self) +{ + + if (response == GTK_RESPONSE_OK) { + CcInputSource *source; + + source = cc_input_chooser_get_source (CC_INPUT_CHOOSER (dialog)); + if (source != NULL && get_row_by_source (self, source) == NULL) { + add_input_row (self, source); + update_input (self); + } + } + gtk_window_destroy (GTK_WINDOW (dialog)); +} + static void show_input_chooser (CcInputListBox *self) { @@ -448,18 +470,10 @@ show_input_chooser (CcInputListBox *self) NULL #endif ); - gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self)))); - - if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_OK) { - CcInputSource *source; - - source = cc_input_chooser_get_source (chooser); - if (source != NULL && get_row_by_source (self, source) == NULL) { - add_input_row (self, source); - update_input (self); - } - } - gtk_widget_destroy (GTK_WIDGET (chooser)); + gtk_window_set_transient_for (GTK_WINDOW (chooser), + GTK_WINDOW (gtk_widget_get_native (GTK_WIDGET (self)))); + g_signal_connect (chooser, "response", G_CALLBACK (on_chooser_response_cb), self); + gtk_window_present (GTK_WINDOW (chooser)); } // Duplicated from cc-region-panel.c @@ -501,23 +515,20 @@ add_input (CcInputListBox *self) } static GtkWidget * -find_sibling (GtkContainer *container, GtkWidget *child) +find_sibling (GtkWidget *child) { - g_autoptr(GList) list = NULL; - GList *c, *l; GtkWidget *sibling; - list = gtk_container_get_children (container); - c = g_list_find (list, child); - - for (l = c->next; l; l = l->next) { - sibling = l->data; + for (sibling = gtk_widget_get_next_sibling (child); + sibling; + sibling = gtk_widget_get_next_sibling (child)) { if (gtk_widget_get_visible (sibling) && gtk_widget_get_child_visible (sibling)) return sibling; } - for (l = c->prev; l; l = l->prev) { - sibling = l->data; + for (sibling = gtk_widget_get_prev_sibling (child); + sibling; + sibling = gtk_widget_get_prev_sibling (child)) { if (gtk_widget_get_visible (sibling) && gtk_widget_get_child_visible (sibling)) return sibling; } @@ -530,11 +541,9 @@ do_remove_input (CcInputListBox *self, CcInputRow *row) { GtkWidget *sibling; - sibling = find_sibling (GTK_CONTAINER (self), GTK_WIDGET (row)); - gtk_container_remove (GTK_CONTAINER (self), GTK_WIDGET (row)); - gtk_list_box_select_row (GTK_LIST_BOX (self), GTK_LIST_BOX_ROW (sibling)); - - cc_list_box_adjust_scrolling (GTK_LIST_BOX(self)); + sibling = find_sibling (GTK_WIDGET (row)); + gtk_list_box_remove (self->listbox, GTK_WIDGET (row)); + gtk_list_box_select_row (self->listbox, GTK_LIST_BOX_ROW (sibling)); update_input (self); update_input_rows (self); @@ -571,12 +580,10 @@ do_move_input (CcInputListBox *self, CcInputRow *source, CcInputRow *dest) dest_index = gtk_list_box_row_get_index (GTK_LIST_BOX_ROW (dest)); g_object_ref (source); - gtk_container_remove (GTK_CONTAINER (self), GTK_WIDGET (source)); - gtk_list_box_insert (GTK_LIST_BOX (self), GTK_WIDGET (source), dest_index); + gtk_list_box_remove (self->listbox, GTK_WIDGET (source)); + gtk_list_box_insert (self->listbox, GTK_WIDGET (source), dest_index); g_object_unref (source); - cc_list_box_adjust_scrolling (GTK_LIST_BOX (self)); - update_input (self); } @@ -659,22 +666,22 @@ set_localed_input (CcInputListBox *self) { g_autoptr(GString) layouts = NULL; g_autoptr(GString) variants = NULL; - g_autoptr(GList) list = NULL; - GList *li; + GtkWidget *child; layouts = g_string_new (""); variants = g_string_new (""); - list = gtk_container_get_children (GTK_CONTAINER (self)); - for (li = list; li; li = li->next) { + for (child = gtk_widget_get_first_child (GTK_WIDGET (self->listbox)); + child; + child = gtk_widget_get_next_sibling (child)) { CcInputRow *row; CcInputSourceXkb *source; g_autofree gchar *id = NULL; const gchar *l, *v; - if (!CC_IS_INPUT_ROW (li->data)) + if (!CC_IS_INPUT_ROW (child)) continue; - row = CC_INPUT_ROW (li->data); + row = CC_INPUT_ROW (child); if (!CC_IS_INPUT_SOURCE_XKB (cc_input_row_get_source (row))) continue; @@ -727,6 +734,7 @@ cc_input_list_box_class_init (CcInputListBoxClass *klass) gtk_widget_class_bind_template_child (widget_class, CcInputListBox, add_input_row); gtk_widget_class_bind_template_child (widget_class, CcInputListBox, input_size_group); + gtk_widget_class_bind_template_child (widget_class, CcInputListBox, listbox); gtk_widget_class_bind_template_child (widget_class, CcInputListBox, no_inputs_row); gtk_widget_class_bind_template_callback (widget_class, input_row_activated_cb); diff --git a/panels/keyboard/cc-input-list-box.h b/panels/keyboard/cc-input-list-box.h index 223112e6e..7045053c7 100644 --- a/panels/keyboard/cc-input-list-box.h +++ b/panels/keyboard/cc-input-list-box.h @@ -26,10 +26,10 @@ G_BEGIN_DECLS -#include +#include #define CC_TYPE_INPUT_LIST_BOX (cc_input_list_box_get_type ()) -G_DECLARE_FINAL_TYPE (CcInputListBox, cc_input_list_box, CC, INPUT_LIST_BOX, GtkListBox) +G_DECLARE_FINAL_TYPE (CcInputListBox, cc_input_list_box, CC, INPUT_LIST_BOX, AdwBin) void cc_input_list_box_set_login (CcInputListBox *box, gboolean login); diff --git a/panels/keyboard/cc-input-list-box.ui b/panels/keyboard/cc-input-list-box.ui index cbe7a9f32..45791de84 100644 --- a/panels/keyboard/cc-input-list-box.ui +++ b/panels/keyboard/cc-input-list-box.ui @@ -1,48 +1,47 @@ -