edit-dialog: wrap in a scrolled window

As we're adding more and more widgets in the Edit dialog,
it is now growing too tall to fit normal screens. Thus, wrap
it in a scrolled window, and let the content height cover
75% of the main window at most.
This commit is contained in:
Georges Basile Stavracas Neto
2017-09-07 14:58:14 -03:00
parent a0e64ca3c8
commit 8927e10ae0
2 changed files with 394 additions and 362 deletions
+14 -4
View File
@@ -122,8 +122,16 @@
</child> </child>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox"> <object class="GtkBox" id="dialog-vbox">
<property name="orientation">vertical</property> <property name="visible">true</property>
<property name="spacing">2</property> <property name="spacing">0</property>
<property name="border_width">0</property>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hscrollbar_policy">never</property>
<property name="min_content_height">400</property>
<property name="propagate_natural_height">true</property>
<child> <child>
<object class="GtkGrid" id="main_grid"> <object class="GtkGrid" id="main_grid">
<property name="visible">True</property> <property name="visible">True</property>
@@ -507,8 +515,8 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkScrolledWindow" id="scrolled_window"> <object class="GtkScrolledWindow">
<property name="height_request">120</property> <property name="min_content_height">120</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="margin-top">12</property> <property name="margin-top">12</property>
@@ -566,6 +574,8 @@
</child> </child>
</object> </object>
</child> </child>
</object>
</child>
</template> </template>
<object class="GtkPopover" id="sources_popover"> <object class="GtkPopover" id="sources_popover">
</object> </object>
+22
View File
@@ -56,6 +56,8 @@ struct _GcalEditDialog
GtkWidget *title_label; GtkWidget *title_label;
GtkWidget *subtitle_label; GtkWidget *subtitle_label;
GtkWidget *scrolled_window;
GtkWidget *lock; GtkWidget *lock;
GtkWidget *source_image; GtkWidget *source_image;
GtkWidget *source_label; GtkWidget *source_label;
@@ -300,6 +302,19 @@ remove_recurrence_properties (GcalEvent *event)
e_cal_component_rescan (comp); e_cal_component_rescan (comp);
} }
static void
transient_size_allocate_cb (GcalEditDialog *self)
{
GtkAllocation alloc;
GtkWindow *transient;
transient = gtk_window_get_transient_for (GTK_WINDOW (self));
gtk_widget_get_allocation (GTK_WIDGET (transient), &alloc);
gtk_scrolled_window_set_max_content_height (GTK_SCROLLED_WINDOW (self->scrolled_window),
MAX (400, (gint) (0.75 * alloc.height)));
}
static void static void
update_location (GtkEntry *entry, update_location (GtkEntry *entry,
GParamSpec *pspec, GParamSpec *pspec,
@@ -659,6 +674,12 @@ gcal_edit_dialog_constructed (GObject* object)
gtk_widget_insert_action_group (GTK_WIDGET (self), gtk_widget_insert_action_group (GTK_WIDGET (self),
"edit", "edit",
G_ACTION_GROUP (self->action_group)); G_ACTION_GROUP (self->action_group));
/* Watch the main window and adapt the maximum size */
g_signal_connect_swapped (gtk_window_get_transient_for (GTK_WINDOW (self)),
"size-allocate",
G_CALLBACK (transient_size_allocate_cb),
self);
} }
static void static void
@@ -801,6 +822,7 @@ gcal_edit_dialog_class_init (GcalEditDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, repeat_duration_combo); gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, repeat_duration_combo);
gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, repeat_duration_stack); gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, repeat_duration_stack);
gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, repeat_limits_box); gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, repeat_limits_box);
gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, scrolled_window);
gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, source_image); gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, source_image);
gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, sources_popover); gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, sources_popover);
gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, until_date_selector); gtk_widget_class_bind_template_child (widget_class, GcalEditDialog, until_date_selector);