diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-05-11 14:23:58 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-05-11 14:23:58 -0400 |
commit | ea53b445a852ebc4d0c98e5a1d0607a0fcc2a7b3 (patch) | |
tree | 1b9e3a7e8f6109583f964c8690a492fc6de54e99 /gtk/gtkfilechooserdialog.c | |
parent | c8a96d08a0724e9cfa67dcfd0421e83ef9809fe0 (diff) | |
download | gtk+-ea53b445a852ebc4d0c98e5a1d0607a0fcc2a7b3.tar.gz |
filechooserdialog: Be more careful with widgets
We were stepping on our own toes, by first setting
up a save entry and telling the filechooserwidget
about it, and then nuking it by setting a title
on the headerbar. The filechooserwidget wasn't
ready for the entry to die without anybody telling
it.
This fixes a crash when using the filechooser for
print-to-file in the print dialog.
Diffstat (limited to 'gtk/gtkfilechooserdialog.c')
-rw-r--r-- | gtk/gtkfilechooserdialog.c | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c index 4f5e9f6ca4..c6c7b9b22e 100644 --- a/gtk/gtkfilechooserdialog.c +++ b/gtk/gtkfilechooserdialog.c @@ -476,38 +476,41 @@ setup_search (GtkFileChooserDialog *dialog) priv->widget, "search-mode", G_BINDING_BIDIRECTIONAL); - box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_widget_set_valign (box, GTK_ALIGN_CENTER); - - label = gtk_label_new (NULL); - gtk_widget_set_halign (label, GTK_ALIGN_CENTER); - gtk_label_set_single_line_mode (GTK_LABEL (label), TRUE); - gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); - gtk_label_set_width_chars (GTK_LABEL (label), 5); - gtk_widget_add_css_class (label, GTK_STYLE_CLASS_TITLE); - gtk_widget_set_parent (label, box); - - g_object_bind_property (dialog, "title", - label, "label", - G_BINDING_SYNC_CREATE); - - label = gtk_label_new (NULL); - gtk_widget_set_halign (label, GTK_ALIGN_CENTER); - gtk_label_set_single_line_mode (GTK_LABEL (label), TRUE); - gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); - gtk_widget_add_css_class (label, GTK_STYLE_CLASS_SUBTITLE); - gtk_widget_set_parent (label, box); - - g_object_bind_property (priv->widget, "subtitle", - label, "label", - G_BINDING_SYNC_CREATE); - g_object_bind_property_full (priv->widget, "subtitle", - label, "visible", - G_BINDING_SYNC_CREATE, - translate_subtitle_to_visible, - NULL, NULL, NULL); - - gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header), box); + if (!priv->has_entry) + { + box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); + gtk_widget_set_valign (box, GTK_ALIGN_CENTER); + + label = gtk_label_new (NULL); + gtk_widget_set_halign (label, GTK_ALIGN_CENTER); + gtk_label_set_single_line_mode (GTK_LABEL (label), TRUE); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_label_set_width_chars (GTK_LABEL (label), 5); + gtk_widget_add_css_class (label, GTK_STYLE_CLASS_TITLE); + gtk_widget_set_parent (label, box); + + g_object_bind_property (dialog, "title", + label, "label", + G_BINDING_SYNC_CREATE); + + label = gtk_label_new (NULL); + gtk_widget_set_halign (label, GTK_ALIGN_CENTER); + gtk_label_set_single_line_mode (GTK_LABEL (label), TRUE); + gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END); + gtk_widget_add_css_class (label, GTK_STYLE_CLASS_SUBTITLE); + gtk_widget_set_parent (label, box); + + g_object_bind_property (priv->widget, "subtitle", + label, "label", + G_BINDING_SYNC_CREATE); + g_object_bind_property_full (priv->widget, "subtitle", + label, "visible", + G_BINDING_SYNC_CREATE, + translate_subtitle_to_visible, + NULL, NULL, NULL); + + gtk_header_bar_set_title_widget (GTK_HEADER_BAR (header), box); + } gtk_container_forall (GTK_CONTAINER (header), add_button, dialog); } |