- Migrate Glade files to GtkBuilder XML

- Update code to adapt to GtkBuilder


git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1324 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
tchernobog 2007-12-05 10:44:09 +00:00
parent 82f97ffce9
commit a40c636ba7
33 changed files with 2136 additions and 2226 deletions

View file

@ -38,19 +38,18 @@
using namespace sgpem;
using namespace Gtk;
using namespace Glib;
using Gnome::Glade::Xml;
using std::vector;
AddRequestDialog::AddRequestDialog(BaseObjectType* cobject, const RefPtr<Xml>& glade) :
Dialog(cobject), _glade(glade)
AddRequestDialog::AddRequestDialog(BaseObjectType* cobject, const RefPtr<Builder>& ui) :
Dialog(cobject), _ui(ui)
{
_glade->get_widget("SubRequests.View", _list);
_glade->get_widget("Add", _add_button);
_glade->get_widget("Remove", _remove_button);
_glade->get_widget("Resource.Combo", _resource_combo);
_glade->get_widget("OK.Button", _ok_button);
_glade->get_widget("Instant.Spin", _instant_spin);
_glade->get_widget("Duration.Spin", _duration_spin);
_ui->get_widget("SubRequests.View", _list);
_ui->get_widget("Add", _add_button);
_ui->get_widget("Remove", _remove_button);
_ui->get_widget("Resource.Combo", _resource_combo);
_ui->get_widget("OK.Button", _ok_button);
_ui->get_widget("Instant.Spin", _instant_spin);
_ui->get_widget("Duration.Spin", _duration_spin);
/** ATTACH SIGNAL HANDLERS FOR BUTTONS **/

View file

@ -33,11 +33,11 @@ namespace sgpem
#include <gtkmm/dialog.h>
#include <gtkmm/combobox.h>
#include <gtkmm/spinbutton.h>
#include <libglademm/xml.h>
#include <gtkmm/builder.h>
namespace sgpem
{
/** \brief A dialog derived from add-request-dialog.glade
/** \brief A dialog derived from add-request-dialog.ui
*
* Manages the list of subrequests, ensures only "nonempty" requests
* are created, and supports also editing.
@ -45,9 +45,9 @@ namespace sgpem
class AddRequestDialog : public Gtk::Dialog
{
public:
/** \brief Constructor required by libglademm
/** \brief Constructor required by gtkbuilder
*/
AddRequestDialog(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& glade);
AddRequestDialog(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& ui);
/** \brief Attemts to show the dialog, and constructs a new request
* if response is OK
@ -103,7 +103,7 @@ namespace sgpem
*/
void _on_combo_selection_changed();
Glib::RefPtr<Gnome::Glade::Xml> _glade;
Glib::RefPtr<Gtk::Builder> _ui;
Gtk::TreeView* _list;
Glib::RefPtr<Gtk::ListStore> _list_model;
Gtk::TreeModelColumnRecord _list_columns;

View file

@ -37,10 +37,9 @@
#endif
using namespace sgpem;
using Gnome::Glade::Xml;
PreferencesEditor::PreferencesEditor(const std::string& gladefile)
: _refXml(Xml::create(gladefile)),
PreferencesEditor::PreferencesEditor(const std::string& uifile)
: _refXml(Gtk::Builder::create_from_file(uifile)),
preferences_dialog(NULL),
plugins_dirs_treeview(NULL), plugins_treeview(NULL),
policies_dirs_treeview(NULL), policies_treeview(NULL),

View file

@ -25,7 +25,7 @@
#include <sgpemv2/global_preferences.hh>
#include <libglademm/xml.h>
#include <gtkmm/builder.h>
#include <gtkmm/liststore.h>
#include <gtkmm/dialog.h>
#include <gtkmm/treeview.h>
@ -41,7 +41,7 @@ namespace sgpem
public:
explicit PreferencesEditor(const std::string& gladefile = GLADEDIR "/configure-dialog.glade");
explicit PreferencesEditor(const std::string& uifile = UIDIR "/configure-dialog.ui");
void
@ -73,7 +73,7 @@ namespace sgpem
void
update_plugins();
Glib::RefPtr<Gnome::Glade::Xml> _refXml;
Glib::RefPtr<Gtk::Builder> _refXml;
Gtk::Dialog* preferences_dialog;
Gtk::TreeView* plugins_dirs_treeview;

View file

@ -71,8 +71,6 @@
#include <iostream>
using namespace sgpem;
using Gnome::Glade::Xml;
void
GuiBuilder::on_edit_preferences_activate()
@ -83,17 +81,15 @@ GuiBuilder::on_edit_preferences_activate()
void
GuiBuilder::on_simulation_jump_to_clicked()
{
using Gnome::Glade::Xml;
// JumpTo spinbox
Gtk::SpinButton* jump_to_spin;
_refXml->get_widget("BottomHBox.JumpToSpin", jump_to_spin);
int target_instant = jump_to_spin->get_value_as_int();
assert(target_instant >= 0);
Glib::RefPtr<Xml> jump_to_dialog_glade = Xml::create(GLADEDIR "/jump-to-dialog.glade");
Glib::RefPtr<Gtk::Builder> jump_to_dialog_ui = Gtk::Builder::create_from_file(UIDIR "/jump-to-dialog.ui");
JumpToDialog* jump_to_dialog = NULL;
jump_to_dialog_glade->get_widget_derived("JumpToDialog", jump_to_dialog);
jump_to_dialog_ui->get_widget_derived("JumpToDialog", jump_to_dialog);
jump_to_dialog->set_transient_for(get_initial_window());
jump_to_dialog->set_target_instant(target_instant);
@ -226,7 +222,8 @@ GuiBuilder::on_file_open_activate()
}
if(!msg.empty())
{
Gtk::Statusbar* sbar = _refXml->get_widget("MainStatusBar", sbar);
Gtk::Statusbar* sbar;
_refXml->get_widget("MainStatusBar", sbar);
sbar->push(msg);
}
}
@ -274,7 +271,8 @@ GuiBuilder::on_file_save_activate()
if(!msg.empty())
{
Gtk::Statusbar* sbar = _refXml->get_widget("MainStatusBar", sbar);
Gtk::Statusbar* sbar;
_refXml->get_widget("MainStatusBar", sbar);
sbar->push(msg);
}
}
@ -351,7 +349,8 @@ GuiBuilder::on_file_saveas_activate()
if(!msg.empty())
{
Gtk::Statusbar* sbar = _refXml->get_widget("MainStatusBar", sbar);
Gtk::Statusbar* sbar;
_refXml->get_widget("MainStatusBar", sbar);
sbar->push(msg);
}
}
@ -529,6 +528,7 @@ GuiBuilder::on_selected_resource_policy(ResourcePolicy* pol)
sbar->push(_("Selected resource policy ") + pol->get_name());
}
void
GuiBuilder::on_toggle_simulation_mode()
{
@ -572,8 +572,8 @@ GuiBuilder::set_filename(const std::string& filename)
}
GuiBuilder::GuiBuilder(const std::string& gladefile)
: _refXml(Xml::create(gladefile)), _controller(Simulation::get_instance(), _refXml),
GuiBuilder::GuiBuilder(const std::string& uifile)
: _refXml(Gtk::Builder::create_from_file(uifile)), _controller(Simulation::get_instance(), _refXml),
_holt_container(Simulation::get_instance()),
_show_threads(true)
{
@ -674,7 +674,7 @@ GuiBuilder::GuiBuilder(const std::string& gladefile)
_refXml->get_widget("AboutDialog", about_dialog);
help_about->signal_activate().connect(sigc::mem_fun(*about_dialog, &Window::show));
about_dialog->set_wrap_license(true);
about_dialog->set_logo(Gdk::Pixbuf::create_from_file(GLADEDIR "/logo.png"));
about_dialog->set_logo(Gdk::Pixbuf::create_from_file(UIDIR "/logo.png"));
// Insert the schedulables TreeView custom widget

View file

@ -33,7 +33,7 @@
#include <gtkmm/menu.h>
#include <gtkmm/window.h>
#include <libglademm/xml.h>
#include <gtkmm/builder.h>
#include <string>
@ -46,7 +46,7 @@ namespace sgpem
class GuiBuilder
{
public:
GuiBuilder(const std::string& gladefile = GLADEDIR "/main-window.glade");
GuiBuilder(const std::string& uifile = UIDIR "/main-window.ui");
~GuiBuilder();
Gtk::Window& get_initial_window() const;
@ -76,7 +76,7 @@ namespace sgpem
void populate_with_resource_policies(Gtk::Menu& menu);
private:
Glib::RefPtr<Gnome::Glade::Xml> _refXml;
Glib::RefPtr<Gtk::Builder> _refXml;
SimulationController _controller;
// Used to store the loaded snapshot filename, when !empty

View file

@ -38,15 +38,14 @@
using namespace sgpem;
using namespace Gtk;
using namespace Glib;
using Gnome::Glade::Xml;
JumpToDialog::JumpToDialog(BaseObjectType* cobject, const RefPtr<Xml>& glade) :
JumpToDialog::JumpToDialog(BaseObjectType* cobject, const RefPtr<Builder>& ui) :
Dialog(cobject), _target_instant(0)
{
Button* stop_button;
glade->get_widget("Button.Stop", stop_button);
glade->get_widget("ProgressBar", _progress);
ui->get_widget("Button.Stop", stop_button);
ui->get_widget("ProgressBar", _progress);
// Attach signal handlers
stop_button->signal_clicked().connect(sigc::mem_fun(*this, &JumpToDialog::_on_stop));

View file

@ -27,14 +27,14 @@
#include <gtkmm/dialog.h>
#include <gtkmm/progressbar.h>
#include <libglademm/xml.h>
#include <gtkmm/builder.h>
namespace sgpem
{
class JumpToDialog : public Gtk::Dialog, public SimulationObserver
{
public:
JumpToDialog(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& glade);
JumpToDialog(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& ui);
unsigned int set_target_instant(unsigned int new_target = 0);
unsigned int get_target_instant() const;

View file

@ -44,7 +44,6 @@
using namespace sgpem;
using namespace Gtk;
using namespace Glib;
using Gnome::Glade::Xml;
PropertyProxy_Base
ResourcesWidget::CellRendererTextMarkup::_property_renderable()
@ -52,9 +51,9 @@ ResourcesWidget::CellRendererTextMarkup::_property_renderable()
return Glib::PropertyProxy_Base(this, "markup");
}
ResourcesWidget::ResourcesWidget(BaseObjectType* cobject, const RefPtr<Xml>& glade) :
ResourcesWidget::ResourcesWidget(BaseObjectType* cobject, const RefPtr<Builder>& ui) :
TreeView(cobject),
_add_resource_dialog_glade(Xml::create(GLADEDIR "/add-resource-dialog.glade"))
_add_resource_dialog_ui(Builder::create_from_file(UIDIR "/add-resource-dialog.ui"))
{
_columns.add(_key_column);
_columns.add(_main_column);
@ -68,7 +67,7 @@ ResourcesWidget::ResourcesWidget(BaseObjectType* cobject, const RefPtr<Xml>& gla
tvc->set_cell_data_func(_cell_renderer, sigc::mem_fun(*this, &ResourcesWidget::_on_cell_name_data));
/** DIALOGS **/
_add_resource_dialog_glade->get_widget("AddResourceDialog", _add_resource_dialog);
_add_resource_dialog_ui->get_widget("AddResourceDialog", _add_resource_dialog);
set_headers_visible(false);
@ -195,8 +194,8 @@ ResourcesWidget::add_edit_resource(bool adding)
Resource* resource = NULL;
_add_resource_dialog_glade->get_widget("Name.Entry", name_entry);
_add_resource_dialog_glade->get_widget("Places.Spin", places_spin);
_add_resource_dialog_ui->get_widget("Name.Entry", name_entry);
_add_resource_dialog_ui->get_widget("Places.Spin", places_spin);
if(adding)
{

View file

@ -34,7 +34,7 @@ namespace sgpem
#include <gtkmm/uimanager.h>
#include <gtkmm/actiongroup.h>
#include <gtkmm/dialog.h>
#include <libglademm/xml.h>
#include <gtkmm/builder.h>
#include <sgpemv2/history_observer.hh>
@ -53,9 +53,9 @@ namespace sgpem
class ResourcesWidget : public Gtk::TreeView, public HistoryObserver
{
public:
/** \brief Constructor required by libglademm
/** \brief Constructor required by gtkbuilder
*/
ResourcesWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& glade);
ResourcesWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& ui);
/// \brief Standard virtual destructor.
///
@ -133,7 +133,7 @@ namespace sgpem
Gtk::TreeModelColumn<void*> _handles_column;
Glib::RefPtr<Gtk::UIManager> _UIManager;
Glib::RefPtr<Gnome::Glade::Xml> _add_resource_dialog_glade;
Glib::RefPtr<Gtk::Builder> _add_resource_dialog_ui;
Gtk::Dialog* _add_resource_dialog;
CellRendererTextMarkup _cell_renderer;

View file

@ -40,12 +40,11 @@
#include <gtk/gtk.h>
#include <gtkmm/entry.h>
#include <gtkmm/spinbutton.h>
#include <gtkmm/builder.h>
using namespace sgpem;
using namespace Gtk;
using namespace Glib;
using Gnome::Glade::Xml;
PropertyProxy_Base
SchedulablesTreeWidget::CellRendererTextMarkup::_property_renderable()
@ -355,20 +354,20 @@ SchedulablesTreeWidget::add_edit_process(bool adding)
/** This is ugly, I know, we should be using derived widgets, but I also believe we
* have little time, and I'm not going to waste too much of it on the frontend */
RefPtr<Xml> glade(Xml::create(GLADEDIR "/add-process-dialog.glade"));
RefPtr<Builder> ui(Builder::create_from_file(UIDIR "/add-process-dialog.ui"));
Dialog* add_process_dialog;
glade->get_widget("AddProcessDialog", add_process_dialog);
ui->get_widget("AddProcessDialog", add_process_dialog);
Entry* name_entry;
SpinButton* arrival_time_spin;
SpinButton* duration_spin;
SpinButton* base_priority_spin;
glade->get_widget("Name.Entry", name_entry);
glade->get_widget("ArrivalTime.Spin", arrival_time_spin);
glade->get_widget("Duration.Spin", duration_spin);
glade->get_widget("BasePriority.Spin", base_priority_spin);
ui->get_widget("Name.Entry", name_entry);
ui->get_widget("ArrivalTime.Spin", arrival_time_spin);
ui->get_widget("Duration.Spin", duration_spin);
ui->get_widget("BasePriority.Spin", base_priority_spin);
Process* selection = NULL;
@ -430,20 +429,20 @@ SchedulablesTreeWidget::add_edit_thread(bool adding)
/** This is ugly, I know, we should be using derived widgets, but I also believe we
* have little time, and I'm not going to waste too much of it on the frontend */
RefPtr<Xml> glade(Xml::create(GLADEDIR "/add-thread-dialog.glade"));
RefPtr<Builder> ui(Builder::create_from_file(UIDIR "/add-thread-dialog.ui"));
Dialog* add_thread_dialog;
glade->get_widget("AddThreadDialog", add_thread_dialog);
ui->get_widget("AddThreadDialog", add_thread_dialog);
Entry* name_entry;
SpinButton* cpu_time_spin;
SpinButton* arrival_time_spin;
SpinButton* base_priority_spin;
glade->get_widget("Name.Entry", name_entry);
glade->get_widget("CpuTime.Spin", cpu_time_spin);
glade->get_widget("ArrivalTime.Spin", arrival_time_spin);
glade->get_widget("BasePriority.Spin", base_priority_spin);
ui->get_widget("Name.Entry", name_entry);
ui->get_widget("CpuTime.Spin", cpu_time_spin);
ui->get_widget("ArrivalTime.Spin", arrival_time_spin);
ui->get_widget("BasePriority.Spin", base_priority_spin);
Thread* t = NULL;
@ -490,12 +489,12 @@ SchedulablesTreeWidget::add_edit_thread(bool adding)
void
SchedulablesTreeWidget::_on_add_request()
{
RefPtr<Xml> glade(Xml::create(GLADEDIR "/add-request-dialog.glade"));
RefPtr<Builder> ui(Builder::create_from_file(UIDIR "/add-request-dialog.ui"));
AddRequestDialog* add_request_dialog;
// NOTE This is *not* reflective programming! AddRequestDialog is the name of
// the base widget in the glade file.
glade->get_widget_derived("AddRequestDialog", add_request_dialog);
// the base widget in the xml ui file.
ui->get_widget_derived("AddRequestDialog", add_request_dialog);
Thread* t = get_selected<Thread>();
assert(t != NULL);
@ -508,12 +507,12 @@ SchedulablesTreeWidget::_on_edit_request()
{
using std::vector;
RefPtr<Xml> glade(Xml::create(GLADEDIR "/add-request-dialog.glade"));
RefPtr<Builder> ui(Builder::create_from_file(UIDIR "/add-request-dialog.ui"));
AddRequestDialog* add_request_dialog;
// NOTE This is *not* reflective programming! AddRequestDialog is the name of
// the base widget in the glade file.
glade->get_widget_derived("AddRequestDialog", add_request_dialog);
// the base widget in the xml ui file.
ui->get_widget_derived("AddRequestDialog", add_request_dialog);
Request* r = get_selected<Request>();
assert(r != NULL);

View file

@ -38,7 +38,6 @@ namespace sgpem
#include <gtkmm/uimanager.h>
#include <gtkmm/actiongroup.h>
#include <gtkmm/dialog.h>
#include <libglademm/xml.h>
#include <sgpemv2/history_observer.hh>
#include <sgpemv2/schedulable.hh>

View file

@ -44,10 +44,9 @@
#endif
using namespace sgpem;
using Gnome::Glade::Xml;
SimulationController::SimulationController(Simulation& simulation, Glib::RefPtr<Xml> refXml)
SimulationController::SimulationController(Simulation& simulation, Glib::RefPtr<Gtk::Builder> refXml)
: _sim(simulation), _break_requested(false)
{
using namespace Gtk;

View file

@ -27,7 +27,7 @@
#include <gtkmm/toolbutton.h>
#include <gtkmm/menuitem.h>
#include <libglademm/xml.h>
#include <gtkmm/builder.h>
namespace sgpem
{
@ -41,7 +41,7 @@ namespace sgpem
class SimulationController : public SimulationObserver
{
public:
SimulationController(Simulation& simulation, Glib::RefPtr<Gnome::Glade::Xml> main_window);
SimulationController(Simulation& simulation, Glib::RefPtr<Gtk::Builder> main_window);
virtual ~SimulationController();
/** \brief Update sensitivities of toolbar buttons and menu items

View file

@ -25,12 +25,11 @@
using namespace Gtk;
using Gnome::Glade::Xml;
using namespace sgpem;
using namespace std;
StatisticsContainerWindow::StatisticsContainerWindow(const std::string& gladefile)
: _refXml(Xml::create(gladefile))
StatisticsContainerWindow::StatisticsContainerWindow(const std::string& uifile)
: _refXml(Builder::create_from_file(uifile))
{
_refXml->get_widget("StatisticsWindow", _main_win);
// This just sets the title of our new window.

View file

@ -32,7 +32,7 @@
#include <gtkmm/window.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/scrollbar.h>
#include <libglademm/xml.h>
#include <gtkmm/builder.h>
#include <cassert>
#include <iostream>
@ -45,7 +45,7 @@ namespace sgpem
class StatisticsContainerWindow
{
public:
explicit StatisticsContainerWindow(const std::string& gladefile = GLADEDIR "/statistics-window.glade");
explicit StatisticsContainerWindow(const std::string& uifile = UIDIR "/statistics-window.ui");
virtual ~StatisticsContainerWindow();
void make_child(Gtk::Window&);
@ -54,7 +54,7 @@ namespace sgpem
Gtk::Window* get_main_window();
protected:
Glib::RefPtr<Gnome::Glade::Xml> _refXml;
Glib::RefPtr<Gtk::Builder> _refXml;
Gtk::Window* _main_win;
TabularSchedulableStatisticsWidget* _tab_sched;
TabularSimulationStatisticsWidget* _tab_sim;