[nemiver/profiler] WIP from Dodji's review
- From: Fabien Parent <fparent src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver/profiler] WIP from Dodji's review
- Date: Sun, 19 Aug 2012 17:49:55 +0000 (UTC)
commit 1b0502189e7025f78467116037a75d855a94e2e3
Author: Fabien Parent <parent f gmail com>
Date: Sun Aug 19 18:19:39 2012 +0200
WIP from Dodji's review
src/main.cc | 236 +------------------
src/persp/dbgperspective/nmv-dbg-perspective.cc | 22 +-
src/persp/dbgperspective/nmv-dbg-perspective.h | 5 +-
src/persp/dbgperspective/plugin-descriptor.xml | 2 +-
src/persp/nmv-i-perspective.h | 5 +-
src/workbench/nmv-i-workbench.h | 6 +-
src/workbench/nmv-workbench.cc | 295 ++++++++++++++++++++++-
7 files changed, 300 insertions(+), 271 deletions(-)
---
diff --git a/src/main.cc b/src/main.cc
index e55481e..71e9bda 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -50,73 +50,6 @@ using nemiver::IPerspectiveSafePtr;
using nemiver::common::UString;
using nemiver::common::GCharSafePtr;
-static gchar *gv_log_domains=0;
-static bool gv_show_version = false;
-static gchar *gv_tool = (gchar*) "dbgperspective";
-
-static GOptionEntry entries[] =
-{
- {
- "tool",
- 0,
- 0,
- G_OPTION_ARG_STRING,
- &gv_tool,
- _("Use the nemiver tool named <name>"),
- "<name>"
- },
- { "log-domains",
- 0,
- 0,
- G_OPTION_ARG_STRING,
- &gv_log_domains,
- _("Enable logging domains DOMAINS"),
- "<DOMAINS>"
- },
- {
- "version",
- 0,
- 0,
- G_OPTION_ARG_NONE,
- &gv_show_version,
- _("Show the version number of Nemiver"),
- 0
- },
- {0, 0, 0, (GOptionArg) 0, 0, 0, 0}
-};
-
-struct GOptionContextUnref {
- void operator () (GOptionContext *a_opt)
- {
- if (a_opt) {
- g_option_context_free (a_opt);
- }
- }
-};//end struct GOptionContextUnref
-
-struct GOptionGroupUnref {
- void operator () (GOptionGroup *a_group)
- {
- if (a_group) {
- g_option_group_free (a_group);
- }
- }
-};//end struct GOptionGroupUnref
-
-struct GOptionContextRef {
- void operator () (GOptionContext *a_opt)
- {
- if (a_opt) {}
- }
-};//end struct GOptionContextRef
-
-struct GOptionGroupRef {
- void operator () (GOptionGroup *a_group)
- {
- if (a_group) {}
- }
-};//end struct GOptionGroupRef
-
static IWorkbench *s_workbench=0;
void
@@ -132,155 +65,6 @@ sigint_handler (int a_signum)
s_got_down = true;
}
}
-typedef SafePtr<GOptionContext,
- GOptionContextRef,
- GOptionContextUnref> GOptionContextSafePtr;
-
-typedef SafePtr<GOptionGroup,
- GOptionGroupRef,
- GOptionGroupUnref> GOptionGroupSafePtr;
-
-static GOptionContext*
-init_option_context ()
-{
- GOptionContextSafePtr context;
- context.reset (g_option_context_new
- (_(" [<prog-to-debug> [prog-args]]")));
-#if GLIB_CHECK_VERSION (2, 12, 0)
- g_option_context_set_summary (context.get (),
- _("A C/C++ debugger for GNOME"));
-#endif
- g_option_context_set_help_enabled (context.get (), true);
- g_option_context_add_main_entries (context.get (),
- entries,
- GETTEXT_PACKAGE);
- g_option_context_set_ignore_unknown_options (context.get (), false);
- GOptionGroupSafePtr gtk_option_group (gtk_get_option_group (FALSE));
- THROW_IF_FAIL (gtk_option_group);
- g_option_context_add_group (context.get (),
- gtk_option_group.release ());
-
- std::list<IPerspectiveSafePtr>::iterator perspective;
- std::list<IPerspectiveSafePtr> perspectives = s_workbench->perspectives ();
- for (perspective = perspectives.begin ();
- perspective != perspectives.end ();
- ++perspective) {
- if (*perspective && (*perspective)->option_group ()) {
- g_option_context_add_group
- (context.get (), (*perspective)->option_group ());
- }
- }
-
- return context.release ();
-}
-
-/// Parse the command line and edits it
-/// to make it contain the command line of the inferior program.
-/// If an error happens (e.g, the user provided the wrong command
-/// lines) then display an usage help message and return
-/// false. Otherwise, return true.
-/// \param a_arg the argument count. This is the length of a_argv.
-/// This is going to be edited. After edit, only the number of
-/// arguments of the inferior will be put in this variable.
-/// \param a_argv the string of arguments passed to Nemiver. This is
-/// going to be edited so that only the arguments passed to the
-/// inferior will be left in this.
-/// \return true upon successful completion, false otherwise. If the
-static bool
-parse_command_line (int& a_argc,
- char** a_argv)
-{
- GOptionContextSafePtr context (init_option_context ());
- THROW_IF_FAIL (context);
-
- if (a_argc == 1) {
- // We have no inferior program so edit the command like accordingly.
- a_argc = 0;
- a_argv[0] = 0;
- return true;
- }
-
- // Split the command line in two parts. One part is made of the
- // options for Nemiver itself, and the other part is the options
- // relevant to the inferior.
- int i;
- std::vector<UString> args;
- for (i = 1; i < a_argc; ++i)
- if (a_argv[i][0] != '-')
- break;
-
- // Now parse only the part of the command line that is related
- // to Nemiver and not to the inferior.
- // Once parsed, make a_argv and a_argv contain the command line
- // of the inferior.
- char **nmv_argv, **inf_argv;
- int nmv_argc = a_argc;
- int inf_argc = 0;
-
- if (i < a_argc) {
- nmv_argc = i;
- inf_argc = a_argc - i;
- }
- nmv_argv = a_argv;
- inf_argv = a_argv + i;
- GError *error = 0;
- if (g_option_context_parse (context.get (),
- &nmv_argc,
- &nmv_argv,
- &error) != TRUE) {
- NEMIVER_TRY;
- if (error)
- cerr << "error: "<< error->message << std::endl;
- NEMIVER_CATCH;
- g_error_free (error);
-
- GCharSafePtr help_message;
- help_message.reset (g_option_context_get_help (context.get (),
- true, 0));
- cerr << help_message.get () << std::endl;
- return false;
- }
-
- IPerspectiveSafePtr perspective = s_workbench->get_perspective (gv_tool);
- if (!perspective) {
- std::cerr << "Invalid tool name: " << gv_tool << std::endl;
- return false;
- }
-
- if (!perspective->process_options (context.get (), inf_argc, inf_argv)) {
- return false;
- }
-
- if (a_argv != inf_argv) {
- memmove (a_argv, inf_argv, inf_argc * sizeof (char*));
- a_argc = inf_argc;
- }
-
- return true;
-}
-
-// Return true if Nemiver should keep going after the non gui options
-// have been processed.
-static bool
-process_non_gui_options ()
-{
- if (gv_show_version) {
- cout << PACKAGE_VERSION << endl;
- return false;
- }
-
- if (gv_log_domains) {
- UString log_domains (gv_log_domains);
- vector<UString> domains = log_domains.split (" ");
- for (vector<UString>::const_iterator iter = domains.begin ();
- iter != domains.end ();
- ++iter) {
- LOG_STREAM.enable_domain (*iter);
- }
- }
-
- return true;
-}
int
main (int a_argc, char *a_argv[])
@@ -304,31 +88,13 @@ main (int a_argc, char *a_argv[])
THROW_IF_FAIL (s_workbench);
LOG_D ("workbench refcount: " << (int) s_workbench->get_refcount (),
"refcount-domain");
- s_workbench->load_perspectives ();
- if (!parse_command_line (a_argc, a_argv))
- return -1;
-
- if (!process_non_gui_options ()) {
+ if (!s_workbench->do_init (gtk_kit, a_argc, a_argv)) {
return -1;
}
-
- s_workbench->do_init (gtk_kit);
LOG_D ("workbench refcount: " << (int) s_workbench->get_refcount (),
"refcount-domain");
- IPerspectiveSafePtr perspective = s_workbench->get_perspective (gv_tool);
- if (!perspective) {
- std::cerr << "Invalid tool name: " << gv_tool << std::endl;
- return -1;
- }
-
- if (!perspective->process_gui_options (a_argc, a_argv)) {
- return -1;
- }
-
- s_workbench->select_perspective (perspective);
-
//intercept ctrl-c/SIGINT
signal (SIGINT, sigint_handler);
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 716df9b..2ed272b 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -640,7 +640,7 @@ public:
IWorkbench& get_workbench ();
- std::list<Gtk::UIManager::ui_merge_id> edit_workbench_menu ();
+ const std::list<Gtk::UIManager::ui_merge_id>& edit_workbench_menu ();
SourceEditor* create_source_editor (Glib::RefPtr<Gsv::Buffer> &a_source_buf,
bool a_asm_view,
@@ -1022,6 +1022,7 @@ struct DBGPerspective::Priv {
Glib::RefPtr<Gtk::ActionGroup> debugger_busy_action_group;
Glib::RefPtr<Gtk::UIManager> ui_manager;
Glib::RefPtr<Gtk::IconFactory> icon_factory;
+ std::list<Gtk::UIManager::ui_merge_id> merge_ids;
Gtk::UIManager::ui_merge_id memoryview_merge_id;
Gtk::UIManager::ui_merge_id menubar_merge_id;
Gtk::UIManager::ui_merge_id toolbar_merge_id;
@@ -5381,16 +5382,18 @@ DBGPerspective::get_workbench ()
return workbench ();
}
-std::list<Gtk::UIManager::ui_merge_id>
+const std::list<Gtk::UIManager::ui_merge_id>&
DBGPerspective::edit_workbench_menu ()
{
CHECK_P_INIT;
add_perspective_menu_entries ();
- std::list<Gtk::UIManager::ui_merge_id> merge_ids;
- merge_ids.push_back (m_priv->menubar_merge_id);
- merge_ids.push_back (m_priv->memoryview_merge_id);
- return merge_ids;
+ m_priv->merge_ids.clear ();
+ m_priv->merge_ids.push_back (m_priv->menubar_merge_id);
+ m_priv->merge_ids.push_back (m_priv->memoryview_merge_id);
+ m_priv->merge_ids.push_back (m_priv->toolbar_merge_id);
+ m_priv->merge_ids.push_back (m_priv->contextual_menu_merge_id);
+ return m_priv->merge_ids;
}
SourceEditor*
@@ -5498,13 +5501,6 @@ DBGPerspective::option_group () const
return m_priv->option_group;
}
-const UString&
-DBGPerspective::name () const
-{
- static const UString s_name (_("Debugger"));
- return s_name;
-}
-
bool
DBGPerspective::open_file (const UString &a_path, int current_line)
{
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.h b/src/persp/dbgperspective/nmv-dbg-perspective.h
index 433655e..b3a839a 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.h
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.h
@@ -79,7 +79,8 @@ public:
virtual IWorkbench& get_workbench () = 0;
- virtual std::list<Gtk::UIManager::ui_merge_id> edit_workbench_menu () = 0;
+ virtual const std::list<Gtk::UIManager::ui_merge_id>&
+ edit_workbench_menu () = 0;
virtual void open_file () = 0;
@@ -186,8 +187,6 @@ public:
virtual sigc::signal<void>& layout_changed_signal () = 0;
- virtual const UString& name () const = 0;
-
virtual bool agree_to_shutdown () = 0;
};//end class IDBGPerspective
diff --git a/src/persp/dbgperspective/plugin-descriptor.xml b/src/persp/dbgperspective/plugin-descriptor.xml
index 48e9b82..cd031f1 100644
--- a/src/persp/dbgperspective/plugin-descriptor.xml
+++ b/src/persp/dbgperspective/plugin-descriptor.xml
@@ -1,5 +1,5 @@
<plugindescriptor autoactivate="yes" candeactivate="no">
- <name>dbgperspective</name>
+ <name>debugger</name>
<version>0.0.1</version>
<entrypoint>
<modulename>dbgperspective</modulename>
diff --git a/src/persp/nmv-i-perspective.h b/src/persp/nmv-i-perspective.h
index 444ae45..694868a 100644
--- a/src/persp/nmv-i-perspective.h
+++ b/src/persp/nmv-i-perspective.h
@@ -73,8 +73,6 @@ public:
virtual GOptionGroup* option_group () const = 0;
- virtual const UString& name () const = 0;
-
/// initialize the perspective within the context of
/// of the workbench that loads it.
/// \param a_workbench, the workbench that loaded the
@@ -102,7 +100,8 @@ public:
/// This method is only called once, during the
/// perspective's initialisation time,
/// by the workbench.
- virtual std::list<Gtk::UIManager::ui_merge_id> edit_workbench_menu () = 0;
+ virtual const std::list<Gtk::UIManager::ui_merge_id>&
+ edit_workbench_menu () = 0;
/// \brief load a menu file
/// \param a_filename the file name of the menu file.
diff --git a/src/workbench/nmv-i-workbench.h b/src/workbench/nmv-i-workbench.h
index 02a5ac8..e47c3bb 100644
--- a/src/workbench/nmv-i-workbench.h
+++ b/src/workbench/nmv-i-workbench.h
@@ -109,7 +109,7 @@ public:
/// \brief initialization function
/// \param a_main the main loop created by the application.
- virtual void do_init (Gtk::Main &a_main) = 0;
+ virtual bool do_init (Gtk::Main &a_main, int a_argc, char **a_argv) = 0;
virtual void shut_down () = 0;
@@ -137,15 +137,13 @@ public:
/// \return the Gtk::UIManager of the workbench
virtual Glib::RefPtr<Gtk::UIManager>& get_ui_manager () = 0;
- virtual std::list<IPerspectiveSafePtr> perspectives () const = 0;
+ virtual const std::list<IPerspectiveSafePtr>& perspectives () const = 0;
/// \return the perspective that which name matches a_name
virtual IPerspectiveSafePtr get_perspective (const UString &a_name) = 0;
virtual void select_perspective (IPerspectiveSafePtr &a_perspective) = 0;
- virtual void load_perspectives () = 0;
-
/// set the configuration manager used by this interface
virtual void do_init (IConfMgrSafePtr &) = 0;
diff --git a/src/workbench/nmv-workbench.cc b/src/workbench/nmv-workbench.cc
index 1437424..9a2fa7a 100644
--- a/src/workbench/nmv-workbench.cc
+++ b/src/workbench/nmv-workbench.cc
@@ -50,6 +50,91 @@ using namespace nemiver::common;
NEMIVER_BEGIN_NAMESPACE (nemiver)
+static gchar *gv_log_domains = 0;
+static bool gv_show_version = false;
+static gchar *gv_tool = (gchar*) "debugger";
+static bool gv_show_tool_list = false;
+
+static GOptionEntry entries[] =
+{
+ {
+ "tool",
+ 0,
+ 0,
+ G_OPTION_ARG_STRING,
+ &gv_tool,
+ _("Use the nemiver tool named <name>"),
+ "<name>; use --list-tools to get the possibilities"
+ },
+ {
+ "list-tools",
+ 0,
+ 0,
+ G_OPTION_ARG_NONE,
+ &gv_show_tool_list,
+ _("Show the list of tool available"),
+ 0
+ },
+ { "log-domains",
+ 0,
+ 0,
+ G_OPTION_ARG_STRING,
+ &gv_log_domains,
+ _("Enable logging domains DOMAINS"),
+ "<DOMAINS>"
+ },
+ {
+ "version",
+ 0,
+ 0,
+ G_OPTION_ARG_NONE,
+ &gv_show_version,
+ _("Show the version number of Nemiver"),
+ 0
+ },
+ {0, 0, 0, (GOptionArg) 0, 0, 0, 0}
+};
+
+struct GOptionContextUnref {
+ void operator () (GOptionContext *a_opt)
+ {
+ if (a_opt) {
+ g_option_context_free (a_opt);
+ }
+ }
+};//end struct GOptionContextUnref
+
+struct GOptionGroupUnref {
+ void operator () (GOptionGroup *a_group)
+ {
+ if (a_group) {
+ g_option_group_free (a_group);
+ }
+ }
+};//end struct GOptionGroupUnref
+
+struct GOptionContextRef {
+ void operator () (GOptionContext *a_opt)
+ {
+ if (a_opt) {}
+ }
+};//end struct GOptionContextRef
+
+struct GOptionGroupRef {
+ void operator () (GOptionGroup *a_group)
+ {
+ if (a_group) {}
+ }
+};//end struct GOptionGroupRef
+
+typedef SafePtr<GOptionContext,
+ GOptionContextRef,
+ GOptionContextUnref> GOptionContextSafePtr;
+
+typedef SafePtr<GOptionGroup,
+ GOptionGroupRef,
+ GOptionGroupUnref> GOptionGroupSafePtr;
+
class WorkbenchStaticInit {
WorkbenchStaticInit ()
{
@@ -106,9 +191,10 @@ private:
bool remove_perspective_body (IPerspectiveSafePtr &a_perspective);
void remove_all_perspective_bodies ();
void disconnect_all_perspective_signals ();
-
+ bool process_non_gui_options ();
void save_window_geometry ();
-
+ bool parse_command_line (int &a_argc, char** a_argv);
+ GOptionContext* init_option_context ();
void do_init ()
{
@@ -121,7 +207,7 @@ public:
Workbench (DynamicModule *a_dynmod);
virtual ~Workbench ();
void load_perspectives ();
- void do_init (Gtk::Main &a_main);
+ bool do_init (Gtk::Main &a_main, int a_argc, char **a_argv);
void do_init (IConfMgrSafePtr &);
void select_perspective (IPerspectiveSafePtr &a_perspective);
void shut_down ();
@@ -133,7 +219,7 @@ public:
void set_title_extension (const UString &a_str);
Glib::RefPtr<Gtk::UIManager>& get_ui_manager () ;
IPerspectiveSafePtr get_perspective (const UString &a_name);
- std::list<IPerspectiveSafePtr> perspectives () const;
+ const std::list<IPerspectiveSafePtr>& perspectives () const;
void set_configuration_manager (IConfMgrSafePtr &);
IConfMgrSafePtr get_configuration_manager () ;
Glib::RefPtr<Glib::MainContext> get_main_context () ;
@@ -213,7 +299,8 @@ Workbench::on_perspective_changed ()
for (iter = m_priv->perspectives.begin ();
iter != m_priv->perspectives.end ();
++iter) {
- if ((*iter)->name () == name) {
+ THROW_IF_FAIL ((*iter)->descriptor ());
+ if ((*iter)->descriptor ()->name () == name) {
select_perspective (*iter);
return;
}
@@ -429,16 +516,183 @@ Workbench::load_perspectives ()
NEMIVER_CATCH;
}
+GOptionContext*
+Workbench::init_option_context ()
+{
+ GOptionContextSafePtr context;
+ context.reset (g_option_context_new
+ (_(" [<prog-to-debug> [prog-args]]")));
+#if GLIB_CHECK_VERSION (2, 12, 0)
+ g_option_context_set_summary (context.get (),
+ _("A C/C++ debugger for GNOME"));
+#endif
+ g_option_context_set_help_enabled (context.get (), true);
+ g_option_context_add_main_entries (context.get (),
+ entries,
+ GETTEXT_PACKAGE);
+ g_option_context_set_ignore_unknown_options (context.get (), false);
+ GOptionGroupSafePtr gtk_option_group (gtk_get_option_group (FALSE));
+ THROW_IF_FAIL (gtk_option_group);
+ g_option_context_add_group (context.get (),
+ gtk_option_group.release ());
+
+ std::list<IPerspectiveSafePtr>::const_iterator perspective;
+ const std::list<IPerspectiveSafePtr> &perps = perspectives ();
+ for (perspective = perps.begin ();
+ perspective != perps.end ();
+ ++perspective) {
+ if (*perspective && (*perspective)->option_group ()) {
+ g_option_context_add_group
+ (context.get (), (*perspective)->option_group ());
+ }
+ }
+
+ return context.release ();
+}
+
+/// Parse the command line and edits it
+/// to make it contain the command line of the inferior program.
+/// If an error happens (e.g, the user provided the wrong command
+/// lines) then display an usage help message and return
+/// false. Otherwise, return true.
+/// \param a_arg the argument count. This is the length of a_argv.
+/// This is going to be edited. After edit, only the number of
+/// arguments of the inferior will be put in this variable.
+/// \param a_argv the string of arguments passed to Nemiver. This is
+/// going to be edited so that only the arguments passed to the
+/// inferior will be left in this.
+/// \return true upon successful completion, false otherwise. If the
+bool
+Workbench::parse_command_line (int &a_argc, char** a_argv)
+{
+ GOptionContextSafePtr context (init_option_context ());
+ THROW_IF_FAIL (context);
+
+ if (a_argc == 1) {
+ // We have no inferior program so edit the command like accordingly.
+ a_argc = 0;
+ a_argv[0] = 0;
+ return true;
+ }
+
+ // Split the command line in two parts. One part is made of the
+ // options for Nemiver itself, and the other part is the options
+ // relevant to the inferior.
+ int i;
+ std::vector<UString> args;
+ for (i = 1; i < a_argc; ++i)
+ if (a_argv[i][0] != '-')
+ break;
+
+ // Now parse only the part of the command line that is related
+ // to Nemiver and not to the inferior.
+ // Once parsed, make a_argv and a_argv contain the command line
+ // of the inferior.
+ char **nmv_argv, **inf_argv;
+ int nmv_argc = a_argc;
+ int inf_argc = 0;
+
+ if (i < a_argc) {
+ nmv_argc = i;
+ inf_argc = a_argc - i;
+ }
+ nmv_argv = a_argv;
+ inf_argv = a_argv + i;
+ GError *error = 0;
+ if (g_option_context_parse (context.get (),
+ &nmv_argc,
+ &nmv_argv,
+ &error) != TRUE) {
+ NEMIVER_TRY;
+ if (error)
+ cerr << "error: "<< error->message << std::endl;
+ NEMIVER_CATCH;
+ g_error_free (error);
+
+ GCharSafePtr help_message;
+ help_message.reset (g_option_context_get_help (context.get (),
+ true, 0));
+ cerr << help_message.get () << std::endl;
+ return false;
+ }
+
+ IPerspectiveSafePtr perspective = get_perspective (gv_tool);
+ if (!perspective) {
+ std::cerr << "Invalid tool name: " << gv_tool << std::endl;
+ return false;
+ }
+
+ if (!perspective->process_options (context.get (), inf_argc, inf_argv)) {
+ return false;
+ }
+
+ if (a_argv != inf_argv) {
+ memmove (a_argv, inf_argv, inf_argc * sizeof (char*));
+ a_argc = inf_argc;
+ }
+
+ return true;
+}
+
+// Return true if Nemiver should keep going after the non gui options
+// have been processed.
+bool
+Workbench::process_non_gui_options ()
+{
+ if (gv_show_version) {
+ std::cout << PACKAGE_VERSION << endl;
+ return false;
+ }
+
+ if (gv_show_tool_list) {
+ const std::list<IPerspectiveSafePtr> &persp = perspectives ();
+ std::list<IPerspectiveSafePtr>::const_iterator perspective;
+ std::cout << "Tools available: \n";
+
+ for (perspective = persp.begin ();
+ perspective != persp.end ();
+ ++perspective) {
+ THROW_IF_FAIL (*perspective);
+ THROW_IF_FAIL ((*perspective)->descriptor ());
+ std::cout << "\t- " << (*perspective)->descriptor ()->name ()
+ << std::endl;
+ }
+
+ return false;
+ }
+
+ if (gv_log_domains) {
+ UString log_domains (gv_log_domains);
+ vector<UString> domains = log_domains.split (" ");
+ for (vector<UString>::const_iterator iter = domains.begin ();
+ iter != domains.end ();
+ ++iter) {
+ LOG_STREAM.enable_domain (*iter);
+ }
+ }
+
+ return true;
+}
+
/// Initialize the workbench by doing all the graphical plumbling
/// needed to setup the perspectives held by this workbench. Calling
/// this function is mandatory prior to using the workbench.
///
/// \param a_main the Gtk main object the workbench is going to use.
-void
-Workbench::do_init (Gtk::Main &a_main)
+bool
+Workbench::do_init (Gtk::Main &a_main, int a_argc, char **a_argv)
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
+ load_perspectives ();
+
+ if (!parse_command_line (a_argc, a_argv))
+ return false;
+
+ if (!process_non_gui_options ()) {
+ return false;
+ }
+
m_priv->main = &a_main;
// set the icon that will be used by all workbench windows that don't
@@ -501,10 +755,25 @@ Workbench::do_init (Gtk::Main &a_main)
if (!m_priv->perspectives.empty ()) {
perspective = *m_priv->perspectives.begin ();
THROW_IF_FAIL (perspective);
+ THROW_IF_FAIL (perspective->descriptor ());
m_priv->persp_selector_combobox->set_active_text
- (perspective->name ());
+ (perspective->descriptor ()->name ());
+ }
+
+ perspective = get_perspective (gv_tool);
+ if (!perspective) {
+ std::cerr << "Invalid tool name: " << gv_tool << std::endl;
+ return false;
+ }
+
+ if (!perspective->process_gui_options (a_argc, a_argv)) {
+ return false;
}
+
+ select_perspective (perspective);
NEMIVER_CATCH
+
+ return true;
}
void
@@ -572,7 +841,7 @@ Workbench::get_ui_manager ()
return m_priv->ui_manager;
}
-std::list<IPerspectiveSafePtr>
+const std::list<IPerspectiveSafePtr>&
Workbench::perspectives () const
{
THROW_IF_FAIL (m_priv);
@@ -884,9 +1153,10 @@ Workbench::add_perspective_to_perspective_selector
THROW_IF_FAIL (m_priv);
THROW_IF_FAIL (a_perspective);
THROW_IF_FAIL (m_priv->persp_selector_combobox);
+ THROW_IF_FAIL (a_perspective->descriptor ());
m_priv->persp_selector_combobox->append
- (a_perspective->name ());
+ (a_perspective->descriptor ()->name ());
}
void
@@ -1008,6 +1278,7 @@ Workbench::select_perspective (IPerspectiveSafePtr &a_perspective)
THROW_IF_FAIL (m_priv->toolbar_container);
THROW_IF_FAIL (m_priv->bodies_container);
THROW_IF_FAIL (a_perspective);
+ THROW_IF_FAIL (a_perspective->descriptor ());
map<IPerspective*, int>::const_iterator iter, nil;
int toolbar_index=0, body_index=0;
@@ -1038,9 +1309,9 @@ Workbench::select_perspective (IPerspectiveSafePtr &a_perspective)
m_priv->bodies_container->set_current_page (body_index);
UString name = m_priv->persp_selector_combobox->get_active_text ();
- if (a_perspective->name () != name) {
+ if (a_perspective->descriptor ()->name () != name) {
m_priv->persp_selector_combobox->set_active_text
- (a_perspective->name ());
+ (a_perspective->descriptor ()->name ());
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]