Logo Search packages:      
Sourcecode: bibledit version File versions  Download package

dialogstylesheet.cpp

/*
** Copyright (C) 2003-2006 Teus Benschop.
**  
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**  
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**  
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**  
*/


#include "libraries.h"
#include <glib.h>
#include "dialogstylesheet.h"
#include "utilities.h"
#include "stylesheetutils.h"
#include "dialogentry.h"
#include "projectutils.h"
#include "directories.h"
#include "usfm.h"
#include "gtkwrappers.h"
#include "constants.h"


/*
Usage of user variables.

userint1
- Footnote / crossreference: NoteNumberingRestartType

userbool2
- Footnotes: whether to allow extra space for the caller.
- Crossreferences: whether to allow extra space for the caller.
*/

StylesheetDialog::StylesheetDialog (const ustring& stylesheet, const ustring& style)
{
  // Save variables.
  mystylesheet = stylesheet;
  mystyle = style;

  stylesheetdialog = gtk_dialog_new ();
  ustring s;
  s = "Stylesheet " + stylesheet + ", style " + style;
  gtk_window_set_title (GTK_WINDOW (stylesheetdialog), s.c_str());
  gtk_window_set_position (GTK_WINDOW (stylesheetdialog), GTK_WIN_POS_CENTER_ON_PARENT);
  gtk_window_set_modal (GTK_WINDOW (stylesheetdialog), TRUE);
  gtk_window_set_destroy_with_parent (GTK_WINDOW (stylesheetdialog), TRUE);
  gtk_window_set_type_hint (GTK_WINDOW (stylesheetdialog), GDK_WINDOW_TYPE_HINT_DIALOG);

  dialog_vbox1 = GTK_DIALOG (stylesheetdialog)->vbox;
  gtk_widget_show (dialog_vbox1);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox1);
  gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);

  vbox2 = gtk_vbox_new (FALSE, 6);
  gtk_widget_show (vbox2);
  gtk_box_pack_start (GTK_BOX (vbox1), vbox2, TRUE, TRUE, 0);

  hbox1 = gtk_hbox_new (FALSE, 4);
  gtk_widget_show (hbox1);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox1, TRUE, TRUE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (hbox1), 2);

  label6 = gtk_label_new_with_mnemonic ("Style:");
  gtk_widget_show (label6);
  gtk_box_pack_start (GTK_BOX (hbox1), label6, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label6), 0, 0.5);

  labelstyle = gtk_label_new ("");
  gtk_widget_show (labelstyle);
  gtk_box_pack_start (GTK_BOX (hbox1), labelstyle, TRUE, TRUE, 0);
  gtk_misc_set_alignment (GTK_MISC (labelstyle), 0, 0.5);

  label37 = gtk_label_new_with_mnemonic ("N_ame");
  gtk_widget_show (label37);
  gtk_box_pack_start (GTK_BOX (vbox2), label37, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label37), 0, 0.5);

  entryname = gtk_entry_new ();
  gtk_widget_show (entryname);
  gtk_box_pack_start (GTK_BOX (vbox2), entryname, FALSE, FALSE, 0);

  label36 = gtk_label_new_with_mnemonic ("D_escription");
  gtk_widget_show (label36);
  gtk_box_pack_start (GTK_BOX (vbox2), label36, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label36), 0, 0.5);

  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow1);
  gtk_box_pack_start (GTK_BOX (vbox2), scrolledwindow1, TRUE, TRUE, 0);
  gtk_widget_set_size_request (scrolledwindow1, -1, 100);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

  textview1 = gtk_text_view_new ();
  gtk_widget_show (textview1);
  gtk_container_add (GTK_CONTAINER (scrolledwindow1), textview1);
  gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (textview1), GTK_WRAP_WORD);

  hseparator1 = gtk_hseparator_new ();
  gtk_widget_show (hseparator1);
  gtk_box_pack_start (GTK_BOX (vbox2), hseparator1, TRUE, TRUE, 0);

  hbox8 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox8);
  gtk_box_pack_start (GTK_BOX (vbox2), hbox8, TRUE, TRUE, 0);

  vbox5 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox5);
  gtk_box_pack_start (GTK_BOX (hbox8), vbox5, TRUE, TRUE, 0);

  label21 = gtk_label_new_with_mnemonic ("_This style:");
  gtk_widget_show (label21);
  gtk_box_pack_start (GTK_BOX (vbox5), label21, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label21), 0, 0.5);

  vbox3 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox3);
  gtk_box_pack_start (GTK_BOX (vbox5), vbox3, FALSE, TRUE, 0);

  GSList *radiobutton_id_group = NULL;
  
  radiobutton_id = gtk_radio_button_new_with_mnemonic (NULL, "is an identifier");
  gtk_widget_show (radiobutton_id);
  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_id, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_id), radiobutton_id_group);
  radiobutton_id_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_id));

  radiobutton_comment = gtk_radio_button_new_with_mnemonic (NULL, "is a comment");
  gtk_widget_show (radiobutton_comment);
  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_comment, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_comment), radiobutton_id_group);
  radiobutton_id_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_comment));

  radiobutton_runningheader = gtk_radio_button_new_with_mnemonic (NULL, "is a running header");
  gtk_widget_show (radiobutton_runningheader);
  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_runningheader, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_runningheader), radiobutton_id_group);
  radiobutton_id_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_runningheader));

  radiobutton_paragraph = gtk_radio_button_new_with_mnemonic (NULL, "starts a new paragraph");
  gtk_widget_show (radiobutton_paragraph);
  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_paragraph, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_paragraph), radiobutton_id_group);
  radiobutton_id_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_paragraph));

  radiobutton_inline = gtk_radio_button_new_with_mnemonic (NULL, "is inline text with endmarker");
  gtk_widget_show (radiobutton_inline);
  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_inline, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_inline), radiobutton_id_group);
  radiobutton_id_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_inline));

  radiobutton_chapter = gtk_radio_button_new_with_mnemonic (NULL, "is a chapter number");
  gtk_widget_show (radiobutton_chapter);
  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_chapter, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_chapter), radiobutton_id_group);
  radiobutton_id_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_chapter));

  radiobutton_verse = gtk_radio_button_new_with_mnemonic (NULL, "is a verse number");
  gtk_widget_show (radiobutton_verse);
  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_verse, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_verse), radiobutton_id_group);
  radiobutton_id_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_verse));

  radiobutton_footendnote = gtk_radio_button_new_with_mnemonic (NULL, "is a footnote or endnote");
  gtk_widget_show (radiobutton_footendnote);
  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_footendnote, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_footendnote), radiobutton_id_group);
  radiobutton_id_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_footendnote));

  radiobutton_crossreference = gtk_radio_button_new_with_mnemonic (NULL, "is a crossreference");
  gtk_widget_show (radiobutton_crossreference);
  gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_crossreference, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_crossreference), radiobutton_id_group);
  radiobutton_id_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_crossreference));

  vseparator1 = gtk_vseparator_new ();
  gtk_widget_show (vseparator1);
  gtk_box_pack_start (GTK_BOX (hbox8), vseparator1, FALSE, FALSE, 0);

  notebook_subtype = gtk_notebook_new ();
  gtk_widget_show (notebook_subtype);
  gtk_box_pack_start (GTK_BOX (hbox8), notebook_subtype, TRUE, TRUE, 0);
  gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook_subtype), FALSE);
  GTK_WIDGET_UNSET_FLAGS (notebook_subtype, GTK_CAN_FOCUS);
  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook_subtype), FALSE);
  gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook_subtype), FALSE);

  empty_notebook_page = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (empty_notebook_page);
  gtk_container_add (GTK_CONTAINER (notebook_subtype), empty_notebook_page);

  label47 = gtk_label_new ("");
  gtk_widget_show (label47);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook_subtype), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook_subtype), 0), label47);

  vbox8 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox8);
  gtk_container_add (GTK_CONTAINER (notebook_subtype), vbox8);

  label50 = gtk_label_new ("This one:");
  gtk_widget_show (label50);
  gtk_box_pack_start (GTK_BOX (vbox8), label50, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label50), 0, 0.5);

  GSList *radiobutton_footnote_group = NULL;
  
  radiobutton_footnote = gtk_radio_button_new_with_mnemonic (NULL, "starts a footnote");
  gtk_widget_show (radiobutton_footnote);
  gtk_box_pack_start (GTK_BOX (vbox8), radiobutton_footnote, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_footnote), radiobutton_footnote_group);
  radiobutton_footnote_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_footnote));

  radiobutton_endnote = gtk_radio_button_new_with_mnemonic (NULL, "starts an endnote");
  gtk_widget_show (radiobutton_endnote);
  gtk_box_pack_start (GTK_BOX (vbox8), radiobutton_endnote, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_endnote), radiobutton_footnote_group);
  radiobutton_footnote_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_endnote));

  radiobutton_note_content_standard = gtk_radio_button_new_with_mnemonic (NULL, "is standard content");
  gtk_widget_show (radiobutton_note_content_standard);
  gtk_box_pack_start (GTK_BOX (vbox8), radiobutton_note_content_standard, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_content_standard), radiobutton_footnote_group);
  radiobutton_footnote_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_content_standard));

  radiobutton_note_content = gtk_radio_button_new_with_mnemonic (NULL, "is content");
  gtk_widget_show (radiobutton_note_content);
  gtk_box_pack_start (GTK_BOX (vbox8), radiobutton_note_content, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_content), radiobutton_footnote_group);
  radiobutton_footnote_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_content));

  radiobutton_note_content_endmarker = gtk_radio_button_new_with_mnemonic (NULL, "is content with endmarker");
  gtk_widget_show (radiobutton_note_content_endmarker);
  gtk_box_pack_start (GTK_BOX (vbox8), radiobutton_note_content_endmarker, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_content_endmarker), radiobutton_footnote_group);
  radiobutton_footnote_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_content_endmarker));

  radiobutton_note_paragraph = gtk_radio_button_new_with_mnemonic (NULL, "starts another paragraph");
  gtk_widget_show (radiobutton_note_paragraph);
  gtk_box_pack_start (GTK_BOX (vbox8), radiobutton_note_paragraph, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_paragraph), radiobutton_footnote_group);
  radiobutton_footnote_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_paragraph));

  label48 = gtk_label_new ("");
  gtk_widget_show (label48);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook_subtype), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook_subtype), 1), label48);

  vbox9 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox9);
  gtk_container_add (GTK_CONTAINER (notebook_subtype), vbox9);

  label51 = gtk_label_new ("This one:");
  gtk_widget_show (label51);
  gtk_box_pack_start (GTK_BOX (vbox9), label51, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label51), 0, 0.5);

  GSList *radiobutton_xref_group = NULL;

  radiobutton_xref = gtk_radio_button_new_with_mnemonic (NULL, "starts a crossreference");
  gtk_widget_show (radiobutton_xref);
  gtk_box_pack_start (GTK_BOX (vbox9), radiobutton_xref, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_xref), radiobutton_xref_group);
  radiobutton_xref_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_xref));

  radiobutton_xref_content_standard = gtk_radio_button_new_with_mnemonic (NULL, "is standard content");
  gtk_widget_show (radiobutton_xref_content_standard);
  gtk_box_pack_start (GTK_BOX (vbox9), radiobutton_xref_content_standard, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_xref_content_standard), radiobutton_xref_group);
  radiobutton_xref_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_xref_content_standard));

  radiobutton_xref_content = gtk_radio_button_new_with_mnemonic (NULL, "is content");
  gtk_widget_show (radiobutton_xref_content);
  gtk_box_pack_start (GTK_BOX (vbox9), radiobutton_xref_content, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_xref_content), radiobutton_xref_group);
  radiobutton_xref_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_xref_content));

  radiobutton_xref_content_endmarker = gtk_radio_button_new_with_mnemonic (NULL, "is content with endmarker");
  gtk_widget_show (radiobutton_xref_content_endmarker);
  gtk_box_pack_start (GTK_BOX (vbox9), radiobutton_xref_content_endmarker, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_xref_content_endmarker), radiobutton_xref_group);
  radiobutton_xref_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_xref_content_endmarker));

  label49 = gtk_label_new ("");
  gtk_widget_show (label49);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook_subtype), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook_subtype), 2), label49);

  vbox13 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox13);
  gtk_container_add (GTK_CONTAINER (notebook_subtype), vbox13);
  gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (notebook_subtype), vbox13,
                                      FALSE, FALSE, GTK_PACK_START);

  label55 = gtk_label_new ("This one:");
  gtk_widget_show (label55);
  gtk_box_pack_start (GTK_BOX (vbox13), label55, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label55), 0, 0.5);

  GSList *radiobutton_paragraph_type_main_title_group = NULL;

  radiobutton_paragraph_type_main_title = gtk_radio_button_new_with_mnemonic (NULL, "is a main title");
  gtk_widget_show (radiobutton_paragraph_type_main_title);
  gtk_box_pack_start (GTK_BOX (vbox13), radiobutton_paragraph_type_main_title, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_paragraph_type_main_title), radiobutton_paragraph_type_main_title_group);
  radiobutton_paragraph_type_main_title_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_paragraph_type_main_title));

  radiobutton_paragraph_type_subtitle = gtk_radio_button_new_with_mnemonic (NULL, "is a subtitle");
  gtk_widget_show (radiobutton_paragraph_type_subtitle);
  gtk_box_pack_start (GTK_BOX (vbox13), radiobutton_paragraph_type_subtitle, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_paragraph_type_subtitle), radiobutton_paragraph_type_main_title_group);
  radiobutton_paragraph_type_main_title_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_paragraph_type_subtitle));

  radiobutton_paragraph_type_section_heading = gtk_radio_button_new_with_mnemonic (NULL, "is a section heading");
  gtk_widget_show (radiobutton_paragraph_type_section_heading);
  gtk_box_pack_start (GTK_BOX (vbox13), radiobutton_paragraph_type_section_heading, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_paragraph_type_section_heading), radiobutton_paragraph_type_main_title_group);
  radiobutton_paragraph_type_main_title_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_paragraph_type_section_heading));

  radiobutton_paragraph_type_text = gtk_radio_button_new_with_mnemonic (NULL, "is a normal paragraph");
  gtk_widget_show (radiobutton_paragraph_type_text);
  gtk_box_pack_start (GTK_BOX (vbox13), radiobutton_paragraph_type_text, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_paragraph_type_text), radiobutton_paragraph_type_main_title_group);
  radiobutton_paragraph_type_main_title_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_paragraph_type_text));

  label54 = gtk_label_new ("");
  gtk_widget_show (label54);
  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook_subtype), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook_subtype), 3), label54);

  vseparator2 = gtk_vseparator_new ();
  gtk_widget_show (vseparator2);
  gtk_box_pack_start (GTK_BOX (hbox8), vseparator2, TRUE, TRUE, 0);

  vbox6 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox6);
  gtk_box_pack_start (GTK_BOX (hbox8), vbox6, TRUE, TRUE, 0);

  // Optional widgets, set them all to NULL.
  hbox2 = NULL;
  hbox6 = NULL;
  checkbutton_italic = NULL;
  checkbutton_bold = NULL;
  checkbutton_underline = NULL;
  checkbutton_small_caps = NULL;
  table2 = NULL;
  checkbutton_superscript = NULL;
  vbox4 = NULL;
  checkbutton_apocrypha = NULL;
  checkbutton_span = NULL;
  vbox10 = NULL;
  hbox10 = NULL;
  checkbutton_notecaller_spacious = NULL;
  
  dialog_action_area1 = GTK_DIALOG (stylesheetdialog)->action_area;
  gtk_widget_show (dialog_action_area1);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);

  cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_show (cancelbutton1);
  gtk_dialog_add_action_widget (GTK_DIALOG (stylesheetdialog), cancelbutton1, GTK_RESPONSE_CANCEL);
  GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);

  okbutton = gtk_button_new_from_stock ("gtk-ok");
  gtk_widget_show (okbutton);
  gtk_dialog_add_action_widget (GTK_DIALOG (stylesheetdialog), okbutton, GTK_RESPONSE_OK);
  GTK_WIDGET_SET_FLAGS (okbutton, GTK_CAN_DEFAULT);

  g_signal_connect ((gpointer) okbutton, "clicked", G_CALLBACK (on_okbutton_clicked), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_id, "toggled", G_CALLBACK (on_style_type_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_comment, "toggled", G_CALLBACK (on_style_type_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_runningheader, "toggled", G_CALLBACK (on_style_type_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_paragraph, "toggled", G_CALLBACK (on_style_type_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_inline, "toggled", G_CALLBACK (on_style_type_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_chapter, "toggled", G_CALLBACK (on_style_type_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_verse, "toggled", G_CALLBACK (on_style_type_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_footendnote, "toggled", G_CALLBACK (on_style_type_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_crossreference, "toggled", G_CALLBACK (on_style_type_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_footnote, "toggled", G_CALLBACK (on_radiobutton_note_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_endnote, "toggled", G_CALLBACK (on_radiobutton_note_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_note_content_standard, "toggled", G_CALLBACK (on_radiobutton_note_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_note_content, "toggled", G_CALLBACK (on_radiobutton_note_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_note_content_endmarker, "toggled", G_CALLBACK (on_radiobutton_note_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_note_paragraph, "toggled", G_CALLBACK (on_radiobutton_note_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_xref, "toggled", G_CALLBACK (on_radiobutton_xref_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_xref_content_standard, "toggled", G_CALLBACK (on_radiobutton_xref_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_xref_content, "toggled", G_CALLBACK (on_radiobutton_xref_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_xref_content_endmarker, "toggled", G_CALLBACK (on_radiobutton_xref_toggled), gpointer(this));

  gtk_label_set_mnemonic_widget (GTK_LABEL (label37), entryname);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label36), textview1);

  gtk_widget_grab_default (okbutton);
  
  // Display the style.
  set_gui ();
}


StylesheetDialog::~StylesheetDialog ()
{
  gtk_widget_destroy (stylesheetdialog);
}


int StylesheetDialog::run ()
{
  return gtk_dialog_run (GTK_DIALOG (stylesheetdialog));
}


void StylesheetDialog::on_okbutton_clicked (GtkButton *button, gpointer user_data)
{
  ((StylesheetDialog *) user_data)->on_ok ();
}


void StylesheetDialog::on_ok()
{
  save_style ();
  name = gtk_entry_get_text (GTK_ENTRY (entryname));
}


void StylesheetDialog::on_style_type_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
  ((StylesheetDialog *) user_data)->on_style_type (togglebutton);
}


void StylesheetDialog::on_style_type (GtkToggleButton *togglebutton)
{
  // Set this togglebutton as the widget that gets activated on the shortcut.
  gtk_label_set_mnemonic_widget (GTK_LABEL (label21), GTK_WIDGET (togglebutton));
  // Destroy any optional widgets.
  destroy_optional_widgets ();
  // Get the type of the style.
  StyleType type = get_styletype();
  switch (type) {
    case stIdentifier:
    {
      // Notebook subtype
      // 0: hidden
      // 1: footnote/endnote
      // 2: crossreference
      // 3: paragraph
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 0);
      break;
    }
    case stComment:
    {
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 0);
      break;
    }
    case stRunningHeader:
    {
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 0);
      fontsize_points_create ();
      italic_simple_create ();
      bold_simple_create ();
      underline_simple_create ();
      smallcaps_simple_create ();
      break;
    }
    case stStartsParagraph:
    {
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 3);
      fontsize_points_create ();
      italic_simple_create ();
      bold_simple_create ();
      underline_simple_create ();
      smallcaps_simple_create ();
      paragraph_create ();
      span_columns_create ();
      break;
    }
    case stInlineText:
    {
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 0);
      fontsize_percentage_create ();
      italic_bold_underline_smallcaps_extended_create ();
      superscript_create ();
      break;
    }
    case stChapterNumber:
    {
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 0);
      fontsize_points_create ();
      italic_simple_create ();
      bold_simple_create ();
      underline_simple_create ();
      smallcaps_simple_create ();
      paragraph_create ();
      span_columns_create ();
      break;
    }
    case stVerseNumber:
    {
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 0);
      fontsize_percentage_create ();
      italic_bold_underline_smallcaps_extended_create ();
      superscript_create ();
      break;
    }
    case stFootEndNote:
    {
      on_radiobutton_note ();
      break;
    }
    case stCrossreference:
    {
      on_radiobutton_xref ();
      break;
    }
  }
}


void StylesheetDialog::on_alignment_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
  ((StylesheetDialog *) user_data)->on_alignment (togglebutton);
}


void StylesheetDialog::on_alignment (GtkToggleButton *togglebutton)
{
  // Set this togglebutton as the widget that gets activated on the shortcut.
  gtk_label_set_mnemonic_widget (GTK_LABEL (label10), GTK_WIDGET (togglebutton));
}


void StylesheetDialog::set_gui ()
{
  // Get all available styles in this stylesheet.
  vector<Style> styles;
  stylesheet_get_styles (mystylesheet, styles);
  // Get the style we now display.
  int pointer = stylesheet_style_get_pointer (styles, mystyle);
  if (pointer >= 0) {
    // Store values in the object.
    fontsize_points = styles[pointer].fontsize;
    fontsize_percentage = styles[pointer].fontpercentage;
    italic = styles[pointer].italic;
    bold = styles[pointer].bold;
    underline = styles[pointer].underline;
    smallcaps = styles[pointer].smallcaps;
    superscript = styles[pointer].superscript;
    justification = styles[pointer].justification;
    spacebefore = styles[pointer].spacebefore;
    spaceafter = styles[pointer].spaceafter;
    leftmargin = styles[pointer].leftmargin;
    rightmargin = styles[pointer].rightmargin;
    firstlineindent = styles[pointer].firstlineindent;
    spancolumns = styles[pointer].spancolumns;
    userbool1 = styles[pointer].userbool1;
    userbool2 = styles[pointer].userbool2;
    userbool3 = styles[pointer].userbool3;
    userint1 = styles[pointer].userint1;
    userint2 = styles[pointer].userint2;
    userint3 = styles[pointer].userint3;
    userstring1 = styles[pointer].userstring1;
    userstring2 = styles[pointer].userstring2;
    userstring3 = styles[pointer].userstring3;
    // Display information about this style.
    ustring info;
    info = "\\" + mystyle;
    gtk_label_set_text (GTK_LABEL (labelstyle), info.c_str());
    gtk_entry_set_text (GTK_ENTRY (entryname), styles[pointer].name.c_str());
    gtk_text_buffer_set_text (gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview1)), styles[pointer].info.c_str(), -1);
    // Set publication information.
    GtkWidget * togglebutton = radiobutton_comment;
    switch (styles[pointer].type) {
      case stIdentifier      : 
        togglebutton = radiobutton_id;
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_id), true);
        gtk_label_set_mnemonic_widget (GTK_LABEL (label21), radiobutton_id);
        break;
      case stComment         : 
        togglebutton = radiobutton_comment;
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_comment), true);
        gtk_label_set_mnemonic_widget (GTK_LABEL (label21), radiobutton_comment);
        break;
      case stRunningHeader   :
        togglebutton = radiobutton_runningheader;
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_runningheader), true);
        gtk_label_set_mnemonic_widget (GTK_LABEL (label21), radiobutton_runningheader);
        break;
      case stStartsParagraph :
        togglebutton = radiobutton_paragraph;
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_paragraph), true);
        gtk_label_set_mnemonic_widget (GTK_LABEL (label21), radiobutton_paragraph);
        break;
      case stInlineText      :
        togglebutton = radiobutton_inline;
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_inline), true);
        gtk_label_set_mnemonic_widget (GTK_LABEL (label21), radiobutton_inline);
        break;
      case stChapterNumber   :
        togglebutton = radiobutton_chapter;
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_chapter), true);
        gtk_label_set_mnemonic_widget (GTK_LABEL (label21), radiobutton_chapter);
        break;
      case stVerseNumber     :
        togglebutton = radiobutton_verse;
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_verse), true);
        gtk_label_set_mnemonic_widget (GTK_LABEL (label21), radiobutton_verse);
        break;
      case stFootEndNote     :
        togglebutton = radiobutton_footendnote;
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_footendnote), true);
        gtk_label_set_mnemonic_widget (GTK_LABEL (label21), radiobutton_footendnote);
        break;
      case stCrossreference  :
        togglebutton = radiobutton_crossreference;
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_crossreference), true);
        gtk_label_set_mnemonic_widget (GTK_LABEL (label21), radiobutton_crossreference);
        break;
    }
    on_style_type (GTK_TOGGLE_BUTTON (togglebutton));
    set_subtype (styles[pointer].type, styles[pointer].subtype);
  }
}


void StylesheetDialog::save_style ()
{
  // Destroy relevant widgets, so saving their value.
  destroy_optional_widgets ();
  // Get the type of this style.
  StyleType type = get_styletype();
  // Get remaining value of this style.
  ustring info;
  GtkTextBuffer * buffer;
  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview1));
  GtkTextIter startiter;
  GtkTextIter enditer;
  gtk_text_buffer_get_start_iter (buffer, &startiter);
  gtk_text_buffer_get_end_iter (buffer, &enditer);
  info = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (buffer), &startiter, &enditer, false);
  info = trim (info);
  // Save this style.
  stylesheet_save_style (mystylesheet, mystyle,
    gtk_entry_get_text (GTK_ENTRY (entryname)), info, type, get_subtype (),
    fontsize_points, fontsize_percentage, italic, bold, underline, smallcaps,
    superscript, justification, spacebefore, spaceafter, leftmargin, 
    rightmargin, firstlineindent, spancolumns, userbool1, userbool2, userbool3, 
    userint1, userint2, userint3, userstring1, userstring2, userstring3
  );
}


void StylesheetDialog::set_justification (const ustring& justification)
// Sets the GUI.
{
  if (justification == CENTER) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_center), true);
    on_alignment (GTK_TOGGLE_BUTTON (radiobutton_center));
  } else if (justification == RIGHT) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_right), true);
    on_alignment (GTK_TOGGLE_BUTTON (radiobutton_right));
  } else if (justification == JUSTIFIED) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_full), true);
    on_alignment (GTK_TOGGLE_BUTTON (radiobutton_full));
  } else {
    // Defaults to left.
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_left), true);
    on_alignment (GTK_TOGGLE_BUTTON (radiobutton_left));
  }
}


ustring StylesheetDialog::get_justification ()
// Get the string that indicates the justification, from the GUI.
{
  ustring result;
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_center))) {
    result = CENTER;
  } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_right))) {
    result = RIGHT;
  } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_full))) {
    result = JUSTIFIED;
  } else {
    // Defaults to left.
    result = LEFT;
  }
  return result;
}


void StylesheetDialog::set_italic ()
{
  if (italic == ON) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_italics_on), true);
    on_radiobutton_italic (radiobutton_italics_on);
  } else if (italic == INHERIT) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_italics_inherit), true);
    on_radiobutton_italic (radiobutton_italics_inherit);
  } else if (italic == TOGGLE) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_italics_toggle), true);
    on_radiobutton_italic (radiobutton_italics_toggle);
  } else {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_italics_off), true);
    on_radiobutton_italic (radiobutton_italics_off);
  }
}


ustring StylesheetDialog::get_italic ()
{
  // Defaults to off.
  ustring result = OFF;
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_italics_on))) {
    result = ON;
  } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_italics_inherit))) {
    result = INHERIT;
  } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_italics_toggle))) {
    result = TOGGLE;
  }
  return result;
}


void StylesheetDialog::set_bold ()
{
  if (bold == ON) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_bold_on), true);
    on_radiobutton_bold (radiobutton_bold_on);
  } else if (bold == INHERIT) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_bold_inherit), true);
    on_radiobutton_bold (radiobutton_bold_inherit);
  } else if (bold == TOGGLE) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_bold_toggle), true);
    on_radiobutton_bold (radiobutton_bold_toggle);
  } else {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_bold_off), true);
    on_radiobutton_bold (radiobutton_bold_off);
  }
}


ustring StylesheetDialog::get_bold ()
{
  // Defaults to off.
  ustring result = OFF;
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_bold_on))) {
    result = ON;
  } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_bold_inherit))) {
    result = INHERIT;
  } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_bold_toggle))) {
    result = TOGGLE;
  }
  return result;
}


void StylesheetDialog::set_underline ()
{
  if (underline == ON) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_underline_on), true);
    on_radiobutton_underline (radiobutton_underline_on);
  } else if (underline == INHERIT) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_underline_inherit), true);
    on_radiobutton_underline (radiobutton_underline_inherit);
  } else if (underline == TOGGLE) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_underline_toggle), true);
    on_radiobutton_underline (radiobutton_underline_toggle);
  } else {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_underline_off), true);
    on_radiobutton_underline (radiobutton_underline_off);
  }
}


ustring StylesheetDialog::get_underline ()
{
  // Defaults to off.
  ustring result = OFF;
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_underline_on))) {
    result = ON;
  } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_underline_inherit))) {
    result = INHERIT;
  } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_underline_toggle))) {
    result = TOGGLE;
  }
  return result;
}


void StylesheetDialog::set_small_caps ()
{
  if (smallcaps == ON) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_small_caps_on), true);
    on_radiobutton_small_caps (radiobutton_small_caps_on);
  } else if (smallcaps == INHERIT) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_small_caps_inherit), true);
    on_radiobutton_small_caps (radiobutton_small_caps_inherit);
  } else if (smallcaps == TOGGLE) {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_small_caps_toggle), true);
    on_radiobutton_small_caps (radiobutton_small_caps_toggle);
  } else {
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_small_caps_off), true);
   on_radiobutton_small_caps (radiobutton_small_caps_off);
  }
}


ustring StylesheetDialog::get_small_caps ()
{
  // Defaults to off.
  ustring result = OFF;
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_small_caps_on))) {
    result = ON;
  } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_small_caps_inherit))) {
    result = INHERIT;
  } else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_small_caps_toggle))) {
    result = TOGGLE;
  }
  return result;
}


StyleType StylesheetDialog::get_styletype ()
{
  StyleType type = stComment;
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_id))) {
    type = stIdentifier;
  }
  else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_comment))) {
    type = stComment;
  }
  else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_runningheader))) {
    type = stRunningHeader;
  }
  else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_paragraph))) {
    type = stStartsParagraph;
  }
  else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_inline))) {
    type = stInlineText;
  }
  else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_chapter))) {
    type = stChapterNumber;
  }
  else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_verse))) {
    type = stVerseNumber;
  }
  else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_footendnote))) {
    type = stFootEndNote;
  }
  else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_crossreference))) {
    type = stCrossreference;
  }
  return type;
}


void StylesheetDialog::on_radiobutton_italic_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
  ((StylesheetDialog *) user_data)->on_radiobutton_italic (GTK_WIDGET (togglebutton));
}


void StylesheetDialog::on_radiobutton_italic (GtkWidget *togglebutton)
{
  gtk_label_set_mnemonic_widget (GTK_LABEL (label40), togglebutton);
}


void StylesheetDialog::on_radiobutton_bold_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
  ((StylesheetDialog *) user_data)->on_radiobutton_bold (GTK_WIDGET (togglebutton));
}


void StylesheetDialog::on_radiobutton_bold (GtkWidget *togglebutton)
{
  gtk_label_set_mnemonic_widget (GTK_LABEL (label41), togglebutton);
}


void StylesheetDialog::on_radiobutton_underline_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
  ((StylesheetDialog *) user_data)->on_radiobutton_underline (GTK_WIDGET (togglebutton));
}


void StylesheetDialog::on_radiobutton_underline (GtkWidget *togglebutton)
{
  gtk_label_set_mnemonic_widget (GTK_LABEL (label42), togglebutton);
}


void StylesheetDialog::on_radiobutton_small_caps_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
  ((StylesheetDialog *) user_data)->on_radiobutton_small_caps (GTK_WIDGET (togglebutton));
}


void StylesheetDialog::on_radiobutton_small_caps (GtkWidget *togglebutton)
{
  gtk_label_set_mnemonic_widget (GTK_LABEL (label_small_caps), togglebutton);
}


void StylesheetDialog::set_subtype (StyleType maintype, int subtype)
{
  switch (maintype) {
    case stIdentifier      : 
      break;
    case stComment         : 
      break;
    case stRunningHeader   :
      break;
    case stStartsParagraph :
    {
      ParagraphType paragraphtype = (ParagraphType) subtype;
      switch (paragraphtype) {
        case ptMainTitle:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_paragraph_type_main_title), true);
          break;
        case ptSubTitle:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_paragraph_type_subtitle), true);
          break;
        case ptSectionHeading:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_paragraph_type_section_heading), true);
          break;
        case ptNormalParagraph:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_paragraph_type_text), true);
          break;
      }
      break;
    }
    case stInlineText      :
      break;
    case stChapterNumber   :
      break;
    case stVerseNumber     :
      break;
    case stFootEndNote     :
    {  
      FootEndNoteType footnotetype = (FootEndNoteType) subtype;
      switch (footnotetype) {
        case fentFootnote:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_footnote), true);
          break;
        case fentEndnote:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_endnote), true);
          break;
        case fentStandardContent:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_content_standard), true);
          break;
        case fentContent:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_content), true);
          break;
        case fentContentWithEndmarker:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_content_endmarker), true);
          break;
        case fentParagraph:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_paragraph), true);
          break;
      }
      break;
    }
    case stCrossreference  :
    {
      CrossreferenceType crossreferencetype = (CrossreferenceType) subtype;
      switch (crossreferencetype) {
        case ctCrossreference:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_xref), true);
          break;
        case ctStandardContent:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_xref_content_standard), true);
          break;
        case ctContent:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_xref_content), true);
          break;
        case ctContentWithEndmarker:
          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_xref_content_endmarker), true);
          break;
      }
      break;
    }
  }
}


int StylesheetDialog::get_subtype ()
{
  int subtype = 0;
  switch (gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook_subtype))) {
    case 0 :
      // Subtype is not relevant here.
      break;
    case 1 :
      // Get subtype for footnotes and endnotes.
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_footnote)))
        subtype = fentFootnote;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_endnote)))
        subtype = fentEndnote;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_content)))
        subtype = fentContent;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_content_standard)))
        subtype = fentStandardContent;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_content_endmarker)))
        subtype = fentContentWithEndmarker;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_paragraph)))
        subtype = fentParagraph;
      break;
    case 2 :
      // Get subtype for crossreferences.
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_xref)))
        subtype = ctCrossreference;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_xref_content_standard)))
        subtype = ctStandardContent;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_xref_content)))
        subtype = ctContent;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_xref_content_endmarker)))
        subtype = ctContentWithEndmarker;
      break;
    case 3 :
      // Get subtype for paragraphs.
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_paragraph_type_main_title)))
        subtype = ptMainTitle;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_paragraph_type_subtitle)))
        subtype = ptSubTitle;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_paragraph_type_section_heading)))
        subtype = ptSectionHeading;
      if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_paragraph_type_text)))
        subtype = ptNormalParagraph;
      break;
  }    
  return subtype;
}


void StylesheetDialog::on_radiobutton_note_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
  ((StylesheetDialog *) user_data)->on_radiobutton_note ();
}


void StylesheetDialog::on_radiobutton_note ()
{
  // Destroy any optional widgets.
  destroy_optional_widgets ();
  // Show/hide notebooks with visual settings.
  FootEndNoteType subtype = (FootEndNoteType) get_subtype ();
  switch (subtype) {
    case fentFootnote:
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 1);
      fontsize_percentage_create ();
      italic_bold_underline_smallcaps_extended_create ();
      superscript_create ();
      note_numbering_type_create ();
      note_numering_restart_create ();
      note_caller_spacious_create ();
      break;
    case fentEndnote:
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 1);
      fontsize_percentage_create ();
      italic_bold_underline_smallcaps_extended_create ();
      superscript_create ();
      break;
    case fentStandardContent:
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 1);
      fontsize_points_create ();
      italic_simple_create ();
      bold_simple_create ();
      underline_simple_create ();
      smallcaps_simple_create ();
      superscript_create ();
      paragraph_create ();
      apocrypha_create ();
      break;
    case fentContent:
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 1);
      fontsize_percentage_create ();
      italic_bold_underline_smallcaps_extended_create ();
      superscript_create ();
      apocrypha_create ();
      break;
    case fentContentWithEndmarker:
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 1);
      fontsize_percentage_create ();
      italic_bold_underline_smallcaps_extended_create ();
      superscript_create ();
      apocrypha_create ();
      break;
    case fentParagraph:
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 1);
      fontsize_points_create ();
      italic_simple_create ();
      bold_simple_create ();
      underline_simple_create ();
      smallcaps_simple_create ();
      superscript_create ();
      paragraph_create ();
      apocrypha_create ();
      break;
  }
}


void StylesheetDialog::on_radiobutton_xref_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
  ((StylesheetDialog *) user_data)->on_radiobutton_xref ();
}


void StylesheetDialog::on_radiobutton_xref ()
{
  // Destroy any optional widgets.
  destroy_optional_widgets ();
  // Show/hide notebooks with visual settings.
  CrossreferenceType subtype = (CrossreferenceType) get_subtype ();
  switch (subtype) {
    case ctCrossreference:
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 2);
      fontsize_percentage_create ();
      italic_bold_underline_smallcaps_extended_create ();
      superscript_create ();
      note_numbering_type_create ();
      note_numering_restart_create ();
      note_caller_spacious_create ();
      break;
    case ctStandardContent:
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 2);
      fontsize_points_create ();
      italic_simple_create ();
      bold_simple_create ();
      underline_simple_create ();
      smallcaps_simple_create ();
      superscript_create ();
      paragraph_create ();
      apocrypha_create ();
      break;
    case ctContent:
    case ctContentWithEndmarker:
      gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook_subtype), 2);
      fontsize_percentage_create ();
      italic_bold_underline_smallcaps_extended_create ();
      superscript_create ();
      apocrypha_create ();
      break;
  }
}


void StylesheetDialog::destroy_optional_widgets ()
/*
Store the values of the optional widgets, and destroy them.

General strategy.
- If a widget is not NULL, it means it is in use and we need to handle it.
- Update all spin buttons to get the correct value in them after manual edit.
  If this were not done, manual changes in a spinbutton might get lost.
- Extract the value and store it.
- Destroy the top widget, which will destroy all its children as well.
- Set the top widget to NULL.

*/
{
  // Fontsize in points.
  if (hbox2) {
    gtk_spin_button_update (GTK_SPIN_BUTTON (spinbuttonfontsize));
    fontsize_points = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbuttonfontsize));
    gtk_widget_destroy (hbox2);
    hbox2 = NULL;
  }
  // Fontsize in percentages.
  if (hbox6) {
    gtk_spin_button_update (GTK_SPIN_BUTTON (spinbuttonfontpercentage));
    fontsize_percentage = int (gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbuttonfontpercentage)));
    gtk_widget_destroy (hbox6);
    hbox6 = NULL;
  }
  // Simple italic;
  if (checkbutton_italic) {
    italic = OFF;
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_italic)))
      italic = ON;
    gtk_widget_destroy (checkbutton_italic);
    checkbutton_italic = NULL;
  }
  // Simple bold;
  if (checkbutton_bold) {
    bold = OFF;
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_bold)))
      bold = ON;
    gtk_widget_destroy (checkbutton_bold);
    checkbutton_bold = NULL;
  }
  // Simple underline;
  if (checkbutton_underline) {
    underline = OFF;
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_underline)))
      underline = ON;
    gtk_widget_destroy (checkbutton_underline);
    checkbutton_underline = NULL;
  }
  // Simple small caps;
  if (checkbutton_small_caps) {
    smallcaps = OFF;
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_small_caps)))
      smallcaps = ON;
    gtk_widget_destroy (checkbutton_small_caps);
    checkbutton_small_caps = NULL;
  }
  // Extended italic/bold/underline/small caps.
  if (table2) {
    italic = get_italic ();
    bold = get_bold ();
    underline = get_underline ();
    smallcaps = get_small_caps ();
    gtk_widget_destroy (table2);
    table2 = NULL;
  }
  // Superscript
  if (checkbutton_superscript) {
    superscript = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_superscript));
    gtk_widget_destroy (checkbutton_superscript);
    checkbutton_superscript = NULL;
  }
  // Paragraph
  if (vbox4) {
    gtk_spin_button_update (GTK_SPIN_BUTTON (spinbutton_before));
    gtk_spin_button_update (GTK_SPIN_BUTTON (spinbutton_after));
    gtk_spin_button_update (GTK_SPIN_BUTTON (spinbutton_left));
    gtk_spin_button_update (GTK_SPIN_BUTTON (spinbutton_right));
    gtk_spin_button_update (GTK_SPIN_BUTTON (spinbutton_first));
    justification = get_justification(),
    spacebefore = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton_before)),
    spaceafter = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton_after)),
    leftmargin = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton_left)),
    rightmargin = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton_right)),
    firstlineindent = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spinbutton_first)),
    gtk_widget_destroy (vbox4);
    vbox4 = NULL;    
  }
  // Span columns
  if (checkbutton_span) {
    spancolumns = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_span)),
    gtk_widget_destroy (checkbutton_span);
    checkbutton_span = NULL;    
  }
  // Apocrypha
  if (checkbutton_apocrypha) {
    userbool1 = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_apocrypha));
    gtk_widget_destroy (checkbutton_apocrypha);
    checkbutton_apocrypha = NULL;
  }
  // Note numbering type
  if (vbox10) {
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_1)))
      userint1 = nntNumerical;
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_a)))
      userint1 = nntAlphabetical;
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_user)))
      userint1 = nntUserDefined;
    userstring1 = gtk_entry_get_text (GTK_ENTRY (entry_note_numbering));
    gtk_widget_destroy (vbox10);
    vbox10 = NULL;
  }
  // Note numbering restart
  if (hbox10) {
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_restart_never)))
      userint2 = nnrtNever;
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_restart_book)))
      userint2 = nnrtBook;
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_restart_chapter)))
      userint2 = nnrtChapter;
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_restart_page)))
      userint2 = nnrtPage;
    gtk_widget_destroy (hbox10);
    hbox10 = NULL;
  }
  // Spacious note caller.
  if (checkbutton_notecaller_spacious) {
    userbool2 = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_notecaller_spacious));
    gtk_widget_destroy (checkbutton_notecaller_spacious);
    checkbutton_notecaller_spacious = NULL;
  }
}


void StylesheetDialog::fontsize_points_create ()
{
  hbox2 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox2);
  gtk_box_pack_start (GTK_BOX (vbox6), hbox2, TRUE, TRUE, 0);

  label8 = gtk_label_new_with_mnemonic ("_Font size");
  gtk_widget_show (label8);
  gtk_box_pack_start (GTK_BOX (hbox2), label8, FALSE, FALSE, 0);
  gtk_misc_set_padding (GTK_MISC (label8), 4, 0);

  spinbuttonfontsize_adj = gtk_adjustment_new (12, 5, 60, 0.1, 1, 1);
  spinbuttonfontsize = gtk_spin_button_new (GTK_ADJUSTMENT (spinbuttonfontsize_adj), 1, 1);
  gtk_widget_show (spinbuttonfontsize);
  gtk_box_pack_start (GTK_BOX (hbox2), spinbuttonfontsize, FALSE, FALSE, 0);

  label9 = gtk_label_new ("points");
  gtk_widget_show (label9);
  gtk_box_pack_start (GTK_BOX (hbox2), label9, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label9), 0, 0.5);
  gtk_misc_set_padding (GTK_MISC (label9), 4, 0);
  
  gtk_label_set_mnemonic_widget (GTK_LABEL (label8), spinbuttonfontsize);

  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbuttonfontsize), fontsize_points);
}


void StylesheetDialog::fontsize_percentage_create ()
{
  hbox6 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox6);
  gtk_box_pack_start (GTK_BOX (vbox6), hbox6, TRUE, TRUE, 0);

  label31 = gtk_label_new_with_mnemonic ("_Font size");
  gtk_widget_show (label31);
  gtk_box_pack_start (GTK_BOX (hbox6), label31, FALSE, FALSE, 0);
  gtk_misc_set_padding (GTK_MISC (label31), 4, 0);

  spinbuttonfontpercentage_adj = gtk_adjustment_new (100, 20, 500, 1, 10, 10);
  spinbuttonfontpercentage = gtk_spin_button_new (GTK_ADJUSTMENT (spinbuttonfontpercentage_adj), 1, 0);
  gtk_widget_show (spinbuttonfontpercentage);
  gtk_box_pack_start (GTK_BOX (hbox6), spinbuttonfontpercentage, FALSE, FALSE, 0);

  label32 = gtk_label_new ("percent of surrounding text");
  gtk_widget_show (label32);
  gtk_box_pack_start (GTK_BOX (hbox6), label32, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label32), 0, 0.5);
  gtk_misc_set_padding (GTK_MISC (label32), 4, 0);
  
  gtk_label_set_mnemonic_widget (GTK_LABEL (label31), spinbuttonfontpercentage);

  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbuttonfontpercentage), fontsize_percentage);
}


void StylesheetDialog::italic_simple_create ()
{
  checkbutton_italic = gtk_check_button_new_with_mnemonic ("_Italic");
  gtk_widget_show (checkbutton_italic);
  gtk_box_pack_start (GTK_BOX (vbox6), checkbutton_italic, FALSE, FALSE, 0);

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_italic), italic == ON);
}


void StylesheetDialog::bold_simple_create ()
{
  checkbutton_bold = gtk_check_button_new_with_mnemonic ("_Bold");
  gtk_widget_show (checkbutton_bold);
  gtk_box_pack_start (GTK_BOX (vbox6), checkbutton_bold, FALSE, FALSE, 0);

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_bold), bold == ON);
}


void StylesheetDialog::underline_simple_create ()
{
  checkbutton_underline = gtk_check_button_new_with_mnemonic ("_Underline");
  gtk_widget_show (checkbutton_underline);
  gtk_box_pack_start (GTK_BOX (vbox6), checkbutton_underline, FALSE, FALSE, 0);

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_underline), underline == ON);
}


void StylesheetDialog::smallcaps_simple_create ()
{
  checkbutton_small_caps = gtk_check_button_new_with_mnemonic ("S_mall caps");
  gtk_widget_show (checkbutton_small_caps);
  gtk_box_pack_start (GTK_BOX (vbox6), checkbutton_small_caps, FALSE, FALSE, 0);

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_small_caps), smallcaps == ON);
}


void StylesheetDialog::italic_bold_underline_smallcaps_extended_create ()
{
  table2 = gtk_table_new (4, 5, FALSE);
  gtk_widget_show (table2);
  gtk_box_pack_start (GTK_BOX (vbox6), table2, TRUE, TRUE, 0);
  gtk_table_set_row_spacings (GTK_TABLE (table2), 1);
  gtk_table_set_col_spacings (GTK_TABLE (table2), 2);

  label40 = gtk_label_new_with_mnemonic ("_Italic");
  gtk_widget_show (label40);
  gtk_table_attach (GTK_TABLE (table2), label40, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label40), 0, 0.5);

  label41 = gtk_label_new_with_mnemonic ("_Bold");
  gtk_widget_show (label41);
  gtk_table_attach (GTK_TABLE (table2), label41, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label41), 0, 0.5);

  label42 = gtk_label_new_with_mnemonic ("_Underline");
  gtk_widget_show (label42);
  gtk_table_attach (GTK_TABLE (table2), label42, 0, 1, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label42), 0, 0.5);

  label_small_caps = gtk_label_new_with_mnemonic ("S_mall caps");
  gtk_widget_show (label_small_caps);
  gtk_table_attach (GTK_TABLE (table2), label_small_caps, 0, 1, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label_small_caps), 0, 0.5);

  GSList *radiobutton_italics_group = NULL;
  GSList *radiobutton_bold_group = NULL;
  GSList *radiobutton_underline_group = NULL;
  GSList *radiobutton_small_caps_group = NULL;

  radiobutton_italics_off = gtk_radio_button_new_with_mnemonic (NULL, "Off");
  gtk_widget_show (radiobutton_italics_off);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_italics_off, 1, 2, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_italics_off), radiobutton_italics_group);
  radiobutton_italics_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_italics_off));

  radiobutton_italics_on = gtk_radio_button_new_with_mnemonic (NULL, "On");
  gtk_widget_show (radiobutton_italics_on);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_italics_on, 2, 3, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_italics_on), radiobutton_italics_group);
  radiobutton_italics_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_italics_on));

  radiobutton_italics_inherit = gtk_radio_button_new_with_mnemonic (NULL, "Inherit");
  gtk_widget_show (radiobutton_italics_inherit);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_italics_inherit, 3, 4, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_italics_inherit), radiobutton_italics_group);
  radiobutton_italics_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_italics_inherit));

  radiobutton_italics_toggle = gtk_radio_button_new_with_mnemonic (NULL, "Toggle");
  gtk_widget_show (radiobutton_italics_toggle);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_italics_toggle, 4, 5, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_italics_toggle), radiobutton_italics_group);
  radiobutton_italics_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_italics_toggle));

  radiobutton_bold_off = gtk_radio_button_new_with_mnemonic (NULL, "Off");
  gtk_widget_show (radiobutton_bold_off);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_bold_off, 1, 2, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_bold_off), radiobutton_bold_group);
  radiobutton_bold_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_bold_off));

  radiobutton_bold_on = gtk_radio_button_new_with_mnemonic (NULL, "On");
  gtk_widget_show (radiobutton_bold_on);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_bold_on, 2, 3, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_bold_on), radiobutton_bold_group);
  radiobutton_bold_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_bold_on));

  radiobutton_bold_inherit = gtk_radio_button_new_with_mnemonic (NULL, "Inherit");
  gtk_widget_show (radiobutton_bold_inherit);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_bold_inherit, 3, 4, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_bold_inherit), radiobutton_bold_group);
  radiobutton_bold_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_bold_inherit));

  radiobutton_bold_toggle = gtk_radio_button_new_with_mnemonic (NULL, "Toggle");
  gtk_widget_show (radiobutton_bold_toggle);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_bold_toggle, 4, 5, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_bold_toggle), radiobutton_bold_group);
  radiobutton_bold_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_bold_toggle));

  radiobutton_underline_off = gtk_radio_button_new_with_mnemonic (NULL, "Off");
  gtk_widget_show (radiobutton_underline_off);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_underline_off, 1, 2, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_underline_off), radiobutton_underline_group);
  radiobutton_underline_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_underline_off));

  radiobutton_underline_on = gtk_radio_button_new_with_mnemonic (NULL, "On");
  gtk_widget_show (radiobutton_underline_on);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_underline_on, 2, 3, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_underline_on), radiobutton_underline_group);
  radiobutton_underline_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_underline_on));

  radiobutton_underline_inherit = gtk_radio_button_new_with_mnemonic (NULL, "Inherit");
  gtk_widget_show (radiobutton_underline_inherit);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_underline_inherit, 3, 4, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_underline_inherit), radiobutton_underline_group);
  radiobutton_underline_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_underline_inherit));

  radiobutton_underline_toggle = gtk_radio_button_new_with_mnemonic (NULL, "Toggle");
  gtk_widget_show (radiobutton_underline_toggle);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_underline_toggle, 4, 5, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_underline_toggle), radiobutton_underline_group);
  radiobutton_underline_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_underline_toggle));

  radiobutton_small_caps_off = gtk_radio_button_new_with_mnemonic (NULL, "Off");
  gtk_widget_show (radiobutton_small_caps_off);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_small_caps_off, 1, 2, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_small_caps_off), radiobutton_small_caps_group);
  radiobutton_small_caps_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_small_caps_off));

  radiobutton_small_caps_on = gtk_radio_button_new_with_mnemonic (NULL, "On");
  gtk_widget_show (radiobutton_small_caps_on);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_small_caps_on, 2, 3, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_small_caps_on), radiobutton_small_caps_group);
  radiobutton_small_caps_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_small_caps_on));

  radiobutton_small_caps_inherit = gtk_radio_button_new_with_mnemonic (NULL, "Inherit");
  gtk_widget_show (radiobutton_small_caps_inherit);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_small_caps_inherit, 3, 4, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_small_caps_inherit), radiobutton_small_caps_group);
  radiobutton_small_caps_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_small_caps_inherit));

  radiobutton_small_caps_toggle = gtk_radio_button_new_with_mnemonic (NULL, "Toggle");
  gtk_widget_show (radiobutton_small_caps_toggle);
  gtk_table_attach (GTK_TABLE (table2), radiobutton_small_caps_toggle, 4, 5, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_small_caps_toggle), radiobutton_small_caps_group);
  radiobutton_small_caps_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_small_caps_toggle));

  g_signal_connect ((gpointer) radiobutton_italics_off, "toggled", G_CALLBACK (on_radiobutton_italic_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_italics_on, "toggled", G_CALLBACK (on_radiobutton_italic_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_italics_inherit, "toggled", G_CALLBACK (on_radiobutton_italic_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_italics_toggle, "toggled", G_CALLBACK (on_radiobutton_italic_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_bold_off, "toggled", G_CALLBACK (on_radiobutton_bold_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_bold_on, "toggled", G_CALLBACK (on_radiobutton_bold_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_bold_inherit, "toggled", G_CALLBACK (on_radiobutton_bold_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_bold_toggle, "toggled", G_CALLBACK (on_radiobutton_bold_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_underline_off, "toggled", G_CALLBACK (on_radiobutton_underline_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_underline_on, "toggled", G_CALLBACK (on_radiobutton_underline_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_underline_inherit, "toggled", G_CALLBACK (on_radiobutton_underline_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_underline_toggle, "toggled", G_CALLBACK (on_radiobutton_underline_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_small_caps_off, "toggled", G_CALLBACK (on_radiobutton_small_caps_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_small_caps_on, "toggled", G_CALLBACK (on_radiobutton_small_caps_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_small_caps_inherit, "toggled", G_CALLBACK (on_radiobutton_small_caps_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_small_caps_toggle, "toggled", G_CALLBACK (on_radiobutton_small_caps_toggled), gpointer(this));

  set_italic ();
  set_bold ();
  set_underline ();
  set_small_caps ();
}


void StylesheetDialog::superscript_create () 
{
  checkbutton_superscript = gtk_check_button_new_with_mnemonic ("Su_perscript");
  gtk_widget_show (checkbutton_superscript);
  gtk_box_pack_start (GTK_BOX (vbox6), checkbutton_superscript, FALSE, FALSE, 0);

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_superscript), superscript);  
}


void StylesheetDialog::paragraph_create ()
{
  vbox4 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox4);
  gtk_box_pack_start (GTK_BOX (vbox6), vbox4, TRUE, TRUE, 0);

  hbox4 = gtk_hbox_new (FALSE, 10);
  gtk_widget_show (hbox4);
  gtk_box_pack_start (GTK_BOX (vbox4), hbox4, TRUE, TRUE, 0);

  label10 = gtk_label_new_with_mnemonic ("Te_xt alignment");
  gtk_widget_show (label10);
  gtk_box_pack_start (GTK_BOX (hbox4), label10, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label10), 0, 0.5);

  GSList *radiobutton_left_group = NULL;

  radiobutton_left = gtk_radio_button_new_with_mnemonic (NULL, "Left");
  gtk_widget_show (radiobutton_left);
  gtk_box_pack_start (GTK_BOX (hbox4), radiobutton_left, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_left), radiobutton_left_group);
  radiobutton_left_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_left));

  radiobutton_center = gtk_radio_button_new_with_mnemonic (NULL, "Center");
  gtk_widget_show (radiobutton_center);
  gtk_box_pack_start (GTK_BOX (hbox4), radiobutton_center, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_center), radiobutton_left_group);
  radiobutton_left_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_center));

  radiobutton_right = gtk_radio_button_new_with_mnemonic (NULL, "Right");
  gtk_widget_show (radiobutton_right);
  gtk_box_pack_start (GTK_BOX (hbox4), radiobutton_right, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_right), radiobutton_left_group);
  radiobutton_left_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_right));

  radiobutton_full = gtk_radio_button_new_with_mnemonic (NULL, "Justified");
  gtk_widget_show (radiobutton_full);
  gtk_box_pack_start (GTK_BOX (hbox4), radiobutton_full, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_full), radiobutton_left_group);
  radiobutton_left_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_full));

  table1 = gtk_table_new (5, 4, FALSE);
  gtk_widget_show (table1);
  gtk_box_pack_start (GTK_BOX (vbox4), table1, TRUE, TRUE, 0);
  gtk_table_set_row_spacings (GTK_TABLE (table1), 4);
  gtk_table_set_col_spacings (GTK_TABLE (table1), 4);

  label11 = gtk_label_new_with_mnemonic ("S_pace before paragraph");
  gtk_widget_show (label11);
  gtk_table_attach (GTK_TABLE (table1), label11, 0, 1, 0, 1,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label11), 1, 0.5);

  label12 = gtk_label_new_with_mnemonic ("Space afte_r paragraph");
  gtk_widget_show (label12);
  gtk_table_attach (GTK_TABLE (table1), label12, 0, 1, 1, 2,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label12), 1, 0.5);

  label13 = gtk_label_new_with_mnemonic ("_Left margin");
  gtk_widget_show (label13);
  gtk_table_attach (GTK_TABLE (table1), label13, 0, 1, 2, 3,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label13), 1, 0.5);

  label14 = gtk_label_new_with_mnemonic ("Ri_ght margin");
  gtk_widget_show (label14);
  gtk_table_attach (GTK_TABLE (table1), label14, 0, 1, 3, 4,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label14), 1, 0.5);

  label15 = gtk_label_new_with_mnemonic ("_1st Line indent");
  gtk_widget_show (label15);
  gtk_table_attach (GTK_TABLE (table1), label15, 0, 1, 4, 5,
                    (GtkAttachOptions) (GTK_FILL),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label15), 1, 0.5);

  label16 = gtk_label_new ("mm");
  gtk_widget_show (label16);
  gtk_table_attach (GTK_TABLE (table1), label16, 2, 3, 0, 1,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label16), 0, 0.5);

  label17 = gtk_label_new ("mm");
  gtk_widget_show (label17);
  gtk_table_attach (GTK_TABLE (table1), label17, 2, 3, 1, 2,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label17), 0, 0.5);

  label18 = gtk_label_new ("mm");
  gtk_widget_show (label18);
  gtk_table_attach (GTK_TABLE (table1), label18, 2, 3, 2, 3,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label18), 0, 0.5);

  label19 = gtk_label_new ("mm");
  gtk_widget_show (label19);
  gtk_table_attach (GTK_TABLE (table1), label19, 2, 3, 3, 4,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label19), 0, 0.5);

  label20 = gtk_label_new ("mm");
  gtk_widget_show (label20);
  gtk_table_attach (GTK_TABLE (table1), label20, 2, 3, 4, 5,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);
  gtk_misc_set_alignment (GTK_MISC (label20), 0, 0.5);

  spinbutton_first_adj = gtk_adjustment_new (0, -100, 100, 0.1, 1, 1);
  spinbutton_first = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_first_adj), 1, 1);
  gtk_widget_show (spinbutton_first);
  gtk_table_attach (GTK_TABLE (table1), spinbutton_first, 1, 2, 4, 5,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);

  spinbutton_before_adj = gtk_adjustment_new (0, 0, 100, 0.1, 1, 1);
  spinbutton_before = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_before_adj), 1, 1);
  gtk_widget_show (spinbutton_before);
  gtk_table_attach (GTK_TABLE (table1), spinbutton_before, 1, 2, 0, 1,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);

  spinbutton_after_adj = gtk_adjustment_new (0, 0, 100, 0.1, 1, 1);
  spinbutton_after = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_after_adj), 1, 1);
  gtk_widget_show (spinbutton_after);
  gtk_table_attach (GTK_TABLE (table1), spinbutton_after, 1, 2, 1, 2,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);

  spinbutton_left_adj = gtk_adjustment_new (0, -100, 100, 0.1, 1, 1);
  spinbutton_left = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_left_adj), 1, 1);
  gtk_widget_show (spinbutton_left);
  gtk_table_attach (GTK_TABLE (table1), spinbutton_left, 1, 2, 2, 3,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);

  spinbutton_right_adj = gtk_adjustment_new (0, -100, 100, 0.1, 1, 1);
  spinbutton_right = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_right_adj), 1, 1);
  gtk_widget_show (spinbutton_right);
  gtk_table_attach (GTK_TABLE (table1), spinbutton_right, 1, 2, 3, 4,
                    (GtkAttachOptions) (0),
                    (GtkAttachOptions) (0), 0, 0);

  gtk_label_set_mnemonic_widget (GTK_LABEL (label11), spinbutton_before);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label12), spinbutton_after);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label13), spinbutton_left);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label14), spinbutton_right);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label15), spinbutton_first);

  g_signal_connect ((gpointer) radiobutton_left, "toggled", G_CALLBACK (on_alignment_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_center, "toggled", G_CALLBACK (on_alignment_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_right, "toggled", G_CALLBACK (on_alignment_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_full, "toggled", G_CALLBACK (on_alignment_toggled), gpointer(this));
  
  set_justification (justification);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_before), spacebefore);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_after), spaceafter);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_left), leftmargin);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_right), rightmargin);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_first), firstlineindent);
}


void StylesheetDialog::span_columns_create ()
{
  checkbutton_span = gtk_check_button_new_with_mnemonic ("Spans the t_wo columns");
  gtk_widget_show (checkbutton_span);
  gtk_box_pack_start (GTK_BOX (vbox6), checkbutton_span, FALSE, FALSE, 0);

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_span), spancolumns);
}


void StylesheetDialog::apocrypha_create () 
{
  checkbutton_apocrypha = gtk_check_button_new_with_mnemonic ("Refers to the Apocrypha");
  gtk_widget_show (checkbutton_apocrypha);
  gtk_box_pack_start (GTK_BOX (vbox6), checkbutton_apocrypha, FALSE, FALSE, 0);
  
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_apocrypha), userbool1);
}


void StylesheetDialog::note_numbering_type_create ()
{
  vbox10 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox10);
  gtk_box_pack_start (GTK_BOX (vbox6), vbox10, TRUE, TRUE, 0);

  hbox9 = gtk_hbox_new (FALSE, 4);
  gtk_widget_show (hbox9);
  gtk_box_pack_start (GTK_BOX (vbox10), hbox9, TRUE, TRUE, 0);

  label52 = gtk_label_new ("Numbering");
  gtk_widget_show (label52);
  gtk_box_pack_start (GTK_BOX (hbox9), label52, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label52), 0, 0);

  vbox11 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox11);
  gtk_box_pack_start (GTK_BOX (hbox9), vbox11, TRUE, TRUE, 0);

  GSList *radiobutton_note_numbering_1_group = NULL;

  radiobutton_note_numbering_1 = gtk_radio_button_new_with_mnemonic (NULL, "1, 2, 3 ...");
  gtk_widget_show (radiobutton_note_numbering_1);
  gtk_box_pack_start (GTK_BOX (vbox11), radiobutton_note_numbering_1, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_1), radiobutton_note_numbering_1_group);
  radiobutton_note_numbering_1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_1));

  radiobutton_note_numbering_a = gtk_radio_button_new_with_mnemonic (NULL, "a, b, c ...");
  gtk_widget_show (radiobutton_note_numbering_a);
  gtk_box_pack_start (GTK_BOX (vbox11), radiobutton_note_numbering_a, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_a), radiobutton_note_numbering_1_group);
  radiobutton_note_numbering_1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_a));

  radiobutton_note_numbering_user = gtk_radio_button_new_with_mnemonic (NULL, "User defined");
  gtk_widget_show (radiobutton_note_numbering_user);
  gtk_box_pack_start (GTK_BOX (vbox11), radiobutton_note_numbering_user, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_user), radiobutton_note_numbering_1_group);
  radiobutton_note_numbering_1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_user));

  entry_note_numbering = gtk_entry_new ();
  gtk_widget_show (entry_note_numbering);
  gtk_box_pack_start (GTK_BOX (vbox10), entry_note_numbering, FALSE, FALSE, 0);
  gtk_entry_set_activates_default (GTK_ENTRY (entry_note_numbering), TRUE);

  g_signal_connect ((gpointer) radiobutton_note_numbering_1, "toggled", G_CALLBACK (on_radiobutton_note_numbering_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_note_numbering_a, "toggled", G_CALLBACK (on_radiobutton_note_numbering_toggled), gpointer(this));
  g_signal_connect ((gpointer) radiobutton_note_numbering_user, "toggled", G_CALLBACK (on_radiobutton_note_numbering_toggled), gpointer(this));

  NoteNumberingType note_numbering_type = (NoteNumberingType) userint1;
  switch (note_numbering_type) {
    case nntNumerical:
    {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_1), true);
      break;
    }
    case nntAlphabetical:
    {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_a), true);
      break;
    }
    case nntUserDefined:
    {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_user), true);
      break;
    }
  }
  gtk_entry_set_text (GTK_ENTRY (entry_note_numbering), userstring1.c_str());
  on_radiobutton_note_numbering ();
}


void StylesheetDialog::note_numering_restart_create ()
{
  hbox10 = gtk_hbox_new (FALSE, 4);
  gtk_widget_show (hbox10);
  gtk_box_pack_start (GTK_BOX (vbox6), hbox10, TRUE, TRUE, 0);

  label53 = gtk_label_new ("Restart");
  gtk_widget_show (label53);
  gtk_box_pack_start (GTK_BOX (hbox10), label53, FALSE, FALSE, 0);
  gtk_misc_set_alignment (GTK_MISC (label53), 0, 0);

  vbox12 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox12);
  gtk_box_pack_start (GTK_BOX (hbox10), vbox12, TRUE, TRUE, 0);

  GSList *radiobutton_note_numbering_restart_never_group = NULL;

  radiobutton_note_numbering_restart_never = gtk_radio_button_new_with_mnemonic (NULL, "never");
  gtk_widget_show (radiobutton_note_numbering_restart_never);
  gtk_box_pack_start (GTK_BOX (vbox12), radiobutton_note_numbering_restart_never, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_restart_never), radiobutton_note_numbering_restart_never_group);
  radiobutton_note_numbering_restart_never_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_restart_never));

  radiobutton_note_numbering_restart_book = gtk_radio_button_new_with_mnemonic (NULL, "every book");
  gtk_widget_show (radiobutton_note_numbering_restart_book);
  gtk_box_pack_start (GTK_BOX (vbox12), radiobutton_note_numbering_restart_book, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_restart_book), radiobutton_note_numbering_restart_never_group);
  radiobutton_note_numbering_restart_never_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_restart_book));

  radiobutton_note_numbering_restart_chapter = gtk_radio_button_new_with_mnemonic (NULL, "every chapter");
  gtk_widget_show (radiobutton_note_numbering_restart_chapter);
  gtk_box_pack_start (GTK_BOX (vbox12), radiobutton_note_numbering_restart_chapter, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_restart_chapter), radiobutton_note_numbering_restart_never_group);
  radiobutton_note_numbering_restart_never_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_restart_chapter));

  radiobutton_note_numbering_restart_page = gtk_radio_button_new_with_mnemonic (NULL, "every page");
  gtk_widget_show (radiobutton_note_numbering_restart_page);
  gtk_box_pack_start (GTK_BOX (vbox12), radiobutton_note_numbering_restart_page, FALSE, FALSE, 0);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_restart_page), radiobutton_note_numbering_restart_never_group);
  radiobutton_note_numbering_restart_never_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton_note_numbering_restart_page));

  NoteNumberingRestartType note_numbering_type = (NoteNumberingRestartType) userint2;
  switch (note_numbering_type) {
    case nnrtNever:
    {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_restart_never), true);
      break;
    }
    case nnrtBook:
    {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_restart_book), true);
      break;
    }
    case nnrtChapter:
    {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_restart_chapter), true);
      break;
    }
    case nnrtPage:
    {
      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_restart_page), true);
      break;
    }
  }
}


void StylesheetDialog::on_radiobutton_note_numbering_toggled (GtkToggleButton *togglebutton, gpointer user_data)
{
  ((StylesheetDialog *) user_data)->on_radiobutton_note_numbering ();
}


void StylesheetDialog::on_radiobutton_note_numbering ()
{
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radiobutton_note_numbering_user))) {
    gtk_widget_set_sensitive (entry_note_numbering, true);
    gtk_widget_grab_focus (entry_note_numbering);
  } else {
    gtk_widget_set_sensitive (entry_note_numbering, false);
  }
}


void StylesheetDialog::note_caller_spacious_create ()
{
  checkbutton_notecaller_spacious = gtk_check_button_new_with_mnemonic ("Allow double space for note caller");
  gtk_widget_show (checkbutton_notecaller_spacious);
  gtk_box_pack_start (GTK_BOX (vbox6), checkbutton_notecaller_spacious, FALSE, FALSE, 0);

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_notecaller_spacious), userbool2);
}

Generated by  Doxygen 1.6.0   Back to index