Code

Modification of the parameters/return value of SPDesktop::getToplevel
authorjoelholdsworth <joelholdsworth@users.sourceforge.net>
Sat, 28 Jul 2007 20:08:47 +0000 (20:08 +0000)
committerjoelholdsworth <joelholdsworth@users.sourceforge.net>
Sat, 28 Jul 2007 20:08:47 +0000 (20:08 +0000)
src/desktop.cpp
src/desktop.h
src/interface.cpp
src/verbs.cpp

index 4cfc279ccc6933c3b1acd0adc66f17985111be69..e785aab6dcd7a4b0e48cf1bfbc3e6f03cf5961fa 100644 (file)
@@ -1030,9 +1030,10 @@ SPDesktop::setWindowTransient (void *p, int transient_policy)
     _widget->setTransient (p, transient_policy);
 }
 
-void SPDesktop::getToplevel( Gtk::Widget*& toplevel )
+Gtk::Window*
+SPDesktop::getToplevel( )
 {
-    toplevel = (Gtk::Widget*)_widget->getWindow();
+    return _widget->getWindow();
 }
 
 void
index 3bf6fa65a99e5f6ee373fd1c520b2f3c50cdc3c7..ca2d2420465f919ac7ab474cc5c637b96eb76adc 100644 (file)
@@ -52,7 +52,7 @@ struct SPViewWidget;
 
 namespace Gtk
 {
-  class Widget;
+  class Window;
 }
 
 typedef int sp_verb_t;
@@ -238,7 +238,7 @@ struct SPDesktop : public Inkscape::UI::View::View
     void setWindowPosition (NR::Point p);
     void setWindowSize (gint w, gint h);
     void setWindowTransient (void* p, int transient_policy=1);
-    void getToplevel( Gtk::Widget*& toplevel );
+    Gtk::Window* getToplevel();
     void presentWindow();
     bool warnDialog (gchar *text);
     void toggleRulers();
index eada69c34ffdd5bb59f1162c036b68dd70f470cf..a041f5cf582ce91a2ddf4480be158f7df0a4e308 100644 (file)
@@ -1297,13 +1297,7 @@ sp_ui_overwrite_file(gchar const *filename)
     bool return_value = FALSE;
 
     if (Inkscape::IO::file_test(filename, G_FILE_TEST_EXISTS)) {
-        Gtk::Widget* ancestor = NULL;
-        SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-        if ( desktop ) {
-            desktop->getToplevel( ancestor );
-        }
-        Gtk::Window *window = ancestor->is_toplevel() ?
-                       dynamic_cast<Gtk::Window*>( ancestor ) : 0;
+        Gtk::Window *window = SP_ACTIVE_DESKTOP->getToplevel();
         gchar* baseName = g_path_get_basename( filename );
         gchar* dirName = g_path_get_dirname( filename );
         GtkWidget* dialog = gtk_message_dialog_new_with_markup( window->gobj(),
index a81157ab87cb979b257f16ece7fae78e8df87e15..41d6fcdcc8e787762c61d105afa5ef90456e3a57 100644 (file)
@@ -792,10 +792,9 @@ FileVerb::perform(SPAction *action, void *data, void *pdata)
 #endif
     
     SPDesktop *desktop = dynamic_cast<SPDesktop*>(sp_action_get_view(action));
-       Gtk::Window *parent = NULL;
-       if(desktop == NULL) return;
-       desktop->getToplevel((Gtk::Widget*&)parent);
-       if(parent == NULL) return;
+       g_assert(desktop != NULL);
+       Gtk::Window *parent = desktop->getToplevel();
+       g_assert(parent != NULL);
     
     switch ((long) data) {
         case SP_VERB_FILE_NEW: