diff options
author | Tim Moore <timoore@redhat.com> | 2009-09-30 19:02:42 +0200 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-09-30 20:45:09 +0200 |
commit | 90b64e1e89a33317d6008e10fe2c106a0dc34c7a (patch) | |
tree | 74bb42bdce674fce19bda066d7e7f4bb4f1ce4d7 | |
parent | 4cba1a1a2cb6d5fc03f0f89f480c6761974938af (diff) | |
download | systemtap-steved-90b64e1e89a33317d6008e10fe2c106a0dc34c7a.tar.gz systemtap-steved-90b64e1e89a33317d6008e10fe2c106a0dc34c7a.tar.xz systemtap-steved-90b64e1e89a33317d6008e10fe2c106a0dc34c7a.zip |
dialog for choosing stap script and providing arguments to stap and the script
* grapher/grapher.cxx (GraphicalStapLauncher): New class.
(GrapherWindow constructor): Bind actions for graphical launcher buttons
(GrapherWindow::setGraphicalLauncher): new method
(GrapherWindow::on_menu_script_start): new method
grapher/stap-start.glade, grapher/stap-start.gladep: new files
grapher/Makefile.am: install stap-start.glade
-rw-r--r-- | grapher/Makefile.am | 2 | ||||
-rw-r--r-- | grapher/Makefile.in | 4 | ||||
-rw-r--r-- | grapher/grapher.cxx | 93 | ||||
-rw-r--r-- | grapher/stap-start.glade | 248 | ||||
-rw-r--r-- | grapher/stap-start.gladep | 8 |
5 files changed, 348 insertions, 7 deletions
diff --git a/grapher/Makefile.am b/grapher/Makefile.am index 9fd817ec..7f6b56fd 100644 --- a/grapher/Makefile.am +++ b/grapher/Makefile.am @@ -5,5 +5,5 @@ stapgraph_CPPFLAGS = -DPKGDATADIR='"${pkgdatadir}"' stapgraph_CXXFLAGS = $(gtkmm_CFLAGS) -Wall -Werror stapgraph_SOURCES = grapher.cxx StapParser.cxx Graph.cxx GraphWidget.cxx CairoWidget.cxx stapgraph_LDADD = $(gtkmm_LIBS) -dist_pkgdata_DATA = graph-dialog.glade +dist_pkgdata_DATA = graph-dialog.glade stap-start.glade endif diff --git a/grapher/Makefile.in b/grapher/Makefile.in index 564dc95f..44dddf48 100644 --- a/grapher/Makefile.in +++ b/grapher/Makefile.in @@ -71,7 +71,7 @@ CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(stapgraph_SOURCES) DIST_SOURCES = $(am__stapgraph_SOURCES_DIST) -am__dist_pkgdata_DATA_DIST = graph-dialog.glade +am__dist_pkgdata_DATA_DIST = graph-dialog.glade stap-start.glade am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -219,7 +219,7 @@ top_srcdir = @top_srcdir@ @BUILD_GRAPHER_TRUE@stapgraph_CXXFLAGS = $(gtkmm_CFLAGS) -Wall -Werror @BUILD_GRAPHER_TRUE@stapgraph_SOURCES = grapher.cxx StapParser.cxx Graph.cxx GraphWidget.cxx CairoWidget.cxx @BUILD_GRAPHER_TRUE@stapgraph_LDADD = $(gtkmm_LIBS) -@BUILD_GRAPHER_TRUE@dist_pkgdata_DATA = graph-dialog.glade +@BUILD_GRAPHER_TRUE@dist_pkgdata_DATA = graph-dialog.glade stap-start.glade all: all-am .SUFFIXES: diff --git a/grapher/grapher.cxx b/grapher/grapher.cxx index 62a54aec..429d0537 100644 --- a/grapher/grapher.cxx +++ b/grapher/grapher.cxx @@ -15,6 +15,7 @@ #include <signal.h> #include <gtkmm.h> +#include <gtkmm/button.h> #include <gtkmm/stock.h> #include <gtkmm/main.h> #include <gtkmm/window.h> @@ -38,6 +39,7 @@ class ChildDeathReader public: struct Callback { + virtual ~Callback() {} virtual void childDied(int pid) {} }; ChildDeathReader() : sigfd(-1) {} @@ -61,6 +63,23 @@ private: int sigfd; }; +class StapLauncher; + +class GraphicalStapLauncher +{ +public: + GraphicalStapLauncher(StapLauncher* launcher); + bool runDialog(); + void onLaunch(); + void onLaunchCancel(); +private: + Glib::RefPtr<Gnome::Glade::Xml> _launchStapDialog; + Gtk::Window* _scriptWindow; + Gtk::FileChooserButton* _chooserButton; + Gtk::Entry* _stapArgEntry; + Gtk::Entry* _scriptArgEntry; + StapLauncher* _launcher; +}; class GrapherWindow : public Gtk::Window, public ChildDeathReader::Callback { @@ -71,12 +90,19 @@ public: Gtk::ScrolledWindow scrolled; GraphWidget w; void childDied(int pid); + void setGraphicalLauncher(GraphicalStapLauncher* launcher) + { + _graphicalLauncher = launcher; + } + GraphicalStapLauncher* getGraphicalLauncher() { return _graphicalLauncher; } protected: virtual void on_menu_file_quit(); + virtual void on_menu_script_start(); void addGraph(); // menu support Glib::RefPtr<Gtk::UIManager> m_refUIManager; Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup; + GraphicalStapLauncher* _graphicalLauncher; }; @@ -90,10 +116,14 @@ GrapherWindow::GrapherWindow() m_refActionGroup = Gtk::ActionGroup::create(); //File menu: m_refActionGroup->add(Gtk::Action::create("FileMenu", "File")); + m_refActionGroup->add(Gtk::Action::create("StartScript", "Start script"), + sigc::mem_fun(*this, + &GrapherWindow::on_menu_script_start)); m_refActionGroup->add(Gtk::Action::create("AddGraph", "Add graph"), sigc::mem_fun(*this, &GrapherWindow::addGraph)); m_refActionGroup->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT), - sigc::mem_fun(*this, &GrapherWindow::on_menu_file_quit)); + sigc::mem_fun(*this, + &GrapherWindow::on_menu_file_quit)); m_refUIManager = Gtk::UIManager::create(); m_refUIManager->insert_action_group(m_refActionGroup); @@ -103,7 +133,8 @@ GrapherWindow::GrapherWindow() "<ui>" " <menubar name='MenuBar'>" " <menu action='FileMenu'>" - " <menuitem action='AddGraph'/>" + " <menuitem action='StartScript'/>" + " <menuitem action='AddGraph'/>" " <menuitem action='FileQuit'/>" " </menu>" " </menubar>" @@ -126,11 +157,17 @@ GrapherWindow::GrapherWindow() show_all_children(); } + void GrapherWindow::on_menu_file_quit() { hide(); } +void GrapherWindow::on_menu_script_start() +{ + _graphicalLauncher->runDialog(); +} + void GrapherWindow::childDied(int pid) { hide(); @@ -276,7 +313,8 @@ int StapLauncher::launch() { string argString = "stap" + _stapArgs + " " + _script + " " + _scriptArgs; - execl("/bin/sh", "-c", argString.c_str(), static_cast<char*>(0)); + execl("/bin/sh", "sh", "-c", argString.c_str(), + static_cast<char*>(0)); } _exit(1); } @@ -329,7 +367,8 @@ int main(int argc, char** argv) StapParser stapParser(win, win.w); launcher.setStapParser(&stapParser); - + GraphicalStapLauncher graphicalLauncher(&launcher); + win.setGraphicalLauncher(&graphicalLauncher); if (argc > 1) { launcher.setArgv(argv + 1); @@ -353,3 +392,49 @@ void GrapherWindow::addGraph() w.addGraph(); } + +GraphicalStapLauncher::GraphicalStapLauncher(StapLauncher* launcher) + : _launcher(launcher) +{ + try + { + _launchStapDialog + = Gnome::Glade::Xml::create(PKGDATADIR "/stap-start.glade"); + _launchStapDialog->get_widget("window1", _scriptWindow); + _launchStapDialog->get_widget("scriptChooserButton", _chooserButton); + _launchStapDialog->get_widget("stapEntry", _stapArgEntry); + _launchStapDialog->get_widget("scriptEntry", _scriptArgEntry); + Gtk::Button* button = 0; + _launchStapDialog->get_widget("launchButton", button); + button->signal_clicked() + .connect(sigc::mem_fun(*this, &GraphicalStapLauncher::onLaunch), false); + _launchStapDialog->get_widget("cancelButton", button); + button->signal_clicked() + .connect(sigc::mem_fun(*this, &GraphicalStapLauncher::onLaunchCancel), + false); + } + catch (const Gnome::Glade::XmlError& ex ) + { + std::cerr << ex.what() << std::endl; + throw; + } +} + +bool GraphicalStapLauncher::runDialog() +{ + _scriptWindow->show(); + return true; +} + +void GraphicalStapLauncher::onLaunch() +{ + _launcher->setArgs(_stapArgEntry->get_text(), _chooserButton->get_filename(), + _scriptArgEntry->get_text()); + _scriptWindow->hide(); + _launcher->launch(); +} + +void GraphicalStapLauncher::onLaunchCancel() +{ + _scriptWindow->hide(); +} diff --git a/grapher/stap-start.glade b/grapher/stap-start.glade new file mode 100644 index 00000000..780c4bd0 --- /dev/null +++ b/grapher/stap-start.glade @@ -0,0 +1,248 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkWindow" id="window1"> + <property name="title" translatable="yes">start script</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + + <child> + <widget class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkHBox" id="hbox5"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="label" translatable="yes">script:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkFileChooserButton" id="scriptChooserButton"> + <property name="visible">True</property> + <property name="title" translatable="yes">Select A File</property> + <property name="action">GTK_FILE_CHOOSER_ACTION_OPEN</property> + <property name="local_only">True</property> + <property name="show_hidden">False</property> + <property name="do_overwrite_confirmation">False</property> + <property name="width_chars">-1</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox3"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">stap arguments:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="scriptEntry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="label" translatable="yes">script arguments:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkEntry" id="stapEntry"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">True</property> + <property name="visibility">True</property> + <property name="max_length">0</property> + <property name="text" translatable="yes"></property> + <property name="has_frame">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">False</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <placeholder/> + </child> + + <child> + <widget class="GtkButton" id="cancelButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkButton" id="launchButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-ok</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> diff --git a/grapher/stap-start.gladep b/grapher/stap-start.gladep new file mode 100644 index 00000000..315e63d1 --- /dev/null +++ b/grapher/stap-start.gladep @@ -0,0 +1,8 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd"> + +<glade-project> + <name>Grapher</name> + <program_name>grapher</program_name> + <gnome_support>FALSE</gnome_support> +</glade-project> |