}
}
-static void
-attach_widget_hierarchy_changed (GtkWidget *attach_widget,
- GtkWidget *previous_toplevel,
- gpointer data)
-{
- GtkMenu *menu = GTK_MENU (data);
- GtkWidget *new_toplevel = gtk_widget_get_toplevel (attach_widget);
-
- if (g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen"))
- {
- /* If there is an explicit screen set, then don't set WM_TRANSIENT_FOR.
- * Because, what would happen if the attach widget moved to a different
- * screen on a different display? The menu wouldn't move along with it,
- * so we just make it the responsibility of whoever set the screen to
- * also set WM_TRANSIENT_FOR.
- */
- return;
- }
-
- if (menu->toplevel && !g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen") &&
- (!new_toplevel || GTK_IS_WINDOW (new_toplevel)))
- {
- gtk_window_set_transient_for (GTK_WINDOW (menu->toplevel),
- GTK_WINDOW (new_toplevel));
- }
-}
-
void
gtk_menu_attach_to_widget (GtkMenu *menu,
GtkWidget *attach_widget,
G_CALLBACK (attach_widget_screen_changed), menu);
attach_widget_screen_changed (attach_widget, NULL, menu);
- g_signal_connect (attach_widget, "hierarchy_changed",
- G_CALLBACK (attach_widget_hierarchy_changed), menu);
- attach_widget_hierarchy_changed (attach_widget, NULL, menu);
-
data->detacher = detacher;
g_object_set_data (G_OBJECT (menu), I_(attach_data_key), data);
list = g_object_steal_data (G_OBJECT (attach_widget), ATTACHED_MENUS);
g_signal_handlers_disconnect_by_func (data->attach_widget,
(gpointer) attach_widget_screen_changed,
menu);
- g_signal_handlers_disconnect_by_func (data->attach_widget,
- (gpointer) attach_widget_hierarchy_changed,
- menu);
- attach_widget_hierarchy_changed (data->attach_widget, NULL, menu);
if (data->detacher)
data->detacher (data->attach_widget, menu);
GtkMenuShell *menu_shell;
gboolean grab_keyboard;
GtkMenuPrivate *priv;
+ GtkWidget *parent_toplevel;
g_return_if_fail (GTK_IS_MENU (menu));
gtk_menu_reparent (menu, menu->toplevel, FALSE);
}
-
+
+ parent_toplevel = NULL;
if (parent_menu_shell)
+ parent_toplevel = gtk_widget_get_toplevel (parent_menu_shell);
+ else if (!g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen"))
{
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (parent_menu_shell);
- if (GTK_IS_WINDOW (toplevel))
- gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (toplevel)),
- GTK_WINDOW (menu->toplevel));
+ GtkWidget *attach_widget = gtk_menu_get_attach_widget (menu);
+ if (attach_widget)
+ parent_toplevel = gtk_widget_get_toplevel (attach_widget);
}
+
+ /* Set transient for to get the right window group and parent relationship */
+ if (parent_toplevel && GTK_IS_WINDOW (parent_toplevel))
+ gtk_window_set_transient_for (GTK_WINDOW (menu->toplevel),
+ GTK_WINDOW (parent_toplevel));
menu->parent_menu_item = parent_menu_item;
menu->position_func = func;
{
GtkMenuPrivate *private;
GtkMenuShell *menu_shell;
- gboolean had_parent;
g_return_if_fail (GTK_IS_MENU (menu));
menu_shell = GTK_MENU_SHELL (menu);
private = gtk_menu_get_private (menu);
- had_parent = menu_shell->parent_menu_shell != NULL;
menu_shell->parent_menu_shell = NULL;
menu_shell->active = FALSE;
menu_shell->ignore_enter = FALSE;
/* The X Grab, if present, will automatically be removed when we hide
* the window */
gtk_widget_hide (menu->toplevel);
- if (had_parent)
- gtk_window_group_add_window (gtk_window_get_group (NULL), GTK_WINDOW (menu->toplevel));
+ gtk_window_set_transient_for (GTK_WINDOW (menu->toplevel), NULL);
if (menu->torn_off)
{
static void gtk_print_unix_dialog_destroy (GtkPrintUnixDialog *dialog);
static void gtk_print_unix_dialog_finalize (GObject *object);
-static GObject* gtk_print_unix_dialog_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params);
static void gtk_print_unix_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
widget_class = (GtkWidgetClass *) class;
object_class->finalize = gtk_print_unix_dialog_finalize;
- object_class->constructor = gtk_print_unix_dialog_constructor;
object_class->set_property = gtk_print_unix_dialog_set_property;
object_class->get_property = gtk_print_unix_dialog_get_property;
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
-}
-
-static GObject *
-gtk_print_unix_dialog_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params)
-{
- GtkPrintUnixDialog *dialog;
- GObject *object;
-
- object =
- G_OBJECT_CLASS (gtk_print_unix_dialog_parent_class)->constructor (type,
- n_construct_properties,
- construct_params);
- /* We need to populate the dialog after the transient-to has been set.
- * See bug #340401.
- */
- dialog = GTK_PRINT_UNIX_DIALOG (object);
- populate_dialog (dialog);
-
- return object;
+ populate_dialog (dialog);
}
-
static void
gtk_print_unix_dialog_destroy (GtkPrintUnixDialog *dialog)
{
guint accept_focus : 1;
guint focus_on_map : 1;
guint deletable : 1;
+ guint transient_parent_group : 1;
guint reset_type_hint : 1;
GdkWindowTypeHint type_hint;
static void
gtk_window_unset_transient_for (GtkWindow *window)
{
+ GtkWindowPrivate *priv = GTK_WINDOW_GET_PRIVATE (window);
+
if (window->transient_parent)
{
- if (window->transient_parent->group)
- gtk_window_group_remove_window (window->transient_parent->group,
+ if (priv->transient_parent_group)
+ gtk_window_group_remove_window (window->group,
window);
g_signal_handlers_disconnect_by_func (window->transient_parent,
disconnect_parent_destroyed (window);
window->transient_parent = NULL;
+ priv->transient_parent_group = FALSE;
}
}
gtk_window_set_transient_for (GtkWindow *window,
GtkWindow *parent)
{
+ GtkWindowPrivate *priv = GTK_WINDOW_GET_PRIVATE (window);
+
g_return_if_fail (GTK_IS_WINDOW (window));
g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
g_return_if_fail (window != parent);
}
window->transient_parent = parent;
-
+
if (parent)
{
g_signal_connect (parent, "destroy",
GTK_WIDGET (window));
if (parent->group)
- gtk_window_group_add_window (parent->group, window);
+ {
+ gtk_window_group_add_window (parent->group, window);
+ priv->transient_parent_group = TRUE;
+ }
}
}