document-properties.cpp revision e3d18ccd670462801d4938107a72ed6855c469b9
/** @file
* @brief Document properties dialog, Gtkmm-style
*/
/* Authors:
* bulia byak <buliabyak@users.sf.net>
* Bryce W. Harrington <bryce@bryceharrington.org>
* Lauris Kaplinski <lauris@kaplinski.com>
* Jon Phillips <jon@rejon.org>
* Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
* Diederik van Lierop <mail@diedenrezi.nl>
*
* Copyright (C) 2006-2008 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 2000 - 2008 Authors
*
* Released under GNU GPL. Read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "display/canvas-grid.h"
#include "document-properties.h"
#include "document.h"
#include "desktop-handles.h"
#include "desktop.h"
#include <gtkmm.h>
#include "inkscape.h"
#include "preferences.h"
#include "sp-namedview.h"
#include "sp-object-repr.h"
#include "sp-root.h"
#include "sp-script.h"
#include "ui/widget/color-picker.h"
#include "ui/widget/scalar-unit.h"
#include "verbs.h"
#include "xml/node-event-vector.h"
#if ENABLE_LCMS
#include <lcms.h>
//#include "color-profile-fns.h"
#include "color-profile.h"
#endif // ENABLE_LCMS
namespace Inkscape {
namespace UI {
namespace Dialog {
#define SPACE_SIZE_X 15
#define SPACE_SIZE_Y 10
//===================================================
//---------------------------------------------------
static void on_child_added(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
static void on_child_removed(Inkscape::XML::Node *repr, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, void * data);
static void on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer);
on_child_added, // child_added
on_child_removed, // child_removed
NULL, // content_changed
NULL // order_changed
};
{
return instance;
}
//---------------------------------------------------------------
_rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false),
_rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false),
_rcb_shad(_("_Show border shadow"), _("If set, page border shows a shadow on its right and lower side"), "inkscape:showpageshadow", _wr, false),
_rcp_bg(_("Back_ground:"), _("Background color"), _("Color and transparency of the page background (also used for bitmap export)"), "pagecolor", "inkscape:pageopacity", _wr),
_rcp_bord(_("Border _color:"), _("Page border color"), _("Color of the page border"), "bordercolor", "borderopacity", _wr),
//---------------------------------------------------------------
//General snap options
_rcbsng(_("_Snap guides while dragging"), _("While dragging a guide, snap to object nodes or bounding box corners ('Snap to nodes' or 'snap to bounding box corners' must be enabled; only a small part of the guide near the cursor will snap)"),
"inkscape:snap-from-guide", _wr),
_rcp_gui(_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"), "guidecolor", "guideopacity", _wr),
_rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr),
//---------------------------------------------------------------
//TRANSLATORS: only translate "string" in "context|string".
// For more details, see http://developer.gnome.org/doc/API/2.0/glib/glib-I18N.html#Q-:CAPS
// "New" refers to grid
//---------------------------------------------------------------
{
build_page();
build_guides();
build_snap();
#if ENABLE_LCMS
build_cms();
#endif // ENABLE_LCMS
_grids_button_remove.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onRemoveGrid));
signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDocumentReplaced));
signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentProperties::_handleDeactivateDesktop));
}
void
{
update();
}
{
repr->removeListenerByData (this);
root->removeListenerByData (this);
}
//========================================================================
/**
* Helper function that attaches widgets in a 3xn table. The widgets come in an
* array that has two entries per table row. The two entries code for four
* possible cases: (0,0) means insert space in first column; (0, non-0) means
* widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
* (non-0, non-0) means two widgets in columns 2 and 3.
**/
inline void
{
for (unsigned i = 0, r = start; i < n; i += 2)
{
{
}
else
{
if (arr[i+1]) {
// only the PageSizer in Document Properties|Page should be stretched vertically
}
}
else if (arr[i])
{
}
else
{
}
}
++r;
}
}
void
{
_page_page.show();
_page_sizer.init();
{
label_gen, 0,
0, &_rum_deflt,
0, 0,
label_for, 0,
0, &_page_sizer,
0, 0,
label_bor, 0,
0, &_rcb_canb,
0, &_rcb_bord,
0, &_rcb_shad,
};
}
void
{
_page_guides.show();
{
label_gui, 0,
0, &_rcb_sgui,
0, &_rcbsng,
};
}
void
{
_page_snap.show();
_("Snapping distance, in screen pixels, for snapping to objects"), _("Always snap to objects, regardless of their distance"),
_("If set, objects only snap to another object when it's within the range specified below"),
"objecttolerance", _wr);
//Options for snapping to grids
_("Snapping distance, in screen pixels, for snapping to grid"), _("Always snap to grids, regardless of the distance"),
_("If set, objects only snap to a grid line when it's within the range specified below"),
"gridtolerance", _wr);
//Options for snapping to guides
_("Snapping distance, in screen pixels, for snapping to guides"), _("Always snap to guides, regardless of the distance"),
_("If set, objects only snap to a guide when it's within the range specified below"),
"guidetolerance", _wr);
{
label_o, 0,
0, 0,
label_gr, 0,
0, 0,
label_gu, 0,
};
}
#if ENABLE_LCMS
static void
{
if (profile)
{
if (! *name)
*name = _("(invalid UTF-8 string)");
}
else
{
*name = _("None");
}
}
void
for ( Glib::ListHandle<Gtk::Widget*>::iterator it2 = children.begin(); it2 != children.end(); ++it2 ) {
delete(*it2);
}
// Use this loop to iterate through a list of possible document locations.
if (!directory) {
} else {
// g_free((void*)name);
}
}
}
}
}
}
}
/**
* Cleans up name to remove disallowed characters.
* Some discussion at http://markmail.org/message/bhfvdfptt25kgtmj
* Allowed ASCII first characters: ':', 'A'-'Z', '_', 'a'-'z'
* Allowed ASCII remaining chars add: '-', '.', '0'-'9',
*
* @param str the string to clean up.
*/
{
&& (val != '_')
&& (val != ':')) {
}
&& (val != '_')
&& (val != ':')
&& (val != '-')
&& (val != '.')) {
}
}
}
}
void
{
//store this profile in the SVG document (create <color-profile> element in the XML)
// TODO remove use of 'active' desktop
if (!desktop){
g_warning("No active desktop");
} else {
if (!_menu.get_active()){
g_warning("No color profile available.");
return;
}
// Checks whether there is a defs element. Creates it when needed
if (!defsRepr){
}
// TODO check if this next line was sometimes needed. It being there caused an assertion.
//Inkscape::GC::release(defsRepr);
// inform the document, so we can undo
}
}
void
{
while ( current ) {
// row[_LinkedProfilesListColumns.previewColumn] = "Color Preview";
}
}
{
}
}
{
}
}
{
}
{
}
void DocumentProperties::removeSelectedProfile(){
if(_LinkedProfilesList.get_selection()) {
if(i){
} else {
return;
}
}
while ( current ) {
sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile"));
}
}
}
void
{
_page_cms.table().attach(*label_link, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_cms.table().attach(_LinkedProfilesListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_cms.table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_cms.table().attach(*label_avail, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_cms.table().attach(_combo_avail, 0, 2, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
_page_cms.table().attach(_link_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
//# Set up the Linked Profiles combo box
// _LinkedProfilesList.append_column(_("Color Preview"), _LinkedProfilesListColumns.previewColumn);
// TODO restore? _LinkedProfilesList.set_fixed_height_mode(true);
_LinkedProfilesList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::linked_profiles_list_button_release));
cms_create_popup_menu(_LinkedProfilesList, sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile));
if (current) {
}
_emb_profiles_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_linked_profiles_box));
}
#endif // ENABLE_LCMS
void
{
_page_scripting.table().attach(*label_script, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_scripting.table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_scripting.table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
_page_scripting.table().attach(_script_entry, 0, 2, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
_page_scripting.table().attach(_add_btn, 2, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0);
row++;
//# Set up the External Scripts box
// TODO restore? _ExternalScriptsList.set_fixed_height_mode(true);
#if ENABLE_LCMS
_ExternalScriptsList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::external_scripts_list_button_release));
scripting_create_popup_menu(_ExternalScriptsList, sigc::mem_fun(*this, &DocumentProperties::removeExternalScript));
#endif // ENABLE_LCMS
//TODO: review this observers code:
if (current) {
}
_ext_scripts_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_external_scripts_box));
}
void DocumentProperties::addExternalScript(){
if (!desktop){
g_warning("No active desktop");
} else {
// inform the document, so we can undo
}
}
void DocumentProperties::removeExternalScript(){
if(_ExternalScriptsList.get_selection()) {
if(i){
} else {
return;
}
}
while ( current ) {
sp_document_done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_EXTERNAL_SCRIPT, _("Remove external script"));
}
}
}
while ( current ) {
{
}
}
}
/**
* Called for _updating_ the dialog (e.g. when a new grid was manually added in XML)
*/
void
{
//remove all tabs
while (_grids_notebook.get_n_pages() != 0) {
}
//add tabs
bool grids_present = false;
switch (grid->getGridType()) {
case GRID_RECTANGULAR:
icon = "grid-rectangular";
break;
case GRID_AXONOMETRIC:
icon = "grid-axonometric";
break;
default:
break;
}
grids_present = true;
}
if (grids_present)
else
_grids_button_remove.set_sensitive(false);
}
/**
* Build grid page of dialog.
*/
void
{
/// \todo FIXME: gray out snapping when grid is off.
/// Dissenting view: you want snapping without grid.
(void)nv;
for (gint t = 0; t <= GRID_MAXTYPENR; t++) {
}
}
/**
* Update dialog widgets from desktop. Also call updateWidget routines of the grids.
*/
void
{
if (_wr.isUpdating()) return;
_wr.setUpdating (true);
set_sensitive (true);
//-----------------------------------------------------------page page
//-----------------------------------------------------------guide page
//-----------------------------------------------------------snap page
//-----------------------------------------------------------grids page
//------------------------------------------------Color Management page
#if ENABLE_LCMS
#endif // ENABLE_LCMS
_wr.setUpdating (false);
}
// TODO: copied from fill-and-stroke.cpp factor out into new ui/widget file?
{
label_image)));
return *_tab_label_box;
}
//--------------------------------------------------------------------
void
{
{
}
hide();
}
void
{
update();
}
void
{
update();
}
void
{
repr->removeListenerByData(this);
root->removeListenerByData(this);
}
static void
on_child_added(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data)
{
}
static void
on_child_removed(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node */*child*/, Inkscape::XML::Node */*ref*/, void *data)
{
}
/**
* Called when XML node attribute changed; updates dialog widgets.
*/
static void
on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data)
{
}
/*########################################################################
# BUTTON CLICK HANDLERS (callbacks)
########################################################################*/
void
{
// toggle grid showing to ON:
}
void
{
return;
int i = 0;
for (GSList const * l = nv->grids; l != NULL; l = l->next, i++) { // not a very nice fix, but works.
if (pagenum == i) {
found_grid = grid;
break; // break out of for-loop
}
}
if (found_grid) {
// delete the grid that corresponds with the selected tab
// when the grid is deleted from SVG, the SPNamedview handler automatically deletes the object, so found_grid becomes an invalid pointer!
}
}
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :