GTK treeview: click to DnD (not edit), specialize per column
This commit is contained in:
parent
ae321721cf
commit
6725e8b661
|
@ -76,10 +76,6 @@ RegionListBase::RegionListBase ()
|
|||
_display.set_fixed_height_mode (true);
|
||||
_display.set_reorderable (false);
|
||||
|
||||
/* Try to prevent single mouse presses from initiating edits.
|
||||
* This relies on a hack in gtktreeview.c:gtk_treeview_button_press() */
|
||||
_display.set_data ("mouse-edits-require-mod1", (gpointer)0x1);
|
||||
|
||||
_model = TreeStore::create (_columns);
|
||||
_model->set_sort_column (0, SORT_ASCENDING);
|
||||
|
||||
|
@ -115,7 +111,7 @@ RegionListBase::RegionListBase ()
|
|||
}
|
||||
|
||||
void
|
||||
RegionListBase::setup_col (TreeViewColumn* col, int sort_idx, Gtk::AlignmentEnum al, const char* label, const char* tooltip)
|
||||
RegionListBase::setup_col (TreeViewColumn* col, int sort_idx, Gtk::AlignmentEnum al, const char* label, const char* tooltip, bool require_mod_to_edit)
|
||||
{
|
||||
/* add the label */
|
||||
Gtk::Label* l = manage (new Label (label));
|
||||
|
@ -135,6 +131,11 @@ RegionListBase::setup_col (TreeViewColumn* col, int sort_idx, Gtk::AlignmentEnum
|
|||
if (renderer) {
|
||||
renderer->property_xalign () = (al == ALIGN_END ? 1.0 : (al == ALIGN_START ? 0.0 : 0.5));
|
||||
}
|
||||
if (require_mod_to_edit) {
|
||||
/* Try to prevent single mouse presses from initiating edits.
|
||||
* This relies on a hack in gtktreeview.c:gtk_treeview_button_press() */
|
||||
col->set_data ("mouse-edits-require-mod1", (gpointer)0x1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -149,7 +150,7 @@ void
|
|||
RegionListBase::add_name_column ()
|
||||
{
|
||||
TreeViewColumn* tvc = append_col (_columns.name, 120);
|
||||
setup_col (tvc, 0, ALIGN_START, _("Name"), ("Region name"));
|
||||
setup_col (tvc, 0, ALIGN_START, _("Name"), ("Region name"), true);
|
||||
|
||||
tvc->set_resizable (true);
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ protected:
|
|||
return append_col (col, w);
|
||||
}
|
||||
|
||||
void setup_col (Gtk::TreeViewColumn*, int, Gtk::AlignmentEnum, const char*, const char*);
|
||||
void setup_col (Gtk::TreeViewColumn*, int, Gtk::AlignmentEnum, const char*, const char*, bool require_mod_to_edit = false);
|
||||
void setup_toggle (Gtk::TreeViewColumn*, sigc::slot<void, std::string>);
|
||||
|
||||
void freeze_tree_model ();
|
||||
|
|
|
@ -99,10 +99,6 @@ RouteListBase::RouteListBase ()
|
|||
_display.set_rules_hint (true);
|
||||
_display.set_size_request (100, -1);
|
||||
|
||||
/* Try to prevent single mouse presses from initiating edits.
|
||||
* This relies on a hack in gtktreeview.c:gtk_treeview_button_press() */
|
||||
_display.set_data ("mouse-edits-require-mod1", (gpointer)0x1);
|
||||
|
||||
_scroller.add (_display);
|
||||
_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
|
||||
|
||||
|
@ -133,12 +129,17 @@ RouteListBase::~RouteListBase ()
|
|||
}
|
||||
|
||||
void
|
||||
RouteListBase::setup_col (Gtk::TreeViewColumn* tvc, const char* label, const char* tooltip)
|
||||
RouteListBase::setup_col (Gtk::TreeViewColumn* tvc, const char* label, const char* tooltip, bool require_mod_to_edit)
|
||||
{
|
||||
Gtk::Label* l = manage (new Label (label));
|
||||
set_tooltip (*l, tooltip);
|
||||
tvc->set_widget (*l);
|
||||
l->show ();
|
||||
if (require_mod_to_edit) {
|
||||
/* Try to prevent single mouse presses from initiating edits.
|
||||
* This relies on a hack in gtktreeview.c:gtk_treeview_button_press() */
|
||||
tvc->set_data ("mouse-edits-require-mod1", (gpointer)0x1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -146,7 +147,7 @@ RouteListBase::add_name_column ()
|
|||
{
|
||||
Gtk::TreeViewColumn* tvc = manage (new Gtk::TreeViewColumn ("", _columns.text));
|
||||
|
||||
setup_col (tvc, _("Name"), ("Track/Bus name"));
|
||||
setup_col (tvc, _("Name"), ("Track/Bus name"), true);
|
||||
|
||||
CellRendererText* cell = dynamic_cast<CellRendererText*> (tvc->get_first_cell ());
|
||||
cell->signal_editing_started ().connect (sigc::mem_fun (*this, &RouteListBase::name_edit_started));
|
||||
|
|
|
@ -64,7 +64,7 @@ protected:
|
|||
void append_col_mute ();
|
||||
void append_col_solo ();
|
||||
|
||||
void setup_col (Gtk::TreeViewColumn*, const char*, const char*);
|
||||
void setup_col (Gtk::TreeViewColumn*, const char*, const char*, bool require_mod_to_edit = false);
|
||||
|
||||
template <class T, class U>
|
||||
Gtk::TreeViewColumn* append_toggle (Gtk::TreeModelColumn<T> const& col_state, Gtk::TreeModelColumn<U> const& col_viz, sigc::slot<void, std::string> cb)
|
||||
|
|
Loading…
Reference in New Issue
Block a user