[nemiver/profiler] Add option to save reports on the filesystem
- From: Fabien Parent <fparent src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nemiver/profiler] Add option to save reports on the filesystem
- Date: Sat, 18 Aug 2012 20:55:47 +0000 (UTC)
commit 638a131423f8c14529bd23e868d53188de5d36b2
Author: Fabien Parent <parent f gmail com>
Date: Sat Aug 18 22:55:09 2012 +0200
Add option to save reports on the filesystem
src/persp/profperspective/menus/menus.xml | 3 +
src/persp/profperspective/nmv-prof-perspective.cc | 55 +++++++++++++++++++++
src/profengine/nmv-i-profiler.h | 2 +
src/profengine/nmv-perf-engine.cc | 7 +++
src/profengine/nmv-perf-engine.h | 1 +
5 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/src/persp/profperspective/menus/menus.xml b/src/persp/profperspective/menus/menus.xml
index 1bf0058..d7154c3 100644
--- a/src/persp/profperspective/menus/menus.xml
+++ b/src/persp/profperspective/menus/menus.xml
@@ -11,6 +11,9 @@
name="AttachToProcessItem"/>
<menuitem action="SystemWideRecordAction"
name="SystemWideRecordItem"/>
+ <separator />
+ <menuitem action="SaveReportAsAction"
+ name="SaveReportAsItem"/>
</placeholder>
</menu>
<menu action="EditMenuAction" name="EditMenu">
diff --git a/src/persp/profperspective/nmv-prof-perspective.cc b/src/persp/profperspective/nmv-prof-perspective.cc
index 13b3937..76639d1 100644
--- a/src/persp/profperspective/nmv-prof-perspective.cc
+++ b/src/persp/profperspective/nmv-prof-perspective.cc
@@ -39,6 +39,7 @@
#include "uicommon/nmv-proc-list-dialog.h"
#include <list>
+#include <cerrno>
#include <glib/gi18n.h>
#include <gtkmm/widget.h>
@@ -77,6 +78,7 @@ class ProfPerspective : public IProfPerspective {
std::map<UString, int> symbol_to_pagenum_map;
Glib::RefPtr<Gtk::ActionGroup> default_action_group;
+ Glib::RefPtr<Gtk::ActionGroup> record_action_group;
Glib::RefPtr<Gtk::ActionGroup> recording_action_group;
Gtk::Notebook body;
IWorkbench *workbench;
@@ -122,6 +124,7 @@ public:
void attach_to_process (unsigned a_pid);
IProcMgr* process_manager ();
+ void on_save_as_action ();
void on_system_wide_record_action ();
void on_preferences_action ();
void on_attach_to_process_action ();
@@ -447,6 +450,7 @@ ProfPerspective::on_record_done_signal (const UString &a_report_path)
profiler ()->report (a_report_path);
recording_action_group->set_sensitive (false);
+ record_action_group->set_sensitive (true);
NEMIVER_CATCH
}
@@ -512,6 +516,19 @@ ProfPerspective::init_actions ()
}
};
+ static ui_utils::ActionEntry s_record_action_entries [] = {
+ {
+ "SaveReportAsAction",
+ Gtk::Stock::SAVE_AS,
+ _("Save As..."),
+ _("Save the report"),
+ sigc::mem_fun (*this, &ProfPerspective::on_save_as_action),
+ ui_utils::ActionEntry::DEFAULT,
+ "",
+ false
+ }
+ };
+
static ui_utils::ActionEntry s_recording_action_entries [] = {
{
"StopProfilingMenuItemAction",
@@ -529,6 +546,10 @@ ProfPerspective::init_actions ()
Gtk::ActionGroup::create ("profiler-default-action-group");
default_action_group->set_sensitive (true);
+ record_action_group =
+ Gtk::ActionGroup::create ("profiler-record-action-group");
+ record_action_group->set_sensitive (false);
+
recording_action_group =
Gtk::ActionGroup::create ("profiler-recording-action-group");
recording_action_group->set_sensitive (false);
@@ -536,12 +557,18 @@ ProfPerspective::init_actions ()
int num_default_actions =
sizeof (s_default_action_entries) / sizeof (ui_utils::ActionEntry);
+ int num_record_actions =
+ sizeof (s_record_action_entries) / sizeof (ui_utils::ActionEntry);
+
int num_recording_actions =
sizeof (s_recording_action_entries) / sizeof (ui_utils::ActionEntry);
ui_utils::add_action_entries_to_action_group
(s_default_action_entries, num_default_actions, default_action_group);
+ ui_utils::add_action_entries_to_action_group
+ (s_record_action_entries, num_record_actions, record_action_group);
+
ui_utils::add_action_entries_to_action_group (s_recording_action_entries,
num_recording_actions,
recording_action_group);
@@ -549,6 +576,7 @@ ProfPerspective::init_actions ()
Glib::RefPtr<Gtk::UIManager> uimanager = get_workbench ().get_ui_manager ();
THROW_IF_FAIL (uimanager);
uimanager->insert_action_group (default_action_group);
+ uimanager->insert_action_group (record_action_group);
uimanager->insert_action_group (recording_action_group);
}
@@ -753,6 +781,33 @@ ProfPerspective::on_load_report_file_action ()
}
void
+ProfPerspective::on_save_as_action ()
+{
+ NEMIVER_TRY;
+
+ Gtk::FileChooserDialog dialog ("Save Report As...",
+ Gtk::FILE_CHOOSER_ACTION_SAVE);
+ dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK);
+
+ if (dialog.run()) {
+
+ Glib::RefPtr<Gio::File> dest =
+ Gio::File::create_for_path (dialog.get_filename());
+ THROW_IF_FAIL (dest);
+
+ THROW_IF_FAIL (profiler ());
+ Glib::RefPtr<Gio::File> src =
+ Gio::File::create_for_path (profiler ()->report_filepath ());
+ THROW_IF_FAIL (src);
+
+ src->copy (dest, Gio::FILE_COPY_OVERWRITE);
+ }
+
+ NEMIVER_CATCH;
+}
+
+void
ProfPerspective::on_preferences_action ()
{
NEMIVER_TRY;
diff --git a/src/profengine/nmv-i-profiler.h b/src/profengine/nmv-i-profiler.h
index e5e384a..147899c 100644
--- a/src/profengine/nmv-i-profiler.h
+++ b/src/profengine/nmv-i-profiler.h
@@ -79,6 +79,8 @@ public:
virtual void report (const UString &a_data_file) = 0;
+ virtual const UString& report_filepath () const = 0;
+
virtual void system_wide_record (const RecordOptions &a_options) = 0;
virtual void record (const UString &a_program_path,
diff --git a/src/profengine/nmv-perf-engine.cc b/src/profengine/nmv-perf-engine.cc
index 333a821..4f66f11 100644
--- a/src/profengine/nmv-perf-engine.cc
+++ b/src/profengine/nmv-perf-engine.cc
@@ -407,6 +407,13 @@ PerfEngine::do_init (IConfMgrSafePtr a_conf_mgr)
m_priv->conf_manager = a_conf_mgr;
}
+const UString&
+PerfEngine::report_filepath () const
+{
+ THROW_IF_FAIL (m_priv);
+ return m_priv->record_filepath;
+}
+
void
PerfEngine::attach_to_pid (int a_pid, const RecordOptions &a_options)
{
diff --git a/src/profengine/nmv-perf-engine.h b/src/profengine/nmv-perf-engine.h
index 56eff6f..70e6971 100644
--- a/src/profengine/nmv-perf-engine.h
+++ b/src/profengine/nmv-perf-engine.h
@@ -52,6 +52,7 @@ public:
void system_wide_record (const RecordOptions &a_options);
void stop_recording ();
void annotate_symbol (const UString &a_symbol_name);
+ const UString& report_filepath () const;
void do_init (IConfMgrSafePtr a_conf_mgr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]