Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
static void
go_combo_box_popup_hide_unconditional (GOComboBox *combo_box)
{
	gboolean popup_info_destroyed = FALSE;
	GObject *pdc;

	g_return_if_fail (combo_box != NULL);
	g_return_if_fail (GO_IS_COMBO_BOX (combo_box));

	gtk_widget_hide (combo_box->priv->toplevel);
	gtk_widget_hide (combo_box->priv->popup);
	if (combo_box->priv->torn_off)
		go_combo_set_tearoff_state (combo_box, FALSE);

	do_focus_change (combo_box->priv->toplevel, FALSE);
	gtk_grab_remove (combo_box->priv->toplevel);
	gdk_device_ungrab (gtk_get_current_event_device (),
	                   GDK_CURRENT_TIME);

	pdc = g_object_ref (combo_box->priv->popdown_container);
	g_signal_emit (combo_box,
		       go_combo_box_signals [POP_DOWN_DONE], 0,
		       pdc, &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 (pdc);
	set_arrow_state (combo_box, FALSE);
}
Exemplo n.º 4
0
/**
 * go_combo_box_set_tearable:
 * @combo: Combo box
 * @tearable: whether to allow the @combo to be tearable
 *
 * controls whether the combo box's pop up widget can be torn off.
 */
void
go_combo_box_set_tearable (GOComboBox *combo, gboolean tearable)
{
	g_return_if_fail (IS_GO_COMBO_BOX (combo));

	if (tearable){
		gtk_widget_show (combo->priv->tearable);
	} else {
		go_combo_set_tearoff_state (combo, FALSE);
		gtk_widget_hide (combo->priv->tearable);
	}
}
Exemplo n.º 5
0
static gboolean
cb_tearable_button_release (GtkWidget *w, G_GNUC_UNUSED GdkEventButton *event,
			    GOComboBox *combo)
{
	g_return_val_if_fail (w != NULL, FALSE);
	g_return_val_if_fail (GTK_IS_TEAROFF_MENU_ITEM (w), FALSE);

	/* FIXME: should we notify the parent menu? */

	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;
}