index f70ade5a3cae4fa816737b30ad3cdc8e523ae2a5..3509a1040d20dc1789ccfe86511e8bbbfc4129ad 100644 (file)
-#define __SP_DESKTOP_WIDGET_C__
-
/** \file
* Desktop widget implementation
*/
* Ralf Stephan <ralf@ark.in-berlin.de>
* John Bintz <jcoswell@coswellproductions.org>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2007 Johan Engelen
* Copyright (C) 2006 John Bintz
#include <extension/db.h>
#include "file.h"
#include "helper/units.h"
+#include "helper/unit-tracker.h"
#include "inkscape-private.h"
#include "interface.h"
#include "macros.h"
#include "ui/widget/layer-selector.h"
#include "ui/widget/selected-style.h"
#include "ui/uxmanager.h"
+#include "util/ege-appear-time-tracker.h"
// We're in the "widgets" directory, so no need to explicitly prefix these:
#include "button.h"
using Inkscape::round;
#endif
-
+using Inkscape::UnitTracker;
using Inkscape::UI::UXManager;
using Inkscape::UI::ToolboxFactory;
+using ege::AppearTimeTracker;
#ifdef WITH_INKBOARD
#endif
return Geom::Point(x,y);
}
+static GTimer *overallTimer = 0;
+
/**
* Registers SPDesktopWidget class and returns its type number.
*/
0 // value_table
};
type = g_type_register_static(SP_TYPE_VIEW_WIDGET, "SPDesktopWidget", &info, static_cast<GTypeFlags>(0));
+ // Begin a timer to watch for the first desktop to appear on-screen
+ overallTimer = g_timer_new();
}
return type;
}
GtkWidget *tbl;
GtkWidget *canvas_tbl;
- GtkWidget *hbox;
GtkWidget *eventbox;
GtkStyle *style;
gtk_box_pack_end( GTK_BOX( dtw->vbox ), GTK_WIDGET(dtw->panels->gobj()), FALSE, TRUE, 0 );
}
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_end (GTK_BOX (dtw->vbox), hbox, TRUE, TRUE, 0);
- gtk_widget_show (hbox);
-
+ dtw->hbox = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_end( GTK_BOX (dtw->vbox), dtw->hbox, TRUE, TRUE, 0 );
+ gtk_widget_show(dtw->hbox);
+
dtw->aux_toolbox = ToolboxFactory::createAuxToolbox();
gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->aux_toolbox, FALSE, TRUE, 0);
dtw->snap_toolbox = ToolboxFactory::createSnapToolbox();
ToolboxFactory::setOrientation( dtw->snap_toolbox, GTK_ORIENTATION_VERTICAL );
- gtk_box_pack_end (GTK_BOX (hbox), dtw->snap_toolbox, FALSE, TRUE, 0);
+ gtk_box_pack_end( GTK_BOX(dtw->hbox), dtw->snap_toolbox, FALSE, TRUE, 0 );
dtw->commands_toolbox = ToolboxFactory::createCommandsToolbox();
gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->commands_toolbox, FALSE, TRUE, 0);
dtw->tool_toolbox = ToolboxFactory::createToolToolbox();
- gtk_box_pack_start (GTK_BOX (hbox), dtw->tool_toolbox, FALSE, TRUE, 0);
+ ToolboxFactory::setOrientation( dtw->tool_toolbox, GTK_ORIENTATION_VERTICAL );
+ gtk_box_pack_start( GTK_BOX(dtw->hbox), dtw->tool_toolbox, FALSE, TRUE, 0 );
tbl = gtk_table_new (2, 3, FALSE);
- gtk_box_pack_start (GTK_BOX (hbox), tbl, TRUE, TRUE, 1);
+ gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl, TRUE, TRUE, 1 );
canvas_tbl = gtk_table_new (3, 3, FALSE);
dtw->_tracker = ege_color_prof_tracker_new(GTK_WIDGET(dtw->layer_selector->gobj()));
#if ENABLE_LCMS
- {
+ bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display");
+ if ( fromDisplay ) {
Glib::ustring id = Inkscape::colorprofile_get_display_id( 0, 0 );
+
bool enabled = false;
if ( dtw->canvas->cms_key ) {
*(dtw->canvas->cms_key) = id;
gtk_widget_show_all (dtw->vbox);
gtk_widget_grab_focus (GTK_WIDGET(dtw->canvas));
+
+ // If this is the first desktop created, report the time it takes to show up
+ if ( overallTimer ) {
+ if ( prefs->getBool("/dialogs/debug/trackAppear", false) ) {
+ // Time tracker takes ownership of the timer.
+ AppearTimeTracker *tracker = new AppearTimeTracker(overallTimer, GTK_WIDGET(dtw), "first SPDesktopWidget");
+ tracker->setAutodelete(true);
+ } else {
+ g_timer_destroy(overallTimer);
+ }
+ overallTimer = 0;
+ }
}
/**
NRRect d;
d.x0 = 0.0;
d.y0 = 0.0;
- d.x1 = sp_document_width (dtw->desktop->doc());
- d.y1 = sp_document_height (dtw->desktop->doc());
+ d.x1 = (dtw->desktop->doc())->getWidth ();
+ d.y1 = (dtw->desktop->doc())->getHeight ();
if ((fabs (d.x1 - d.x0) < 1.0) || (fabs (d.y1 - d.y0) < 1.0)) return;
modified_connection = desktop->namedview->connectModified(sigc::mem_fun(*this, &SPDesktopWidget::namedviewModified));
namedviewModified(desktop->namedview, SP_OBJECT_MODIFIED_FLAG);
- updateTitle(SP_DOCUMENT_NAME (desktop->doc()));
+ updateTitle( desktop->doc()->getName() );
}
/**
dtw->requestCanvasUpdate();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/options/displayprofile/enable", down);
+ if (down) {
+ dtw->setMessage (Inkscape::NORMAL_MESSAGE, _("Color-managed display is <b>enabled</b> in this window"));
+ } else {
+ dtw->setMessage (Inkscape::NORMAL_MESSAGE, _("Color-managed display is <b>disabled</b> in this window"));
+ }
}
#endif // ENABLE_LCMS
}
GTK_BUTTONS_NONE,
_("<span weight=\"bold\" size=\"larger\">Save changes to document \"%s\" before closing?</span>\n\n"
"If you close without saving, your changes will be discarded."),
- SP_DOCUMENT_NAME(doc));
+ doc->getName());
// fix for bug 1767940:
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), GTK_CAN_FOCUS);
{
Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
- sp_document_ref(doc);
+ doc->doRef();
sp_namedview_document_from_window(desktop);
if (sp_file_save_document(*window, doc)) {
- sp_document_unref(doc);
+ doc->doUnref();
} else { // save dialog cancelled or save failed
- sp_document_unref(doc);
+ doc->doUnref();
return TRUE;
}
}
/* Code to check data loss */
bool allow_data_loss = FALSE;
- while (sp_document_repr_root(doc)->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE) {
+ while (doc->getReprRoot()->attribute("inkscape:dataloss") != NULL && allow_data_loss == FALSE) {
GtkWidget *dialog;
/** \todo
GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
_("<span weight=\"bold\" size=\"larger\">The file \"%s\" was saved with a format (%s) that may cause data loss!</span>\n\n"
- "Do you want to save this file as an Inkscape SVG?"),
- SP_DOCUMENT_NAME(doc),
+ "Do you want to save this file as Inkscape SVG?"),
+ doc->getName() ? doc->getName() : "Unnamed",
SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE);
// fix for bug 1767940:
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(GTK_MESSAGE_DIALOG(dialog)->label), GTK_CAN_FOCUS);
switch (response) {
case GTK_RESPONSE_YES:
{
- sp_document_ref(doc);
+ doc->doRef();
Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window");
if (sp_file_save_dialog(*window, doc, Inkscape::Extension::FILE_SAVE_METHOD_INKSCAPE_SVG)) {
- sp_document_unref(doc);
+ doc->doUnref();
} else { // save dialog cancelled or save failed
- sp_document_unref(doc);
+ doc->doUnref();
return TRUE;
}
return isActive;
}
+void SPDesktopWidget::setToolboxPosition(Glib::ustring const& id, GtkPositionType pos)
+{
+ // Note - later on these won't be individual member variables.
+ GtkWidget* toolbox = 0;
+ if (id == "ToolToolbar") {
+ toolbox = tool_toolbox;
+ } else if (id == "AuxToolbar") {
+ toolbox = aux_toolbox;
+ } else if (id == "CommandsToolbar") {
+ toolbox = commands_toolbox;
+ } else if (id == "SnapToolbar") {
+ toolbox = snap_toolbox;
+ }
+
+
+ if (toolbox) {
+ switch(pos) {
+ case GTK_POS_TOP:
+ case GTK_POS_BOTTOM:
+ if ( gtk_widget_is_ancestor(toolbox, hbox) ) {
+ gtk_widget_reparent( toolbox, vbox );
+ gtk_box_set_child_packing(GTK_BOX(vbox), toolbox, FALSE, TRUE, 0, GTK_PACK_START);
+ }
+ ToolboxFactory::setOrientation(toolbox, GTK_ORIENTATION_HORIZONTAL);
+ break;
+ case GTK_POS_LEFT:
+ case GTK_POS_RIGHT:
+ if ( !gtk_widget_is_ancestor(toolbox, hbox) ) {
+ gtk_widget_reparent( toolbox, hbox );
+ gtk_box_set_child_packing(GTK_BOX(hbox), toolbox, FALSE, TRUE, 0, GTK_PACK_START);
+ if (pos == GTK_POS_LEFT) {
+ gtk_box_reorder_child( GTK_BOX(hbox), toolbox, 0 );
+ }
+ }
+ ToolboxFactory::setOrientation(toolbox, GTK_ORIENTATION_VERTICAL);
+ break;
+ }
+ }
+}
+
+
SPViewWidget *sp_desktop_widget_new( SPNamedView *namedview )
{
SPDesktopWidget* dtw = SPDesktopWidget::createInstance(namedview);
- UXManager::getInstance()->addTrack(dtw);
-
return SP_VIEW_WIDGET(dtw);
}
toolboxes.push_back(dtw->aux_toolbox);
toolboxes.push_back(dtw->commands_toolbox);
toolboxes.push_back(dtw->snap_toolbox);
- UXManager::getInstance()->connectToDesktop( toolboxes, dtw->desktop );
dtw->panels->setDesktop( dtw->desktop );
+ UXManager::getInstance()->addTrack(dtw);
+ UXManager::getInstance()->connectToDesktop( toolboxes, dtw->desktop );
+
return dtw;
}
sp_ruler_set_metric(GTK_RULER (this->vruler), nv->getDefaultMetric());
sp_ruler_set_metric(GTK_RULER (this->hruler), nv->getDefaultMetric());
+ /* This loops through all the grandchildren of aux toolbox,
+ * and for each that it finds, it performs an sp_search_by_data_recursive(),
+ * looking for widgets that hold some "tracker" data (this is used by
+ * all toolboxes to refer to the unit selector). The default document units
+ * is then selected within these unit selectors.
+ *
+ * Of course it would be nice to be able to refer to the toolbox and the
+ * unit selector directly by name, but I don't yet see a way to do that.
+ *
+ * This should solve: https://bugs.launchpad.net/inkscape/+bug/362995
+ */
+ if (GTK_IS_CONTAINER(aux_toolbox)) {
+ GList *ch = gtk_container_get_children (GTK_CONTAINER(aux_toolbox));
+ for (GList *i = ch; i != NULL; i = i->next) {
+ if (GTK_IS_CONTAINER(i->data)) {
+ GList *grch = gtk_container_get_children (GTK_CONTAINER(i->data));
+ for (GList *j = grch; j != NULL; j = j->next) {
+ if (!GTK_IS_WIDGET(j->data)) // wasn't a widget
+ continue;
+
+ gpointer t = sp_search_by_data_recursive(GTK_WIDGET(j->data), (gpointer) "tracker");
+ if (t == NULL) // didn't find any tracker data
+ continue;
+
+ UnitTracker *tracker = reinterpret_cast<UnitTracker*>( t );
+ if (tracker == NULL) // it's null when inkscape is first opened
+ continue;
+
+ tracker->setActiveUnit( nv->doc_units );
+ } // grandchildren
+ } // if child is a container
+ } // children
+ } // if aux_toolbox is a container
+
gtk_tooltips_set_tip(this->tt, this->hruler_box, gettext(sp_unit_get_plural (nv->doc_units)), NULL);
gtk_tooltips_set_tip(this->tt, this->vruler_box, gettext(sp_unit_get_plural (nv->doc_units)), NULL);
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/options/bitmapautoreload/value", true)) {
- GSList const *imageList = sp_document_get_resource_list(desktop->doc(), "image");
+ GSList const *imageList = (desktop->doc())->getResourceList("image");
for (GSList const *p = imageList; p; p = p->next) {
SPImage* image = SP_IMAGE(p->data);
sp_image_refresh_if_outdated( image );
/* The desktop region we always show unconditionally */
SPDocument *doc = dtw->desktop->doc();
- Geom::Rect darea ( Geom::Point(-sp_document_width(doc), -sp_document_height(doc)),
- Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc)) );
+ Geom::Rect darea ( Geom::Point(-doc->getWidth(), -doc->getHeight()),
+ Geom::Point(2 * doc->getWidth(), 2 * doc->getHeight()) );
SPObject* root = doc->root;
SPItem* item = SP_ITEM(root);
- Geom::OptRect deskarea = Geom::unify(darea, sp_item_bbox_desktop(item));
+ Geom::OptRect deskarea = Geom::unify(darea, item->getBboxDesktop());
/* Canvas region we always show unconditionally */
Geom::Rect carea( Geom::Point(deskarea->min()[Geom::X] * scale - 64, deskarea->max()[Geom::Y] * -scale - 64),