From 15c6760a96379ba8c6e6ed21bcc3683437a7bfeb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 29 Aug 2020 16:00:01 -0400 Subject: [PATCH 1/3] print dialog: Prevent cascading paper dialogs We trigger the paper dialog when the "manage" item in the dropdown is selected. But the selection also changes due to internal changes, such as reloading the custom paper list when the paper dialog is closed. We need to be extra careful to avoid triggering another paper dialog when that happens. --- gtk/gtkprintunixdialog.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c index 5375926db4..b7e486fb30 100644 --- a/gtk/gtkprintunixdialog.c +++ b/gtk/gtkprintunixdialog.c @@ -1614,7 +1614,7 @@ set_paper_size (GtkPrintUnixDialog *dialog, if (page_setup == NULL) return FALSE; - model = G_LIST_MODEL (dialog->page_setup_list); + model = gtk_drop_down_get_model (GTK_DROP_DOWN (dialog->paper_size_combo)); for (i = 0; i < g_list_model_get_n_items (model); i++) { list_page_setup = g_list_model_get_item (model, i); @@ -2901,9 +2901,8 @@ custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog, { GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (user_data); - gtk_print_load_custom_papers (dialog->custom_paper_list); - dialog->internal_page_setup_change = TRUE; + gtk_print_load_custom_papers (dialog->custom_paper_list); update_paper_sizes (dialog); dialog->internal_page_setup_change = FALSE; From 8e74687ab30a9579234da3e0d8d92ae22aaee19a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 29 Aug 2020 16:29:28 -0400 Subject: [PATCH 2/3] page setup dialog: Prevent cascading paper dialogs We trigger the paper dialog when the "manage" item in the dropdown is selected. But the selection also changes due to internal changes, such as reloading the custom paper list when the paper dialog is closed. We need to be extra careful to avoid triggering another paper dialog when that happens. Fixes: #3098 --- gtk/gtkpagesetupunixdialog.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/gtk/gtkpagesetupunixdialog.c b/gtk/gtkpagesetupunixdialog.c index 190a9f7e9a..ed8135eb34 100644 --- a/gtk/gtkpagesetupunixdialog.c +++ b/gtk/gtkpagesetupunixdialog.c @@ -81,6 +81,8 @@ struct _GtkPageSetupUnixDialog GtkPrintSettings *print_settings; + gboolean internal_change; + /* Save last setup so we can re-set it after selecting manage custom sizes */ GtkPageSetup *last_setup; }; @@ -273,6 +275,7 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog) GtkFilter *filter; GtkPageSetup *page_setup; + dialog->internal_change = TRUE; dialog->print_backends = NULL; gtk_widget_init_template (GTK_WIDGET (dialog)); @@ -337,6 +340,7 @@ gtk_page_setup_unix_dialog_init (GtkPageSetupUnixDialog *dialog) /* Load data */ gtk_print_load_custom_papers (dialog->custom_paper_list); load_print_backends (dialog); + dialog->internal_change = FALSE; } static void @@ -638,11 +642,19 @@ custom_paper_dialog_response_cb (GtkDialog *custom_paper_dialog, gpointer user_data) { GtkPageSetupUnixDialog *dialog = GTK_PAGE_SETUP_UNIX_DIALOG (user_data); + GtkPageSetup *last_page_setup; + dialog->internal_change = TRUE; gtk_print_load_custom_papers (dialog->custom_paper_list); - - /* Update printer page list */ printer_changed_callback (GTK_DROP_DOWN (dialog->printer_combo), NULL, dialog); + dialog->internal_change = FALSE; + + if (dialog->last_setup) + last_page_setup = g_object_ref (dialog->last_setup); + else + last_page_setup = gtk_page_setup_new (); /* "good" default */ + set_paper_size (dialog, last_page_setup, FALSE, TRUE); + g_object_unref (last_page_setup); gtk_window_destroy (GTK_WINDOW (custom_paper_dialog)); } @@ -660,6 +672,9 @@ paper_size_changed (GtkDropDown *combo_box, GtkLabel *label; const char *unit_str; + if (dialog->internal_change) + return; + label = GTK_LABEL (dialog->paper_size_label); selected = gtk_drop_down_get_selected (GTK_DROP_DOWN (combo_box)); From c51f69c446648312f1eba9c2baaef5ef6a0ae1fb Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 29 Aug 2020 16:42:30 -0400 Subject: [PATCH 3/3] gtk-demo: Cosmetic change to the css shadows demo Make the text view in the bottom take up the bulk of the window, as it used to be. --- demos/gtk-demo/css_shadows.c | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/gtk-demo/css_shadows.c b/demos/gtk-demo/css_shadows.c index 74236c6f3c..cb534a451c 100644 --- a/demos/gtk-demo/css_shadows.c +++ b/demos/gtk-demo/css_shadows.c @@ -106,6 +106,7 @@ do_css_shadows (GtkWidget *do_widget) child = create_toolbar (); gtk_paned_set_start_child (GTK_PANED (paned), child); + gtk_paned_set_resize_start_child (GTK_PANED (paned), FALSE); text = gtk_text_buffer_new (NULL); gtk_text_buffer_create_tag (text,