Code

Add default CC metadata and license to preferences.
authorbryce <bryce@users.sourceforge.net>
Mon, 31 Dec 2007 09:52:40 +0000 (09:52 +0000)
committerbryce <bryce@users.sourceforge.net>
Mon, 31 Dec 2007 09:52:40 +0000 (09:52 +0000)
(Closes LP: #169954)

src/dialogs/rdf.cpp
src/preferences-skeleton.h
src/ui/dialog/inkscape-preferences.cpp
src/ui/dialog/inkscape-preferences.h

index 320608e9ab055716083d9575d9b3add5200fd30e..c371b62fe9b8b2a227cd1de57232e2b273cd7680 100644 (file)
@@ -23,6 +23,7 @@
 #include "xml/repr.h"
 #include "rdf.h"
 #include "sp-item-group.h"
+#include "prefs-utils.h"
 
 /*
 
@@ -976,6 +977,20 @@ struct rdf_entity_default_t {
 struct rdf_entity_default_t rdf_defaults[] = {
     { "format",      "image/svg+xml", },
     { "type",        "http://purl.org/dc/dcmitype/StillImage", },
+    { "title",       "", },
+    { "date",        "", },
+    { "creator",     "", },
+    { "rights",      "", },
+    { "publisher",   "", },
+    { "identifier",  "", },
+    { "source",      "", },
+    { "relation",    "", },
+    { "language",    "", },
+    { "subject",     "", },
+    { "coverage",    "", },
+    { "description", "", },
+    { "contributor", "", },
+    { "license_uri", "", },
     { NULL,          NULL, }
 };
 
@@ -1004,8 +1019,11 @@ rdf_set_defaults ( SPDocument * doc )
         struct rdf_work_entity_t * entity = rdf_find_entity ( rdf_default->name );
         g_assert ( entity != NULL );
 
+        //get default matedata defined by user preferences
+        const gchar * text = prefs_get_string_attribute ("options.defaultmetadata", rdf_default->name);
+
         if ( rdf_get_work_entity ( doc, entity ) == NULL ) {
-            rdf_set_work_entity ( doc, entity, rdf_default->text );
+            rdf_set_work_entity ( doc, entity, text ? text : rdf_default->text );
         }
     }
 }
index b013d52b623eddde3f379d1b55de49541e9b4407..825bf37bdefaa8b06edb97a5835fdf574f509d1c 100644 (file)
@@ -228,6 +228,7 @@ static char const preferences_skeleton[] =
 "    <group id=\"transform\" stroke=\"1\" rectcorners=\"1\" pattern=\"1\" gradient=\"1\" />\n"
 "    <group id=\"kbselection\" inlayer=\"1\" onlyvisible=\"1\" onlysensitive=\"1\" />\n"
 "    <group id=\"selection\" layerdeselect=\"1\" />\n"
+"    <group id=\"defaultmetadata\" title=\"\" date=\"\" format=\"\" type=\"\" creator=\"\" rights=\"\" publisher=\"\" identifier=\"\" source=\"\" relation=\"\" language=\"\" subject=\"\" coverage=\"\" description=\"\" contributor=\"\" license=\"0\" license_uri=\"\" inkscapedefaults=\"1\" />\n"
 "    <group id=\"createbitmap\"/>\n"
 "    <group id=\"compassangledisplay\" value=\"0\"/>\n"
 "    <group id=\"maskobject\" topmost=\"1\" remove=\"1\"/>\n"
index dfbfdcf58660d2f655e15de57e369c773ff98ffc..e1219c6eceb669b654faa7c35ee778919fcd27d2 100644 (file)
@@ -10,7 +10,7 @@
  * Copyright (C) 2004-2007 Authors
  *
  * Released under GNU GPL.  Read the file 'COPYING' for more information.
- */ 
+ */
 
 #ifdef HAVE_CONFIG_H
 # include <config.h>
@@ -39,6 +39,7 @@
 #include "display/nr-filter-gaussian.h"
 #include "color-profile-fns.h"
 #include "display/canvas-grid.h"
+#include "dialogs/rdf.h"
 
 namespace Inkscape {
 namespace UI {
@@ -46,10 +47,10 @@ namespace Dialog {
 
 InkscapePreferences::InkscapePreferences()
     : UI::Widget::Panel ("", "dialogs.preferences", SP_VERB_DIALOG_DISPLAY),
-      _max_dialog_width(0), 
+      _max_dialog_width(0),
       _max_dialog_height(0),
       _current_page(0)
-{ 
+{
     //get the width of a spinbutton
     Gtk::SpinButton* sb = new Gtk::SpinButton;
     sb->set_width_chars(6);
@@ -106,6 +107,8 @@ InkscapePreferences::InkscapePreferences()
     initPageImportExport();
     initPageCMS();
     initPageGrids();
+    initPageMetadata();
+    initPageLicense();
     initPageMisc();
 
     signalPresent().connect(sigc::mem_fun(*this, &InkscapePreferences::_presentPages));
@@ -839,6 +842,97 @@ void InkscapePreferences::initPageGrids()
     this->AddPage(_page_grids, _("Grids"), PREFS_PAGE_GRIDS);
 }
 
+void InkscapePreferences::initPageMetadata()
+{
+    _metadata_title.init        ( "options.defaultmetadata", "title", true);
+    _metadata_date.init         ( "options.defaultmetadata", "date", true);
+    _metadata_format.init       ( "options.defaultmetadata", "format", true);
+    _metadata_type.init         ( "options.defaultmetadata", "type", true);
+    _metadata_creator.init      ( "options.defaultmetadata", "creator", true);
+    _metadata_rights.init       ( "options.defaultmetadata", "rights", true);
+    _metadata_publisher.init    ( "options.defaultmetadata", "publisher", true);
+    _metadata_identifier.init   ( "options.defaultmetadata", "identifier", true);
+    _metadata_source.init       ( "options.defaultmetadata", "source", true);
+    _metadata_relation.init     ( "options.defaultmetadata", "relation", true);
+    _metadata_language.init     ( "options.defaultmetadata", "language", true);
+    _metadata_subject.init      ( "options.defaultmetadata", "subject", true);
+    _metadata_coverage.init     ( "options.defaultmetadata", "coverage", true);
+    _metadata_description.init  ( "options.defaultmetadata", "description", true);
+    _metadata_contributor.init  ( "options.defaultmetadata", "contributor", true);
+
+    _page_metadata.add_group_header( _("Default metadata that will be used for new documents:"));
+
+    _page_metadata.add_line(true, _("Title:"), _metadata_title, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Date:"), _metadata_date, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Format:"), _metadata_format, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Type:"), _metadata_type, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Creator:"), _metadata_creator, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Rights:"), _metadata_rights, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Publisher:"), _metadata_publisher, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Identifier:"), _metadata_identifier, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Source:"), _metadata_source, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Relation:"), _metadata_relation, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Language:"), _metadata_language, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Subject:"), _metadata_subject, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Coverage:"), _metadata_coverage, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Description:"), _metadata_description, "", _("These values will be used as default metadata for new documents"));
+    _page_metadata.add_line(true, _("Contributor:"), _metadata_contributor, "", _("These values will be used as default metadata for new documents"));
+
+    this->AddPage(_page_metadata, _("Default Metadata"), PREFS_PAGE_METADATA);
+}
+
+void InkscapePreferences::on_license_changed(){
+    int i = prefs_get_int_attribute("options.defaultmetadata", "license", 0);
+    if (i)
+        _license_uri.set_text( rdf_licenses[i - 1].uri );
+    else
+        _license_uri.set_text("");
+}
+
+void InkscapePreferences::initPageLicense()
+{
+    _license_proprietary.init( _("Proprietary"), "options.defaultmetadata", "license", LICENSE_PROPRIETARY, true, 0);
+    _license_ccby.init( _("Creative Commons By 3.0"), "options.defaultmetadata", "license", LICENSE_CC_BY, false, &_license_proprietary);
+    _license_ccbysa.init( _("Creative Commons By Sa 3.0"), "options.defaultmetadata", "license", LICENSE_CC_BY_SA, false, &_license_proprietary);
+    _license_ccbynd.init( _("Creative Commons By Nd 3.0"), "options.defaultmetadata", "license", LICENSE_CC_BY_ND, false, &_license_proprietary);
+    _license_ccbync.init( _("Creative Commons By Nc 3.0"), "options.defaultmetadata", "license", LICENSE_CC_BY_NC, false, &_license_proprietary);
+    _license_ccbyncsa.init( _("Creative Commons By Nc Sa 3.0"), "options.defaultmetadata", "license", LICENSE_CC_BY_NC_SA, false, &_license_proprietary);
+    _license_ccbyncnd.init( _("Creative Commons By Nc Nd 3.0"), "options.defaultmetadata", "license", LICENSE_CC_BY_NC_ND, false, &_license_proprietary);
+    _license_pdomain.init( _("Public Domain"), "options.defaultmetadata", "license", LICENSE_PUBLIC_DOMAIN, false, &_license_proprietary);
+    _license_freeart.init( _("FreeArt"), "options.defaultmetadata", "license", LICENSE_FREE_ART, false, &_license_proprietary);
+    _license_openfont.init( _("Open Font License"), "options.defaultmetadata", "license", LICENSE_OPEN_FONT, false, &_license_proprietary);
+    _license_uri.init( "options.defaultmetadata", "license_uri", true);
+
+    _license_proprietary.signal_toggled().connect(sigc::mem_fun( *this, &InkscapePreferences::on_license_changed ));
+    _license_ccby.signal_toggled().connect(sigc::mem_fun( *this, &InkscapePreferences::on_license_changed));
+    _license_ccbysa.signal_toggled().connect(sigc::mem_fun( *this, &InkscapePreferences::on_license_changed));
+    _license_ccbynd.signal_toggled().connect(sigc::mem_fun( *this, &InkscapePreferences::on_license_changed));
+    _license_ccbync.signal_toggled().connect(sigc::mem_fun( *this, &InkscapePreferences::on_license_changed));
+    _license_ccbyncsa.signal_toggled().connect(sigc::mem_fun( *this, &InkscapePreferences::on_license_changed));
+    _license_ccbyncnd.signal_toggled().connect(sigc::mem_fun( *this, &InkscapePreferences::on_license_changed));
+    _license_pdomain.signal_toggled().connect(sigc::mem_fun( *this, &InkscapePreferences::on_license_changed));
+    _license_freeart.signal_toggled().connect(sigc::mem_fun( *this, &InkscapePreferences::on_license_changed));
+    _license_openfont.signal_toggled().connect(sigc::mem_fun( *this, &InkscapePreferences::on_license_changed));
+
+    _page_license.add_group_header( _("Default Licensing for new documents:"));
+
+    _page_license.add_line(true, "", _license_proprietary, "", _("All Rights Reserved"));
+    _page_license.add_line(true, "", _license_ccby, "", _("Creative Commons: Attribution"));
+    _page_license.add_line(true, "", _license_ccbysa, "", _("Creative Commons: Attribution-ShareAlike"));
+    _page_license.add_line(true, "", _license_ccbynd, "", _("Creative Commons: Attribution-NoDerivatives"));
+    _page_license.add_line(true, "", _license_ccbync, "", _("Creative Commons: Attribution-NonCommercial"));
+    _page_license.add_line(true, "", _license_ccbyncsa, "", _("Creative Commons: Attribution-NonCommercial-ShareAlike"));
+    _page_license.add_line(true, "", _license_ccbyncnd, "", _("Creative Commons: Attribution-NonCommercial-NoDerivatives"));
+    _page_license.add_line(true, "", _license_pdomain, "", _("Public Domain"));
+    _page_license.add_line(true, "", _license_freeart, "", _("Free Art License"));
+    _page_license.add_line(true, "", _license_openfont, "", _("Open Font License"));
+
+    _page_license.add_line(true, _("URL:"), _license_uri, "", "");
+
+    this->AddPage(_page_license, _("Default License"), PREFS_PAGE_LICENSE);
+}
+
+
 void InkscapePreferences::initPageMisc()
 {
     _misc_comment.init( _("Add label comments to printing output"), "printing.debug", "show-label-comments", false);
index 4b62f3947d9edf53cfcf24184cfd4a3e728690f2..1609e808ce35e8beb29b9a4ab267932ff0dbd6cb 100644 (file)
@@ -67,9 +67,24 @@ enum {
     PREFS_PAGE_IMPORTEXPORT,
     PREFS_PAGE_CMS,
     PREFS_PAGE_GRIDS,
+    PREFS_PAGE_METADATA,
+    PREFS_PAGE_LICENSE,
     PREFS_PAGE_MISC
 };
 
+enum {
+    LICENSE_PROPRIETARY = 0,
+    LICENSE_CC_BY = 1,
+    LICENSE_CC_BY_SA = 2,
+    LICENSE_CC_BY_ND = 3,
+    LICENSE_CC_BY_NC = 4,
+    LICENSE_CC_BY_NC_SA = 5,
+    LICENSE_CC_BY_NC_ND = 6,
+    LICENSE_PUBLIC_DOMAIN = 7,
+    LICENSE_FREE_ART = 8,
+    LICENSE_OPEN_FONT = 9
+};
+
 using namespace Inkscape::UI::Widget;
 
 namespace Inkscape {
@@ -85,7 +100,7 @@ public:
 protected:
     Gtk::Frame _page_frame;
     Gtk::Label _page_title;
-    Gtk::TreeView _page_list;  
+    Gtk::TreeView _page_list;
     Glib::RefPtr<Gtk::TreeStore> _page_list_model;
 
     //Pagelist model columns:
@@ -104,8 +119,8 @@ protected:
     Gtk::TreeModel::Path _path_shapes;
 
     DialogPage _page_mouse, _page_scrolling, _page_steps, _page_tools, _page_windows,
-        _page_clones, _page_mask, _page_transforms, _page_filters, _page_select, 
-        _page_importexport, _page_cms, _page_grids, _page_misc;
+        _page_clones, _page_mask, _page_transforms, _page_filters, _page_select,
+        _page_importexport, _page_cms, _page_grids, _page_metadata, _page_license, _page_misc;
     DialogPage _page_selector, _page_node, _page_zoom, _page_shapes, _page_pencil, _page_pen,
                _page_calligraphy, _page_text, _page_gradient, _page_connector, _page_dropper;
     DialogPage _page_rectangle, _page_3dbox, _page_ellipse, _page_star, _page_spiral, _page_paintbucket;
@@ -132,21 +147,32 @@ protected:
     PrefCheckButton _win_hide_task, _win_zoom_resize , _win_show_close;
 
 // FIXME: Temporary Win32 special code to enable transient dialogs
-#ifdef WIN32 
-    PrefCheckButton _win_ontop_win32;   
-#endif    
+#ifdef WIN32
+    PrefCheckButton _win_ontop_win32;
+#endif
 
     PrefCheckButton _calligrapy_use_abs_size;
     PrefCheckButton _calligrapy_keep_selected;
 
     PrefCheckButton _connector_ignore_text;
-    
+
     PrefRadioButton _clone_option_parallel, _clone_option_stay, _clone_option_transform,
                     _clone_option_unlink, _clone_option_delete;
 
     PrefCheckButton _mask_mask_on_top;
     PrefCheckButton _mask_mask_remove;
 
+    PrefEntry _metadata_title, _metadata_date, _metadata_format, _metadata_type, _metadata_creator;
+    PrefEntry _metadata_rights, _metadata_publisher, _metadata_identifier, _metadata_source;
+    PrefEntry _metadata_relation, _metadata_language, _metadata_subject, _metadata_coverage;
+    PrefEntry _metadata_description, _metadata_contributor;
+
+    PrefRadioButton _license_ccby, _license_ccbysa, _license_ccbync, _license_ccbynd;
+    PrefRadioButton _license_ccbyncsa, _license_ccbyncnd;
+    PrefRadioButton _license_freeart, _license_pdomain, _license_openfont, _license_proprietary;
+    PrefEntry _license_uri;
+    void on_license_changed();
+
     PrefRadioButton _blur_quality_best, _blur_quality_better, _blur_quality_normal, _blur_quality_worse, _blur_quality_worst;
 
     PrefCheckButton _trans_scale_stroke, _trans_scale_corner, _trans_gradient,_trans_pattern;
@@ -231,6 +257,8 @@ protected:
     void initPageImportExport();
     void initPageCMS();
     void initPageGrids();
+    void initPageMetadata();
+    void initPageLicense();
     void initPageMisc();
 
     void _presentPages();