Using a GtkFileDialog with multiple GtkWindows in a GtkStack

I have a simple GTK Application, that concists of a GtkStack that contains three GtkWindow objects. Each GtkWindow represents a different area/page/mode of the application. In other words, at a particular moment, the user should be seeing just one of these three pages.

The first page of the application, which is the first window that the user sees when the application starts, contains a button. When this button get’s pressed, I want to open a GtkFileDialog (or a GtkFileChooser), to let the user choose a particular file to work with.

A quick sketch of the application structure:

Reading the documentation, it seems that any GtkFileDialog object is actually a GtkWindow object under the hood, and also, any GtkFileDialog must be associated with an existing parent GtkWindow.

Since my GtkWindow objects are inside a GtkStack, and only one GtkWindow can be shown at a time in a GtkStack, my question is: “is my application structure wrong? Should I use a different structure?”

In other words, my concern is that the GtkStack might block the GtkFileDialog to be displayed, either as a modal or not. I have made some tests, trying to follow this structure, but I’m getting a segmentation fault error.

I think you are misunderstanding what GtkFileDialog is, or does.

A GtkFileDialog is a “fire and forget” object: you create an instance when you want to let the user select a file; you start an asynchronous operation with it, and when the operation is completed, you release the reference you have on the instance you created.

Your application’s structure has no bearing or influence on GtkFileDialog; in most Linux systems, the file selection dialog is not even going to be in the same process as your application.

1 Like

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