Unable to place a window on top on another window

Main Application runs

An user event like button click triggers a task.

Task progress is shown using progress bar on a different window

I call the window with the progress bar when the task starts.

I try using

grab_focus(),
present(),
set_keep_above(true) and 
show_all() 

In this specific order on the progress bar window, but the main application window always stays on top. Only after when the task gets completed the progress bar window appears.

Desired result

  1. Show Progress bar window on top of application window when the task starts
  2. Hide Progress bar window leave only the application window to be shown when the task ends

What am i doing wrong?
How do I achieve the desired work flow of the two windows to be in syn?

I suspect that your application need to be multi-threaded with two threads.
One thread handles the UI, the other thread executes the task.

There is an example of a multi-threaded application in the gtkmm tutorial.

gtkmm tutorial, multi-threaded programs
source code

I assume that you use gtkmm3. show_all() does not exist in gtkmm4.

Your application becomes more complicated, unfortunately.

Just needed to call

  while(Gtk::Main::events_pending())
    Gtk::Main::iteration();

After every update message to the progress bar

Don’t do that, please: it’s just a workaround for a broken design. You’re interrupting the main loop with some synchronous operation, and thus you’re preventing anything else that GTK or other dependencies are doing.

1 Like

Yes a workaround. But for the current situation a big chunk of code had to be removed from the GUI and placed into the core for which I don’t have time. I do understand what you are trying to say but I don’t have control over the design.

Set the progress window modal and transient for main window.

Ideally, use an osd progress bar on main window.

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