[evolution-data-server/wip/mcrha/gtk4] Cover EWebDAVDiscoverWidget/Dialog



commit 1b5384c7c5cd9cedf4c4bab9fff90bc69b9ea815
Author: Milan Crha <mcrha redhat com>
Date:   Fri Oct 15 12:37:12 2021 +0200

    Cover EWebDAVDiscoverWidget/Dialog

 src/libedataserverui/e-webdav-discover-widget.c | 48 +++++++++++++++++++++----
 1 file changed, 42 insertions(+), 6 deletions(-)
---
diff --git a/src/libedataserverui/e-webdav-discover-widget.c b/src/libedataserverui/e-webdav-discover-widget.c
index 812a2f513..280014ba3 100644
--- a/src/libedataserverui/e-webdav-discover-widget.c
+++ b/src/libedataserverui/e-webdav-discover-widget.c
@@ -165,11 +165,19 @@ e_webdav_discover_content_new (ECredentialsPrompter *credentials_prompter,
                "valign", GTK_ALIGN_FILL,
                NULL);
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+       scrolled_window = gtk_scrolled_window_new ();
+#else
        scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+#endif
        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+       gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (scrolled_window), tree_view);
+#else
        gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
+#endif
        gtk_grid_attach (GTK_GRID (self), scrolled_window, 0, 0, 1, 1);
 
        self->sources_tree_view = GTK_TREE_VIEW (tree_view);
@@ -204,8 +212,13 @@ e_webdav_discover_content_new (ECredentialsPrompter *credentials_prompter,
                widget = gtk_label_new_with_mnemonic (_("_User mail:"));
                gtk_label_set_mnemonic_widget (GTK_LABEL (widget), GTK_WIDGET (self->email_addresses_combo));
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+               gtk_box_append (GTK_BOX (box), widget);
+               gtk_box_append (GTK_BOX (box), GTK_WIDGET (self->email_addresses_combo));
+#else
                gtk_container_add (GTK_CONTAINER (box), widget);
                gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (self->email_addresses_combo));
+#endif
 
                g_object_set (G_OBJECT (widget),
                        "hexpand", FALSE,
@@ -231,7 +244,10 @@ e_webdav_discover_content_new (ECredentialsPrompter *credentials_prompter,
                gtk_grid_attach (GTK_GRID (self), box, 0, 1, 1, 1);
        }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
        gtk_widget_show_all (GTK_WIDGET (self));
+#endif
+
        return GTK_WIDGET (self);
 }
 
@@ -624,7 +640,7 @@ refresh_data_free (gpointer data)
 
                if (content) {
                        if (content->info_bar && gtk_info_bar_get_message_type (content->info_bar) == 
GTK_MESSAGE_INFO) {
-                               gtk_widget_destroy (GTK_WIDGET (content->info_bar));
+                               g_object_unref (G_OBJECT (content->info_bar));
                                content->info_bar = NULL;
                        }
 
@@ -748,7 +764,14 @@ e_webdav_discover_content_refresh_done_cb (GObject *source_object,
                        GtkWindow *parent;
                        GtkWidget *widget;
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+                       widget = GTK_WIDGET (rd->content);
+                       while (widget && !GTK_IS_WINDOW (widget)) {
+                               widget = gtk_widget_get_parent (widget);
+                       }
+#else
                        widget = gtk_widget_get_toplevel (GTK_WIDGET (rd->content));
+#endif
                        parent = widget ? GTK_WINDOW (widget) : NULL;
 
                        e_trust_prompt_run_for_source (parent, source, certificate_pem, certificate_errors,
@@ -897,13 +920,17 @@ e_webdav_discover_content_refresh (GtkWidget *content,
                gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (self->email_addresses_combo));
 
        if (self->info_bar)
-               gtk_widget_destroy (GTK_WIDGET (self->info_bar));
+               g_object_unref (G_OBJECT (self->info_bar));
 
        self->info_bar = GTK_INFO_BAR (gtk_info_bar_new_with_buttons (_("Cancel"), GTK_RESPONSE_CANCEL, 
NULL));
        gtk_info_bar_set_message_type (self->info_bar, GTK_MESSAGE_INFO);
        gtk_info_bar_set_show_close_button (self->info_bar, FALSE);
        label = gtk_label_new (_("Searching server sources..."));
+#if GTK_CHECK_VERSION(4, 0, 0)
+       gtk_info_bar_add_child (self->info_bar, label);
+#else
        gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (self->info_bar)), label);
+#endif
        gtk_widget_show (label);
        gtk_widget_show (GTK_WIDGET (self->info_bar));
 
@@ -962,7 +989,7 @@ e_webdav_discover_info_bar_error_response_cb (GtkInfoBar *info_bar,
 
        self = (EWebDAVDiscoverContent *)content;
        if (self->info_bar == info_bar) {
-               gtk_widget_destroy (GTK_WIDGET (self->info_bar));
+               g_object_unref (G_OBJECT (self->info_bar));
                self->info_bar = NULL;
        }
 }
@@ -989,7 +1016,7 @@ e_webdav_discover_content_show_error (GtkWidget *content,
 
        self = (EWebDAVDiscoverContent *)content;
        if (self->info_bar) {
-               gtk_widget_destroy (GTK_WIDGET (self->info_bar));
+               g_object_unref (G_OBJECT (self->info_bar));
                self->info_bar = NULL;
        }
 
@@ -1003,11 +1030,16 @@ e_webdav_discover_content_show_error (GtkWidget *content,
        label = gtk_label_new (error->message);
        gtk_label_set_width_chars (GTK_LABEL (label), 20);
        gtk_label_set_max_width_chars (GTK_LABEL (label), 120);
-       gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
        gtk_label_set_selectable (GTK_LABEL (label), TRUE);
+#if GTK_CHECK_VERSION(4, 0, 0)
+       gtk_label_set_wrap (GTK_LABEL (label), TRUE);
+       gtk_info_bar_add_child (self->info_bar, label);
+#else
+       gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
        gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (self->info_bar)), label);
        gtk_widget_show (label);
        gtk_widget_show (GTK_WIDGET (self->info_bar));
+#endif
 
        g_signal_connect (self->info_bar, "response", G_CALLBACK 
(e_webdav_discover_info_bar_error_response_cb), content);
 
@@ -1066,7 +1098,7 @@ e_webdav_discover_dialog_init (EWebDAVDiscoverDialog *self)
  * can be asked for currently selected source(s).
  *
  * Returns: (transfer full): a newly created #GtkDialog, which should be freed
- * with gtk_widget_destroy(), when no longer needed.
+ * with g_object_unref(), when no longer needed.
  *
  * Since: 3.18
  **/
@@ -1107,7 +1139,11 @@ e_webdav_discover_dialog_new (GtkWindow *parent,
                NULL);
 
        container = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+#if GTK_CHECK_VERSION(4, 0, 0)
+       gtk_box_append (GTK_BOX (container), widget);
+#else
        gtk_container_add (GTK_CONTAINER (container), widget);
+#endif
 
        selection = e_webdav_discover_content_get_tree_selection (widget);
        g_signal_connect (selection, "changed", G_CALLBACK (e_webdav_discover_content_selection_changed_cb), 
dialog);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]