6 #include <boost/filesystem.hpp> 
    7 #include <boost/property_tree/xml_parser.hpp> 
    8 #include <boost/property_tree/ptree.hpp> 
    9 #include <boost/foreach.hpp> 
   12 #define ROOT_PATH @ROOT_PATH@ 
   16 using namespace boost;
 
   17 using namespace boost::property_tree;
 
   25             set_title(
"Package interpreter");
 
   26             set_default_size(1100,800);
 
   33             ref_tree_model = Gtk::ListStore::create(columns);
 
   36             tree_view.set_model(ref_tree_model);
 
   39             Gtk::TreeModel::Row row;
 
   40             for(uint i=0;i<packages.size();i++)
 
   42                 row = *(ref_tree_model->append());
 
   44                 row[columns.col_package] = packages[i].name;
 
   45                 row[columns.col_author] = packages[i].author;
 
   47                 string maintainer_plus_email = packages[i].maintainer + 
" (" + packages[i].maintainer_email + 
")";
 
   48                 row[columns.col_maintainer] = maintainer_plus_email;
 
   49                 row[columns.col_licence] = packages[i].license;
 
   53             tree_view.append_column(
"Package", columns.col_package);
 
   54             tree_view.append_column(
"Author", columns.col_author);
 
   55             tree_view.append_column(
"Maintainer", columns.col_maintainer);
 
   56             tree_view.append_column(
"License", columns.col_licence);
 
   60             tree_view.set_reorderable();
 
   61             tree_view.set_enable_search();
 
   65             scrolled_window.add(tree_view);
 
   80             boost::filesystem::path 
path;
 
  110             for(uint i=0;i<paths.size();i++)
 
  111                 interpreterFile(paths[i]);
 
  124             if(!fb.open(path.string().c_str(),std::ios::in))
 
  126                 cout<<
"Cannot open file: "<<path.string()<<endl;
 
  130             std::istream is(&fb);
 
  133             using boost::property_tree::ptree;
 
  140             BOOST_FOREACH(ptree::value_type 
const& v, pt.get_child(
"package") )
 
  142                 if( v.first == 
"name" )
 
  143                     package.
name = v.second.get_value<
string>();
 
  145                 if( v.first == 
"maintainer" )
 
  147                     package.
maintainer = v.second.get_value<
string>();
 
  149                     const ptree & attributes = v.second.get_child(
"<xmlattr>", empty_ptree());
 
  150                     BOOST_FOREACH(
const ptree::value_type &va, attributes)
 
  151                         if(va.first == 
"email")
 
  155                 if( v.first == 
"author" )
 
  156                     package.
author = v.second.get_value<
string>();
 
  158                 if( v.first == 
"license" )
 
  159                     package.
license = v.second.get_value<
string>();
 
  161                 if(package.
name.empty())
 
  162                     package.
name = 
"NO NAME";
 
  167                 if(package.
author.empty())
 
  168                     package.
author = 
"NO AUTHOR";
 
  171                     package.
license = 
"NO LICENSE";
 
  174             packages.push_back(package);
 
  182             boost::filesystem::recursive_directory_iterator dir(top_path), end;
 
  185                 if (dir->path().filename() == 
"package.xml")
 
  186                     paths.push_back(dir->path());
 
  192         vector<boost::filesystem::path> 
paths;
 
  203     Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, 
"org.gtkmm.example");
 
  207     return app->run(gui);
 
int main(int argc, char **argv)
 
Gtk::TreeModelColumn< Glib::ustring > col_author
 
Gtk::TreeModelColumn< Glib::ustring > col_package
 
const ptree & empty_ptree()
 
void interpreterFile(boost::filesystem::path path)
 
Gtk::TreeModelColumn< Glib::ustring > col_licence
 
boost::filesystem::path path
 
virtual ~InterpreterGUI()
 
void getPaths(boost::filesystem::path top_path)
 
Glib::RefPtr< Gtk::ListStore > ref_tree_model
 
vector< PackageXML > packages
 
Gtk::ScrolledWindow scrolled_window
 
vector< boost::filesystem::path > paths
 
Gtk::TreeModelColumn< Glib::ustring > col_maintainer