GtkFileChooser takes too much time to start

I’m moving from Gtk2 to Gtk3 under Windows. GtkFileChooser takes too much time to start.
The example below takes 6 seconds to start and if I comment FileChooser line, it starts in one second.
If I disconnect my PC from ethernet it takes 25 seconds. If I add other GtkFileChooser objects I have to wait more time.
Is there a way to bypass this behavior?
Thanks

#include <string.h>
#include <stdio.h>
#include <math.h>
#include <gtk/gtk.h>

clock_t ct;

void realize_time (GtkWidget *widget, gpointer   user_data){
	
	printf("time: %d\n", (int) (clock() - ct));
	
}

int main(int argc, char **argv){
	GtkWidget *window, *box, *wid;
/* initialize gtk */
	gtk_init(&argc, &argv);
/* Create new top level window. */
	
	ct = clock();
	 
	window = gtk_window_new( GTK_WINDOW_TOPLEVEL);
		gtk_window_set_default_size (GTK_WINDOW(window),1000,1000);
		gtk_window_set_title(GTK_WINDOW(window), "GL Area");
		gtk_container_set_border_width(GTK_CONTAINER(window), 10);
	box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
		g_object_set (box, "margin", 12, NULL);
		gtk_box_set_spacing (GTK_BOX (box), 6);
		gtk_container_add (GTK_CONTAINER (window), box);

	wid = (GtkWidget *) gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
	gtk_box_pack_start (GTK_BOX(box), wid,1,1, 0);

	wid = (GtkWidget *) gtk_file_chooser_button_new ("File", GTK_FILE_CHOOSER_ACTION_OPEN);
	gtk_box_pack_start (GTK_BOX(box), wid,1,1, 0);

	g_signal_connect(G_OBJECT(wid), "realize", G_CALLBACK(realize_time), NULL);
		
	g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(gtk_main_quit), NULL);
	
	gtk_widget_show_all(GTK_WIDGET(window));
	gtk_main();

	return 0;
}

This behaviour on Windows is typically the result of some slowness in enumerating the drives and volumes available. That work is done in GLib, not GTK.

This looks like GLib issue 2096, which should have been fixed in GLib 2.68, released in March. Could you please try with that?

Thanks for your answer. I compile glib 2.68.1 and replace in the test program (I print glib version to be sure that it calls right library). No change.

After test, I found that the problem is with the cd reader: if it is empty FileChooser takes a lot of time, if I insert a cd in it, FileChooser opens immediatly. Is there a way to bypass this problem?

Not really. The logic is not inside GTK, it’s inside GIO, and there’s no provision to not enumerate mount points.

You probably want to trace the mount point enumeration on Windows, and find out where it’s spending its time.

Ok, my workaround is to disable dvd device from device manager in Windows (maybe usefull for others).
I will post this question to Glib discussion group.
Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.