Beispiel #1
0
static void
cb_toolbar_reconfigured (GOToolComboPixmaps *tool, GtkAction *a)
{
	GtkOrientation o = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (tool));
	GtkReliefStyle relief = gtk_tool_item_get_relief_style (GTK_TOOL_ITEM (tool));
	GOActionComboPixmaps *paction = (GOActionComboPixmaps *)a;
	GOActionComboPixmapsElement const *el = paction->elements;

	g_object_set (G_OBJECT (tool->combo),
		      "show-arrow", o == GTK_ORIENTATION_HORIZONTAL,
		      NULL);

	go_combo_pixmaps_clear_elements (tool->combo);
	for ( ; el->stock_id != NULL ; el++) {
		GdkPixbuf *icon = make_icon (a, el->stock_id, GTK_WIDGET (tool));
		/*
		 * FIXME FIXME FIXME: we must find a better solution for
		 * translating strings not in goffice domain
		 */
		go_combo_pixmaps_add_element (tool->combo,
					      icon,
					      el->id,
					      gettext (el->untranslated_tooltip));
	}
	go_combo_pixmaps_select_id (tool->combo, paction->selected_id);

	go_combo_box_set_relief (GO_COMBO_BOX (tool->combo), relief);
}
void
go_combo_box_construct (GOComboBox *combo,
			GtkWidget *display_widget,
			GtkWidget *popdown_container,
			G_GNUC_UNUSED GtkWidget *popdown_focus)
{
	GtkWidget *tearable;
	GtkWidget *vbox;

	g_return_if_fail (GO_IS_COMBO_BOX (combo));

	gtk_box_set_spacing (GTK_BOX (combo), 0);
	gtk_box_set_homogeneous (GTK_BOX (combo), FALSE);

	combo->priv->popdown_container = popdown_container;
	combo->priv->display_widget = NULL;

	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	tearable = gtk_tearoff_menu_item_new ();
	g_signal_connect (tearable, "enter-notify-event",
			  G_CALLBACK (cb_tearable_enter_leave),
			  GINT_TO_POINTER (TRUE));
	g_signal_connect (tearable, "leave-notify-event",
			  G_CALLBACK (cb_tearable_enter_leave),
			  GINT_TO_POINTER (FALSE));
	g_signal_connect (tearable, "button-release-event",
			  G_CALLBACK (cb_tearable_button_release),
			  (gpointer) combo);
	g_signal_connect (tearable, "parent-set",
			  G_CALLBACK (cb_tearable_parent_changed),
			  (gpointer) combo);
	gtk_box_pack_start (GTK_BOX (vbox), tearable, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), popdown_container, TRUE, TRUE, 0);
	combo->priv->tearable = tearable;
	g_object_set (tearable, "no-show-all", TRUE, NULL);

	go_combo_box_set_tearable (combo, FALSE);

	go_combo_box_set_relief (combo, GTK_RELIEF_NORMAL);

	go_combo_box_set_display (combo, display_widget);
	gtk_container_add (GTK_CONTAINER (combo->priv->frame), vbox);
	gtk_widget_show_all (combo->priv->frame);
}