here we go:

TreeModelColumn<bool> active;

is the toggle which shows up right but is not editable.

cheers
Chris


#ifndef PROFILE_SELECTOR_H_
#define PROFILE_SELECTOR_H_

.h file:
========
#include <gtkmm.h>

#include "Profile_DB.h"


using namespace Gtk;


//Tree model columns:
class ModelColumns : public TreeModel::ColumnRecord
{
public:
        TreeModelColumn<int> index;
        TreeModelColumn<bool> active;
        TreeModelColumn<Glib::ustring> apn;
        TreeModelColumn<Glib::ustring> userid;
        TreeModelColumn<Glib::ustring> password;
        TreeModelColumn<Glib::ustring> dns1;
        TreeModelColumn<Glib::ustring> dns2;

        ModelColumns() { add (index); add (active); add (apn);
                add (userid); add (password); add (dns1); add (dns2);
        }
};


class Profile_Selector : public Dialog
{
public:
        Profile_Selector (Window* win);
        virtual ~Profile_Selector();

        void insert_row (profile_t& prof);

private:
        Glib::RefPtr<Gtk::ListStore> profile_tree_model;
        ModelColumns model_colums;
};


#endif /*PROFILE_SELECTOR_H_*/


.c file:
========

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <glibmm/i18n.h>
#include "Profile_Selector.h"
#include "iostream"


Profile_Selector::Profile_Selector (Window* win)

        : Gtk::Dialog (APPLICATION_NAME, *win, true, false)

{
        set_position (Gtk::WIN_POS_CENTER);
        set_border_width (10);
        set_default_size (480, 240);
        get_vbox()->set_spacing (10);
        
        Frame* sub1_frame1 = manage (new Frame (_("Custom Profiles")));
        ScrolledWindow* sub1_scrollw1 = manage (new ScrolledWindow ());
        TreeView* sub1_treeview1 = manage (new TreeView ());

        get_vbox()->add (*sub1_frame1);
        sub1_frame1->add (*sub1_scrollw1);
        sub1_scrollw1->add (*sub1_treeview1);
        
        //Create the Tree model:
        profile_tree_model = Gtk::ListStore::create (model_colums);

        sub1_treeview1->append_column_editable("Active", model_colums.active);
        sub1_treeview1->append_column_editable("APN", model_colums.apn);
        sub1_treeview1->append_column_editable("User ID", model_colums.userid);
        sub1_treeview1->append_column_editable("Password", 
model_colums.password);
        sub1_treeview1->append_column_editable("DNS 1", model_colums.dns1);
        sub1_treeview1->append_column_editable("DNS 2", model_colums.dns2);
        
        sub1_scrollw1->set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC);
        sub1_scrollw1->set_border_width (10);
        sub1_treeview1->set_model (profile_tree_model);
        
        Button* butedit = add_button (Stock::EDIT, 1);
        Button* butok = add_button (Stock::OK, RESPONSE_OK);

        set_default_response (Gtk::RESPONSE_OK);
        butok->grab_focus ();
                
        show_all_children();
}


Profile_Selector::~Profile_Selector()
{
}


// puts date in the model
void Profile_Selector::insert_row (profile_t& prof)
{
        TreeModel::Row row = *(profile_tree_model->append());

        row[model_colums.index] =    prof.index;
        row[model_colums.active] =   prof.active;
        row[model_colums.apn] =      prof.apn;
        row[model_colums.userid] =   prof.user;
        row[model_colums.password] = prof.password;
        row[model_colums.dns1] =     prof.dns1;
        row[model_colums.dns2] =     prof.dns2;
}       



Am Samstag 27 Oktober 2007 17:00:27 schrieb Murray Cumming:
> On Sat, 2007-10-27 at 16:44 +0200, Milosz Derezynski wrote:
> > The togglebutton is just an indicator (going with MVC stuff here);
> > that means that you need to set up a callback on:
> >
> > http://gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1CellRende
> >rerToggle.html#0332ce9231ca8d0694f7f1e1b2350bf4
> >
> > and in that callback, which gives you a string tree path, do whatever
> > should be done when it's clicked, and change the state of the
> > togglebutton (just negating the state of model_columns.active for that
> > row, and using property_active() of the Renderer to reflect the new
> > state).
>
> No, append_column_editable() takes care of this, just as it does for
> numeric and text columns. You only need to connect signal handlers if
> you want to use the regular append_column() methods and have more
> control.
>
> It works in the examples/book/treeview/editable_cells/ example, so I
> guess we need to see Christopher's simple example of it not working to
> investigate more.

_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to