[Glade-users] glade and/or gtkmm, insert a FileChooserDialog inside a Notebook tab

On Fri, Jan 30, 2015 at 8:44 PM, Nicolas J?ger <jagernicolas at legtux.org> wrote:

However, since the introduction of GIO and D-Bus, it is (strictly
speaking) unsafe to use that paradigm, I don't have all the details
on this fresh on my mind, I'm sure that Ryan Lortie could explain
this in better detail. But essentially you are running a nested
mainloop in the same global GMainContext, asynchronous responses
to any D-Bus calls, possibly not triggered even by your own code,
will also be processed while the dialog is 'running', which makes
things typically hard to track.

I imagine that an application using gtk has at least one thread per
widget, certainly more than one. I'm a little aware about problems
related to asynchronous programming. It's also for that reason I'm not
very excited by the idea to use a thread to set my issue...

Certainly not, GTK+ runs in a single thread for the most part right now (however
it's possible that in future developments, some of the rendering can be deferred
to another thread).

However some things, like file monitoring and such desktop integration, can
be implemented under the hood as threads or as D-Bus notifications (wrapped
under abstractions in GIO).

I'm curious about something, when you are using a file chooser dialog,
I guess you are not using `run()`, but somewhere in your program you
must wait that user has decided where he want to save his file. How do
you make your program waiting ?

You dont.

Instead you let the user fire up a file chooser dialog and make sure that that
file chooser dialog is 'modal' (so that the user cannot interact with any other
components in your app).

Then you keep on trucking in your mainloop, at this point you may have some
state (like "the filechooser dialog is open"), so you might avoid doing things
in your mainloop that you would otherwise do - usually that isnt needed, but
it's possible.

Then one day, the user clicks "Cancel" in the file chooser dialog, and then
your "response" signal fires... OK, nothing to do here... carry on...

When it happens that the "Save" button was clicked and you get the appropriate
response ... then it's time to do something - then you have an action requested
by the user, to save something, complete with a selected file and all.

The only thing you have to do when the user performs an action which requires
a dialog be shown, is create that modal dialog, show it, make sure you have
a callback connected to "response", and then return.


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