Re: [PATCH] 672409 - activate correct views in static layouts
- From: Dodji Seketeli <dodji seketeli org>
- To: The mailing list of the Nemiver project <nemiver-list gnome org>
- Subject: Re: [PATCH] 672409 - activate correct views in static layouts
- Date: Tue, 27 Mar 2012 20:51:24 +0200
Dodji Seketeli <dodji seketeli org> a écrit:
> Fabien Parent <parent f gmail com> a écrit:
>
>> +++ b/src/persp/dbgperspective/nmv-dbg-perspective-default-layout.cc
>
> [...]
>
>> void
>> @@ -188,9 +191,7 @@ DBGPerspectiveDefaultLayout::add_view (Gtk::Widget &a_widget,
>>
>> m_priv->views.insert (std::make_pair<int, Gtk::Widget&> (a_index, a_widget));
>> a_widget.show_all ();
>> - int page_num = m_priv->statuses_notebook->insert_page (a_widget,
>> - a_title,
>> - a_index);
>> + int page_num = m_priv->statuses_notebook->prepend_page (a_widget,
>> a_title);
>
> Prepending the page here seems surprising. Rather, I'd prefer that
> DBGPerspective::add_views_to_layout add views in ascending order
> (starting from TARGET_TERMINAL_VIEW_INDEX, and going upward to
> MEMORY_VIEW_INDEX), and here we'd use
> m_priv->statuses_notebook->append_page instead. I think it would be
> good to add a comment to DBGPerspective::add_views_to_layout function
> saying that, and to maybe change the name of Layout::add_view in to
> Layout::append_view, to make it clearer that views are being appended.
I went forward and made the improvements I was asking. I have updated
the ChangeLog accordingly. Below is what I have tested and committed to
master.
Thank you for your hard work.
>From c64415bc0e22ae741f2b8c6670330b22b75dc821 Mon Sep 17 00:00:00 2001
From: Fabien Parent <parent f gmail com>
Date: Mon, 19 Mar 2012 19:34:43 +0100
Subject: [PATCH] 672409 - activate correct views in static layouts
* src/uicommon/nmv-layout.h (Layout::append_view): Renamed
add_view into this. Updated comment.
* src/persp/dbgperspective/nmv-dbg-perspective-default-layout.h
(DBGPerspectiveDefaultLayout::append_view): Renamed add_view into
this.
* src/persp/dbgperspective/nmv-dbg-perspective-default-layout.cc
(DBGPerspectiveDefaultLayout::activate_view): Set the current page
of the notebook to the page number of the widget to activate
instead of its ID
(DBGPerspectiveDefaultLayout::append_view): Renamed add_view into
this. Append the widget instead of trying to put it at specific
position in the notebook
* src/persp/dbgperspective/nmv-dbg-perspective-dynamic-layout.h
(DBGPerspectiveDynamicLayout::append_view): Renamed add_view into
this.
* src/persp/dbgperspective/nmv-dbg-perspective-dynamic-layout.cc
(DBGPerspectiveDynamicLayout::append_view): Likewise.
* src/persp/dbgperspective/nmv-dbg-perspective-two-pane-layout.h
(DBGPerspectiveTwoPaneLayout::activate_view): Renamed add_view
into this.
* src/persp/dbgperspective/nmv-dbg-perspective-two-pane-layout.cc
(DBGPerspectiveTwoPaneLayout::activate_view): Fix wrong assertion
(DBGPerspectiveTwoPaneLayout::append_view): Renamed add_view into
this. Append the widget instead of trying to put it at a specific
position in the notebook.
* src/persp/dbgperspective/nmv-dbg-perspective-wide-layout.h
(DBGPerspectiveWideLayout::append_view): Renamed add_view into
this.
* src/persp/dbgperspective/nmv-dbg-perspective-wide-layout.cc
(DBGPerspectiveWideLayout::activate_view): Set the current page of the
notebook to the page number of the widget to activate instead of its ID
(DBGPerspectiveWideLayout::append_view): Renamed add_view into
this. Append the widget instead of trying to put at a specific
position in the notebook.
* src/persp/dbgperspective/nmv-dbg-perspective.cc
(DBGPerspective::add_views_to_layout): Update this to use
Layout::append_view and to append views in the proper order. Add
comment.
---
.../nmv-dbg-perspective-default-layout.cc | 11 +++---
.../nmv-dbg-perspective-default-layout.h | 2 +-
.../nmv-dbg-perspective-dynamic-layout.cc | 6 ++--
.../nmv-dbg-perspective-dynamic-layout.h | 2 +-
.../nmv-dbg-perspective-two-pane-layout.cc | 10 +++---
.../nmv-dbg-perspective-two-pane-layout.h | 2 +-
.../nmv-dbg-perspective-wide-layout.cc | 11 +++---
.../nmv-dbg-perspective-wide-layout.h | 2 +-
src/persp/dbgperspective/nmv-dbg-perspective.cc | 38 ++++++++++---------
src/uicommon/nmv-layout.h | 11 ++++--
10 files changed, 51 insertions(+), 44 deletions(-)
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective-default-layout.cc b/src/persp/dbgperspective/nmv-dbg-perspective-default-layout.cc
index 05f7619..987a215 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective-default-layout.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective-default-layout.cc
@@ -154,7 +154,10 @@ DBGPerspectiveDefaultLayout::activate_view (int a_view)
THROW_IF_FAIL (m_priv);
THROW_IF_FAIL (m_priv->statuses_notebook);
- m_priv->statuses_notebook->set_current_page (a_view);
+ int page_num =
+ m_priv->statuses_notebook->page_num (m_priv->views.at (a_view));
+ THROW_IF_FAIL (page_num >= 0);
+ m_priv->statuses_notebook->set_current_page (page_num);
}
void
@@ -175,7 +178,7 @@ DBGPerspectiveDefaultLayout::save_configuration ()
}
void
-DBGPerspectiveDefaultLayout::add_view (Gtk::Widget &a_widget,
+DBGPerspectiveDefaultLayout::append_view (Gtk::Widget &a_widget,
const UString &a_title,
int a_index)
{
@@ -188,9 +191,7 @@ DBGPerspectiveDefaultLayout::add_view (Gtk::Widget &a_widget,
m_priv->views.insert (std::make_pair<int, Gtk::Widget&> (a_index, a_widget));
a_widget.show_all ();
- int page_num = m_priv->statuses_notebook->insert_page (a_widget,
- a_title,
- a_index);
+ int page_num = m_priv->statuses_notebook->append_page (a_widget, a_title);
m_priv->statuses_notebook->set_current_page (page_num);
}
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective-default-layout.h b/src/persp/dbgperspective/nmv-dbg-perspective-default-layout.h
index d8e4b09..5d84811 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective-default-layout.h
+++ b/src/persp/dbgperspective/nmv-dbg-perspective-default-layout.h
@@ -60,7 +60,7 @@ public:
void save_configuration ();
- void add_view (Gtk::Widget&, const UString&, int);
+ void append_view (Gtk::Widget&, const UString&, int);
void remove_view (int);
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective-dynamic-layout.cc b/src/persp/dbgperspective/nmv-dbg-perspective-dynamic-layout.cc
index 796549a..b0866c0 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective-dynamic-layout.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective-dynamic-layout.cc
@@ -236,9 +236,9 @@ DBGPerspectiveDynamicLayout::save_configuration ()
}
void
-DBGPerspectiveDynamicLayout::add_view (Gtk::Widget &a_widget,
- const UString &a_title,
- int a_index)
+DBGPerspectiveDynamicLayout::append_view (Gtk::Widget &a_widget,
+ const UString &a_title,
+ int a_index)
{
THROW_IF_FAIL (m_priv);
if (m_priv->views.count (a_index) || a_widget.get_parent ()) {
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective-dynamic-layout.h b/src/persp/dbgperspective/nmv-dbg-perspective-dynamic-layout.h
index 489ec2d..405372e 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective-dynamic-layout.h
+++ b/src/persp/dbgperspective/nmv-dbg-perspective-dynamic-layout.h
@@ -60,7 +60,7 @@ public:
void save_configuration ();
- void add_view (Gtk::Widget&, const UString&, int);
+ void append_view (Gtk::Widget&, const UString&, int);
void remove_view (int);
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective-two-pane-layout.cc b/src/persp/dbgperspective/nmv-dbg-perspective-two-pane-layout.cc
index deb0e27..be88fd0 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective-two-pane-layout.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective-two-pane-layout.cc
@@ -193,7 +193,7 @@ DBGPerspectiveTwoPaneLayout::activate_view (int a_view)
LOG_FUNCTION_SCOPE_NORMAL_DD;
THROW_IF_FAIL (m_priv);
- THROW_IF_FAIL (!m_priv->views.count (a_view));
+ THROW_IF_FAIL (m_priv->views.count (a_view));
Gtk::Notebook &status_notebook = m_priv->statuses_notebook (a_view);
int page_num = status_notebook.page_num (m_priv->views.at (a_view));
@@ -222,9 +222,9 @@ DBGPerspectiveTwoPaneLayout::save_configuration ()
}
void
-DBGPerspectiveTwoPaneLayout::add_view (Gtk::Widget &a_widget,
- const UString &a_title,
- int a_index)
+DBGPerspectiveTwoPaneLayout::append_view (Gtk::Widget &a_widget,
+ const UString &a_title,
+ int a_index)
{
THROW_IF_FAIL (m_priv);
if (m_priv->views.count (a_index) || a_widget.get_parent ()) {
@@ -234,7 +234,7 @@ DBGPerspectiveTwoPaneLayout::add_view (Gtk::Widget &a_widget,
m_priv->views.insert (std::make_pair<int, Gtk::Widget&> (a_index, a_widget));
a_widget.show_all ();
Gtk::Notebook &statuses_notebook = m_priv->statuses_notebook (a_index);
- int page_num = statuses_notebook.insert_page (a_widget, a_title, a_index);
+ int page_num = statuses_notebook.append_page (a_widget, a_title);
statuses_notebook.set_current_page (page_num);
}
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective-two-pane-layout.h b/src/persp/dbgperspective/nmv-dbg-perspective-two-pane-layout.h
index 0728ed2..cc10571 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective-two-pane-layout.h
+++ b/src/persp/dbgperspective/nmv-dbg-perspective-two-pane-layout.h
@@ -60,7 +60,7 @@ public:
void save_configuration ();
- void add_view (Gtk::Widget&, const UString&, int);
+ void append_view (Gtk::Widget&, const UString&, int);
void remove_view (int);
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective-wide-layout.cc b/src/persp/dbgperspective/nmv-dbg-perspective-wide-layout.cc
index 72370ae..04eb1d7 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective-wide-layout.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective-wide-layout.cc
@@ -151,7 +151,10 @@ DBGPerspectiveWideLayout::activate_view (int a_view)
THROW_IF_FAIL (m_priv);
THROW_IF_FAIL (m_priv->statuses_notebook);
- m_priv->statuses_notebook->set_current_page (a_view);
+ int page_num =
+ m_priv->statuses_notebook->page_num (m_priv->views.at (a_view));
+ THROW_IF_FAIL (page_num >= 0);
+ m_priv->statuses_notebook->set_current_page (page_num);
}
void
@@ -172,7 +175,7 @@ DBGPerspectiveWideLayout::save_configuration ()
}
void
-DBGPerspectiveWideLayout::add_view (Gtk::Widget &a_widget,
+DBGPerspectiveWideLayout::append_view (Gtk::Widget &a_widget,
const UString &a_title,
int a_index)
{
@@ -185,9 +188,7 @@ DBGPerspectiveWideLayout::add_view (Gtk::Widget &a_widget,
m_priv->views.insert (std::make_pair<int, Gtk::Widget&> (a_index, a_widget));
a_widget.show_all ();
- int page_num = m_priv->statuses_notebook->insert_page (a_widget,
- a_title,
- a_index);
+ int page_num = m_priv->statuses_notebook->append_page (a_widget, a_title);
m_priv->statuses_notebook->set_current_page (page_num);
}
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective-wide-layout.h b/src/persp/dbgperspective/nmv-dbg-perspective-wide-layout.h
index c57a73c..46aebc8 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective-wide-layout.h
+++ b/src/persp/dbgperspective/nmv-dbg-perspective-wide-layout.h
@@ -60,7 +60,7 @@ public:
void save_configuration ();
- void add_view (Gtk::Widget&, const UString&, int);
+ void append_view (Gtk::Widget&, const UString&, int);
void remove_view (int);
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 347b1ef..2560498 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -4928,29 +4928,31 @@ DBGPerspective::get_find_text_dialog ()
return *m_priv->find_text_dialog;
}
+/// Adds the views of the debugger to the layout. It adds them in a
+/// left to right manner (if you consider the defaut layout at
+/// least).
void
DBGPerspective::add_views_to_layout ()
{
THROW_IF_FAIL (m_priv);
-#ifdef WITH_MEMORYVIEW
- m_priv->layout ().add_view (get_memory_view ().widget (),
- MEMORY_VIEW_TITLE,
- MEMORY_VIEW_INDEX);
-#endif // WITH_MEMORYVIEW
- m_priv->layout ().add_view (get_registers_scrolled_win (),
- REGISTERS_VIEW_TITLE,
- REGISTERS_VIEW_INDEX);
- m_priv->layout ().add_view (get_breakpoints_scrolled_win (),
- BREAKPOINTS_VIEW_TITLE,
- BREAKPOINTS_VIEW_INDEX);
- m_priv->layout ().add_view (get_context_paned (),
- CONTEXT_VIEW_TITLE,
- CONTEXT_VIEW_INDEX);
- m_priv->layout ().add_view (get_terminal_box (),
- TARGET_TERMINAL_VIEW_TITLE,
- TARGET_TERMINAL_VIEW_INDEX);
-
+ m_priv->layout ().append_view (get_terminal_box (),
+ TARGET_TERMINAL_VIEW_TITLE,
+ TARGET_TERMINAL_VIEW_INDEX);
+ m_priv->layout ().append_view (get_context_paned (),
+ CONTEXT_VIEW_TITLE,
+ CONTEXT_VIEW_INDEX);
+ m_priv->layout ().append_view (get_breakpoints_scrolled_win (),
+ BREAKPOINTS_VIEW_TITLE,
+ BREAKPOINTS_VIEW_INDEX);
+ m_priv->layout ().append_view (get_registers_scrolled_win (),
+ REGISTERS_VIEW_TITLE,
+ REGISTERS_VIEW_INDEX);
+ #ifdef WITH_MEMORYVIEW
+ m_priv->layout ().append_view (get_memory_view ().widget (),
+ MEMORY_VIEW_TITLE,
+ MEMORY_VIEW_INDEX);
+ #endif // WITH_MEMORYVIEW
m_priv->layout ().do_init ();
}
diff --git a/src/uicommon/nmv-layout.h b/src/uicommon/nmv-layout.h
index 46635ff..8e8b900 100644
--- a/src/uicommon/nmv-layout.h
+++ b/src/uicommon/nmv-layout.h
@@ -89,13 +89,16 @@ public:
/// \param a_view_identifier The view to activate
virtual void activate_view (int a_view_identifier) = 0;
- /// \brief add a view to the layout
+ /// \brief appends a view to the layout
+ ///
+ /// The view is added to the end of the existing list of views
+ /// contained in the layout.
/// \param a_widget Widget of the view to add to the layout
/// \param a_title Title of the view (will appears in notebook label, ...)
/// \param a_index Unique identifier of the view to add to the layout
- virtual void add_view (Gtk::Widget &a_widget,
- const UString &a_title,
- int a_index) = 0;
+ virtual void append_view (Gtk::Widget &a_widget,
+ const UString &a_title,
+ int a_index) = 0;
/// \brief remove a view from the layout
/// \param a_index Unique identifier of the view to remove from the layout
--
1.7.6.5
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]