- Done some more experimental work on the tree widget, indeed I hoped gtk were a more developer-friendly toolkit than it is...
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@843 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
69c8341384
commit
97d6f574af
|
@ -294,6 +294,7 @@ sgpemv2_SOURCES = \
|
|||
src/gui_builder.cc \
|
||||
src/main.cc \
|
||||
src/parse_opts.cc \
|
||||
src/schedulables_tree_widget.cc \
|
||||
src/schedulables_widget.cc \
|
||||
src/text_simulation.cc
|
||||
|
||||
|
@ -303,6 +304,7 @@ noinst_HEADERS += \
|
|||
src/gui_builder.hh \
|
||||
src/main.hh \
|
||||
src/parse_opts.hh \
|
||||
src/schedulables_tree_widget.hh \
|
||||
src/schedulables_widget.hh \
|
||||
src/text_simulation.hh
|
||||
|
||||
|
|
|
@ -19,17 +19,23 @@
|
|||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "schedulables_tree_widget.hh"
|
||||
#include <iostream>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
using namespace sgpem;
|
||||
using namespace Gtk;
|
||||
using namespace Glib;
|
||||
using Gnome::Glade::Xml;
|
||||
|
||||
SchedulablesTreeWidget::SchedulablesTreeWidget()
|
||||
SchedulablesTreeWidget::SchedulablesTreeWidget() :
|
||||
_add_process_dialog_glade(Xml::create(GLADEDIR "/add-process-dialog.glade"))
|
||||
{
|
||||
_columns.add(_column);
|
||||
_model = TreeStore::create(_columns);
|
||||
|
||||
set_model(_model);
|
||||
|
||||
/** JUST A BIT OF DATA FOR TESTING **/
|
||||
|
||||
Gtk::TreeModel::Row row1 = *(_model->append());
|
||||
row1[_column] = ustring("ciccio");
|
||||
|
@ -38,9 +44,53 @@ SchedulablesTreeWidget::SchedulablesTreeWidget()
|
|||
row2[_column] = ustring("pippo");
|
||||
|
||||
append_column("schedulables", _column);
|
||||
|
||||
/** POPUP MENU **/
|
||||
|
||||
_action_group = Gtk::ActionGroup::create();
|
||||
|
||||
// _action_group->add( Gtk::Action::create("ContextMenu", "Schedulables") );
|
||||
// _action_group->add( Gtk::Action::create("Add Process", Gtk::Stock::NEW),
|
||||
// sigc::mem_fun(*this, &SchedulablesTreeWidget::on_action_file_new) );
|
||||
_action_group->add( Gtk::Action::create("AddProcess", "Add Process"),
|
||||
sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_add_process) );
|
||||
//_action_group->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
|
||||
// sigc::mem_fun(*this, &SchedulablesTreeWidget::on_action_file_quit) );
|
||||
|
||||
_UIManager = Gtk::UIManager::create();
|
||||
_UIManager->insert_action_group(_action_group);
|
||||
|
||||
Glib::ustring ui_info =
|
||||
"<ui>"
|
||||
" <popup name='PopupMenu'>"
|
||||
// " <menuitem action='ContextMenu'/>"
|
||||
" <menuitem action='AddProcess'/>"
|
||||
" </popup>"
|
||||
"</ui>";
|
||||
|
||||
_UIManager->add_ui_from_string(ui_info);
|
||||
_menu = dynamic_cast<Gtk::Menu*>(_UIManager->get_widget("/PopupMenu"));
|
||||
|
||||
/** DIALOGS **/
|
||||
_add_process_dialog_glade->get_widget("AddProcessDialog", _add_process_dialog);
|
||||
//FIXME why do I need to call this? Is it reasonable?
|
||||
_add_process_dialog->hide();
|
||||
|
||||
set_headers_visible(false);
|
||||
}
|
||||
|
||||
bool SchedulablesTreeWidget::on_button_press_event(GdkEventButton* event)
|
||||
{
|
||||
TreeView::on_button_press_event(event);
|
||||
|
||||
if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) )
|
||||
{
|
||||
_menu->popup(event->button, event->time);
|
||||
return true; //It has been handled.
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
SchedulablesTreeWidget::~SchedulablesTreeWidget()
|
||||
{}
|
||||
|
@ -49,3 +99,18 @@ void
|
|||
SchedulablesTreeWidget::update(const History& history)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
SchedulablesTreeWidget::_on_add_process()
|
||||
{
|
||||
switch(_add_process_dialog->run())
|
||||
{
|
||||
case RESPONSE_OK:
|
||||
std::cout << "added the process ;-)\n";
|
||||
break;
|
||||
default:
|
||||
std::cout << "operation cancelled ;-)\n";
|
||||
}
|
||||
|
||||
_add_process_dialog->hide();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
|
||||
#include <gtkmm/treeview.h>
|
||||
#include <gtkmm/treestore.h>
|
||||
#include <gtkmm/menu.h>
|
||||
#include <gtkmm/uimanager.h>
|
||||
#include <gtkmm/actiongroup.h>
|
||||
#include <gtkmm/dialog.h>
|
||||
#include <libglademm/xml.h>
|
||||
|
||||
#include "backend/history_observer.hh"
|
||||
|
||||
|
@ -41,11 +46,20 @@ namespace sgpem
|
|||
virtual ~SchedulablesTreeWidget();
|
||||
|
||||
virtual void update(const History& history);
|
||||
|
||||
bool on_button_press_event(GdkEventButton* event);
|
||||
|
||||
private:
|
||||
void _on_add_process();
|
||||
|
||||
Glib::RefPtr<Gtk::TreeStore> _model;
|
||||
Gtk::TreeModelColumnRecord _columns;
|
||||
Gtk::TreeModelColumn<Glib::ustring> _column;
|
||||
Glib::RefPtr<Gtk::ActionGroup> _action_group;
|
||||
Glib::RefPtr<Gtk::UIManager> _UIManager;
|
||||
Gtk::Menu* _menu;
|
||||
Glib::RefPtr<Gnome::Glade::Xml> _add_process_dialog_glade;
|
||||
Gtk::Dialog* _add_process_dialog;
|
||||
};
|
||||
|
||||
} //~ namespace sgpem
|
||||
|
|
Loading…
Reference in New Issue