summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2019-01-20 18:35:46 +0000
committerTavmjong Bah <tavmjong@free.fr>2019-01-20 18:35:46 +0000
commitda5621d2df20473ec743a788b87f5eea8006ba15 (patch)
treed51539257203569a7e680195642679d5c30e60bd /src
parentUse document rather than namedview in creating desktop widget. (diff)
downloadinkscape-da5621d2df20473ec743a788b87f5eea8006ba15.tar.gz
inkscape-da5621d2df20473ec743a788b87f5eea8006ba15.zip
No longer use widget data to store pointer to desktop widget.
Diffstat (limited to 'src')
-rw-r--r--src/desktop.cpp17
-rw-r--r--src/desktop.h13
-rw-r--r--src/display/sp-canvas.cpp5
-rw-r--r--src/document.cpp7
-rw-r--r--src/inkscape-window.cpp1
5 files changed, 31 insertions, 12 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 5ae70094b..4e3a28243 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -35,6 +35,7 @@
#include "device-manager.h"
#include "document-undo.h"
#include "event-log.h"
+#include "inkscape-window.h"
#include "layer-fns.h"
#include "layer-manager.h"
#include "message-context.h"
@@ -681,12 +682,14 @@ SPDesktop::change_document (SPDocument *theDocument)
/* update the rulers, connect the desktop widget's signal to the new namedview etc.
(this can probably be done in a better way) */
- Gtk::Window *parent = this->getToplevel();
+ InkscapeWindow *parent = this->getInkscapeWindow();
g_assert(parent != nullptr);
- SPDesktopWidget *dtw = (SPDesktopWidget *) parent->get_data("desktopwidget");
+ SPDesktopWidget *dtw = parent->get_desktop_widget();
if (dtw) {
dtw->desktop = this;
dtw->updateNamedview();
+ } else {
+ std::cerr << "SPDesktop::change_document: failed to get desktop widget!" << std::endl;
}
_namedview_modified (namedview, SP_OBJECT_MODIFIED_FLAG, this);
@@ -1377,6 +1380,16 @@ SPDesktop::getToplevel( )
return _widget->getWindow();
}
+InkscapeWindow*
+SPDesktop::getInkscapeWindow( )
+{
+ InkscapeWindow* window = dynamic_cast<InkscapeWindow*>(_widget->getWindow());
+ if (!window) {
+ std::cerr << "SPDesktop::getInkscapeWindow: Failed to get window." << std::endl;
+ }
+ return window;
+}
+
void
SPDesktop::presentWindow()
{
diff --git a/src/desktop.h b/src/desktop.h
index d75c3cd25..539e55935 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -24,18 +24,20 @@
#include <cstddef>
#include <sigc++/sigc++.h>
+#include <glibmm/ustring.h>
#include <2geom/affine.h>
#include <2geom/transforms.h>
#include <2geom/rect.h>
-#include "ui/view/view.h"
+#include "preferences.h"
+
#include "display/rendermode.h"
-#include <glibmm/ustring.h>
-#include "preferences.h"
#include "object/sp-gradient.h" // TODO refactor enums out to their own .h file
+
#include "ui/dialog/print.h"
+#include "ui/view/view.h"
class SPCSSAttr;
struct SPCanvas;
@@ -59,6 +61,8 @@ class SPObject;
class SPStyle;
typedef struct _DocumentInterface DocumentInterface;//struct DocumentInterface;
+class InkscapeWindow;
+
namespace Gtk
{
class Window;
@@ -373,7 +377,8 @@ public:
void setWindowPosition (Geom::Point p);
void setWindowSize (gint w, gint h);
void setWindowTransient (void* p, int transient_policy=1);
- Gtk::Window* getToplevel();
+ Gtk::Window* getToplevel(); // To be removed in favor of getInkscapeWindow
+ InkscapeWindow* getInkscapeWindow();
void presentWindow();
bool showInfoDialog( Glib::ustring const &message );
bool warnDialog (Glib::ustring const &text);
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index 2bf7600c7..8d10ccb33 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -38,6 +38,7 @@
#include "display/sp-canvas.h"
#include "helper/sp-marshal.h"
#include "inkscape.h"
+#include "inkscape-window.h"
#include "preferences.h"
#include "sodipodi-ctrlrect.h"
#include "ui/tools/tool-base.h"
@@ -2392,8 +2393,8 @@ int SPCanvas::paint()
arena = SP_CANVAS_ARENA(desktop->drawing);
rm = arena->drawing.renderMode();
if (split) {
- auto window = desktop->getToplevel();
- auto dtw = static_cast<SPDesktopWidget *>(window->get_data("desktopwidget"));
+ auto window = desktop->getInkscapeWindow();
+ auto dtw = window->get_desktop_widget();
bool hasrullers = prefs->getBool(desktop->is_fullscreen() ? "/fullscreen/rulers/state" : "/window/rulers/state");
int hruler_gap = hasrullers ? dtw->get_hruler_thickness() : 1;
int vruler_gap = hasrullers ? dtw->get_vruler_thickness() : 1;
diff --git a/src/document.cpp b/src/document.cpp
index 3daae3deb..d8871da7d 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -49,6 +49,7 @@
#include "id-clash.h"
#include "inkscape-version.h"
#include "inkscape.h"
+#include "inkscape-window.h"
#include "profile-manager.h"
#include "rdf.h"
@@ -1825,9 +1826,9 @@ bool SPDocument::isSeeking() const {
void SPDocument::setModifiedSinceSave(bool modified) {
this->modified_since_save = modified;
if (SP_ACTIVE_DESKTOP) {
- Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel();
- if (parent) { // during load, SP_ACTIVE_DESKTOP may be !nullptr, but parent might still be nullptr
- SPDesktopWidget *dtw = static_cast<SPDesktopWidget *>(parent->get_data("desktopwidget"));
+ InkscapeWindow *window = SP_ACTIVE_DESKTOP->getInkscapeWindow();
+ if (window) { // during load, SP_ACTIVE_DESKTOP may be !nullptr, but parent might still be nullptr
+ SPDesktopWidget *dtw = window->get_desktop_widget();
dtw->updateTitle( this->getName() );
}
}
diff --git a/src/inkscape-window.cpp b/src/inkscape-window.cpp
index ff797f072..c5507b76b 100644
--- a/src/inkscape-window.cpp
+++ b/src/inkscape-window.cpp
@@ -82,7 +82,6 @@ InkscapeWindow::InkscapeWindow(SPDocument* document)
_desktop_widget->window = this;
set_data("desktop", _desktop);
- set_data("desktopwidget", _desktop_widget);
signal_delete_event().connect( sigc::mem_fun(*_desktop, &SPDesktop::onDeleteUI));
signal_window_state_event().connect(sigc::mem_fun(*_desktop, &SPDesktop::onWindowStateEvent));