[Glade-users] gtk and STL
- From: shatri_h at hotmail.com (hussein alshatri)
- Subject: [Glade-users] gtk and STL
- Date: Fri, 28 Sep 2007 15:16:47 +0000
Hi all
I am making a list in Glade2. using gtk. it has just three signals (adding to, erase from, get select)
the problem that my application is written in C++ using STL. so I want to call the function of glade with
std::string variables and and also return std::string.
Here is the code...
class AUCompList : public AUCompList_glade
{
private:
struct Columns : public Gtk::TreeModelColumnRecord
{
Gtk::TreeModelColumn<std::string> column1;
Gtk::TreeModelColumn<std::string> name;
Columns() { add(column1);add(name); }
};
Columns columns;
Gtk::CellRendererText* cell_renderer_text;
Gtk::TreeViewColumn* name_column;
Gtk::TreeRow row;
public:
AUCompList(GlademmData *gmm_data); //: AUCompList_glade(gmm_data)
~AUCompList();
Glib::RefPtr<Gtk::ListStore> treestore;
void AddRow( std::string peer );
void RemoveRow( std::string peer );
std::string selected_peer();
};
AUCompList::AUCompList(GlademmData *gmm_data): AUCompList_glade(gmm_data)
{
treestore = Gtk::ListStore::create( columns );
set_model( treestore );
append_column("Peer Name", columns.column1);
name_column = get_column(0);
Gtk::CellRenderer* cell_renderer = name_column->get_first_cell_renderer();
cell_renderer_text = dynamic_cast<Gtk::CellRendererText*>(cell_renderer);
}
void AUCompList::AddRow( std::string peer )
{
row = *(treestore->append());
//row[columns.name] = "red";
//name_column->add_attribute(cell_renderer_text->property_background(), columns.name);
row[columns.column1] = peer;
}
void AUCompList::RemoveRow( std::string peer )
{
row = *(treestore->erase(peer));
}
std::string AUCompList::selected_peer()
{
std::string str;
get_selection()->get_selected()->get_value(columns.column1, str);
return str;
}
Thank you in advance
Hussein
_________________________________________________________________
Get the new Windows Live Messenger!
http://get.live.com/messenger/overview
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20070928/2a09de29/attachment.html
[
Date Prev][
Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]