import-dialog: Adjust dialog to content size

Ports the import dialog out of AdwPreferencesPage to
modify some properties of the ScrolledWindow so the dialog
does the sizing as expected

This avoids scrolling when the natural height of the contents
fits within the window
This commit is contained in:
Diego Iván
2024-08-05 15:54:23 +00:00
committed by Georges Basile Stavracas Neto
parent 9ea843807d
commit 7e4a4ca99b
2 changed files with 51 additions and 31 deletions
+4 -4
View File
@@ -41,13 +41,13 @@ struct _GcalImportDialog
{
AdwDialog parent;
GtkBox *calendars_box;
GtkWidget *cancel_button;
AdwComboRow *calendar_combo_row;
AdwPreferencesGroup *files_group;
AdwHeaderBar *headerbar;
GtkWidget *import_button;
GtkWidget *placeholder_spinner;
AdwPreferencesPage *preferences_page;
GtkSizeGroup *title_sizegroup;
AdwToastOverlay *toast_overlay;
@@ -151,7 +151,7 @@ add_file (GcalImportDialog *self,
adw_preferences_group_set_title (group, basename);
}
adw_preferences_page_add (self->preferences_page, group);
gtk_box_append (self->calendars_box, GTK_WIDGET (group));
self->rows = g_list_prepend (self->rows, row);
gtk_widget_set_visible (self->placeholder_spinner, FALSE);
@@ -170,7 +170,7 @@ setup_files (GcalImportDialog *self,
self->n_files = n_files;
for (i = 0; i < n_files; i++)
add_file(self, files[i], n_files > 1);
add_file (self, files[i], n_files > 1);
GCAL_EXIT;
}
@@ -529,7 +529,7 @@ gcal_import_dialog_class_init (GcalImportDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, GcalImportDialog, headerbar);
gtk_widget_class_bind_template_child (widget_class, GcalImportDialog, import_button);
gtk_widget_class_bind_template_child (widget_class, GcalImportDialog, placeholder_spinner);
gtk_widget_class_bind_template_child (widget_class, GcalImportDialog, preferences_page);
gtk_widget_class_bind_template_child (widget_class, GcalImportDialog, calendars_box);
gtk_widget_class_bind_template_child (widget_class, GcalImportDialog, title_sizegroup);
gtk_widget_class_bind_template_child (widget_class, GcalImportDialog, toast_overlay);
+47 -27
View File
@@ -2,8 +2,8 @@
<interface>
<template class="GcalImportDialog" parent="AdwDialog">
<property name="title" translatable="yes">Import Files…</property>
<property name="content-width">500</property>
<property name="content-height">500</property>
<property name="height-request">294</property>
<property name="follows-content-size">True</property>
<child>
<object class="AdwToastOverlay" id="toast_overlay">
<child>
@@ -36,39 +36,59 @@
</object>
</child>
<property name="content">
<object class="AdwPreferencesPage" id="preferences_page">
<object class="GtkScrolledWindow">
<property name="propagate-natural-height">True</property>
<property name="propagate-natural-width">True</property>
<!-- Calendar -->
<child>
<object class="AdwPreferencesGroup">
<object class="AdwClamp">
<property name="margin-top">24</property>
<property name="margin-bottom">24</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="AdwComboRow" id="calendar_combo_row">
<property name="activatable">True</property>
<property name="title" translatable="yes">C_alendar</property>
<property name="use-underline">True</property>
<property name="factory">
<object class="GtkSignalListItemFactory">
<signal name="bind" handler="on_combo_row_signal_factory_bind_cb" object="GcalImportDialog" swapped="no" />
<signal name="setup" handler="on_combo_row_signal_factory_setup_cb" object="GcalImportDialog" swapped="no" />
<object class="GtkBox" id="calendars_box">
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<!-- Calendar -->
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="AdwComboRow" id="calendar_combo_row">
<property name="activatable">True</property>
<property name="title" translatable="yes">C_alendar</property>
<property name="use-underline">True</property>
<property name="factory">
<object class="GtkSignalListItemFactory">
<signal name="bind" handler="on_combo_row_signal_factory_bind_cb" object="GcalImportDialog" swapped="no" />
<signal name="setup" handler="on_combo_row_signal_factory_setup_cb" object="GcalImportDialog" swapped="no" />
</object>
</property>
<signal name="notify::selected-item" handler="on_calendar_combo_row_selected_item_changed_cb" object="GcalImportDialog" swapped="no" />
</object>
</child>
</object>
</property>
<signal name="notify::selected-item" handler="on_calendar_combo_row_selected_item_changed_cb" object="GcalImportDialog" swapped="no" />
</object>
</child>
</object>
</child>
</child>
<!-- Files overview -->
<child>
<object class="AdwPreferencesGroup" id="files_group">
<child>
<object class="GtkSpinner" id="placeholder_spinner">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="spinning">True</property>
<!-- Files overview -->
<child>
<object class="AdwPreferencesGroup" id="files_group">
<child>
<object class="GtkSpinner" id="placeholder_spinner">
<property name="halign">center</property>
<property name="valign">center</property>
<property name="spinning">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>