Code

Fix missing ruler and document title updates when a file is opened in an existing...
authorcilix42 <cilix42@users.sourceforge.net>
Sun, 3 Feb 2008 16:04:33 +0000 (16:04 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Sun, 3 Feb 2008 16:04:33 +0000 (16:04 +0000)
src/desktop.cpp
src/desktop.h
src/widgets/desktop-widget.cpp
src/widgets/desktop-widget.h

index 8cd63a68cd9ed1eb47b4af87958b54670fcdf15a..d2547f5a60895fce146a486dcc1a286285d646d0 100644 (file)
@@ -85,6 +85,7 @@
 #include "layer-manager.h"
 #include "event-log.h"
 #include "display/canvas-grid.h"
+#include "widgets/desktop-widget.h"
 
 #include "display/sp-canvas.h"
 
@@ -501,6 +502,15 @@ SPDesktop::change_document (SPDocument *theDocument)
     selection->clear();
 
     setDocument (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();
+    g_assert(parent != NULL);
+    SPDesktopWidget *dtw = (SPDesktopWidget *) parent->get_data("desktopwidget");
+    if (dtw) dtw->desktop = this;
+    sp_desktop_widget_update_namedview(dtw);
+
     _namedview_modified (namedview, SP_OBJECT_MODIFIED_FLAG, this);
     _document_replaced_signal.emit (this, theDocument);
 }
index 0a3732d56cd54ec91cb1b9d9eedf2d30d14dbf0f..84b8297268f83672b71f2a3c65e6c86bb1bb7fa9 100644 (file)
@@ -42,13 +42,11 @@ typedef struct _GtkWidget GtkWidget;
 struct SPCanvas;
 struct SPCanvasItem;
 struct SPCanvasGroup;
-struct SPDesktopWidget;
 struct SPEventContext;
 struct SPItem;
 struct SPNamedView;
 struct SPObject;
 struct SPStyle;
-struct SPViewWidget;
 
 namespace Gtk
 {
index 146717fc2578dcf55dbce10172f367f9f3481fdd..f4d87f0844fffde744917500fbe1ca29bd81b183 100644 (file)
@@ -701,6 +701,15 @@ sp_desktop_widget_realize (GtkWidget *widget)
 
     dtw->desktop->set_display_area (d.x0, d.y0, d.x1, d.y1, 10);
 
+    sp_desktop_widget_update_namedview(dtw);
+}
+
+/* This is just to provide access to common functionality from sp_desktop_widget_realize() above
+   as well as from SPDesktop::change_document() */
+void
+sp_desktop_widget_update_namedview (SPDesktopWidget *dtw) {
+    g_return_if_fail(dtw);
+
     /* Listen on namedview modification */
     // originally (prior to the sigc++ conversion) the signal was simply
     // connected twice rather than disconnecting the first connection
index c20a8524edcb431305a125e3e201d41994a479a6..aece4f75db5ac3edfba3710e0a7522791593ceec 100644 (file)
@@ -46,6 +46,8 @@ void sp_desktop_widget_update_rulers (SPDesktopWidget *dtw);
 void sp_desktop_widget_update_hruler (SPDesktopWidget *dtw);
 void sp_desktop_widget_update_vruler (SPDesktopWidget *dtw);
 
+void sp_desktop_widget_update_namedview (SPDesktopWidget *dtw);
+
 /* Show/hide rulers & scrollbars */
 void sp_desktop_widget_toggle_rulers (SPDesktopWidget *dtw);
 void sp_desktop_widget_toggle_scrollbars (SPDesktopWidget *dtw);