List view callback

pcr <[email protected]> Fri, 26 Jul 2019 20:33:50 -0600
Newsgroups gmane.editors.abiword.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------F7EE80C659D16FA5CD42CDFC
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit

I am having difficulty calling a routine when a row in my list view is 
clicked.  My example code is attached.  I get a compile error saying: 
  error: ‘m_Columns’ does not name a type; did you mean ‘ModelColumns’?
   m_Columns.signal_listview_row_activated().connect( sigc::mem_fun(*this,
   ^~~~~~~~~
   ModelColumns

But ModelColumns does not work either.  Any help is appreciated greatly!


--------------F7EE80C659D16FA5CD42CDFC
Content-Type: text/x-c++src;
 name="test.cc"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="test.cc"

//compile me with:  g++ -g -Wall -o test test.cc `(pkg-config --cflags --libs gtkmm-3.0)`

#include <gtkmm.h>
#include <iostream>


class ExampleWindow : public Gtk::Window
{
public:
  ExampleWindow();
  virtual ~ExampleWindow();



protected:
  //Signal handlers:????????
  void on_listview_row_activated();// this is not being called, why???

  //Tree model columns:
  class ModelColumns : public Gtk::TreeModel::ColumnRecord
  {
  public:

    ModelColumns()
    { add(m_col_id); add(m_col_name);}

    Gtk::TreeModelColumn<unsigned int> m_col_id;
    Gtk::TreeModelColumn<Glib::ustring> m_col_name;
   
  };

  ModelColumns m_Columns;

 //Conection from signal to callback ????
	m_Columns.signal_listview_row_activated().connect( sigc::mem_fun(*this,
 	&ExampleWindow::on_listview_row_activated));

  //Child widgets:
  Gtk::Box m_VBox;

  Gtk::ScrolledWindow m_ScrolledWindow;
  Gtk::TreeView m_TreeView;
  Glib::RefPtr<Gtk::ListStore> m_refTreeModel;

 

 };


ExampleWindow::ExampleWindow()
: m_VBox(Gtk::ORIENTATION_VERTICAL)
{
  set_title("Gtk::TreeView simplified with callback");
  set_border_width(5);
  set_default_size(400, 200);

  add(m_VBox);

  //Add the TreeView, inside a ScrolledWindow, with the button underneath:
  m_ScrolledWindow.add(m_TreeView);

  //Only show the scrollbars when they are necessary:
  m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);

  m_VBox.pack_start(m_ScrolledWindow);
 

  //Create the Tree model:
  m_refTreeModel = Gtk::ListStore::create(m_Columns);
  m_TreeView.set_model(m_refTreeModel);

  //Fill the TreeView's model
  Gtk::TreeModel::Row row = *(m_refTreeModel->append());
  row[m_Columns.m_col_id] = 1;
  row[m_Columns.m_col_name] = "Billy Bob";
  
  //Add the TreeView's view columns:
  //This number will be shown with the default numeric formatting.
  m_TreeView.append_column("ID", m_Columns.m_col_id);
  m_TreeView.append_column("Name", m_Columns.m_col_name);

 
  show_all_children();
}

ExampleWindow::~ExampleWindow()
{
}

void ExampleWindow::on_listview_row_activated()
{
	//Why is this not being called when the row is clicked?????
	std::cout << "row gtkmm-3.0 activated" << std::endl;
}


int main(int argc, char *argv[])
{
	auto app = Gtk::Application::create(argc,argv, "org.pcrt.example");
	ExampleWindow window;
	return app->run(window);
}


--------------F7EE80C659D16FA5CD42CDFC--
-----------------------------------------------
To unsubscribe from this list, send a message to
[email protected] with the word
unsubscribe in the message body.