2
* @brief Document metadata dialog, Gtkmm-style
5
* bulia byak <buliabyak@users.sf.net>
6
* Bryce W. Harrington <bryce@bryceharrington.org>
7
* Lauris Kaplinski <lauris@kaplinski.com>
8
* Jon Phillips <jon@rejon.org>
9
* Ralf Stephan <ralf@ark.in-berlin.de> (Gtkmm)
11
* Copyright (C) 2000 - 2006 Authors
13
* Released under GNU GPL. Read the file 'COPYING' for more information
21
#include "desktop-handles.h"
24
#include "sp-namedview.h"
25
#include "ui/widget/entity-entry.h"
27
#include "xml/node-event-vector.h"
29
#include "document-metadata.h"
37
#define SPACE_SIZE_X 15
38
#define SPACE_SIZE_Y 15
40
//===================================================
42
//---------------------------------------------------
44
static void on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer);
46
static Inkscape::XML::NodeEventVector const _repr_events = {
47
NULL, /* child_added */
48
NULL, /* child_removed */
50
NULL, /* content_changed */
51
NULL /* order_changed */
56
DocumentMetadata::getInstance()
58
DocumentMetadata &instance = *new DocumentMetadata();
64
DocumentMetadata::DocumentMetadata()
65
: UI::Widget::Panel ("", "/dialogs/documentmetadata", SP_VERB_DIALOG_METADATA),
66
_page_metadata1(1, 1), _page_metadata2(1, 1)
70
_getContents()->set_spacing (4);
71
_getContents()->pack_start(_notebook, true, true);
73
_notebook.append_page(_page_metadata1, _("Metadata"));
74
_notebook.append_page(_page_metadata2, _("License"));
76
signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentMetadata::_handleDocumentReplaced));
77
signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentMetadata::_handleActivateDesktop));
78
signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentMetadata::_handleDeactivateDesktop));
84
DocumentMetadata::init()
88
Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(getDesktop()));
89
repr->addListener (&_repr_events, this);
94
DocumentMetadata::~DocumentMetadata()
96
Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(getDesktop()));
97
repr->removeListenerByData (this);
99
for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); it++)
103
//========================================================================
106
* Helper function that attachs widgets in a 3xn table. The widgets come in an
107
* array that has two entries per table row. The two entries code for four
108
* possible cases: (0,0) means insert space in first column; (0, non-0) means
109
* widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
110
* (non-0, non-0) means two widgets in columns 2 and 3.
113
attach_all (Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int start = 0)
115
for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2)
117
if (arr[i] && arr[i+1])
119
table.attach (const_cast<Gtk::Widget&>(*arr[i]), 1, 2, r, r+1,
120
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
121
table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 2, 3, r, r+1,
122
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
127
table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1,
128
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
131
Gtk::Label& label = static_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i]));
132
label.set_alignment (0.0);
133
table.attach (label, 0, 3, r, r+1,
134
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
138
Gtk::HBox *space = manage (new Gtk::HBox);
139
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
140
table.attach (*space, 0, 1, r, r+1,
141
(Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
149
DocumentMetadata::build_metadata()
151
_page_metadata1.show();
153
Gtk::Label *label = manage (new Gtk::Label);
154
label->set_markup (_("<b>Dublin Core Entities</b>"));
155
label->set_alignment (0.0);
156
_page_metadata1.table().attach (*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
157
/* add generic metadata entry areas */
158
struct rdf_work_entity_t * entity;
160
for (entity = rdf_work_entities; entity && entity->name; entity++, row++) {
161
if ( entity->editable == RDF_EDIT_GENERIC ) {
162
EntityEntry *w = EntityEntry::create (entity, _tt, _wr);
163
_rdflist.push_back (w);
164
Gtk::HBox *space = manage (new Gtk::HBox);
165
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
166
_page_metadata1.table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
167
_page_metadata1.table().attach (w->_label, 1,2, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
168
_page_metadata1.table().attach (*w->_packable, 2,3, row, row+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
172
_page_metadata2.show();
175
Gtk::Label *llabel = manage (new Gtk::Label);
176
llabel->set_markup (_("<b>License</b>"));
177
llabel->set_alignment (0.0);
178
_page_metadata2.table().attach (*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
179
/* add license selector pull-down and URI */
181
_licensor.init (_tt, _wr);
182
Gtk::HBox *space = manage (new Gtk::HBox);
183
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
184
_page_metadata2.table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0);
185
_page_metadata2.table().attach (_licensor, 1,3, row, row+1, Gtk::EXPAND|Gtk::FILL, (Gtk::AttachOptions)0,0,0);
189
* Update dialog widgets from desktop.
192
DocumentMetadata::update()
194
if (_wr.isUpdating()) return;
196
_wr.setUpdating (true);
197
set_sensitive (true);
199
//-----------------------------------------------------------meta pages
200
/* update the RDF entities */
201
for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); it++)
202
(*it)->update (SP_ACTIVE_DOCUMENT);
204
_licensor.update (SP_ACTIVE_DOCUMENT);
206
_wr.setUpdating (false);
210
DocumentMetadata::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *)
212
Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop));
213
repr->addListener (&_repr_events, this);
218
DocumentMetadata::_handleActivateDesktop(Inkscape::Application *, SPDesktop *desktop)
220
Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop));
221
repr->addListener(&_repr_events, this);
226
DocumentMetadata::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *desktop)
228
Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop));
229
repr->removeListenerByData(this);
232
//--------------------------------------------------------------------
235
* Called when XML node attribute changed; updates dialog widgets.
238
on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer data)
240
if (DocumentMetadata *dialog = static_cast<DocumentMetadata *>(data))
244
} // namespace Dialog
246
} // namespace Inkscape
251
c-file-style:"stroustrup"
252
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
257
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :