Hi Kjell,

Thank you for your response. Your answer works perfectly fine. The popup
window displayed & hided as expected.

But I also want to propose another solution that I have found to work quite
well too, so people that later visit this thread will be aware of this.

I found out that Gtk::WINDOW_POPUP does not need to be in a
Gtk::Main::run() to be shown. I can just call show() & hide() without
calling the Gtk::Main::run() on the d_popup_win since calling
Gtk::Main::run() on d_popup_win plus calling hide() will make the main loop
stop & the whole program quit.

So my solution was not to call Gtk::Main::run(d_popup_win) at all and
instead just call d_popup_win.show() & d_popup_win.hide() when I need to
show & hide d_popup_win, since d_popup_win is only a Gtk::WINDOW_POPUP and
it only serves as a container for the control widgets of the fullscreen()
mode.

On Wed, Nov 23, 2011 at 5:01 AM, Kjell Ahlstedt <[email protected]
> wrote:

>  2011-11-21 13:01, Phong Cao skrev:
>
> Hello everybody,
>
>  I am writing a small media player that allows the users to click on
> Gtk::DrawingArea to switch to fullscreen() or unfullscreen() mode, as well
> as hide() or show() a popup window (which is used to put
> play/pause/stop/progress widgets on top to control the progress of the
> video)
> - When the users do a double right-click, the main window will be
> fullscreen() or unfullscreen().
> - If the users do a right-click, and the window is in fullscreen() mode,
> the popup window will be hide() or show().
>
>  However, whenever I switch to fullscreen() mode (which also show() the
> popup window), then right-click 3 times (hide(), show(), then hide() the
> popup window), the whole program suddenly quits. I dont know why this
> happens and whether this is because of me.
>
>  I already attached the source code of the program with this email. If
> you can please download and see what I did wrong.
>
>  Just uncompress it & run `make` to compile. My program uses gtkmm-3.0
>
>  Thank you for reading my message! Have a good Thanksgiving!
>
>  Best regards,
>
>  --
> Phong V. Cao
> [email protected]
>
>  You need one Gtk::Main::run(d_popup_win) for each d_popup_win.hide(),
> otherwise the main loop that was started by Gtk::Main::run(topwin) in
> main.cc ends. Add a line in TopWin::onDrawingAreaClicked:
>
> else if ((event->type == GDK_BUTTON_PRESS) && (event->button == 3)) {
>     if (is_fullscreen) {
>     // if we are in fullscreen mode...
>
>       if (is_hide) {
>         // ...and d_popup_win is hidden then show d_popup_win
>         d_popup_win.show();
>         is_hide = false;
>
>       Gtk::Main::run(d_popup_win); // !!! added
>       }
>
> A question that you don't have to answer: Are you really sure you don't
> want to use a Gtk::Dialog instead?
>
> Kjell Ahlstedt
>



-- 
Phong V. Cao
[email protected]
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to