void  AP_UnixDialog_FormatTOC::event_Apply(void)
{
	UT_DEBUGMSG(("Doing apply \n"));

// Heading Text

	GtkWidget * pW = _getWidget("edHeadingText");
	UT_UTF8String sVal;
	sVal = gtk_entry_get_text(GTK_ENTRY(pW));
	setTOCProperty("toc-heading",sVal.utf8_str());

// Text before and after

	pW = _getWidget("edTextAfter");
	sVal = gtk_entry_get_text(GTK_ENTRY(pW));
	UT_UTF8String sProp;
	sProp = static_cast<const char *> (g_object_get_data(G_OBJECT(pW),"toc-prop"));
	UT_String sNum =  UT_String_sprintf("%d",getDetailsLevel());
	sProp += sNum.c_str();
	setTOCProperty(sProp,sVal);

	pW = _getWidget("edTextBefore");
	sVal = gtk_entry_get_text(GTK_ENTRY(pW));
	sProp = static_cast<const char *> (g_object_get_data(G_OBJECT(pW),"toc-prop"));
	sProp += sNum.c_str();
	setTOCProperty(sProp,sVal);
	Apply();
}
void AP_UnixDialog_FormatTOC::_createLabelTypeItems(void)
{
	const FootnoteTypeDesc* vecTypeList = AP_Dialog_FormatFootnotes::getFootnoteTypeLabelList();

//	sProp = new UT_UTF8String("toc-label-type");
	m_wLabelChoose = _getWidget("wLabelChoose");
	GtkComboBox * combo = GTK_COMBO_BOX(m_wLabelChoose);
	XAP_makeGtkComboBoxText2(combo, G_TYPE_INT, G_TYPE_STRING);
	const FootnoteTypeDesc* current = vecTypeList;
	for(; current->n != _FOOTNOTE_TYPE_INVALID; current++)
	{
		UT_DEBUGMSG(("Got label %s for prop %s \n",current->label,
					 current->prop));
		XAP_appendComboBoxTextAndIntString(combo, current->label, 
										   current->n, current->prop);
	}

// Now the Page Numbering style
//
//	sProp = new UT_UTF8String("toc-page-type");
	m_wPageNumberingChoose = _getWidget("wPageNumberingChoose");
	combo = GTK_COMBO_BOX(m_wPageNumberingChoose);
	XAP_makeGtkComboBoxText2(combo, G_TYPE_INT, G_TYPE_STRING);
	current = vecTypeList;
	for(; current->n != _FOOTNOTE_TYPE_INVALID; current++)
	{
		XAP_appendComboBoxTextAndIntString(combo, current->label, 
										   current->n, current->prop);

	}
}
void AP_UnixDialog_FormatTOC::_createLevelItems(void)
{
	const XAP_StringSet * pSS = XAP_App::getApp()->getStringSet ();
	UT_UTF8String s;

	GtkComboBox *combo;

	combo = GTK_COMBO_BOX(_getWidget("wLevelOption"));
	XAP_makeGtkComboBoxText(combo, G_TYPE_INT);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level1,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 1);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level2,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 2);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level3,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 3);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level4,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 4);
	gtk_combo_box_set_active(combo, 0);

//////////////////////////////////////////////////////////////////////////////

	combo = GTK_COMBO_BOX(_getWidget("wDetailsLevel"));
	XAP_makeGtkComboBoxText(combo, G_TYPE_INT);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level1,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 1);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level2,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 2);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level3,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 3);
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Level4,s);
	XAP_appendComboBoxTextAndInt(combo, s.utf8_str(), 4);
	gtk_combo_box_set_active(combo, 0);
}
void AP_UnixDialog_FormatTOC::_setHasHeadingSensitivity(bool bSensitive)
{
	gtk_widget_set_sensitive(_getWidget("lbHeadingText"), bSensitive);
	gtk_widget_set_sensitive(_getWidget("edHeadingText"), bSensitive);
	gtk_widget_set_sensitive(_getWidget("lbHeadingStyle"), bSensitive);
	gtk_widget_set_sensitive(_getWidget("lbCurrentHeadingStyle"), bSensitive);
	gtk_widget_set_sensitive(_getWidget("lbChangeHeadingStyle"), bSensitive);		

}
void  AP_UnixDialog_FormatTOC::_connectSignals(void)
{
	g_signal_connect(G_OBJECT(m_windowMain), "response", 
					 G_CALLBACK(s_response_triggered), this);
	// the catch-alls
	// Dont use gtk_signal_connect_after for modeless dialogs
	g_signal_connect(G_OBJECT(m_windowMain),
			   "destroy",
			   G_CALLBACK(s_destroy_clicked),
			   (gpointer) this);
	g_signal_connect(G_OBJECT(m_windowMain),
			   "delete_event",
			   G_CALLBACK(s_delete_clicked),
			   (gpointer) this);
	g_signal_connect(G_OBJECT(_getWidget("lbChangeHeadingStyle")),
					  "clicked",
					  G_CALLBACK(s_set_style),
					  (gpointer) this);

	g_signal_connect(G_OBJECT(_getWidget("wChangeFill")),
					 "clicked",
					 G_CALLBACK(s_set_style),
					 (gpointer) this);
	g_signal_connect(G_OBJECT(_getWidget("wChangeDisp")),
					 "clicked",
					 G_CALLBACK(s_set_style),
					 (gpointer) this);

	g_signal_connect(G_OBJECT(_getWidget("wLevelOption")),
					 "changed",
					 G_CALLBACK(s_MainLevel_changed),
					 (gpointer) this);
	g_signal_connect(G_OBJECT(_getWidget("wDetailsLevel")),
					 "changed",
					 G_CALLBACK(s_DetailsLevel_changed),
					 (gpointer) this);
	g_signal_connect(G_OBJECT(_getWidget("wLabelChoose")),
					 "changed",
					 G_CALLBACK(s_NumType_changed),
					 (gpointer) this);
	g_signal_connect(G_OBJECT(_getWidget("wPageNumberingChoose")),
					 "changed",
					 G_CALLBACK(s_NumType_changed),
					 (gpointer) this);
	g_signal_connect(G_OBJECT(_getWidget("wTabLeaderChoose")),
					 "changed",
					 G_CALLBACK(s_TabLeader_changed),
					 (gpointer) this);
}
void AP_UnixDialog_FormatTOC::setMainLevel(UT_sint32 iLevel)
{
	AP_Dialog_FormatTOC::setMainLevel(iLevel);
	UT_UTF8String sVal;
	sVal = getTOCPropVal("toc-dest-style",getMainLevel());
	GtkWidget * pW= _getWidget("wDispStyle");
	gtk_label_set_text(GTK_LABEL(pW),sVal.utf8_str());


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

	sVal = getTOCPropVal("toc-source-style",getMainLevel());
	pW = _getWidget("wFillStyle");
	gtk_label_set_text(GTK_LABEL(pW),sVal.utf8_str());
}
void AP_UnixDialog_FormatTOC::_createTABTypeItems(void)
{
	const UT_GenericVector<const gchar*> * vecLabels = getVecTABLeadersLabel();
	const UT_GenericVector<const gchar*> * vecProps = getVecTABLeadersProp();
	UT_sint32 nTypes = vecLabels->getItemCount();
	UT_sint32 j = 0;
	const char *sProp = "toc-tab-leader";
	GtkComboBox * combo = GTK_COMBO_BOX(_getWidget("wTabLeaderChoose"));
	XAP_makeGtkComboBoxText2(combo, G_TYPE_STRING, G_TYPE_STRING);
	for(j=0; j< nTypes; j++)
	{
		const gchar *sVal = vecProps->getNthItem(j);
		const gchar * szLab = vecLabels->getNthItem(j);
		UT_DEBUGMSG(("Got label %s for item %d \n",szLab,j));
		XAP_appendComboBoxTextAndStringString(combo, szLab, sProp, sVal);
	}
}
void AP_UnixDialog_FormatTOC::event_IndentChanged(GtkWidget * wSpin)
{
	UT_sint32 iNew = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(wSpin));
	bool bInc = true;
	UT_DEBUGMSG(("New Indent value %d \n",iNew));
	if(iNew == m_iIndentValue)
	{
		return;
	}
	if(iNew < m_iIndentValue)
	{
		bInc = false;
	}
	m_iIndentValue = iNew;
	incrementIndent(getDetailsLevel(),bInc);
	UT_UTF8String sVal = getTOCPropVal("toc-indent",getDetailsLevel());
	GtkWidget * pW = _getWidget("wIndentEntry");
	gtk_entry_set_text(GTK_ENTRY(pW),sVal.utf8_str());
}
/*!
 * 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);
}
void AP_UnixDialog_FormatTOC::setDetailsLevel(UT_sint32 iLevel)
{
	AP_Dialog_FormatTOC::setDetailsLevel(iLevel);
	UT_UTF8String sVal;

	sVal = getTOCPropVal("toc-label-after",getDetailsLevel());
	GtkWidget * pW = _getWidget("edTextAfter");
	gtk_entry_set_text(GTK_ENTRY(pW),sVal.utf8_str());

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

	sVal = getTOCPropVal("toc-label-start",getDetailsLevel());
	pW = _getWidget("wStartEntry");
	gtk_entry_set_text(GTK_ENTRY(pW),sVal.utf8_str());


	sVal = getTOCPropVal("toc-indent",getDetailsLevel());
	pW = _getWidget("wIndentEntry");
	gtk_entry_set_text(GTK_ENTRY(pW),sVal.utf8_str());
	

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


	FV_View * pView = static_cast<FV_View *>(getActiveFrame()->getCurrentView());
	sVal = getTOCPropVal("toc-label-type",getDetailsLevel());
	pW = _getWidget("wLabelChoose"); 
	GtkComboBox *combo = GTK_COMBO_BOX(pW);
	UT_sint32 iHist = static_cast<UT_sint32>(pView->getLayout()->FootnoteTypeFromString(sVal.utf8_str()));
	gtk_combo_box_set_active(combo,iHist);

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

	sVal = getTOCPropVal("toc-tab-leader",getDetailsLevel());
	pW = _getWidget("wTabLeaderChoose");
	combo = GTK_COMBO_BOX(pW);
	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(combo,iHist);
}
GtkWidget * AP_UnixDialog_FormatTOC::_constructWindow(void)
{
#if GTK_CHECK_VERSION(3,0,0)
    m_pBuilder = newDialogBuilder("ap_UnixDialog_FormatTOC.ui");
#else
    m_pBuilder = newDialogBuilder("ap_UnixDialog_FormatTOC-2.ui");
#endif
	
	const XAP_StringSet * pSS = m_pApp->getStringSet ();

	m_windowMain   = _getWidget("ap_UnixDialog_FormatTOC");
	m_wApply = _getWidget("wApply");
	m_wClose = _getWidget("wClose");

	// set the dialog title
	UT_UTF8String s;
	pSS->getValueUTF8(AP_STRING_ID_DLG_FormatTOC_Title,s);
	abiDialogSetTitle(m_windowMain, "%s", s.utf8_str());

// localize notebook tabs
	localizeLabel(_getWidget( "lbGeneral"), pSS, AP_STRING_ID_DLG_FormatTOC_General);
	localizeLabel(_getWidget( "lbLayoutDetails"), pSS, AP_STRING_ID_DLG_FormatTOC_LayoutDetails);

// Heading settings

	localizeButtonMarkup(_getWidget( "cbHasHeading"), pSS, AP_STRING_ID_DLG_FormatTOC_HasHeading);
	localizeLabelUnderline(_getWidget( "lbHeadingText"), pSS, AP_STRING_ID_DLG_FormatTOC_HeadingText);
	localizeLabel(_getWidget( "lbHeadingStyle"), pSS, AP_STRING_ID_DLG_FormatTOC_HeadingStyle);

	localizeButton(_getWidget( "lbChangeHeadingStyle"), pSS, AP_STRING_ID_DLG_FormatTOC_ChangeStyle);

// Main level definitions
	localizeLabelMarkup(_getWidget( "lbMainLevelDefs"), pSS, AP_STRING_ID_DLG_FormatTOC_LevelDefs);
	localizeButtonUnderline(_getWidget( "wHasLabel"), pSS, AP_STRING_ID_DLG_FormatTOC_HasLabel);	
	localizeLabel(_getWidget( "lbFillStyle"), pSS, AP_STRING_ID_DLG_FormatTOC_FillStyle);
	localizeLabel(_getWidget( "lbDispStyle"), pSS, AP_STRING_ID_DLG_FormatTOC_DispStyle);
	localizeButton(_getWidget( "wChangeFill"), pSS, AP_STRING_ID_DLG_FormatTOC_ChangeStyle);
	localizeButton(_getWidget( "wChangeDisp"), pSS, AP_STRING_ID_DLG_FormatTOC_ChangeStyle);

// Details top
	localizeLabelMarkup(_getWidget( "lbDetails"), pSS, AP_STRING_ID_DLG_FormatTOC_DetailsTop);
	localizeLabelUnderline(_getWidget( "lbStartAt"), pSS, AP_STRING_ID_DLG_FormatTOC_StartAt);
	localizeLabelUnderline(_getWidget( "lbTextBefore"), pSS, AP_STRING_ID_DLG_FormatTOC_TextBefore);
	localizeLabelUnderline(_getWidget( "lbNumberingType"), pSS, AP_STRING_ID_DLG_FormatTOC_NumberingType);
	localizeLabelUnderline(_getWidget( "lbTextAfter"), pSS, AP_STRING_ID_DLG_FormatTOC_TextAfter);
	localizeButtonUnderline(_getWidget( "cbInherit"), pSS, AP_STRING_ID_DLG_FormatTOC_InheritLabel);

// Tabs and numbering
	localizeLabelMarkup(_getWidget( "lbTabPage"), pSS, AP_STRING_ID_DLG_FormatTOC_DetailsTabPage);
	localizeLabelUnderline(_getWidget( "lbTabLeader"), pSS, AP_STRING_ID_DLG_FormatTOC_TabLeader);
	localizeLabelUnderline(_getWidget( "lbPageNumbering"), pSS, AP_STRING_ID_DLG_FormatTOC_PageNumbering);
	localizeLabelUnderline(_getWidget( "lbIndent"), pSS, AP_STRING_ID_DLG_FormatTOC_Indent);

// Create the itemlists
	_createLabelTypeItems();
	_createTABTypeItems();
	_createLevelItems();
	return m_windowMain;
}
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;
}