static void gtk_tearoff_menu_item_parent_set (GtkWidget *widget, GtkWidget *previous) { GtkTearoffMenuItem *tearoff_menu_item = GTK_TEAROFF_MENU_ITEM (widget); GtkTearoffMenuItemPrivate *priv = tearoff_menu_item->priv; GtkMenu *menu; GtkWidget *parent; parent = gtk_widget_get_parent (widget); menu = GTK_IS_MENU (parent) ? GTK_MENU (parent) : NULL; if (previous) g_signal_handlers_disconnect_by_func (previous, tearoff_state_changed, tearoff_menu_item); if (menu) { priv->torn_off = gtk_menu_get_tearoff_state (menu); g_signal_connect (menu, "notify::tearoff-state", G_CALLBACK (tearoff_state_changed), tearoff_menu_item); } }
static gboolean cb_tearable_button_release (GtkWidget *w, GdkEventButton *event, GOComboBox *combo) { GtkTearoffMenuItem *tearable; g_return_val_if_fail (w != NULL, FALSE); g_return_val_if_fail (GTK_IS_TEAROFF_MENU_ITEM (w), FALSE); tearable = GTK_TEAROFF_MENU_ITEM (w); tearable->torn_off = !tearable->torn_off; if (!combo->priv->torn_off) { gboolean need_connect; need_connect = (!combo->priv->tearoff_window); go_combo_set_tearoff_state (combo, TRUE); if (need_connect) g_signal_connect_swapped (combo->priv->tearoff_window, "delete_event", G_CALLBACK (cb_popup_delete), combo); } else go_combo_box_popup_hide_unconditional (combo); return TRUE; }
static void go_combo_box_popup_hide_unconditional (GOComboBox *combo_box) { gboolean popup_info_destroyed = FALSE; g_return_if_fail (combo_box != NULL); g_return_if_fail (IS_GO_COMBO_BOX (combo_box)); gtk_widget_hide (combo_box->priv->toplevel); gtk_widget_hide (combo_box->priv->popup); if (combo_box->priv->torn_off) { GTK_TEAROFF_MENU_ITEM (combo_box->priv->tearable)->torn_off = FALSE; go_combo_set_tearoff_state (combo_box, FALSE); } do_focus_change (combo_box->priv->toplevel, FALSE); gtk_grab_remove (combo_box->priv->toplevel); gdk_display_pointer_ungrab (gtk_widget_get_display (combo_box->priv->toplevel), GDK_CURRENT_TIME); g_object_ref (combo_box->priv->popdown_container); g_signal_emit (combo_box, go_combo_box_signals [POP_DOWN_DONE], 0, combo_box->priv->popdown_container, &popup_info_destroyed); if (popup_info_destroyed){ gtk_container_remove ( GTK_CONTAINER (combo_box->priv->frame), combo_box->priv->popdown_container); combo_box->priv->popdown_container = NULL; } g_object_unref (combo_box->priv->popdown_container); set_arrow_state (combo_box, FALSE); }
static void tearoff_state_changed (GtkMenu *menu, GParamSpec *pspec, gpointer data) { GtkTearoffMenuItem *tearoff_menu_item = GTK_TEAROFF_MENU_ITEM (data); tearoff_menu_item->torn_off = gtk_menu_get_tearoff_state (menu); }