/** * go_combo_popup_tear_off * @combo: Combo box * @set_position: Set to position of popup shell if true * * Tear off the popup * * FIXME: * Gtk popup menus are toplevel windows, not dialogs. I think this is wrong, * and make the popups dialogs. But may be there should be a way to make * them toplevel. We can do this after creating: * GTK_WINDOW (tearoff)->type = GTK_WINDOW_TOPLEVEL; */ static void go_combo_popup_tear_off (GOComboBox *combo, gboolean set_position) { int x, y; if (!combo->priv->tearoff_window) { GtkWidget *tearoff; gchar const *title; /* FIXME: made this a toplevel, not a dialog ! */ tearoff = gtk_window_new (GTK_WINDOW_TOPLEVEL); #if GLIB_CHECK_VERSION(2,10,0) && GTK_CHECK_VERSION(2,8,14) g_object_ref_sink (tearoff); #else g_object_ref (tearoff); gtk_object_sink (GTK_OBJECT (tearoff)); #endif combo->priv->tearoff_window = tearoff; gtk_widget_set_app_paintable (tearoff, TRUE); g_signal_connect (tearoff, "key_press_event", G_CALLBACK (cb_combo_keypress), combo); gtk_widget_realize (tearoff); title = go_combo_box_get_title (combo); if (title) gdk_window_set_title (tearoff->window, title); g_object_set (G_OBJECT (tearoff), "allow-shrink", FALSE, "allow-grow", TRUE, NULL); gtk_window_set_transient_for (GTK_WINDOW (tearoff), GTK_WINDOW (gtk_widget_get_toplevel GTK_WIDGET (combo))); } if (GTK_WIDGET_VISIBLE (combo->priv->popup)) { gtk_widget_hide (combo->priv->toplevel); gtk_grab_remove (combo->priv->toplevel); gdk_display_pointer_ungrab (gtk_widget_get_display (combo->priv->toplevel), GDK_CURRENT_TIME); } go_combo_popup_reparent (combo->priv->popup, combo->priv->tearoff_window, FALSE); /* It may have got confused about size */ gtk_widget_queue_resize (GTK_WIDGET (combo->priv->popup)); if (set_position) { go_combo_box_get_pos (combo, &x, &y); gtk_window_move (GTK_WINDOW (combo->priv->tearoff_window), x, y); } gtk_widget_show (GTK_WIDGET (combo->priv->popup)); gtk_widget_show (combo->priv->tearoff_window); }
/** * go_combo_popup_tear_off * @combo: Combo box * @set_position: Set to position of popup shell if true * * Tear off the popup * * FIXME: * Gtk popup menus are toplevel windows, not dialogs. I think this is wrong, * and make the popups dialogs. But may be there should be a way to make * them toplevel. We can do this after creating: * GTK_WINDOW (tearoff)->type = GTK_WINDOW_TOPLEVEL; */ static void go_combo_popup_tear_off (GOComboBox *combo, gboolean set_position) { int x, y; if (!combo->priv->tearoff_window) { GtkWidget *tearoff; gchar const *title; /* FIXME: made this a toplevel, not a dialog ! */ tearoff = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_object_ref_sink (tearoff); combo->priv->tearoff_window = tearoff; gtk_widget_set_app_paintable (tearoff, TRUE); g_signal_connect (tearoff, "key_press_event", G_CALLBACK (cb_combo_keypress), combo); gtk_widget_realize (tearoff); title = go_combo_box_get_title (combo); if (title) gdk_window_set_title (gtk_widget_get_window (tearoff), title); gtk_window_set_transient_for (GTK_WINDOW (tearoff), GTK_WINDOW (gtk_widget_get_toplevel GTK_WIDGET (combo))); } if (gtk_widget_get_visible (combo->priv->popup)) { gtk_widget_hide (combo->priv->toplevel); gtk_grab_remove (combo->priv->toplevel); gdk_device_ungrab (gtk_get_current_event_device (), GDK_CURRENT_TIME); } go_combo_popup_reparent (combo->priv->popup, combo->priv->tearoff_window, FALSE); /* It may have got confused about size */ gtk_widget_queue_resize (GTK_WIDGET (combo->priv->popup)); if (set_position) { go_combo_box_get_pos (combo, &x, &y); gtk_window_move (GTK_WINDOW (combo->priv->tearoff_window), x, y); } gtk_widget_show (GTK_WIDGET (combo->priv->popup)); gtk_widget_show (combo->priv->tearoff_window); }