diff options
author | Tim Moore <timoore@redhat.com> | 2009-05-25 18:12:41 +0200 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-07-28 10:15:14 +0200 |
commit | f7cfc39c07d0cf872559f9716643491b8d79de75 (patch) | |
tree | f155a848e8f818ece81d27b0b31fb698a7b9179e /grapher | |
parent | 0f262fd10d337db0ec435d840b541d629879ce9f (diff) | |
download | systemtap-steved-f7cfc39c07d0cf872559f9716643491b8d79de75.tar.gz systemtap-steved-f7cfc39c07d0cf872559f9716643491b8d79de75.tar.xz systemtap-steved-f7cfc39c07d0cf872559f9716643491b8d79de75.zip |
Incorporate grapher widget in real application
* grapher/grapher.cxx (GrapherWindow): New class.
(main): Instantiate GrapherWindow.
Diffstat (limited to 'grapher')
-rw-r--r-- | grapher/grapher.cxx | 89 |
1 files changed, 78 insertions, 11 deletions
diff --git a/grapher/grapher.cxx b/grapher/grapher.cxx index 4f9ccae8..b7292cfd 100644 --- a/grapher/grapher.cxx +++ b/grapher/grapher.cxx @@ -1,40 +1,107 @@ #include "GraphWidget.hxx" #include "StapParser.hxx" +#include <cerrno> #include <cmath> +#include <cstdio> +#include <iostream> #include <sstream> #include <string> #include <map> +#include <gtkmm.h> +#include <gtkmm/stock.h> #include <gtkmm/main.h> #include <gtkmm/window.h> #include <unistd.h> #include <poll.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/wait.h> using namespace systemtap; +class GrapherWindow : public Gtk::Window +{ +public: + GrapherWindow(); + virtual ~GrapherWindow() {} + Gtk::VBox m_Box; + GraphWidget w; +protected: + virtual void on_menu_file_quit(); + // menu support + Glib::RefPtr<Gtk::UIManager> m_refUIManager; + Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup; + +}; + +GrapherWindow::GrapherWindow() +{ + set_title("systemtap grapher"); + add(m_Box); + w.setExtents(0.0, 1.0, 5.0, 0.0); + w.setLineWidth(2); + + + + //Create actions for menus and toolbars: + m_refActionGroup = Gtk::ActionGroup::create(); + //File menu: + m_refActionGroup->add(Gtk::Action::create("FileMenu", "File")); + m_refActionGroup->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), + sigc::mem_fun(*this, &GrapherWindow::on_menu_file_quit)); + m_refUIManager = Gtk::UIManager::create(); + m_refUIManager->insert_action_group(m_refActionGroup); + + add_accel_group(m_refUIManager->get_accel_group()); + //Layout the actions in a menubar and toolbar: + Glib::ustring ui_info = + "<ui>" + " <menubar name='MenuBar'>" + " <menu action='FileMenu'>" + " <menuitem action='FileQuit'/>" + " </menu>" + " </menubar>" + "</ui>"; + try + { + m_refUIManager->add_ui_from_string(ui_info); + } + catch(const Glib::Error& ex) + { + std::cerr << "building menus failed: " << ex.what(); + } + Gtk::Widget* pMenubar = m_refUIManager->get_widget("/MenuBar"); + if(pMenubar) + m_Box.pack_start(*pMenubar, Gtk::PACK_SHRINK); + m_Box.pack_start(w, Gtk::PACK_EXPAND_WIDGET); + w.show(); + + show_all_children(); + +} +void GrapherWindow::on_menu_file_quit() +{ + hide(); +} + int main(int argc, char** argv) { - Gtk::Main app(argc, argv); + Gtk::Main app(argc, argv); - Gtk::Window win; + GrapherWindow win; - win.set_title("Grapher"); - win.set_default_size(600, 200); + win.set_title("Grapher"); + win.set_default_size(600, 200); - GraphWidget w; - - w.setExtents(0.0, 1.0, 5.0, 0.0); - w.setLineWidth(2); + StapParser stapParser(win, win.w); StapParser stapParser(win, w); Glib::signal_io().connect(sigc::mem_fun(stapParser, &StapParser::ioCallback), 0, Glib::IO_IN); - win.add(w); - w.show(); - Gtk::Main::run(win); return 0; |