[gtkmm-documentation] C++11: Use of auto.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] C++11: Use of auto.
- Date: Fri, 17 Mar 2017 15:36:05 +0000 (UTC)
commit 729fb5d1897eba31947a568eec3fe89ddebd4cdb
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Mar 17 16:25:47 2017 +0100
C++11: Use of auto.
examples/book/clipboard/ideal/examplewindow.cc | 6 ++--
examples/book/combobox/complex/examplewindow.cc | 10 ++++----
.../book/combobox/entry_complex/examplewindow.cc | 4 +-
examples/book/custom/custom_widget/mywidget.cc | 4 +-
examples/book/custom/custom_widget/mywidget2.cc | 4 +-
.../dialogs/filechooserdialog/examplewindow.cc | 2 +-
.../dialogs/fontchooserdialog/examplewindow.cc | 4 +-
examples/book/entry/completion/examplewindow.cc | 14 ++++++------
.../giomm/monitor_directory/monitor_directory.cc | 2 +-
examples/book/headerbar/examplewindow.cc | 4 +-
examples/book/iconview/examplewindow.cc | 10 ++++----
examples/book/listbox/examplewindow.cc | 2 +-
examples/book/listmodel/examplewindow.cc | 4 +-
examples/book/multithread/examplewindow.cc | 2 +-
examples/book/paned/messageslist.cc | 2 +-
examples/book/paned/messagetext.cc | 2 +-
examples/book/popover/examplewindow.cc | 2 +-
examples/book/printing/advanced/previewdialog.cc | 2 +-
.../book/printing/advanced/printformoperation.cc | 6 ++--
.../book/printing/simple/printformoperation.cc | 4 +-
examples/book/range_widgets/examplewindow.cc | 8 +++---
examples/book/revealer/examplewindow.cc | 4 +-
examples/book/timeout/timerexample.cc | 2 +-
examples/book/toolpalette/canvas.cc | 6 ++--
examples/book/toolpalette/examplewindow.cc | 22 ++++++++++----------
.../book/treeview/combo_renderer/examplewindow.cc | 6 ++--
.../book/treeview/drag_and_drop/examplewindow.cc | 4 +-
.../book/treeview/drag_and_drop/treemodel_dnd.cc | 2 +-
.../book/treeview/editable_cells/examplewindow.cc | 12 +++++-----
.../book/treeview/editable_cells/examplewindow.h | 2 +-
examples/book/treeview/filter/examplewindow.cc | 2 +-
.../book/treeview/filter_modify/examplewindow.cc | 4 +-
examples/book/treeview/list/examplewindow.cc | 2 +-
examples/book/treeview/modelsort/examplewindow.cc | 2 +-
examples/book/treeview/popup/treeview_withpopup.cc | 4 +-
examples/book/treeview/tree/examplewindow.cc | 8 +++---
.../others/cellrenderercustom/cellrendererlist.cc | 4 +-
.../others/cellrenderercustom/cellrendererpopup.cc | 6 ++--
.../cellrenderercustom/cellrenderertoggle.cc | 6 ++--
examples/others/cellrenderercustom/testpopup.cc | 4 +-
examples/others/window/wheelbarrow.cc | 2 +-
41 files changed, 101 insertions(+), 101 deletions(-)
---
diff --git a/examples/book/clipboard/ideal/examplewindow.cc b/examples/book/clipboard/ideal/examplewindow.cc
index 8c78377..5d706c2 100644
--- a/examples/book/clipboard/ideal/examplewindow.cc
+++ b/examples/book/clipboard/ideal/examplewindow.cc
@@ -128,7 +128,7 @@ void ExampleWindow::on_clipboard_get(Gtk::SelectionData& selection_data,
// info corresponds to the optional info parameter in Gtk::TargetEntry's
// constructor. We don't use that, so we use selection_data's target instead.
- const std::string target = selection_data.get_target();
+ const auto target = selection_data.get_target();
if(target == example_target_custom)
{
@@ -164,13 +164,13 @@ void ExampleWindow::on_clipboard_clear()
void ExampleWindow::on_clipboard_received(
const Gtk::SelectionData& selection_data)
{
- const std::string target = selection_data.get_target();
+ const auto target = selection_data.get_target();
//It should always be this, because that's what we asked for when calling
//request_contents().
if(target == example_target_custom)
{
- Glib::ustring clipboard_data = selection_data.get_data_as_string();
+ auto clipboard_data = selection_data.get_data_as_string();
//See comment in on_button_copy() about this silly clipboard format.
if(clipboard_data.size() >= 4)
diff --git a/examples/book/combobox/complex/examplewindow.cc b/examples/book/combobox/complex/examplewindow.cc
index 9d4fd7d..06ce985 100644
--- a/examples/book/combobox/complex/examplewindow.cc
+++ b/examples/book/combobox/complex/examplewindow.cc
@@ -27,14 +27,14 @@ ExampleWindow::ExampleWindow()
m_Combo.set_model(m_refTreeModel);
//Fill the ComboBox's Tree Model:
- Gtk::TreeModel::iterator iter = m_refTreeModel->append();
- Gtk::TreeModel::Row row = *iter;
+ auto iter = m_refTreeModel->append();
+ auto row = *iter;
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "Billy Bob";
row[m_Columns.m_col_extra] = "something";
m_Combo.set_active(iter);
/*
- Gtk::TreeModel::Row childrow = *(m_refTreeModel->append(row.children()));
+ auto childrow = *(m_refTreeModel->append(row.children()));
childrow[m_Columns.m_col_id] = 11;
childrow[m_Columns.m_col_name] = "Billy Bob Junior";
@@ -102,10 +102,10 @@ void ExampleWindow::on_cell_data_extra(const Gtk::TreeModel::const_iterator& ite
void ExampleWindow::on_combo_changed()
{
- Gtk::TreeModel::iterator iter = m_Combo.get_active();
+ const auto iter = m_Combo.get_active();
if(iter)
{
- Gtk::TreeModel::Row row = *iter;
+ const auto row = *iter;
if(row)
{
//Get the data for the selected row, using our knowledge of the tree
diff --git a/examples/book/combobox/entry_complex/examplewindow.cc
b/examples/book/combobox/entry_complex/examplewindow.cc
index cc298ed..2d03c25 100644
--- a/examples/book/combobox/entry_complex/examplewindow.cc
+++ b/examples/book/combobox/entry_complex/examplewindow.cc
@@ -28,11 +28,11 @@ ExampleWindow::ExampleWindow()
m_Combo.set_model(m_refTreeModel);
//Fill the ComboBox's Tree Model:
- Gtk::TreeModel::Row row = *(m_refTreeModel->append());
+ auto row = *(m_refTreeModel->append());
row[m_Columns.m_col_id] = "1";
row[m_Columns.m_col_name] = "Billy Bob";
/*
- Gtk::TreeModel::Row childrow = *(m_refTreeModel->append(row.children()));
+ auto childrow = *(m_refTreeModel->append(row.children()));
childrow[m_Columns.m_col_id] = 11;
childrow[m_Columns.m_col_name] = "Billy Bob Junior";
diff --git a/examples/book/custom/custom_widget/mywidget.cc b/examples/book/custom/custom_widget/mywidget.cc
index 7e9b659..05303b3 100644
--- a/examples/book/custom/custom_widget/mywidget.cc
+++ b/examples/book/custom/custom_widget/mywidget.cc
@@ -173,8 +173,8 @@ void MyWidget::on_unrealize()
void MyWidget::snapshot_vfunc(Gtk::Snapshot& snapshot)
{
- const Gtk::Allocation allocation = get_allocation();
- Gtk::Allocation clip = get_clip();
+ const auto allocation = get_allocation();
+ auto clip = get_clip();
clip.set_x(clip.get_x() - allocation.get_x());
clip.set_y(clip.get_y() - allocation.get_y());
const double scale_x = (double)clip.get_width() / m_scale;
diff --git a/examples/book/custom/custom_widget/mywidget2.cc b/examples/book/custom/custom_widget/mywidget2.cc
index 7f22fd1..7020335 100644
--- a/examples/book/custom/custom_widget/mywidget2.cc
+++ b/examples/book/custom/custom_widget/mywidget2.cc
@@ -172,8 +172,8 @@ void MyWidget2::on_unrealize()
bool MyWidget2::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
- const Gtk::Allocation allocation = get_allocation();
- Gtk::Allocation clip = get_clip();
+ const auto allocation = get_allocation();
+ auto clip = get_clip();
clip.set_x(clip.get_x() - allocation.get_x());
clip.set_y(clip.get_y() - allocation.get_y());
const double scale_x = (double)clip.get_width() / m_scale;
diff --git a/examples/book/dialogs/filechooserdialog/examplewindow.cc
b/examples/book/dialogs/filechooserdialog/examplewindow.cc
index bb7cb4f..38485cb 100644
--- a/examples/book/dialogs/filechooserdialog/examplewindow.cc
+++ b/examples/book/dialogs/filechooserdialog/examplewindow.cc
@@ -115,7 +115,7 @@ void ExampleWindow::on_button_file_clicked()
std::cout << "Open clicked." << std::endl;
//Notice that this is a std::string, not a Glib::ustring.
- std::string filename = dialog.get_filename();
+ auto filename = dialog.get_filename();
std::cout << "File selected: " << filename << std::endl;
break;
}
diff --git a/examples/book/dialogs/fontchooserdialog/examplewindow.cc
b/examples/book/dialogs/fontchooserdialog/examplewindow.cc
index 2bd644c..53b8b81 100644
--- a/examples/book/dialogs/fontchooserdialog/examplewindow.cc
+++ b/examples/book/dialogs/fontchooserdialog/examplewindow.cc
@@ -43,7 +43,7 @@ ExampleWindow::~ExampleWindow()
void ExampleWindow::on_font_button_font_set()
{
- Glib::ustring font_name = m_FontButton.get_font_name();
+ auto font_name = m_FontButton.get_font_name();
std::cout << "Font chosen: " << font_name << std::endl;
}
@@ -61,7 +61,7 @@ void ExampleWindow::on_button_dialog_clicked()
{
case Gtk::RESPONSE_OK:
{
- Glib::ustring font_name = dialog.get_font();
+ auto font_name = dialog.get_font();
std::cout << "Font chosen: " << font_name << std::endl;
m_FontButton.set_font_name(font_name);
break;
diff --git a/examples/book/entry/completion/examplewindow.cc b/examples/book/entry/completion/examplewindow.cc
index d528ab6..b1834f0 100644
--- a/examples/book/entry/completion/examplewindow.cc
+++ b/examples/book/entry/completion/examplewindow.cc
@@ -52,7 +52,7 @@ ExampleWindow::ExampleWindow()
//&ExampleWindow::on_completion_match) );
//Fill the TreeView's model
- Gtk::TreeModel::Row row = *(refCompletionModel->append());
+ auto row = *(refCompletionModel->append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "Alan Zebedee";
@@ -112,12 +112,12 @@ bool ExampleWindow::on_completion_match(const Glib::ustring& key, const
{
if(iter)
{
- Gtk::TreeModel::Row row = *iter;
+ const auto row = *iter;
- Glib::ustring::size_type key_length = key.size();
- Glib::ustring filter_string = row[m_Columns.m_col_name];
+ const auto key_length = key.size();
+ auto filter_string = row[m_Columns.m_col_name];
- Glib::ustring filter_string_start = filter_string.substr(0, key_length);
+ auto filter_string_start = filter_string.substr(0, key_length);
//The key is lower-case, even if the user input is not.
filter_string_start = filter_string_start.lowercase();
@@ -131,10 +131,10 @@ bool ExampleWindow::on_completion_match(const Glib::ustring& key, const
void ExampleWindow::on_completion_action_activated(int index)
{
- type_actions_map::iterator iter = m_CompletionActions.find(index);
+ auto iter = m_CompletionActions.find(index);
if(iter != m_CompletionActions.end()) //If it's in the map
{
- Glib::ustring title = iter->second;
+ auto title = iter->second;
std::cout << "Action selected: " << title << std::endl;
}
}
diff --git a/examples/book/giomm/monitor_directory/monitor_directory.cc
b/examples/book/giomm/monitor_directory/monitor_directory.cc
index 41d75f5..11bdf62 100644
--- a/examples/book/giomm/monitor_directory/monitor_directory.cc
+++ b/examples/book/giomm/monitor_directory/monitor_directory.cc
@@ -109,7 +109,7 @@ int main(int /* argc */, char** /* argv */)
Gio::init();
mainloop = Glib::MainLoop::create();
- std::string current_dir = Glib::get_current_dir();
+ auto current_dir = Glib::get_current_dir();
auto dir = Gio::File::create_for_path(current_dir);
auto monitor = dir->monitor_directory();
diff --git a/examples/book/headerbar/examplewindow.cc b/examples/book/headerbar/examplewindow.cc
index 02df517..3fa4ff6 100644
--- a/examples/book/headerbar/examplewindow.cc
+++ b/examples/book/headerbar/examplewindow.cc
@@ -72,7 +72,7 @@ void ExampleWindow::on_switch_active_changed()
void ExampleWindow::on_title_entry_activate()
{
- const Glib::ustring title = m_title_entry.get_text();
+ const auto title = m_title_entry.get_text();
if(!title.empty())
{
m_header_bar.set_title(title);
@@ -81,7 +81,7 @@ void ExampleWindow::on_title_entry_activate()
void ExampleWindow::on_subtitle_entry_activate()
{
- const Glib::ustring subtitle = m_subtitle_entry.get_text();
+ const auto subtitle = m_subtitle_entry.get_text();
m_header_bar.set_subtitle(subtitle);
}
diff --git a/examples/book/iconview/examplewindow.cc b/examples/book/iconview/examplewindow.cc
index 12baa30..7d3ca73 100644
--- a/examples/book/iconview/examplewindow.cc
+++ b/examples/book/iconview/examplewindow.cc
@@ -107,8 +107,8 @@ void ExampleWindow::on_button_quit()
void ExampleWindow::on_item_activated(const Gtk::TreeModel::Path& path)
{
- Gtk::TreeModel::iterator iter = m_refListModel->get_iter(path);
- Gtk::TreeModel::Row row = *iter;
+ auto iter = m_refListModel->get_iter(path);
+ auto row = *iter;
const std::string filename = row[m_Columns.m_col_filename];
const Glib::ustring description = row[m_Columns.m_col_description];
@@ -128,8 +128,8 @@ void ExampleWindow::on_selection_changed()
if(!selected.empty())
{
const Gtk::TreeModel::Path& path = *selected.begin();
- Gtk::TreeModel::iterator iter = m_refListModel->get_iter(path);
- Gtk::TreeModel::Row row = *iter;
+ auto iter = m_refListModel->get_iter(path);
+ auto row = *iter;
const std::string filename = row[m_Columns.m_col_filename];
const Glib::ustring description = row[m_Columns.m_col_description];
@@ -145,7 +145,7 @@ void ExampleWindow::on_selection_changed()
void ExampleWindow::add_entry(const std::string& filename,
const Glib::ustring& description )
{
- Gtk::TreeModel::Row row = *(m_refListModel->append());
+ auto row = *(m_refListModel->append());
row[m_Columns.m_col_filename] = filename;
row[m_Columns.m_col_description] = description;
diff --git a/examples/book/listbox/examplewindow.cc b/examples/book/listbox/examplewindow.cc
index 4e9c32a..0f7386d 100644
--- a/examples/book/listbox/examplewindow.cc
+++ b/examples/book/listbox/examplewindow.cc
@@ -73,7 +73,7 @@ ExampleWindow::ExampleWindow() :
m_ComboBox.signal_changed().connect(sigc::mem_fun(*this, &ExampleWindow::on_selection_mode_changed));
m_VBox1.pack_start(m_ComboBox, Gtk::PACK_SHRINK);
- const Gtk::SelectionMode mode = m_ListBox.get_selection_mode();
+ const auto mode = m_ListBox.get_selection_mode();
int index = 0;
for (std::size_t i = 0; i < G_N_ELEMENTS(selectionModes); ++i)
{
diff --git a/examples/book/listmodel/examplewindow.cc b/examples/book/listmodel/examplewindow.cc
index 952342e..85a8ba6 100644
--- a/examples/book/listmodel/examplewindow.cc
+++ b/examples/book/listmodel/examplewindow.cc
@@ -31,7 +31,7 @@ m_button_quit("_Quit", true)
for (int i = 0; i < 20; ++i)
{
- const Glib::ustring label = Glib::ustring::format("Item ", i);
+ const auto label = Glib::ustring::format("Item ", i);
m_store->append(MyObject::create(i, label));
}
@@ -111,7 +111,7 @@ void ExampleWindow::on_add_some()
{
const auto n_items = m_store->get_n_items();
const auto i = std::rand() % std::max(2*n_items, 4u);
- const Glib::ustring label = Glib::ustring::format("Added ", i);
+ const auto label = Glib::ustring::format("Added ", i);
m_store->insert_sorted(MyObject::create(i, label),
sigc::ptr_fun(&MyObject::compare));
}
diff --git a/examples/book/multithread/examplewindow.cc b/examples/book/multithread/examplewindow.cc
index 9e39734..9b50ed8 100644
--- a/examples/book/multithread/examplewindow.cc
+++ b/examples/book/multithread/examplewindow.cc
@@ -130,7 +130,7 @@ void ExampleWindow::update_widgets()
buffer->set_text(message_from_worker_thread);
// Scroll the last inserted line into view. That's somewhat complicated.
- Gtk::TextIter iter = buffer->end();
+ auto iter = buffer->end();
iter.set_line_offset(0); // Beginning of last line
auto mark = buffer->get_mark("last_line");
buffer->move_mark(mark, iter);
diff --git a/examples/book/paned/messageslist.cc b/examples/book/paned/messageslist.cc
index e07ff16..14a8d9b 100644
--- a/examples/book/paned/messageslist.cc
+++ b/examples/book/paned/messageslist.cc
@@ -35,7 +35,7 @@ MessagesList::MessagesList()
std::ostringstream text;
text << "message #" << i;
- Gtk::TreeModel::Row row = *(m_refListStore->append());
+ auto row = *(m_refListStore->append());
row[m_Columns.m_col_text] = text.str();
}
diff --git a/examples/book/paned/messagetext.cc b/examples/book/paned/messagetext.cc
index dd8b15d..e936c81 100644
--- a/examples/book/paned/messagetext.cc
+++ b/examples/book/paned/messagetext.cc
@@ -32,7 +32,7 @@ void MessageText::insert_text()
{
auto refTextBuffer = m_TextView.get_buffer();
- Gtk::TextBuffer::iterator iter = refTextBuffer->get_iter_at_offset(0);
+ auto iter = refTextBuffer->get_iter_at_offset(0);
refTextBuffer->insert(iter,
"From: pathfinder nasa gov\n"
"To: mom nasa gov\n"
diff --git a/examples/book/popover/examplewindow.cc b/examples/book/popover/examplewindow.cc
index ebd8226..66948b6 100644
--- a/examples/book/popover/examplewindow.cc
+++ b/examples/book/popover/examplewindow.cc
@@ -153,7 +153,7 @@ void ExampleWindow::on_day_selected()
gdk_window_coords_to_parent (current_event->button.window,
current_event->button.x, current_event->button.y,
¤t_event->button.x, ¤t_event->button.y);
- Gtk::Allocation allocation = m_calendar.get_allocation();
+ auto allocation = m_calendar.get_allocation();
rect.set_x(current_event->button.x - allocation.get_x());
rect.set_y(current_event->button.y - allocation.get_y());
rect.set_width(1);
diff --git a/examples/book/printing/advanced/previewdialog.cc
b/examples/book/printing/advanced/previewdialog.cc
index f95ebf9..22d2ffa 100644
--- a/examples/book/printing/advanced/previewdialog.cc
+++ b/examples/book/printing/advanced/previewdialog.cc
@@ -125,7 +125,7 @@ void PreviewDialog::on_popreview_got_page_size(
const Glib::RefPtr<Gtk::PrintContext>& print_ctx,
const Glib::RefPtr<Gtk::PageSetup>& page_setup)
{
- const Gtk::PaperSize paper_size = page_setup->get_paper_size();
+ const auto paper_size = page_setup->get_paper_size();
const double width = paper_size.get_width(Gtk::UNIT_INCH);
const double height = paper_size.get_height(Gtk::UNIT_INCH);
diff --git a/examples/book/printing/advanced/printformoperation.cc
b/examples/book/printing/advanced/printformoperation.cc
index e993bcc..9cf5fa6 100644
--- a/examples/book/printing/advanced/printformoperation.cc
+++ b/examples/book/printing/advanced/printformoperation.cc
@@ -120,7 +120,7 @@ void PrintFormOperation::on_draw_page(
cairo_ctx->set_source_rgb(0, 0, 0);
//Render Pango LayoutLines over the Cairo context:
- Pango::LayoutIter iter = m_refLayout->get_iter();
+ auto iter = m_refLayout->get_iter();
double start_pos = 0;
int line_index = 0;
@@ -130,7 +130,7 @@ void PrintFormOperation::on_draw_page(
if(line_index >= start_page_line)
{
auto layout_line = iter.get_line();
- Pango::Rectangle logical_rect = iter.get_line_logical_extents();
+ auto logical_rect = iter.get_line_logical_extents();
int baseline = iter.get_baseline();
if (line_index == start_page_line)
@@ -176,7 +176,7 @@ void PrintFormOperation::on_custom_widget_apply(Gtk::Widget*)
// on_create_custom_widget(). We don't need to use it, because we can use the
// child FontButton directly:
- Glib::ustring selected_font = m_FontButton.get_font_name();
+ auto selected_font = m_FontButton.get_font_name();
m_Font = selected_font;
}
diff --git a/examples/book/printing/simple/printformoperation.cc
b/examples/book/printing/simple/printformoperation.cc
index c6ee4f3..da3a954 100644
--- a/examples/book/printing/simple/printformoperation.cc
+++ b/examples/book/printing/simple/printformoperation.cc
@@ -112,7 +112,7 @@ void PrintFormOperation::on_draw_page(
cairo_ctx->set_source_rgb(0, 0, 0);
//Render Pango LayoutLines over the Cairo context:
- Pango::LayoutIter iter = m_refLayout->get_iter();
+ auto iter = m_refLayout->get_iter();
double start_pos = 0;
int line_index = 0;
@@ -122,7 +122,7 @@ void PrintFormOperation::on_draw_page(
if(line_index >= start_page_line)
{
auto layout_line = iter.get_line();
- Pango::Rectangle logical_rect = iter.get_line_logical_extents();
+ auto logical_rect = iter.get_line_logical_extents();
int baseline = iter.get_baseline();
if (line_index == start_page_line)
diff --git a/examples/book/range_widgets/examplewindow.cc b/examples/book/range_widgets/examplewindow.cc
index 4a946ed..c093615 100644
--- a/examples/book/range_widgets/examplewindow.cc
+++ b/examples/book/range_widgets/examplewindow.cc
@@ -91,7 +91,7 @@ ExampleWindow::ExampleWindow()
m_ComboBox_Position.pack_start(m_Columns.m_col_title);
//Fill the ComboBox's Tree Model:
- Gtk::TreeModel::Row row = *(m_refTreeModel->append());
+ auto row = *(m_refTreeModel->append());
row[m_Columns.m_col_position_type] = Gtk::POS_TOP;
row[m_Columns.m_col_title] = "Top";
row = *(m_refTreeModel->append());
@@ -152,15 +152,15 @@ void ExampleWindow::on_checkbutton_toggled()
void ExampleWindow::on_combo_position()
{
- Gtk::TreeModel::iterator iter = m_ComboBox_Position.get_active();
+ const auto iter = m_ComboBox_Position.get_active();
if(!iter)
return;
- Gtk::TreeModel::Row row = *iter;
+ const auto row = *iter;
if(!row)
return;
- const Gtk::PositionType postype = row[m_Columns.m_col_position_type];
+ const auto postype = row[m_Columns.m_col_position_type];
m_VScale.set_value_pos(postype);
m_HScale.set_value_pos(postype);
diff --git a/examples/book/revealer/examplewindow.cc b/examples/book/revealer/examplewindow.cc
index b6a79e0..c3be5db 100644
--- a/examples/book/revealer/examplewindow.cc
+++ b/examples/book/revealer/examplewindow.cc
@@ -78,7 +78,7 @@ void ExampleWindow::compose_transition_selector()
void ExampleWindow::on_switch_active_changed()
{
const bool reveal_child = m_switch.get_active();
- const Gtk::RevealerTransitionType transition_type = get_selected_transition_type();
+ const auto transition_type = get_selected_transition_type();
const guint transition_duration = m_transition_duration.get_value_as_int();
m_revealer.set_transition_type(transition_type);
@@ -88,7 +88,7 @@ void ExampleWindow::on_switch_active_changed()
Gtk::RevealerTransitionType ExampleWindow::get_selected_transition_type()
{
- Gtk::RevealerTransitionType transition_type = Gtk::REVEALER_TRANSITION_TYPE_NONE;
+ auto transition_type = Gtk::REVEALER_TRANSITION_TYPE_NONE;
const int active_row = m_transition_type.get_active_row_number();
switch (active_row)
diff --git a/examples/book/timeout/timerexample.cc b/examples/book/timeout/timerexample.cc
index 57de201..6d0e18f 100644
--- a/examples/book/timeout/timerexample.cc
+++ b/examples/book/timeout/timerexample.cc
@@ -54,7 +54,7 @@ void TimerExample::on_button_add_timer()
&TimerExample::on_timeout), m_timer_number);
// This is where we connect the slot to the Glib::signal_timeout()
- sigc::connection conn = Glib::signal_timeout().connect(my_slot,
+ auto conn = Glib::signal_timeout().connect(my_slot,
timeout_value);
// Remember the connection:
diff --git a/examples/book/toolpalette/canvas.cc b/examples/book/toolpalette/canvas.cc
index 761aada..d8a519d 100644
--- a/examples/book/toolpalette/canvas.cc
+++ b/examples/book/toolpalette/canvas.cc
@@ -63,7 +63,7 @@ void Canvas::on_draw(const Cairo::RefPtr<Cairo::Context>& cr, int width, int hei
cr->rectangle(0, 0, width, height);
cr->fill();
- for(type_vec_items::iterator iter = m_canvas_items.begin();
+ for(auto iter = m_canvas_items.begin();
iter != m_canvas_items.end(); ++iter )
{
item_draw(*iter, cr, false);
@@ -93,7 +93,7 @@ bool Canvas::on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context,
{
// Request DnD data for creating a drop indicator.
// This will cause on_drag_data_received() to be called.
- const Glib::ustring target = drag_dest_find_target(context);
+ const auto target = drag_dest_find_target(context);
if (target.empty())
return false;
@@ -168,7 +168,7 @@ bool Canvas::on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int /*
{
// Request DnD data for creating a dopped item.
// This will cause on_drag_data_received() to be called.
- const Glib::ustring target = drag_dest_find_target(context);
+ const auto target = drag_dest_find_target(context);
if (target.empty())
return false;
diff --git a/examples/book/toolpalette/examplewindow.cc b/examples/book/toolpalette/examplewindow.cc
index 4b5d865..c4de0cf 100644
--- a/examples/book/toolpalette/examplewindow.cc
+++ b/examples/book/toolpalette/examplewindow.cc
@@ -33,9 +33,9 @@ void ExampleWindow::load_icon_items()
Gtk::IconSize::lookup(Gtk::ICON_SIZE_BUTTON, requested_icon_size, requested_icon_height);
const guint max_icons_per_group = 10;
- for (type_stringvec::const_iterator iter = contexts.begin(); iter != contexts.end(); ++iter)
+ for (auto iter = contexts.begin(); iter != contexts.end(); ++iter)
{
- const Glib::ustring context_name = *iter;
+ const auto context_name = *iter;
Gtk::ToolItemGroup* group =
Gtk::manage(new Gtk::ToolItemGroup(context_name));
m_ToolPalette.add(*group);
@@ -44,9 +44,9 @@ void ExampleWindow::load_icon_items()
type_stringvec icon_names_for_context = icon_theme->list_icons(context_name);
std::sort(icon_names_for_context.begin(), icon_names_for_context.end());
guint icons_count = 0;
- for (type_stringvec::const_iterator iconiter = icon_names_for_context.begin(); iconiter !=
icon_names_for_context.end(); ++iconiter)
+ for (auto iconiter = icon_names_for_context.begin(); iconiter != icon_names_for_context.end();
++iconiter)
{
- const Glib::ustring icon_name = *iconiter;
+ const auto icon_name = *iconiter;
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
try
{
@@ -89,7 +89,7 @@ void ExampleWindow::load_toggle_items()
for(int i = 1; i <= 10; ++i)
{
- const Glib::ustring label = Glib::ustring::compose("#%1", i);
+ const auto label = Glib::ustring::compose("#%1", i);
auto button = Gtk::manage(new Gtk::RadioToolButton());
button->set_group(radio_group);
button->set_label(label);
@@ -190,8 +190,8 @@ ExampleWindow::ExampleWindow()
//The Orientation ComboBox:
m_refTreeModelOrientation = Gtk::ListStore::create(m_ColumnsOrientation);
- Gtk::TreeModel::iterator iter = m_refTreeModelOrientation->append();
- Gtk::TreeModel::Row row = *iter;
+ auto iter = m_refTreeModelOrientation->append();
+ auto row = *iter;
row[m_ColumnsOrientation.m_col_value] = Gtk::ORIENTATION_HORIZONTAL;
row[m_ColumnsOrientation.m_col_name] = "Horizontal";\
row = *(m_refTreeModelOrientation->append());
@@ -259,11 +259,11 @@ ExampleWindow::~ExampleWindow()
void ExampleWindow::on_combo_orientation_changed()
{
- Gtk::TreeModel::iterator iter = m_ComboOrientation.get_active();
+ const auto iter = m_ComboOrientation.get_active();
if(!iter)
return;
- Gtk::TreeModel::Row row = *iter;
+ const auto row = *iter;
const Gtk::Orientation value = row[m_ColumnsOrientation.m_col_value];
m_ToolPalette.set_orientation(value);
@@ -276,11 +276,11 @@ void ExampleWindow::on_combo_orientation_changed()
void ExampleWindow::on_combo_style_changed()
{
- Gtk::TreeModel::iterator iter = m_ComboStyle.get_active();
+ const auto iter = m_ComboStyle.get_active();
if(!iter)
return;
- Gtk::TreeModel::Row row = *iter;
+ const auto row = *iter;
const int value = row[m_ColumnsStyle.m_col_value];
if(value == -1)
diff --git a/examples/book/treeview/combo_renderer/examplewindow.cc
b/examples/book/treeview/combo_renderer/examplewindow.cc
index d574c60..86f75db 100644
--- a/examples/book/treeview/combo_renderer/examplewindow.cc
+++ b/examples/book/treeview/combo_renderer/examplewindow.cc
@@ -46,7 +46,7 @@ ExampleWindow::ExampleWindow()
//You could also use set_cell_data_func() to choose or fill these later.
m_refTreeModelCombo1 = Gtk::ListStore::create(m_ColumnsCombo);
- Gtk::TreeModel::Row row = *(m_refTreeModelCombo1->append());
+ auto row = *(m_refTreeModelCombo1->append());
row[m_ColumnsCombo.m_col_choice] = "abc";
row = *(m_refTreeModelCombo1->append());
row[m_ColumnsCombo.m_col_choice] = "def";
@@ -139,11 +139,11 @@ void ExampleWindow::on_cellrenderer_choice_edited(
Gtk::TreePath path(path_string);
//Get the row from the path:
- Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path);
+ auto iter = m_refTreeModel->get_iter(path);
if(iter)
{
//Store the user's new text in the model:
- Gtk::TreeRow row = *iter;
+ auto row = *iter;
row[m_Columns.m_col_itemchosen] = new_text;
}
}
diff --git a/examples/book/treeview/drag_and_drop/examplewindow.cc
b/examples/book/treeview/drag_and_drop/examplewindow.cc
index 1f0e5fc..4f905f3 100644
--- a/examples/book/treeview/drag_and_drop/examplewindow.cc
+++ b/examples/book/treeview/drag_and_drop/examplewindow.cc
@@ -55,13 +55,13 @@ ExampleWindow::ExampleWindow()
m_TreeView.enable_model_drag_dest();
//Fill the TreeView's model
- Gtk::TreeModel::Row row = *(m_refTreeModel->append());
+ auto row = *(m_refTreeModel->append());
row[m_refTreeModel->m_Columns.m_col_id] = 1;
row[m_refTreeModel->m_Columns.m_col_name] = "Billy Bob";
row[m_refTreeModel->m_Columns.m_col_draggable] = true;
row[m_refTreeModel->m_Columns.m_col_receivesdrags] = true;
- Gtk::TreeModel::Row childrow = *(m_refTreeModel->append(row.children()));
+ auto childrow = *(m_refTreeModel->append(row.children()));
childrow[m_refTreeModel->m_Columns.m_col_id] = 11;
childrow[m_refTreeModel->m_Columns.m_col_name] = "Billy Bob Junior";
childrow[m_refTreeModel->m_Columns.m_col_draggable] = true;
diff --git a/examples/book/treeview/drag_and_drop/treemodel_dnd.cc
b/examples/book/treeview/drag_and_drop/treemodel_dnd.cc
index a85657a..1eb7e78 100644
--- a/examples/book/treeview/drag_and_drop/treemodel_dnd.cc
+++ b/examples/book/treeview/drag_and_drop/treemodel_dnd.cc
@@ -58,7 +58,7 @@ TreeModel_Dnd::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest,
//dest is the path that the row would have after it has been dropped:
//But in this case we are more interested in the parent row:
- Gtk::TreeModel::Path dest_parent = dest;
+ auto dest_parent = dest;
bool dest_is_not_top_level = dest_parent.up();
if(!dest_is_not_top_level || dest_parent.empty())
{
diff --git a/examples/book/treeview/editable_cells/examplewindow.cc
b/examples/book/treeview/editable_cells/examplewindow.cc
index 82b7a92..6ce1611 100644
--- a/examples/book/treeview/editable_cells/examplewindow.cc
+++ b/examples/book/treeview/editable_cells/examplewindow.cc
@@ -53,7 +53,7 @@ ExampleWindow::ExampleWindow()
m_TreeView.set_model(m_refTreeModel);
//Fill the TreeView's model
- Gtk::TreeModel::Row row = *(m_refTreeModel->append());
+ auto row = *(m_refTreeModel->append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "Billy Bob";
row[m_Columns.m_col_foo] = true;
@@ -119,12 +119,12 @@ void ExampleWindow::on_button_quit()
void ExampleWindow::treeviewcolumn_validated_on_cell_data(
Gtk::CellRenderer* /* renderer */,
- const Gtk::TreeModel::iterator& iter)
+ const Gtk::TreeModel::const_iterator& iter)
{
//Get the value from the model and show it appropriately in the view:
if(iter)
{
- Gtk::TreeModel::Row row = *iter;
+ const auto row = *iter;
int model_value = row[m_Columns.m_col_number_validated];
//This is just an example.
@@ -133,7 +133,7 @@ void ExampleWindow::treeviewcolumn_validated_on_cell_data(
char buffer[32];
sprintf(buffer, "%d", model_value);
- Glib::ustring view_text = buffer;
+ auto view_text = buffer;
m_cellrenderer_validated.property_text() = view_text;
}
}
@@ -195,10 +195,10 @@ void ExampleWindow::cellrenderer_validated_on_edited(
else
{
//Get the row from the path:
- Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path);
+ auto iter = m_refTreeModel->get_iter(path);
if(iter)
{
- Gtk::TreeModel::Row row = *iter;
+ auto row = *iter;
//Put the new value in the model:
row[m_Columns.m_col_number_validated] = new_value;
diff --git a/examples/book/treeview/editable_cells/examplewindow.h
b/examples/book/treeview/editable_cells/examplewindow.h
index bee353e..e8ff1cb 100644
--- a/examples/book/treeview/editable_cells/examplewindow.h
+++ b/examples/book/treeview/editable_cells/examplewindow.h
@@ -31,7 +31,7 @@ protected:
//Signal handlers:
void on_button_quit();
- void treeviewcolumn_validated_on_cell_data(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator&
iter);
+ void treeviewcolumn_validated_on_cell_data(Gtk::CellRenderer* renderer, const
Gtk::TreeModel::const_iterator& iter);
void cellrenderer_validated_on_editing_started(Gtk::CellEditable* cell_editable, const Glib::ustring&
path);
void cellrenderer_validated_on_edited(const Glib::ustring& path_string, const Glib::ustring& new_text);
diff --git a/examples/book/treeview/filter/examplewindow.cc b/examples/book/treeview/filter/examplewindow.cc
index e3b1c53..81cad64 100644
--- a/examples/book/treeview/filter/examplewindow.cc
+++ b/examples/book/treeview/filter/examplewindow.cc
@@ -60,7 +60,7 @@ ExampleWindow::ExampleWindow()
m_TreeView.set_model(m_refTreeModelFilter);
//Fill the TreeView's model
- Gtk::TreeModel::Row row = *(m_refTreeModel->append());
+ auto row = *(m_refTreeModel->append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "Billy Bob";
row[m_Columns.m_col_show] = true;
diff --git a/examples/book/treeview/filter_modify/examplewindow.cc
b/examples/book/treeview/filter_modify/examplewindow.cc
index 8cd4596..ab9fbc6 100644
--- a/examples/book/treeview/filter_modify/examplewindow.cc
+++ b/examples/book/treeview/filter_modify/examplewindow.cc
@@ -55,7 +55,7 @@ ExampleWindow::ExampleWindow()
m_TreeView.set_model(m_refTreeModelFilter);
//Fill the TreeView's model
- Gtk::TreeModel::Row row = *(m_refTreeModel->append());
+ auto row = *(m_refTreeModel->append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "Billy Bob";
row[m_Columns.m_col_something] = true;
@@ -102,7 +102,7 @@ void ExampleWindow::on_filter_modify(const Gtk::TreeModel::iterator& iter,
//Look in the child model, to calculate the model to show in the filter model:
Gtk::TreeModel::iterator iter_child =
m_refTreeModelFilter->convert_iter_to_child_iter(iter);
- Gtk::TreeModel::Row row_child = *iter_child;
+ auto row_child = *iter_child;
switch(column)
{
diff --git a/examples/book/treeview/list/examplewindow.cc b/examples/book/treeview/list/examplewindow.cc
index d1b909b..d61d14f 100644
--- a/examples/book/treeview/list/examplewindow.cc
+++ b/examples/book/treeview/list/examplewindow.cc
@@ -47,7 +47,7 @@ ExampleWindow::ExampleWindow()
m_TreeView.set_model(m_refTreeModel);
//Fill the TreeView's model
- Gtk::TreeModel::Row row = *(m_refTreeModel->append());
+ auto row = *(m_refTreeModel->append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "Billy Bob";
row[m_Columns.m_col_number] = 10;
diff --git a/examples/book/treeview/modelsort/examplewindow.cc
b/examples/book/treeview/modelsort/examplewindow.cc
index b0fa1fd..791acd9 100644
--- a/examples/book/treeview/modelsort/examplewindow.cc
+++ b/examples/book/treeview/modelsort/examplewindow.cc
@@ -65,7 +65,7 @@ ExampleWindow::ExampleWindow()
//Fill the tree model
- Gtk::TreeModel::Row row = *(m_refTreeModel->append());
+ auto row = *(m_refTreeModel->append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "Zebede Aardvark";
row[m_Columns.m_col_something] = true;
diff --git a/examples/book/treeview/popup/treeview_withpopup.cc
b/examples/book/treeview/popup/treeview_withpopup.cc
index 2f3c6cd..7d06952 100644
--- a/examples/book/treeview/popup/treeview_withpopup.cc
+++ b/examples/book/treeview/popup/treeview_withpopup.cc
@@ -24,7 +24,7 @@ TreeView_WithPopup::TreeView_WithPopup()
set_model(m_refTreeModel);
//Fill the TreeView's model
- Gtk::TreeModel::Row row = *(m_refTreeModel->append());
+ auto row = *(m_refTreeModel->append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "right-click on this";
@@ -91,7 +91,7 @@ void TreeView_WithPopup::on_menu_file_popup_generic()
auto refSelection = get_selection();
if(refSelection)
{
- Gtk::TreeModel::iterator iter = refSelection->get_selected();
+ auto iter = refSelection->get_selected();
if(iter)
{
int id = (*iter)[m_Columns.m_col_id];
diff --git a/examples/book/treeview/tree/examplewindow.cc b/examples/book/treeview/tree/examplewindow.cc
index 1989050..46eaeff 100644
--- a/examples/book/treeview/tree/examplewindow.cc
+++ b/examples/book/treeview/tree/examplewindow.cc
@@ -50,11 +50,11 @@ ExampleWindow::ExampleWindow()
m_TreeView.set_reorderable();
//Fill the TreeView's model
- Gtk::TreeModel::Row row = *(m_refTreeModel->append());
+ auto row = *(m_refTreeModel->append());
row[m_Columns.m_col_id] = 1;
row[m_Columns.m_col_name] = "Billy Bob";
- Gtk::TreeModel::Row childrow = *(m_refTreeModel->append(row.children()));
+ auto childrow = *(m_refTreeModel->append(row.children()));
childrow[m_Columns.m_col_id] = 11;
childrow[m_Columns.m_col_name] = "Billy Bob Junior";
@@ -96,10 +96,10 @@ void ExampleWindow::on_button_quit()
void ExampleWindow::on_treeview_row_activated(const Gtk::TreeModel::Path& path,
Gtk::TreeViewColumn* /* column */)
{
- Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path);
+ const auto iter = m_refTreeModel->get_iter(path);
if(iter)
{
- Gtk::TreeModel::Row row = *iter;
+ const auto row = *iter;
std::cout << "Row activated: ID=" << row[m_Columns.m_col_id] << ", Name="
<< row[m_Columns.m_col_name] << std::endl;
}
diff --git a/examples/others/cellrenderercustom/cellrendererlist.cc
b/examples/others/cellrenderercustom/cellrendererlist.cc
index e6fe1c8..4e8a1a8 100644
--- a/examples/others/cellrenderercustom/cellrendererlist.cc
+++ b/examples/others/cellrenderercustom/cellrendererlist.cc
@@ -67,13 +67,13 @@ CellRendererList::~CellRendererList()
void CellRendererList::append_list_item(const Glib::ustring& text)
{
- Gtk::TreeModel::Row row = *list_store_->append();
+ auto row = *list_store_->append();
row[popup_columns().item] = text;
}
Glib::ustring CellRendererList::get_selected_item()
{
- if(const Gtk::TreeModel::iterator selected = tree_view_.get_selection()->get_selected())
+ if(const auto selected = tree_view_.get_selection()->get_selected())
{
return (*selected)[popup_columns().item];
}
diff --git a/examples/others/cellrenderercustom/cellrendererpopup.cc
b/examples/others/cellrenderercustom/cellrendererpopup.cc
index ca1054b..ab25286 100644
--- a/examples/others/cellrenderercustom/cellrendererpopup.cc
+++ b/examples/others/cellrenderercustom/cellrendererpopup.cc
@@ -159,7 +159,7 @@ void CellRendererPopup::on_show_popup(const Glib::ustring&, int, int y1, int x2,
popup_window_.move(-500, -500);
popup_window_.show();
- const Gtk::Allocation alloc = popup_window_.get_allocation();
+ const auto alloc = popup_window_.get_allocation();
int x = x2;
int y = y2;
@@ -237,7 +237,7 @@ bool CellRendererPopup::on_button_press_event(GdkEventButton* event)
int xoffset = 0, yoffset = 0;
popup_window_.get_window()->get_root_origin(xoffset, yoffset);
- const Gtk::Allocation alloc = popup_window_.get_allocation();
+ const auto alloc = popup_window_.get_allocation();
xoffset += alloc.get_x();
yoffset += alloc.get_y();
@@ -309,7 +309,7 @@ void CellRendererPopup::on_popup_arrow_clicked()
int x = 0, y = 0;
popup_entry_->get_window()->get_origin(x, y);
- const Gtk::Allocation alloc = popup_entry_->get_allocation();
+ const auto alloc = popup_entry_->get_allocation();
signal_show_popup_(popup_entry_->get_path(), x, y, x + alloc.get_width(), y + alloc.get_height());
}
diff --git a/examples/others/cellrenderercustom/cellrenderertoggle.cc
b/examples/others/cellrenderercustom/cellrenderertoggle.cc
index 6fbf527..4e9345a 100644
--- a/examples/others/cellrenderercustom/cellrenderertoggle.cc
+++ b/examples/others/cellrenderercustom/cellrenderertoggle.cc
@@ -189,7 +189,7 @@ void MyCellRendererToggle::snapshot_vfunc(Gtk::Snapshot& snapshot,
if(width <= 0 || height <= 0)
return;
- Gtk::StateFlags state = Gtk::STATE_FLAG_INSENSITIVE;
+ auto state = Gtk::STATE_FLAG_INSENSITIVE;
if (property_activatable_)
state = (Gtk::StateFlags)0;
@@ -267,7 +267,7 @@ AppWindow::AppWindow()
output.str("row #");
output << i;
- Gtk::TreeModel::Row row = *list_store_->append();
+ auto row = *list_store_->append();
row[list_columns_.text] = output.str();
row[list_columns_.active] = ((i % 2) != 0);
@@ -280,7 +280,7 @@ AppWindow::~AppWindow()
void AppWindow::on_cell_toggled(const Glib::ustring& path_string)
{
// Get the model row that has been toggled.
- Gtk::TreeModel::Row row = *list_store_->get_iter(Gtk::TreeModel::Path(path_string));
+ auto row = *list_store_->get_iter(Gtk::TreeModel::Path(path_string));
// Invert the 'active' value in the toggled row.
row[list_columns_.active] = !row[list_columns_.active];
diff --git a/examples/others/cellrenderercustom/testpopup.cc b/examples/others/cellrenderercustom/testpopup.cc
index 9a82716..fd80f1c 100644
--- a/examples/others/cellrenderercustom/testpopup.cc
+++ b/examples/others/cellrenderercustom/testpopup.cc
@@ -83,7 +83,7 @@ AppWindow::AppWindow()
output.str("row #");
output << i;
- Gtk::TreeModel::Row row = *list_store_->append();
+ auto row = *list_store_->append();
row[list_columns_.text1] = output.str();
row[list_columns_.text2] = "foobar!";
@@ -96,7 +96,7 @@ AppWindow::~AppWindow()
void AppWindow::on_cell_edited(const Glib::ustring& path, const Glib::ustring& new_text)
{
// Get the model row that has been edited.
- Gtk::TreeModel::Row row = *list_store_->get_iter(Gtk::TreeModel::Path(path));
+ auto row = *list_store_->get_iter(Gtk::TreeModel::Path(path));
row[list_columns_.text2] = new_text;
}
diff --git a/examples/others/window/wheelbarrow.cc b/examples/others/window/wheelbarrow.cc
index 6e4e700..d87d1b5 100644
--- a/examples/others/window/wheelbarrow.cc
+++ b/examples/others/window/wheelbarrow.cc
@@ -153,7 +153,7 @@ Wheelbarrow::Wheelbarrow()
const Glib::RefPtr<const Gdk::Window> window = get_window();
//TODO: Use get_style_context() and Gdk::RGBA instead?
- const Gdk::Color transparent = Gtk::Widget::get_default_style()->get_bg(Gtk::STATE_NORMAL);
+ const auto transparent = Gtk::Widget::get_default_style()->get_bg(Gtk::STATE_NORMAL);
const auto pixbuf =
Gdk::Pixbuf::create_from_xpm_data(drawable, transparent, wheelbarrow_xpm);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]