void AP_UnixDialog_Paragraph::_populateWindowData(void)
{

	// alignment option menu
	UT_ASSERT(m_listAlignment);
	XAP_comboBoxSetActiveFromIntCol(GTK_COMBO_BOX(m_listAlignment), 1, 
									(gint) _getMenuItemValue(id_MENU_ALIGNMENT));

	// indent and paragraph margins
	UT_ASSERT(m_spinbuttonLeft);
	gtk_entry_set_text(GTK_ENTRY(m_spinbuttonLeft),
					   (const gchar *) _getSpinItemValue(id_SPIN_LEFT_INDENT));

	UT_ASSERT(m_spinbuttonRight);
	gtk_entry_set_text(GTK_ENTRY(m_spinbuttonRight),
					   (const gchar *) _getSpinItemValue(id_SPIN_RIGHT_INDENT));

	UT_ASSERT(m_spinbuttonBy);
	gtk_entry_set_text(GTK_ENTRY(m_spinbuttonBy),
					   (const gchar *) _getSpinItemValue(id_SPIN_SPECIAL_INDENT));

	UT_ASSERT(m_listSpecial);
	XAP_comboBoxSetActiveFromIntCol(GTK_COMBO_BOX(m_listSpecial), 1,
								(gint) _getMenuItemValue(id_MENU_SPECIAL_INDENT));

	// spacing
	UT_ASSERT(m_spinbuttonLeft);
	gtk_entry_set_text(GTK_ENTRY(m_spinbuttonBefore),
					   (const gchar *) _getSpinItemValue(id_SPIN_BEFORE_SPACING));

	UT_ASSERT(m_spinbuttonRight);
	gtk_entry_set_text(GTK_ENTRY(m_spinbuttonAfter),
					   (const gchar *) _getSpinItemValue(id_SPIN_AFTER_SPACING));

	UT_ASSERT(m_spinbuttonAt);
	gtk_entry_set_text(GTK_ENTRY(m_spinbuttonAt),
					   (const gchar *) _getSpinItemValue(id_SPIN_SPECIAL_SPACING));

	UT_ASSERT(m_listLineSpacing);
	XAP_comboBoxSetActiveFromIntCol(GTK_COMBO_BOX(m_listLineSpacing), 1,
								(gint) _getMenuItemValue(id_MENU_SPECIAL_SPACING));

	// set the check boxes
	// TODO : handle tri-state boxes !!!

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GTK_CHECK_BUTTON(m_checkbuttonWidowOrphan)),
								 (_getCheckItemValue(id_CHECK_WIDOW_ORPHAN) == check_TRUE));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GTK_CHECK_BUTTON(m_checkbuttonKeepLines)),
								 (_getCheckItemValue(id_CHECK_KEEP_LINES) == check_TRUE));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GTK_CHECK_BUTTON(m_checkbuttonPageBreak)),
								 (_getCheckItemValue(id_CHECK_PAGE_BREAK) == check_TRUE));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GTK_CHECK_BUTTON(m_checkbuttonSuppress)),
								 (_getCheckItemValue(id_CHECK_SUPPRESS) == check_TRUE));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GTK_CHECK_BUTTON(m_checkbuttonHyphenate)),
								 (_getCheckItemValue(id_CHECK_NO_HYPHENATE) == check_TRUE));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GTK_CHECK_BUTTON(m_checkbuttonKeepNext)),
								 (_getCheckItemValue(id_CHECK_KEEP_NEXT) == check_TRUE));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GTK_CHECK_BUTTON(m_checkbuttonDomDirection)),
								 (_getCheckItemValue(id_CHECK_DOMDIRECTION) == check_TRUE));
}
void AP_UnixDialog_PageSetup::event_PageSizeChanged (fp_PageSize::Predefined pd)
{
	fp_PageSize ps(pd);
	if( TRUE != gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (m_radioPagePortrait)))
	{
		ps.setLandscape();
	}
	m_PageSize = ps;

	// change the units in the dialog, too.
	UT_Dimension new_units = ps.getDims();
	setPageUnits(new_units);
	XAP_comboBoxSetActiveFromIntCol(GTK_COMBO_BOX (m_optionPageUnits), 1, new_units);

	float w, h;

	w = ps.Width (new_units);
	h = ps.Height (new_units);
//  if( !ps.isPortrait())
//  {
//	  h = ps.Width (new_units);
//	  w = ps.Height (new_units);
//  }

  if (true /* fp_PageSize::psCustom != pd */)
  {
	  // set entry values for a non-custom pagesize
	  gchar * val;
	  XAP_GtkSignalBlocker b(G_OBJECT(m_entryPageWidth), m_iEntryPageWidthID);
	  XAP_GtkSignalBlocker c(G_OBJECT(m_entryPageHeight), m_iEntryPageHeightID);
	  val = g_strdup_printf (FMT_STRING, w);
 	  _setWidth(val);
	  gtk_entry_set_text (GTK_ENTRY (m_entryPageWidth), val);
	  g_free (val);

	  val = g_strdup_printf (FMT_STRING, h);
	  _setHeight(val);
	  gtk_entry_set_text (GTK_ENTRY (m_entryPageHeight), val);
	  g_free (val);
  }
  else
  {																	
	  UT_Dimension dim = (UT_Dimension)XAP_comboBoxGetActiveInt(GTK_COMBO_BOX(m_optionPageUnits));
	  ps.Set(atof(gtk_entry_get_text(GTK_ENTRY(m_entryPageWidth))),
			 atof(gtk_entry_get_text(GTK_ENTRY(m_entryPageHeight))),
			 dim);
  }
}
void AP_UnixDialog_Paragraph::_syncControls(tControl changed, bool bAll /* = false */)
{
	// let parent sync any member variables first
	AP_Dialog_Paragraph::_syncControls(changed, bAll);

	// sync the display

	// 1.  link the "hanging indent by" combo and spinner
	if (bAll || (changed == id_SPIN_SPECIAL_INDENT))
	{
		// typing in the control can change the associated combo
		if (_getMenuItemValue(id_MENU_SPECIAL_INDENT) == indent_FIRSTLINE)
		{
			XAP_comboBoxSetActiveFromIntCol(GTK_COMBO_BOX(m_listSpecial),1,
										(gint) _getMenuItemValue(id_MENU_SPECIAL_INDENT));
		}
	}
	if (bAll || (changed == id_MENU_SPECIAL_INDENT))
	{
		switch(_getMenuItemValue(id_MENU_SPECIAL_INDENT))
		{
		case indent_NONE:
			// clear the spin control
			gtk_entry_set_text(GTK_ENTRY(m_spinbuttonBy), "");
			gtk_widget_set_sensitive(m_spinbuttonBy, FALSE);
			break;

		default:
			// set the spin control
			gtk_widget_set_sensitive(m_spinbuttonBy, TRUE);
			gtk_entry_set_text(GTK_ENTRY(m_spinbuttonBy), _getSpinItemValue(id_SPIN_SPECIAL_INDENT));
			break;
		}
	}

	// 2.  link the "line spacing at" combo and spinner

	if (bAll || (changed == id_SPIN_SPECIAL_SPACING))
	{
		// typing in the control can change the associated combo
		if (_getMenuItemValue(id_MENU_SPECIAL_SPACING) == spacing_MULTIPLE)
		{
			XAP_comboBoxSetActiveFromIntCol(GTK_COMBO_BOX(m_listLineSpacing),1,
										(gint) _getMenuItemValue(id_MENU_SPECIAL_SPACING));
		}
	}
	if (bAll || (changed == id_MENU_SPECIAL_SPACING))
	{
		switch(_getMenuItemValue(id_MENU_SPECIAL_SPACING))
		{
		case spacing_SINGLE:
		case spacing_ONEANDHALF:
		case spacing_DOUBLE:
			// clear the spin control
			gtk_entry_set_text(GTK_ENTRY(m_spinbuttonAt), "");
			gtk_widget_set_sensitive(m_spinbuttonAt, FALSE);
			break;

		default:
			// set the spin control
			gtk_widget_set_sensitive(m_spinbuttonAt, TRUE);
			gtk_entry_set_text(GTK_ENTRY(m_spinbuttonAt), _getSpinItemValue(id_SPIN_SPECIAL_SPACING));
			break;
		}
	}

	// 3.  move results of _doSpin() back to screen

	if (!bAll)
	{
		// spin controls only sync when spun
		switch (changed)
		{
		case id_SPIN_LEFT_INDENT:
			gtk_entry_set_text(GTK_ENTRY(m_spinbuttonLeft), 	_getSpinItemValue(id_SPIN_LEFT_INDENT));
			break;
		case id_SPIN_RIGHT_INDENT:
			gtk_entry_set_text(GTK_ENTRY(m_spinbuttonRight), 	_getSpinItemValue(id_SPIN_RIGHT_INDENT));
			break;
		case id_SPIN_SPECIAL_INDENT:
			gtk_entry_set_text(GTK_ENTRY(m_spinbuttonBy), 		_getSpinItemValue(id_SPIN_SPECIAL_INDENT));
			break;
		case id_SPIN_BEFORE_SPACING:
			gtk_entry_set_text(GTK_ENTRY(m_spinbuttonBefore), 	_getSpinItemValue(id_SPIN_BEFORE_SPACING));
			break;
		case id_SPIN_AFTER_SPACING:
			gtk_entry_set_text(GTK_ENTRY(m_spinbuttonAfter), 	_getSpinItemValue(id_SPIN_AFTER_SPACING));
			break;
		case id_SPIN_SPECIAL_SPACING:
			gtk_entry_set_text(GTK_ENTRY(m_spinbuttonAt), 		_getSpinItemValue(id_SPIN_SPECIAL_SPACING));
			break;
		default:
			break;
		}
	}
}
/*!
 * Fill the GUI tree with the styles as defined in the XP tree.
 */
void  AP_UnixDialog_FormatTOC::_fillGUI(void)
{
	UT_UTF8String sVal;
	sVal = getTOCPropVal("toc-has-heading");

	GtkWidget * pW;
	GtkComboBox * combo = GTK_COMBO_BOX(_getWidget("wLevelOption"));
	gtk_combo_box_set_active(combo, getMainLevel()-1);

	pW = _getWidget("cbHasHeading");
	if(g_ascii_strcasecmp(sVal.utf8_str(),"1") == 0)
	{
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pW),TRUE);
		_setHasHeadingSensitivity(TRUE);
	}
	else
	{
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pW),FALSE);
		_setHasHeadingSensitivity(FALSE);
	}
	g_object_set_data(G_OBJECT(pW),"toc-prop",(gpointer) "toc-has-heading");
	g_signal_connect(G_OBJECT(pW),
					 "toggled",
					 G_CALLBACK(s_HasHeading_changed),
					 (gpointer) this);
	
	sVal = getTOCPropVal("toc-heading");
	pW = _getWidget("edHeadingText");
	gtk_entry_set_text(GTK_ENTRY(pW),sVal.utf8_str());
	g_object_set_data(G_OBJECT(pW),"toc-prop",(gpointer) "toc-heading");


	sVal = getTOCPropVal("toc-heading-style");
	pW = _getWidget("lbCurrentHeadingStyle");
	gtk_label_set_text(GTK_LABEL(pW),sVal.utf8_str());
	g_object_set_data(G_OBJECT(_getWidget("lbChangeHeadingStyle")),"display-widget",(gpointer)pW);
	g_object_set_data(G_OBJECT(pW),"toc-prop",(gpointer) "toc-heading-style");


	FV_View * pView = static_cast<FV_View *>(getActiveFrame()->getCurrentView());

	sVal = getTOCPropVal("toc-dest-style",getMainLevel());
	pW= _getWidget("wDispStyle");
	gtk_label_set_text(GTK_LABEL(pW),sVal.utf8_str());
	g_object_set_data(G_OBJECT(_getWidget("wChangeDisp")),"display-widget",(gpointer)pW);
	g_object_set_data(G_OBJECT(pW),"toc-prop",(gpointer) "toc-dest-style");


	sVal = getTOCPropVal("toc-has-label",getMainLevel());
	pW = _getWidget("wHasLabel");
	if(g_ascii_strcasecmp(sVal.utf8_str(),"1") == 0)
	{
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pW),TRUE);
	}
	else
	{
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pW),FALSE);
	}
	g_object_set_data(G_OBJECT(pW),"toc-prop",(gpointer) "toc-has-label");
	g_signal_connect(G_OBJECT(pW),
					 "toggled",
					 G_CALLBACK(s_HasLabel_changed),
					 (gpointer) this);

	sVal = getTOCPropVal("toc-label-after",getDetailsLevel());
	pW = _getWidget("edTextAfter");
	gtk_entry_set_text(GTK_ENTRY(pW),sVal.utf8_str());
	g_object_set_data(G_OBJECT(pW),"toc-prop",(gpointer) "toc-label-after");

	sVal = getTOCPropVal("toc-label-before",getDetailsLevel());
	pW = _getWidget("edTextBefore");
	gtk_entry_set_text(GTK_ENTRY(pW),sVal.utf8_str());
	g_object_set_data(G_OBJECT(pW),"toc-prop",(gpointer) "toc-label-before");

	sVal = getTOCPropVal("toc-label-inherits",getDetailsLevel());
	pW = _getWidget("cbInherit");
	if(g_ascii_strcasecmp(sVal.utf8_str(),"1") == 0)
	{
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pW),TRUE);
	}
	else
	{
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pW),FALSE);
	}
	g_object_set_data(G_OBJECT(pW),"toc-prop",(gpointer) "toc-label-inherits");
	g_signal_connect(G_OBJECT(pW),
					 "toggled",
					 G_CALLBACK(s_check_changedDetails),
					 (gpointer) this);


	sVal = getTOCPropVal("toc-label-start",getDetailsLevel());
	pW = _getWidget("wStartEntry");
	gtk_entry_set_text(GTK_ENTRY(pW),sVal.utf8_str());
	gtk_spin_button_set_value(GTK_SPIN_BUTTON (_getWidget("wStartSpin")),
                                             (gdouble) m_iStartValue );
	g_signal_connect(G_OBJECT(_getWidget("wStartSpin")),
							  "value-changed",
							  G_CALLBACK(s_StartAt_changed),
							  reinterpret_cast<gpointer>(this));

	sVal = getTOCPropVal("toc-indent",getDetailsLevel());
	pW = _getWidget("wIndentEntry");
	gtk_entry_set_text(GTK_ENTRY(pW),sVal.utf8_str());
	gtk_spin_button_set_value(GTK_SPIN_BUTTON (_getWidget("wIndentSpin")),
                                             (gdouble) m_iIndentValue );
	g_signal_connect(G_OBJECT(_getWidget("wIndentSpin")),
							  "value-changed",
							  G_CALLBACK(s_Indent_changed),
							  reinterpret_cast<gpointer>(this));
	

	sVal = getTOCPropVal("toc-label-type",getDetailsLevel());
	pW = _getWidget("wLabelChoose"); 
	UT_sint32 iHist = static_cast<UT_sint32>(pView->getLayout()->FootnoteTypeFromString(sVal.utf8_str()));
	XAP_comboBoxSetActiveFromIntCol(GTK_COMBO_BOX(pW),1,iHist);

	sVal = getTOCPropVal("toc-page-type",getDetailsLevel());
	pW = _getWidget("wPageNumberingChoose"); 
	iHist = static_cast<UT_sint32>(pView->getLayout()->FootnoteTypeFromString(sVal.utf8_str()));
	XAP_comboBoxSetActiveFromIntCol(GTK_COMBO_BOX(pW),1,iHist);

	sVal = getTOCPropVal("toc-source-style",getMainLevel());
	pW = _getWidget("wFillStyle");
	gtk_label_set_text(GTK_LABEL(pW),sVal.utf8_str());
	g_object_set_data(G_OBJECT(_getWidget("wChangeFill")),"display-widget",(gpointer)pW);
	g_object_set_data(G_OBJECT(pW),"toc-prop",(gpointer) "toc-source-style");

	sVal = getTOCPropVal("toc-tab-leader",getDetailsLevel());
	pW = _getWidget("wTabLeaderChoose");
	if(g_ascii_strcasecmp(sVal.utf8_str(),"none") == 0)
	{
		iHist = 0;
	}
	else if(g_ascii_strcasecmp(sVal.utf8_str(),"dot") == 0)
	{
		iHist = 1;
	}
	else if(g_ascii_strcasecmp(sVal.utf8_str(),"hyphen") == 0)
	{
		iHist = 2;
	}
	else if(g_ascii_strcasecmp(sVal.utf8_str(),"underline") == 0)
	{
		iHist = 3;
	}
	else
	{
		iHist = 1;
	}
	gtk_combo_box_set_active(GTK_COMBO_BOX(pW),iHist);
}
GtkWidget * AP_UnixDialog_PageSetup::_constructWindow (void)
{  
	// get the path where our UI file is located
	std::string ui_path = static_cast<XAP_UnixApp*>(XAP_App::getApp())->getAbiSuiteAppUIDir() + "/ap_UnixDialog_PageSetup.xml";

	// load the dialog from the UI file
	m_pBuilder = gtk_builder_new();
	gtk_builder_add_from_file(m_pBuilder, ui_path.c_str(), NULL);

	const XAP_StringSet * pSS = m_pApp->getStringSet ();
	GList *glist;
	GtkLabel *orientation;

	m_window = _getWidget("ap_UnixDialog_PageSetup");
	m_wHelp = _getWidget("wHelp");

	m_comboPageSize = _getWidget("comboPageSize");
	m_entryPageWidth = _getWidget("wWidthSpin");
	m_entryPageHeight = _getWidget("wHeightSpin");
	m_optionPageUnits = _getWidget("optionPageUnits");
	m_radioPagePortrait = _getWidget("rbPortrait");
	m_radioPageLandscape = _getWidget("rbLandscape");
	m_spinPageScale = _getWidget("wPageScale");

	m_optionMarginUnits = _getWidget("optionMarginUnits");
	m_spinMarginTop = _getWidget("wTopSpin");
	m_spinMarginBottom = _getWidget("wBottomSpin");
	m_spinMarginLeft = _getWidget("wLeftSpin");
	m_spinMarginRight = _getWidget("wRightSpin");
	m_spinMarginHeader = _getWidget("wHeaderSpin");
	m_spinMarginFooter = _getWidget("wFooterSpin");

	m_MarginHbox = _getWidget("hbox15");
	m_PageHbox = _getWidget("hbox16");

	/* required for translations */
	gtk_label_set_text (GTK_LABEL (_getWidget("lbPage")), _(AP, DLG_PageSetup_Page));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbMargin")), _(AP, DLG_PageSetup_Margin));
	Markup (_getWidget("lbPaper"), pSS, _(AP, DLG_PageSetup_Paper));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbPaperSize")), _(AP, DLG_PageSetup_Paper_Size));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbPageUnits")), _(AP, DLG_PageSetup_Units));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbWidth")), _(AP, DLG_PageSetup_Width));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbHeight")), _(AP, DLG_PageSetup_Height));
	Markup (_getWidget("lbOrientation"), pSS, _(AP, DLG_PageSetup_Orient));

	/* radio button labels */
	glist = gtk_container_get_children (GTK_CONTAINER (m_radioPagePortrait));
	orientation = GTK_LABEL (g_list_nth_data (glist, 0));
	gtk_label_set_text (GTK_LABEL (orientation), _(AP, DLG_PageSetup_Portrait));

	glist = gtk_container_get_children (GTK_CONTAINER (m_radioPageLandscape));
	orientation = GTK_LABEL (g_list_nth_data (glist, 0));
	gtk_label_set_text (GTK_LABEL (orientation), _(AP, DLG_PageSetup_Landscape));

	Markup (_getWidget("lbScale"), pSS, _(AP, DLG_PageSetup_Scale));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbAdjust")), _(AP, DLG_PageSetup_Adjust));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbPercentNormalSize")), _(AP, DLG_PageSetup_Percent));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbMarginUnits")), _(AP, DLG_PageSetup_Units));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbTop")), _(AP, DLG_PageSetup_Top));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbRight")), _(AP, DLG_PageSetup_Right));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbLeft")), _(AP, DLG_PageSetup_Left));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbBottom")), _(AP, DLG_PageSetup_Bottom));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbHeader")), _(AP, DLG_PageSetup_Header));
	gtk_label_set_text (GTK_LABEL (_getWidget("lbFooter")), _(AP, DLG_PageSetup_Footer));
	/* end translation req */

	/* setup page width and height */
	if (!getPageOrientation () == PORTRAIT)
	{
		m_PageSize.setLandscape();
	}
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_entryPageWidth), m_PageSize.Width (getPageUnits ()));
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_entryPageHeight), m_PageSize.Height (getPageUnits ()));

	/* setup margin numbers */
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_spinMarginTop), getMarginTop ());
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_spinMarginBottom), getMarginBottom ());
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_spinMarginLeft), getMarginLeft ());
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_spinMarginRight), getMarginRight ());
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_spinMarginHeader), getMarginHeader ());
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_spinMarginFooter), getMarginFooter ());

	/* setup scale number */
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_spinPageScale), static_cast<float>(getPageScale ()));

	// fill the combobox all of our supported page sizes
	GtkListStore* pagesize_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
	GtkTreeIter pagesize_iter;
	for (UT_uint32 i = fp_PageSize::_first_predefined_pagesize_; i < fp_PageSize::_last_predefined_pagesize_dont_use_; i++)
	{
		gtk_list_store_append(pagesize_store, &pagesize_iter);
		gtk_list_store_set(pagesize_store, &pagesize_iter,
					0, fp_PageSize::PredefinedToName ((fp_PageSize::Predefined)i),
					1, this,
					-1);
	}
	gtk_combo_box_set_model(GTK_COMBO_BOX(m_comboPageSize), GTK_TREE_MODEL(pagesize_store));
	m_iComboPageSizeListID = g_signal_connect(G_OBJECT(m_comboPageSize),
							"changed",
							G_CALLBACK(s_page_size_changed),
							static_cast<gpointer>(this));

	/* setup page units menu */
	GtkComboBox *combo = GTK_COMBO_BOX(m_optionPageUnits);
	XAP_makeGtkComboBoxText(combo, G_TYPE_INT);
	XAP_appendComboBoxTextAndInt(combo, _(XAP, DLG_Unit_inch), DIM_IN);
	XAP_appendComboBoxTextAndInt(combo, _(XAP, DLG_Unit_cm), DIM_CM);
	XAP_appendComboBoxTextAndInt(combo, _(XAP, DLG_Unit_mm), DIM_MM);
    XAP_comboBoxSetActiveFromIntCol(combo, 1, getPageUnits ());

	/* setup margin units menu */
	combo = GTK_COMBO_BOX(m_optionMarginUnits);
	XAP_makeGtkComboBoxText(combo, G_TYPE_INT);
	XAP_appendComboBoxTextAndInt(combo, _(XAP, DLG_Unit_inch), DIM_IN);
	XAP_appendComboBoxTextAndInt(combo, _(XAP, DLG_Unit_cm), DIM_CM);
	XAP_appendComboBoxTextAndInt(combo, _(XAP, DLG_Unit_mm), DIM_MM);
	last_margin_unit = getMarginUnits ();
    XAP_comboBoxSetActiveFromIntCol(combo, 1, last_margin_unit);

	/* add margin XPM image to the margin window */
	customPreview = create_pixmap (m_MarginHbox, margin_xpm);
	gtk_widget_show (customPreview);
	gtk_box_pack_start (GTK_BOX (m_MarginHbox), customPreview, FALSE, FALSE, 0);

	/* add correct page XPM image to the page window */
	if (getPageOrientation () == PORTRAIT)
	{
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_radioPagePortrait), TRUE);

		customPreview = create_pixmap (m_PageHbox, orient_vertical_xpm);
		gtk_widget_show (customPreview);
		gtk_box_pack_start (GTK_BOX (m_PageHbox), customPreview, FALSE, FALSE, 0);
		gtk_box_reorder_child (GTK_BOX (m_PageHbox), customPreview, 0);
	}
	else
	{
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (m_radioPageLandscape), TRUE);

		customPreview = create_pixmap (m_PageHbox, orient_horizontal_xpm);
		gtk_widget_show (customPreview);
		gtk_box_pack_start (GTK_BOX (m_PageHbox), customPreview, FALSE, FALSE, 0);
		gtk_box_reorder_child (GTK_BOX (m_PageHbox), customPreview, 0);
	}

	abiAddStockButton(GTK_DIALOG(m_window), GTK_STOCK_CANCEL, BUTTON_CANCEL);
	abiAddStockButton(GTK_DIALOG(m_window), GTK_STOCK_OK, BUTTON_OK);
	_connectSignals ();

	return m_window;
}