Re: How to Center Dialogs or Popups Over Any Widget (Source Code Included)



Havoc Pennington wrote:

GTK+ 2.0 supports this natively with GTK_WIN_POS_CENTER_ON_PARENT
(parent being the transient parent from set_transient_for()).
So that will be a better way in the future.

I'll be looking forward to this . . .

present_window() will be the right thing if you want to bring an
existing dialog forward to the user's attention.

and this.


    /*
     * Show.
     */
    gtk_widget_show(window_manager_decides_button);
    gtk_widget_show(center_over_display_button);
    gtk_widget_show(center_over_pointer_button);
    gtk_widget_show(center_over_widget_button);
    gtk_widget_show(label);

gtk_widget_show_all() would save you a lot of typing. ;-)

Well, it's a habit.  I've made a conscience decision to not use
show_all().  It's nice, but I'll often discover a need to have a
couple of widgets hidden on startup.

I just find it more maintainable to put in all the show() calls while
the layout is still fresh in my head.  It's just a little protection
against a possible future burden of adding a hidden widget to a
complicated layout.  I wouldn't expect most people to agree with that
logic though, and you're right, it doesn't make much sense for this
example.


Paul Serice




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