1 |
/* |
/* |
2 |
Copyright (c) 2014,2015 Christian Schoenebeck |
Copyright (c) 2014 - 2017 Christian Schoenebeck |
3 |
|
|
4 |
This file is part of "gigedit" and released under the terms of the |
This file is part of "gigedit" and released under the terms of the |
5 |
GNU General Public License version 2. |
GNU General Public License version 2. |
13 |
Glib::ustring note_str(int note); |
Glib::ustring note_str(int note); |
14 |
|
|
15 |
ReferencesView::ReferencesView(Gtk::Window& parent) : |
ReferencesView::ReferencesView(Gtk::Window& parent) : |
16 |
Gtk::Dialog("", parent, true), m_sample(NULL), |
ManagedDialog("", parent, true), m_sample(NULL), |
17 |
m_closeButton(Gtk::Stock::CLOSE), m_descriptionLabel() |
#if HAS_GTKMM_STOCK |
18 |
|
m_closeButton(Gtk::Stock::CLOSE), |
19 |
|
#else |
20 |
|
m_closeButton(_("_Close"), true), |
21 |
|
#endif |
22 |
|
m_descriptionLabel() |
23 |
{ |
{ |
24 |
set_title("Nothing selected"); |
set_title("Nothing selected"); |
25 |
|
|
26 |
|
#if !HAS_GTKMM_STOCK |
27 |
|
m_closeButton.set_icon_name("window-close"); |
28 |
|
#endif |
29 |
|
|
30 |
m_scrolledWindow.add(m_treeView); |
m_scrolledWindow.add(m_treeView); |
31 |
m_scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
m_scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
32 |
|
|
33 |
|
#if USE_GTKMM_BOX |
34 |
|
get_content_area()->pack_start(m_descriptionLabel, Gtk::PACK_SHRINK); |
35 |
|
get_content_area()->pack_start(m_scrolledWindow); |
36 |
|
get_content_area()->pack_start(m_summaryLabel, Gtk::PACK_SHRINK); |
37 |
|
get_content_area()->pack_start(m_buttonBox, Gtk::PACK_SHRINK); |
38 |
|
#else |
39 |
get_vbox()->pack_start(m_descriptionLabel, Gtk::PACK_SHRINK); |
get_vbox()->pack_start(m_descriptionLabel, Gtk::PACK_SHRINK); |
40 |
get_vbox()->pack_start(m_scrolledWindow); |
get_vbox()->pack_start(m_scrolledWindow); |
41 |
get_vbox()->pack_start(m_summaryLabel, Gtk::PACK_SHRINK); |
get_vbox()->pack_start(m_summaryLabel, Gtk::PACK_SHRINK); |
42 |
get_vbox()->pack_start(m_buttonBox, Gtk::PACK_SHRINK); |
get_vbox()->pack_start(m_buttonBox, Gtk::PACK_SHRINK); |
43 |
|
#endif |
44 |
|
|
45 |
#if GTKMM_MAJOR_VERSION >= 3 |
#if GTKMM_MAJOR_VERSION >= 3 |
46 |
m_descriptionLabel.set_line_wrap(); |
m_descriptionLabel.set_line_wrap(); |
61 |
m_treeView.append_column(_("References"), m_columns.m_col_refcount); |
m_treeView.append_column(_("References"), m_columns.m_col_refcount); |
62 |
m_treeView.set_headers_visible(true); |
m_treeView.set_headers_visible(true); |
63 |
m_treeView.get_selection()->set_mode(Gtk::SELECTION_SINGLE); |
m_treeView.get_selection()->set_mode(Gtk::SELECTION_SINGLE); |
64 |
m_treeView.get_selection()->signal_changed().connect( |
m_treeView.signal_row_activated().connect( |
65 |
sigc::mem_fun(*this, &ReferencesView::onSelectionChanged) |
sigc::mem_fun(*this, &ReferencesView::onSelectionChanged) |
66 |
); |
); |
67 |
|
|
68 |
m_buttonBox.set_layout(Gtk::BUTTONBOX_END); |
m_buttonBox.set_layout(Gtk::BUTTONBOX_END); |
69 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 22) |
70 |
|
m_buttonBox.set_margin(5); |
71 |
|
#else |
72 |
m_buttonBox.set_border_width(5); |
m_buttonBox.set_border_width(5); |
73 |
|
#endif |
74 |
m_buttonBox.pack_start(m_closeButton, Gtk::PACK_SHRINK); |
m_buttonBox.pack_start(m_closeButton, Gtk::PACK_SHRINK); |
75 |
|
|
76 |
m_closeButton.signal_clicked().connect( |
m_closeButton.signal_clicked().connect( |
77 |
sigc::mem_fun(*this, &ReferencesView::hide) |
sigc::mem_fun(*this, &ReferencesView::hide) |
78 |
); |
); |
79 |
|
|
80 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
81 |
show_all_children(); |
show_all_children(); |
82 |
|
#endif |
83 |
} |
} |
84 |
|
|
85 |
void ReferencesView::setSample(gig::Sample* sample) { |
void ReferencesView::setSample(gig::Sample* sample) { |
152 |
m_treeView.expand_all(); |
m_treeView.expand_all(); |
153 |
} |
} |
154 |
|
|
155 |
void ReferencesView::onSelectionChanged() { |
void ReferencesView::onSelectionChanged(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column) { |
156 |
if (!m_sample) return; |
if (!m_sample) return; |
157 |
|
|
158 |
Glib::RefPtr<Gtk::TreeSelection> sel = m_treeView.get_selection(); |
Gtk::TreeModel::iterator it = m_refTreeModel->get_iter(path); |
|
Gtk::TreeModel::iterator it = sel->get_selected(); |
|
|
Gtk::TreeModel::Row row = *it; |
|
159 |
if (!it) return; |
if (!it) return; |
160 |
|
|
161 |
|
Gtk::TreeModel::Row row = *it; |
162 |
|
|
163 |
gig::Instrument* pInstrument = row[m_columns.m_col_instr]; |
gig::Instrument* pInstrument = row[m_columns.m_col_instr]; |
164 |
gig::Region* pRegion = row[m_columns.m_col_region]; |
gig::Region* pRegion = row[m_columns.m_col_region]; |
165 |
gig::DimensionRegion* pDimRgn = NULL; |
gig::DimensionRegion* pDimRgn = NULL; |