From e7d9e019b2ea8c8ccad2bdff32a6fedbd5db0439 Mon Sep 17 00:00:00 2001 From: joelholdsworth Date: Sat, 28 Jul 2007 20:08:47 +0000 Subject: [PATCH] Modification of the parameters/return value of SPDesktop::getToplevel --- src/desktop.cpp | 5 +++-- src/desktop.h | 4 ++-- src/interface.cpp | 8 +------- src/verbs.cpp | 7 +++---- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/desktop.cpp b/src/desktop.cpp index 4cfc279cc..e785aab6d 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -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 diff --git a/src/desktop.h b/src/desktop.h index 3bf6fa65a..ca2d24204 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -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(); diff --git a/src/interface.cpp b/src/interface.cpp index eada69c34..a041f5cf5 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -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( 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(), diff --git a/src/verbs.cpp b/src/verbs.cpp index a81157ab8..41d6fcdcc 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -792,10 +792,9 @@ FileVerb::perform(SPAction *action, void *data, void *pdata) #endif SPDesktop *desktop = dynamic_cast(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: -- 2.30.2