index 7c845e70f62da61aa5b3d9a5c8cc900474b4101b..5956cfb9bca739db16420eda4cb0056696725df8 100644 (file)
//---------------------------------------------------
//---------------------------------------------------
-static DocumentMetadata *_instance = 0;
-
static void on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer);
static void on_repr_attr_changed (Inkscape::XML::Node *, gchar const *, gchar const *, gchar const *, bool, gpointer);
-static void on_doc_replaced (SPDesktop* dt, SPDocument* doc);
-static void on_activate_desktop (Inkscape::Application *, SPDesktop* dt, void*);
-static void on_deactivate_desktop (Inkscape::Application *, SPDesktop* dt, void*);
static Inkscape::XML::NodeEventVector const _repr_events = {
NULL, /* child_added */
static Inkscape::XML::NodeEventVector const _repr_events = {
NULL, /* child_added */
};
};
-DocumentMetadata*
-DocumentMetadata::create()
+DocumentMetadata &
+DocumentMetadata::getInstance()
{
{
- if (_instance) return _instance;
- _instance = new DocumentMetadata;
- _instance->init();
- return _instance;
+ DocumentMetadata &instance = *new DocumentMetadata();
+ instance.init();
+ return instance;
}
}
-void
-DocumentMetadata::destroy()
-{
- if (_instance)
- {
- delete _instance;
- _instance = 0;
- }
-}
-DocumentMetadata::DocumentMetadata()
- : Dialog ("dialogs.documentmetadata", SP_VERB_DIALOG_METADATA),
+DocumentMetadata::DocumentMetadata()
+ : UI::Widget::Panel ("", "dialogs.documentmetadata", SP_VERB_DIALOG_METADATA),
_page_metadata1(1, 1), _page_metadata2(1, 1),
_prefs_path("dialogs.documentmetadata")
{
hide();
_page_metadata1(1, 1), _page_metadata2(1, 1),
_prefs_path("dialogs.documentmetadata")
{
hide();
- set_resizable (true);
_tt.enable();
_tt.enable();
- get_vbox()->set_spacing (4);
- get_vbox()->pack_start (_notebook, true, true);
+ _getContents()->set_spacing (4);
+ _getContents()->pack_start(_notebook, true, true);
_notebook.append_page(_page_metadata1, _("Metadata"));
_notebook.append_page(_page_metadata2, _("License"));
_notebook.append_page(_page_metadata1, _("Metadata"));
_notebook.append_page(_page_metadata2, _("License"));
+ signalDocumentReplaced().connect(sigc::mem_fun(*this, &DocumentMetadata::_handleDocumentReplaced));
+ signalActivateDesktop().connect(sigc::mem_fun(*this, &DocumentMetadata::_handleActivateDesktop));
+ signalDeactiveDesktop().connect(sigc::mem_fun(*this, &DocumentMetadata::_handleDeactivateDesktop));
+
build_metadata();
}
build_metadata();
}
{
update();
{
update();
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(SP_ACTIVE_DESKTOP));
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(getDesktop()));
repr->addListener (&_repr_events, this);
repr->addListener (&_repr_events, this);
- _doc_replaced_connection = SP_ACTIVE_DESKTOP->connectDocumentReplaced (sigc::ptr_fun (on_doc_replaced));
-
- g_signal_connect(G_OBJECT(INKSCAPE), "activate_desktop",
- G_CALLBACK(on_activate_desktop), 0);
-
- g_signal_connect(G_OBJECT(INKSCAPE), "deactivate_desktop",
- G_CALLBACK(on_deactivate_desktop), 0);
-
show_all_children();
show_all_children();
- present();
}
}
-DocumentMetadata::~DocumentMetadata()
+DocumentMetadata::~DocumentMetadata()
{
{
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(SP_ACTIVE_DESKTOP));
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(getDesktop()));
repr->removeListenerByData (this);
repr->removeListenerByData (this);
- _doc_replaced_connection.disconnect();
for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); it++)
delete (*it);
for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); it++)
delete (*it);
@@ -144,28 +122,28 @@ attach_all (Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int star
{
if (arr[i] && arr[i+1])
{
{
if (arr[i] && arr[i+1])
{
- table.attach (const_cast<Gtk::Widget&>(*arr[i]), 1, 2, r, r+1,
+ table.attach (const_cast<Gtk::Widget&>(*arr[i]), 1, 2, r, r+1,
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
- table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 2, 3, r, r+1,
+ table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 2, 3, r, r+1,
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
}
else
{
if (arr[i+1])
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
}
else
{
if (arr[i+1])
- table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1,
+ table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1,
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
else if (arr[i])
{
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
else if (arr[i])
{
- Gtk::Label& label = reinterpret_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i]));
+ Gtk::Label& label = static_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i]));
label.set_alignment (0.0);
label.set_alignment (0.0);
- table.attach (label, 0, 3, r, r+1,
+ table.attach (label, 0, 3, r, r+1,
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
}
else
{
Gtk::HBox *space = manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
}
else
{
Gtk::HBox *space = manage (new Gtk::HBox);
space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
- table.attach (*space, 0, 1, r, r+1,
+ table.attach (*space, 0, 1, r, r+1,
(Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
}
}
(Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
}
}
DocumentMetadata::update()
{
if (_wr.isUpdating()) return;
DocumentMetadata::update()
{
if (_wr.isUpdating()) return;
-
+
_wr.setUpdating (true);
set_sensitive (true);
_wr.setUpdating (true);
set_sensitive (true);
/* update the RDF entities */
for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); it++)
(*it)->update (SP_ACTIVE_DOCUMENT);
/* update the RDF entities */
for (RDElist::iterator it = _rdflist.begin(); it != _rdflist.end(); it++)
(*it)->update (SP_ACTIVE_DOCUMENT);
-
+
_licensor.update (SP_ACTIVE_DOCUMENT);
_wr.setUpdating (false);
}
_licensor.update (SP_ACTIVE_DOCUMENT);
_wr.setUpdating (false);
}
-//--------------------------------------------------------------------
-
-void
-DocumentMetadata::on_response (int id)
+void
+DocumentMetadata::_handleDocumentReplaced(SPDesktop* desktop, SPDocument *)
{
{
- if (id == Gtk::RESPONSE_CLOSE)
- hide();
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop));
+ repr->addListener (&_repr_events, this);
+ update();
}
}
-/**
- * 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)
+void
+DocumentMetadata::_handleActivateDesktop(Inkscape::Application *, SPDesktop *desktop)
{
{
- if (!_instance)
- return;
-
- _instance->update();
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop));
+ repr->addListener(&_repr_events, this);
+ update();
}
}
-static void
-on_activate_desktop (Inkscape::Application *, SPDesktop* dt, void*)
+void
+DocumentMetadata::_handleDeactivateDesktop(Inkscape::Application *, SPDesktop *desktop)
{
{
- if (!_instance)
- return;
-
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(SP_ACTIVE_DESKTOP));
- repr->addListener (&_repr_events, _instance);
- _instance->_doc_replaced_connection = SP_ACTIVE_DESKTOP->connectDocumentReplaced (sigc::ptr_fun (on_doc_replaced));
- _instance->update();
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(desktop));
+ repr->removeListenerByData(this);
}
}
-static void
-on_deactivate_desktop (Inkscape::Application *, SPDesktop* dt, void*)
-{
- if (!_instance)
- return;
-
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(SP_ACTIVE_DESKTOP));
- repr->removeListenerByData (_instance);
- _instance->_doc_replaced_connection.disconnect();
-}
+//--------------------------------------------------------------------
-static void
-on_doc_replaced (SPDesktop* dt, SPDocument* doc)
+/**
+ * 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)
{
{
- if (!_instance)
- return;
-
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(sp_desktop_namedview(dt));
- repr->addListener (&_repr_events, _instance);
- _instance->update();
+ if (DocumentMetadata *dialog = static_cast<DocumentMetadata *>(data))
+ dialog->update();
}
}
-
} // namespace Dialog
} // namespace UI
} // namespace Inkscape
} // namespace Dialog
} // namespace UI
} // namespace Inkscape