void
FontSubstitution::show(Glib::ustring out, GSList *l)
{
   Gtk::MessageDialog warning(_("\nSome fonts are not available and have been substituted."),
                       false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true);
   warning.set_resizable(true);
   warning.set_title(_("Font substitution"));

   GtkWidget *dlg = GTK_WIDGET(warning.gobj());
   sp_transientize(dlg);

   Gtk::TextView * textview = new Gtk::TextView();
   textview->set_editable(false);
   textview->set_wrap_mode(Gtk::WRAP_WORD);
   textview->show();
   textview->get_buffer()->set_text(_(out.c_str()));

   Gtk::ScrolledWindow * scrollwindow = new Gtk::ScrolledWindow();
   scrollwindow->add(*textview);
   scrollwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
   scrollwindow->set_shadow_type(Gtk::SHADOW_IN);
   scrollwindow->set_size_request(0, 100);
   scrollwindow->show();

   Gtk::CheckButton *cbSelect = new Gtk::CheckButton();
   cbSelect->set_label(_("Select all the affected items"));
   cbSelect->set_active(true);
   cbSelect->show();

   Gtk::CheckButton *cbWarning = new Gtk::CheckButton();
   cbWarning->set_label(_("Don't show this warning again"));
   cbWarning->show();

#if GTK_CHECK_VERSION(3,0,0)
   Gtk::Box * box = warning.get_content_area();
#else
   Gtk::Box * box = warning.get_vbox();
#endif
   box->set_spacing(2);
   box->pack_start(*scrollwindow, true, true, 4);
   box->pack_start(*cbSelect, false, false, 0);
   box->pack_start(*cbWarning, false, false, 0);

   warning.run();

   if (cbWarning->get_active()) {
       Inkscape::Preferences *prefs = Inkscape::Preferences::get();
       prefs->setInt("/options/font/substitutedlg", 0);
   }

   if (cbSelect->get_active()) {

       SPDesktop *desktop = SP_ACTIVE_DESKTOP;
       Inkscape::Selection *selection = sp_desktop_selection (desktop);
       selection->clear();
       selection->setList(l);
   }

}
LivePathEffectEditor::LivePathEffectEditor()
    : UI::Widget::Panel("", "/dialogs/livepatheffect", SP_VERB_DIALOG_LIVE_PATH_EFFECT),
      lpe_list_locked(false),
      combo_effecttype(Inkscape::LivePathEffect::LPETypeConverter),
      effectwidget(NULL),
      explain_label("", Gtk::ALIGN_CENTER),
      // TRANSLATORS: this dialog is accessible via menu Path - Path Effect Editor...
      effectapplication_frame(_("Apply new effect")),
      effectcontrol_frame(_("Current effect")),
      effectlist_frame(_("Effect list")),
      button_up(Gtk::Stock::GO_UP),
      button_down(Gtk::Stock::GO_DOWN),
      button_apply(Gtk::Stock::ADD),
      button_remove(Gtk::Stock::REMOVE),
      current_desktop(NULL),
      current_lpeitem(NULL)
{
    Gtk::Box *contents = _getContents();
    contents->set_spacing(4);

    //Add the TreeView, inside a ScrolledWindow, with the button underneath:
    scrolled_window.add(effectlist_view);
    //Only show the scrollbars when they are necessary:
    scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
    scrolled_window.set_size_request(0, 50);

    effectapplication_hbox.set_spacing(4);
    effectcontrol_vbox.set_spacing(4);
    effectlist_vbox.set_spacing(4);

    effectapplication_hbox.pack_start(combo_effecttype, true, true);
    effectapplication_hbox.pack_start(button_apply, true, true);
    effectapplication_frame.add(effectapplication_hbox);

    effectlist_vbox.pack_start(scrolled_window, Gtk::PACK_EXPAND_WIDGET);
    effectlist_vbox.pack_end(toolbar, Gtk::PACK_SHRINK);
   // effectlist_vbox.pack_end(button_hbox, Gtk::PACK_SHRINK);
    effectlist_frame.add(effectlist_vbox);

    effectcontrol_vbox.pack_start(explain_label, true, true);
    effectcontrol_frame.add(effectcontrol_vbox);

 //   button_hbox.pack_start(button_up, true, true);
 //   button_hbox.pack_start(button_down, true, true);
 //   button_hbox.pack_end(button_remove, true, true);
    toolbar.set_toolbar_style(Gtk::TOOLBAR_ICONS);
 // Add toolbar items to toolbar
    toolbar.append(button_up);
    toolbar.append(button_down);
    toolbar.append(button_remove);


    // Add toolbar
    //add_toolbar(toolbar);
    toolbar.show_all(); //Show the toolbar and all its child widgets.


    //Create the Tree model:
    effectlist_store = Gtk::ListStore::create(columns);
    effectlist_view.set_model(effectlist_store);

    effectlist_view.set_headers_visible(false);

    // Handle tree selections
    effectlist_selection = effectlist_view.get_selection();
    effectlist_selection->signal_changed().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_effect_selection_changed) );

    //Add the visibility icon column:
    Inkscape::UI::Widget::ImageToggler *eyeRenderer = manage( new Inkscape::UI::Widget::ImageToggler(
        INKSCAPE_ICON_OBJECT_VISIBLE, INKSCAPE_ICON_OBJECT_HIDDEN) );
    int visibleColNum = effectlist_view.append_column("is_visible", *eyeRenderer) - 1;
    eyeRenderer->signal_toggled().connect( sigc::mem_fun(*this, &LivePathEffectEditor::on_visibility_toggled) );
    eyeRenderer->property_activatable() = true;
    Gtk::TreeViewColumn* col = effectlist_view.get_column(visibleColNum);
    if ( col ) {
        col->add_attribute( eyeRenderer->property_active(), columns.col_visible );
    }

    //Add the effect name column:
    effectlist_view.append_column("Effect", columns.col_name);

    contents->pack_start(effectapplication_frame, false, false);
    contents->pack_start(effectlist_frame, true, true);
    contents->pack_start(effectcontrol_frame, false, false);

    // connect callback functions to buttons
    button_apply.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onApply));
    button_remove.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onRemove));

    button_up.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onUp));
    button_down.signal_clicked().connect(sigc::mem_fun(*this, &LivePathEffectEditor::onDown));

    show_all_children();

    //button_remove.hide();
}
AlignAndDistribute::AlignAndDistribute()
    : UI::Widget::Panel ("", "/dialogs/align", SP_VERB_DIALOG_ALIGN_DISTRIBUTE),
      randomize_bbox(),
      _alignFrame(_("Align")),
      _distributeFrame(_("Distribute")),
      _rearrangeFrame(_("Rearrange")),
      _removeOverlapFrame(_("Remove overlaps")),
      _nodesFrame(_("Nodes")),
#if WITH_GTKMM_3_0
      _alignTable(),
      _distributeTable(),
      _rearrangeTable(),
      _removeOverlapTable(),
      _nodesTable(),
#else
      _alignTable(2, 6, true),
      _distributeTable(2, 6, true),
      _rearrangeTable(1, 5, false),
      _removeOverlapTable(1, 5, false),
      _nodesTable(1, 4, true),
#endif
      _anchorLabel(_("Relative to: ")),
      _selgrpLabel(_("_Treat selection as group: "), 1)
{
    Inkscape::Preferences *prefs = Inkscape::Preferences::get();

    //Instanciate the align buttons
    addAlignButton(INKSCAPE_ICON("align-horizontal-right-to-anchor"),
                   _("Align right edges of objects to the left edge of the anchor"),
                   0, 0);
    addAlignButton(INKSCAPE_ICON("align-horizontal-left"),
                   _("Align left edges"),
                   0, 1);
    addAlignButton(INKSCAPE_ICON("align-horizontal-center"),
                   _("Center on vertical axis"),
                   0, 2);
    addAlignButton(INKSCAPE_ICON("align-horizontal-right"),
                   _("Align right sides"),
                   0, 3);
    addAlignButton(INKSCAPE_ICON("align-horizontal-left-to-anchor"),
                   _("Align left edges of objects to the right edge of the anchor"),
                   0, 4);
    addAlignButton(INKSCAPE_ICON("align-vertical-bottom-to-anchor"),
                   _("Align bottom edges of objects to the top edge of the anchor"),
                   1, 0);
    addAlignButton(INKSCAPE_ICON("align-vertical-top"),
                   _("Align top edges"),
                   1, 1);
    addAlignButton(INKSCAPE_ICON("align-vertical-center"),
                   _("Center on horizontal axis"),
                   1, 2);
    addAlignButton(INKSCAPE_ICON("align-vertical-bottom"),
                   _("Align bottom edges"),
                   1, 3);
    addAlignButton(INKSCAPE_ICON("align-vertical-top-to-anchor"),
                   _("Align top edges of objects to the bottom edge of the anchor"),
                   1, 4);

    //Baseline aligns
    addBaselineButton(INKSCAPE_ICON("align-horizontal-baseline"),
                   _("Align baseline anchors of texts horizontally"),
                      0, 5, this->align_table(), Geom::X, false);
    addBaselineButton(INKSCAPE_ICON("align-vertical-baseline"),
                   _("Align baselines of texts"),
                     1, 5, this->align_table(), Geom::Y, false);

    //The distribute buttons
    addDistributeButton(INKSCAPE_ICON("distribute-horizontal-gaps"),
                        _("Make horizontal gaps between objects equal"),
                        0, 4, true, Geom::X, .5, .5);

    addDistributeButton(INKSCAPE_ICON("distribute-horizontal-left"),
                        _("Distribute left edges equidistantly"),
                        0, 1, false, Geom::X, 1., 0.);
    addDistributeButton(INKSCAPE_ICON("distribute-horizontal-center"),
                        _("Distribute centers equidistantly horizontally"),
                        0, 2, false, Geom::X, .5, .5);
    addDistributeButton(INKSCAPE_ICON("distribute-horizontal-right"),
                        _("Distribute right edges equidistantly"),
                        0, 3, false, Geom::X, 0., 1.);

    addDistributeButton(INKSCAPE_ICON("distribute-vertical-gaps"),
                        _("Make vertical gaps between objects equal"),
                        1, 4, true, Geom::Y, .5, .5);

    addDistributeButton(INKSCAPE_ICON("distribute-vertical-top"),
                        _("Distribute top edges equidistantly"),
                        1, 1, false, Geom::Y, 0, 1);
    addDistributeButton(INKSCAPE_ICON("distribute-vertical-center"),
                        _("Distribute centers equidistantly vertically"),
                        1, 2, false, Geom::Y, .5, .5);
    addDistributeButton(INKSCAPE_ICON("distribute-vertical-bottom"),
                        _("Distribute bottom edges equidistantly"),
                        1, 3, false, Geom::Y, 1., 0.);

    //Baseline distribs
    addBaselineButton(INKSCAPE_ICON("distribute-horizontal-baseline"),
                   _("Distribute baseline anchors of texts horizontally"),
                      0, 5, this->distribute_table(), Geom::X, true);
    addBaselineButton(INKSCAPE_ICON("distribute-vertical-baseline"),
                   _("Distribute baselines of texts vertically"),
                     1, 5, this->distribute_table(), Geom::Y, true);

    // Rearrange
    //Graph Layout
    addGraphLayoutButton(INKSCAPE_ICON("distribute-graph"),
                            _("Nicely arrange selected connector network"),
                            0, 0);
    addExchangePositionsButton(INKSCAPE_ICON("exchange-positions"),
                            _("Exchange positions of selected objects - selection order"),
                            0, 1);
    addExchangePositionsByZOrderButton(INKSCAPE_ICON("exchange-positions-zorder"),
                            _("Exchange positions of selected objects - stacking order"),
                            0, 2);
    addExchangePositionsClockwiseButton(INKSCAPE_ICON("exchange-positions-clockwise"),
                            _("Exchange positions of selected objects - clockwise rotate"),
                            0, 3);

    //Randomize & Unclump
    addRandomizeButton(INKSCAPE_ICON("distribute-randomize"),
                        _("Randomize centers in both dimensions"),
                        0, 4);
    addUnclumpButton(INKSCAPE_ICON("distribute-unclump"),
                        _("Unclump objects: try to equalize edge-to-edge distances"),
                        0, 5);

    //Remove overlaps
    addRemoveOverlapsButton(INKSCAPE_ICON("distribute-remove-overlaps"),
                            _("Move objects as little as possible so that their bounding boxes do not overlap"),
                            0, 0);

    //Node Mode buttons
    // NOTE: "align nodes vertically" means "move nodes vertically until they align on a common
    // _horizontal_ line". This is analogous to what the "align-vertical-center" icon means.
    // There is no doubt some ambiguity. For this reason the descriptions are different.
    addNodeButton(INKSCAPE_ICON("align-vertical-node"),
                  _("Align selected nodes to a common horizontal line"),
                  0, Geom::X, false);
    addNodeButton(INKSCAPE_ICON("align-horizontal-node"),
                  _("Align selected nodes to a common vertical line"),
                  1, Geom::Y, false);
    addNodeButton(INKSCAPE_ICON("distribute-horizontal-node"),
                  _("Distribute selected nodes horizontally"),
                  2, Geom::X, true);
    addNodeButton(INKSCAPE_ICON("distribute-vertical-node"),
                  _("Distribute selected nodes vertically"),
                  3, Geom::Y, true);

    //Rest of the widgetry

    _combo.append(_("Last selected"));
    _combo.append(_("First selected"));
    _combo.append(_("Biggest object"));
    _combo.append(_("Smallest object"));
    _combo.append(_("Page"));
    _combo.append(_("Drawing"));
    _combo.append(_("Selection"));
    _combo.set_active(prefs->getInt("/dialogs/align/align-to", 6));
    _combo.signal_changed().connect(sigc::mem_fun(*this, &AlignAndDistribute::on_ref_change));

    _anchorBox.pack_end(_combo, false, false);
    _anchorBox.pack_end(_anchorLabel, false, false);

    _selgrpLabel.set_mnemonic_widget(_selgrp);
    _selgrpBox.pack_end(_selgrp, false, false);
    _selgrpBox.pack_end(_selgrpLabel, false, false);
    _selgrp.set_active(prefs->getBool("/dialogs/align/sel-as-groups"));
    _selgrp.signal_toggled().connect(sigc::mem_fun(*this, &AlignAndDistribute::on_selgrp_toggled));

    // Right align the buttons
    _alignTableBox.pack_end(_alignTable, false, false);
    _distributeTableBox.pack_end(_distributeTable, false, false);
    _rearrangeTableBox.pack_end(_rearrangeTable, false, false);
    _removeOverlapTableBox.pack_end(_removeOverlapTable, false, false);
    _nodesTableBox.pack_end(_nodesTable, false, false);

    _alignBox.pack_start(_anchorBox);
    _alignBox.pack_start(_selgrpBox);
    _alignBox.pack_start(_alignTableBox);

    _alignFrame.add(_alignBox);
    _distributeFrame.add(_distributeTableBox);
    _rearrangeFrame.add(_rearrangeTableBox);
    _removeOverlapFrame.add(_removeOverlapTableBox);
    _nodesFrame.add(_nodesTableBox);

    Gtk::Box *contents = _getContents();
    contents->set_spacing(4);

    // Notebook for individual transformations

    contents->pack_start(_alignFrame, true, true);
    contents->pack_start(_distributeFrame, true, true);
    contents->pack_start(_rearrangeFrame, true, true);
    contents->pack_start(_removeOverlapFrame, true, true);
    contents->pack_start(_nodesFrame, true, true);

    //Connect to the global tool change signal
    g_signal_connect (G_OBJECT (INKSCAPE), "set_eventcontext", G_CALLBACK (on_tool_changed), this);

    // Connect to the global selection change, to invalidate cached randomize_bbox
    g_signal_connect (G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (on_selection_changed), this);
    randomize_bbox = Geom::OptRect();

    _desktopChangeConn = _deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &AlignAndDistribute::setDesktop) );
    _deskTrack.connect(GTK_WIDGET(gobj()));

    show_all_children();

    on_tool_changed (NULL, NULL, this); // set current mode
}