[nemiver/gtk-app] Simplify actions creation by using G_N_ELEMENTS



commit 9bbb561b2de2bc34b7da1415946f1f0bfe2054e3
Author: Dodji Seketeli <dodji seketeli org>
Date:   Sat Aug 18 17:19:37 2012 +0200

    Simplify actions creation by using G_N_ELEMENTS
    
    	* src/persp/dbgperspective/nmv-dbg-perspective.cc
    	(DBGPerspective::init_actions): Use G_N_ELEMENTS.  Remove
    	num_actions and their uses.
    	* src/workbench/nmv-workbench.cc (Workbench::init_actions):
    	Likewise.

 src/persp/dbgperspective/nmv-dbg-perspective.cc |   42 +++++------------------
 src/workbench/nmv-workbench.cc                  |   11 +++---
 2 files changed, 15 insertions(+), 38 deletions(-)
---
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index b7ad484..f61aaf3 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -3613,65 +3613,41 @@ DBGPerspective::init_actions ()
                 Gtk::ActionGroup::create ("opened-file-action-group");
     m_priv->opened_file_action_group->set_sensitive (false);
 
-    int num_actions =
-        sizeof (s_detach_action_entries) / sizeof (ui_utils::ActionEntry);
+
     ui_utils::add_action_entries_to_action_group
         (s_detach_action_entries,
-         num_actions,
+         G_N_ELEMENTS (s_detach_action_entries),
          m_priv->detach_action_group);
 
-    num_actions =
-     sizeof (s_inferior_loaded_action_entries)
-             /
-             sizeof (ui_utils::ActionEntry);
+
     ui_utils::add_action_entries_to_action_group
                         (s_inferior_loaded_action_entries,
-                         num_actions,
+                         G_N_ELEMENTS (s_inferior_loaded_action_entries),
                          m_priv->inferior_loaded_action_group);
 
-    num_actions =
-     sizeof (s_target_not_started_action_entries)
-                 /
-             sizeof (ui_utils::ActionEntry);
     ui_utils::add_action_entries_to_action_group
                         (s_target_not_started_action_entries,
-                         num_actions,
+                         G_N_ELEMENTS (s_target_not_started_action_entries),
                          m_priv->target_not_started_action_group);
 
-    num_actions =
-         sizeof (s_debugger_ready_action_entries)
-             /
-         sizeof (ui_utils::ActionEntry);
-
     ui_utils::add_action_entries_to_action_group
                         (s_debugger_ready_action_entries,
-                         num_actions,
+                         G_N_ELEMENTS (s_debugger_ready_action_entries),
                          m_priv->debugger_ready_action_group);
 
-    num_actions =
-         sizeof (s_debugger_busy_action_entries)
-             /
-         sizeof (ui_utils::ActionEntry);
-
     ui_utils::add_action_entries_to_action_group
                         (s_debugger_busy_action_entries,
-                         num_actions,
+                         G_N_ELEMENTS (s_debugger_busy_action_entries),
                          m_priv->debugger_busy_action_group);
 
-    num_actions =
-         sizeof (s_default_action_entries)/sizeof (ui_utils::ActionEntry);
-
     ui_utils::add_action_entries_to_action_group
                         (s_default_action_entries,
-                         num_actions,
+                         G_N_ELEMENTS (s_default_action_entries),
                          m_priv->default_action_group);
 
-    num_actions =
-        sizeof (s_file_opened_action_entries)/sizeof (ui_utils::ActionEntry);
-
     ui_utils::add_action_entries_to_action_group
                         (s_file_opened_action_entries,
-                         num_actions,
+                         G_N_ELEMENTS (s_file_opened_action_entries),
                          m_priv->opened_file_action_group);
 
     workbench ().get_ui_manager ()->insert_action_group
diff --git a/src/workbench/nmv-workbench.cc b/src/workbench/nmv-workbench.cc
index fadda00..b4630e7 100644
--- a/src/workbench/nmv-workbench.cc
+++ b/src/workbench/nmv-workbench.cc
@@ -724,11 +724,12 @@ Workbench::init_actions ()
 
     m_priv->default_action_group =
         Gtk::ActionGroup::create ("workbench-default-action-group");
-    int num_default_actions =
-         sizeof (s_default_action_entries)/sizeof (ui_utils::ActionEntry);
-    ui_utils::add_action_entries_to_action_group (s_default_action_entries,
-                                                  num_default_actions,
-                                                  m_priv->default_action_group);
+
+       ui_utils::add_action_entries_to_action_group
+           (s_default_action_entries,
+            G_N_ELEMENTS (s_default_action_entries);
+            m_priv->default_action_group);
+
     get_ui_manager ()->insert_action_group (m_priv->default_action_group);
 }
 



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