82
92
DocumentProperties::DocumentProperties()
83
93
: UI::Widget::Panel ("", "/dialogs/documentoptions", SP_VERB_DIALOG_NAMEDVIEW),
84
94
_page_page(1, 1, true, true), _page_guides(1, 1),
85
_page_snap(1, 1), _page_snap_dtls(1, 1),
95
_page_snap(1, 1), _page_snap_dtls(1, 1), _page_cms(1, 1),
86
96
//---------------------------------------------------------------
87
97
_rcb_canb(_("Show page _border"), _("If set, rectangular page border is shown"), "showborder", _wr, false),
88
98
_rcb_bord(_("Border on _top of drawing"), _("If set, border is always on top of the drawing"), "borderlayer", _wr, false),
100
110
_rcp_hgui(_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr),
101
111
//---------------------------------------------------------------
102
112
_rcbs(_("_Enable snapping"), _("Toggle snapping on or off"), "inkscape:snap-global", _wr),
103
_rcbsi(_("_Enable snap indicator"), _("After snapping, a symbol is drawn at the point that has snapped"), "inkscape:snap-indicator", _wr),
104
113
_rcbsnbb(_("_Bounding box corners"), _("Only available in the selector tool: snap bounding box corners to guides, to grids, and to other bounding boxes (but not to nodes or paths)"),
105
114
"inkscape:snap-bbox", _wr),
106
115
_rcbsnn(_("_Nodes"), _("Snap nodes (e.g. path nodes, special points in shapes, gradient handles, text base points, transformation origins, etc.) to guides, to grids, to paths and to other nodes"),
381
391
attach_all(_page_snap_dtls.table(), array, G_N_ELEMENTS(array));
396
lcms_profile_get_name (cmsHPROFILE profile, const gchar **name)
400
*name = cmsTakeProductDesc (profile);
403
*name = cmsTakeProductName (profile);
405
if (*name && ! g_utf8_validate (*name, -1, NULL))
406
*name = _("(invalid UTF-8 string)");
415
DocumentProperties::populate_available_profiles(){
418
/* Gtk::MenuItem *i = new Gtk::MenuItem();
421
i->set_data("filepath", NULL);
422
i->set_data("name", _("None"));
424
Gtk::HBox *hb = new Gtk::HBox(false, 0);
427
Gtk::Label *l = new Gtk::Label( _("None") );
429
l->set_alignment(0.0, 0.5);
431
hb->pack_start(*l, true, true, 0);
437
std::list<gchar *> sources;
438
sources.push_back( profile_path("color/icc") );
439
//sources.push_back( g_strdup(INKSCAPE_COLORPROFILESDIR) );
443
// Use this loop to iterate through a list of possible document locations.
444
while (!sources.empty()) {
445
gchar *dirname = sources.front();
447
if ( Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS )
448
&& Inkscape::IO::file_test( dirname, G_FILE_TEST_IS_DIR )) {
450
GDir *directory = g_dir_open(dirname, 0, &err);
452
gchar *safeDir = Inkscape::IO::sanitizeString(dirname);
453
g_warning(_("Color profiles directory (%s) is unavailable."), safeDir);
457
while ((filename = (gchar *)g_dir_read_name(directory)) != NULL) {
458
gchar* lower = g_ascii_strdown( filename, -1 );
459
gchar* full = g_build_filename(dirname, filename, NULL);
460
if ( !Inkscape::IO::file_test( full, G_FILE_TEST_IS_DIR ) ) {
461
cmsHPROFILE hProfile = cmsOpenProfileFromFile(full, "r");
462
if (hProfile != NULL){
464
lcms_profile_get_name(hProfile, &name);
465
Gtk::MenuItem* mi = new Gtk::MenuItem();
466
mi->set_data("filepath", g_strdup(full));
467
mi->set_data("name", g_strdup(name));
468
Gtk::HBox *hbox = new Gtk::HBox();
470
Gtk::Label* lbl = manage(new Gtk::Label(name));
472
hbox->pack_start(*lbl, true, true, 0);
476
// g_free((void*)name);
478
cmsCloseProfile(hProfile);
484
g_dir_close(directory);
496
DocumentProperties::onEmbedProfile()
498
//store this profile in the SVG document (create <color-profile> element in the XML)
499
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
501
g_warning("No active desktop");
504
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
505
Inkscape::XML::Node *cprofRepr = xml_doc->createElement("svg:color-profile");
506
cprofRepr->setAttribute("name", (gchar*) _menu.get_active()->get_data("name"));
507
cprofRepr->setAttribute("xlink:href", (gchar*) _menu.get_active()->get_data("filepath"));
509
/* Checks whether there is a defs element. Creates it when needed */
510
Inkscape::XML::Node *defsRepr = sp_repr_lookup_name(xml_doc, "svg:defs");
512
defsRepr = xml_doc->createElement("svg:defs");
513
xml_doc->root()->addChild(defsRepr, NULL);
516
g_assert(SP_ROOT(desktop->doc()->root)->defs);
517
defsRepr->addChild(cprofRepr, NULL);
519
Inkscape::GC::release(defsRepr);
521
// inform the document, so we can undo
522
sp_document_done(desktop->doc(), SP_VERB_EMBED_COLOR_PROFILE, _("Embed Color Profile"));
524
populate_embedded_profiles_box();
528
DocumentProperties::populate_embedded_profiles_box()
530
_EmbeddedProfilesListStore->clear();
531
const GSList *current = sp_document_get_resource_list( SP_ACTIVE_DOCUMENT, "iccprofile" );
533
SPObject* obj = SP_OBJECT(current->data);
534
Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj);
535
Gtk::TreeModel::Row row = *(_EmbeddedProfilesListStore->append());
536
row[_EmbeddedProfilesListColumns.nameColumn] = prof->name;
537
// row[_EmbeddedProfilesListColumns.previewColumn] = "Color Preview";
538
current = g_slist_next(current);
544
DocumentProperties::build_cms()
548
Gtk::Label *label_embed= manage (new Gtk::Label);
549
label_embed->set_markup (_("<b>Embedded Color Profiles:</b>"));
550
Gtk::Label *label_avail = manage (new Gtk::Label);
551
label_avail->set_markup (_("<b>Available Color Profiles:</b>"));
553
_embed_btn.set_label("Embed Profile");
555
Gtk::Widget *const array[] =
558
&_EmbeddedProfilesListScroller, 0,
560
&_combo_avail, &_embed_btn,
563
attach_all(_page_cms.table(), array, G_N_ELEMENTS(array));
565
populate_available_profiles();
567
_combo_avail.set_menu(_menu);
568
_combo_avail.set_history(0);
569
_combo_avail.show_all();
571
//# Set up the Embedded Profiles combo box
572
_EmbeddedProfilesListStore = Gtk::ListStore::create(_EmbeddedProfilesListColumns);
573
_EmbeddedProfilesList.set_model(_EmbeddedProfilesListStore);
574
_EmbeddedProfilesList.append_column(_("Profile Name"), _EmbeddedProfilesListColumns.nameColumn);
575
// _EmbeddedProfilesList.append_column(_("Color Preview"), _EmbeddedProfilesListColumns.previewColumn);
576
_EmbeddedProfilesList.set_headers_visible(false);
577
_EmbeddedProfilesList.set_fixed_height_mode(true);
579
populate_embedded_profiles_box();
581
_EmbeddedProfilesListScroller.add(_EmbeddedProfilesList);
582
_EmbeddedProfilesListScroller.set_shadow_type(Gtk::SHADOW_IN);
583
_EmbeddedProfilesListScroller.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
584
_EmbeddedProfilesListScroller.set_size_request(-1, 90);
586
_embed_btn.signal_clicked().connect(sigc::mem_fun(*this, &DocumentProperties::onEmbedProfile));
588
#endif // ENABLE_LCMS
385
591
* Called for _updating_ the dialog (e.g. when a new grid was manually added in XML)