[nemiver/varobjs-support] Move CallStack::Priv::load_menu to IPerspective.



commit 50f5ae3dbf6288cd91596995defd9ba81c4b8b24
Author: Dodji Seketeli <dodji redhat com>
Date:   Mon May 25 09:16:17 2009 +0200

    Move CallStack::Priv::load_menu to IPerspective.
    
    	* src/persp/nmv-i-perspective.h: (IPerspectrive::load_menu): New
    	New entry point.
    	* src/persp/dbgperspective/nmv-dbg-perspective.cc,h:
    	(DBGPerspective::load_menu): New entry point.
    	* src/persp/dbgperspective/nmv-call-stack.cc:
    	(CallStack::Priv::load_menu): Remove this.
    	CallStack::Priv::(get_call_stack_menu): Rather use the
    	new IPerspective::load_menu method.
---
 src/persp/dbgperspective/nmv-call-stack.cc      |   20 +----------
 src/persp/dbgperspective/nmv-dbg-perspective.cc |   40 ++++++++++++----------
 src/persp/dbgperspective/nmv-dbg-perspective.h  |    3 ++
 src/persp/nmv-i-perspective.h                   |    8 ++++
 4 files changed, 35 insertions(+), 36 deletions(-)

diff --git a/src/persp/dbgperspective/nmv-call-stack.cc b/src/persp/dbgperspective/nmv-call-stack.cc
index daa88a6..8170400 100644
--- a/src/persp/dbgperspective/nmv-call-stack.cc
+++ b/src/persp/dbgperspective/nmv-call-stack.cc
@@ -199,27 +199,11 @@ struct CallStack::Priv {
         return is_visible;
     }
 
-    Gtk::Widget* load_menu (UString a_filename, UString a_widget_name)
-    {
-        NEMIVER_TRY
-        string relative_path = Glib::build_filename ("menus", a_filename);
-        string absolute_path;
-        THROW_IF_FAIL (perspective.build_absolute_resource_path
-                (Glib::locale_to_utf8 (relative_path),
-                 absolute_path));
-
-        workbench.get_ui_manager ()->add_ui_from_file
-            (Glib::locale_to_utf8 (absolute_path));
-
-        NEMIVER_CATCH
-        return workbench.get_ui_manager ()->get_widget (a_widget_name);
-    }
-
     Gtk::Widget* get_call_stack_menu ()
     {
         if (!callstack_menu) {
-            callstack_menu = load_menu ("callstackpopup.xml",
-                                        "/CallStackPopup");
+            callstack_menu = perspective.load_menu ("callstackpopup.xml",
+                                                    "/CallStackPopup");
             THROW_IF_FAIL (callstack_menu);
         }
         return callstack_menu;
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 7756758..e22106e 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -484,6 +484,8 @@ public:
 
     void close_file (const UString &a_path);
 
+    Gtk::Widget* load_menu (const UString &a_filename,
+                            const UString &a_widget_name);
     void close_opened_files ();
 
     void update_file_maps ();
@@ -668,7 +670,6 @@ public:
 
     void unset_where ();
 
-    Gtk::Widget* load_menu (UString a_filename, UString a_widget_name);
     Gtk::Widget* get_contextual_menu ();
     Gtk::Widget* get_call_stack_menu ();
 
@@ -3857,23 +3858,6 @@ DBGPerspective::get_contextual_menu ()
     return m_priv->contextual_menu;
 }
 
-Gtk::Widget*
-DBGPerspective::load_menu (UString a_filename, UString a_widget_name)
-{
-    THROW_IF_FAIL (m_priv);
-    NEMIVER_TRY
-    string relative_path = Glib::build_filename ("menus", a_filename);
-    string absolute_path;
-    THROW_IF_FAIL (build_absolute_resource_path
-            (Glib::filename_to_utf8 (relative_path), absolute_path));
-
-    workbench ().get_ui_manager ()->add_ui_from_file
-                                    (Glib::filename_to_utf8 (absolute_path));
-
-    NEMIVER_CATCH
-    return workbench ().get_ui_manager ()->get_widget (a_widget_name);
-}
-
 ThreadList&
 DBGPerspective::get_thread_list ()
 {
@@ -4729,6 +4713,26 @@ DBGPerspective::close_file (const UString &a_path)
     update_file_maps ();
 }
 
+Gtk::Widget*
+DBGPerspective::load_menu (const UString &a_filename,
+                           const UString &a_widget_name)
+{
+    NEMIVER_TRY
+
+    string relative_path = Glib::build_filename ("menus", a_filename);
+    string absolute_path;
+    THROW_IF_FAIL (build_absolute_resource_path
+                        (Glib::filename_to_utf8 (relative_path),
+                         absolute_path));
+
+    workbench ().get_ui_manager ()->add_ui_from_file
+        (Glib::filename_to_utf8 (absolute_path));
+
+    NEMIVER_CATCH
+
+    return workbench ().get_ui_manager ()->get_widget (a_widget_name);
+}
+
 void
 DBGPerspective::close_opened_files ()
 {
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.h b/src/persp/dbgperspective/nmv-dbg-perspective.h
index 64bfff5..a4a6fed 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.h
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.h
@@ -68,6 +68,9 @@ public:
 
     virtual void close_file (const UString &a_uri) = 0;
 
+    virtual Gtk::Widget* load_menu (const UString &a_filename,
+                                    const UString &a_widget_name) = 0;
+
     virtual void close_opened_files () = 0;
 
     virtual ISessMgr& session_manager () = 0;
diff --git a/src/persp/nmv-i-perspective.h b/src/persp/nmv-i-perspective.h
index 922c565..6d4eb22 100644
--- a/src/persp/nmv-i-perspective.h
+++ b/src/persp/nmv-i-perspective.h
@@ -113,6 +113,14 @@ public:
     /// \param a_uri the uri that identifies the file to close
     virtual void close_file (const UString &a_uri) = 0;
 
+    /// \brief load a menu file
+    /// \param a_filename the file name of the menu file.
+    ///  It's relative to the "menus" subdirectory of the perspective
+    ///  \param a_widget_name the name of the widget to return as the root
+    ///  of the menu.
+    virtual Gtk::Widget* load_menu (const UString &a_filename,
+                                    const UString &a_widget_name) = 0;
+
     /// \name signals
 
     /// @{



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]