[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 04/20: Use ranged for.

noreply at xfce.org noreply at xfce.org
Thu Feb 6 12:03:21 CET 2020


This is an automated email from the git hooks/post-receive script.

g   o   t   t   c   o   d   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-whiskermenu-plugin.

commit 58ebe66090af5c1353de9ca085e369c05d8cb377
Author: Graeme Gott <graeme at gottcode.org>
Date:   Sat Feb 1 11:52:08 2020 -0500

    Use ranged for.
---
 panel-plugin/applications-page.cpp    | 32 ++++++++++++++++----------------
 panel-plugin/category.cpp             | 32 ++++++++++++++++++++------------
 panel-plugin/command.cpp              | 12 +++++-------
 panel-plugin/configuration-dialog.cpp | 27 +++++++++++++--------------
 panel-plugin/favorites-page.cpp       | 22 ++++++++++------------
 panel-plugin/launcher.cpp             | 10 +++++-----
 panel-plugin/page.cpp                 |  5 ++---
 panel-plugin/query.cpp                | 10 +++++-----
 panel-plugin/recent-page.cpp          |  6 +++---
 panel-plugin/resizer-widget.cpp       |  6 +++---
 panel-plugin/search-page.cpp          | 22 +++++++++++-----------
 panel-plugin/settings.cpp             | 14 +++++++-------
 panel-plugin/window.cpp               | 22 +++++++++++-----------
 13 files changed, 111 insertions(+), 109 deletions(-)

diff --git a/panel-plugin/applications-page.cpp b/panel-plugin/applications-page.cpp
index 71cc089..ef66936 100644
--- a/panel-plugin/applications-page.cpp
+++ b/panel-plugin/applications-page.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2015, 2016, 2017, 2018, 2020 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -134,11 +134,11 @@ void ApplicationsPage::apply_filter(GtkToggleButton* togglebutton)
 
 	// Find category matching button
 	Category* category = NULL;
-	for (std::vector<Category*>::const_iterator i = m_categories.begin(), end = m_categories.end(); i != end; ++i)
+	for (auto test_category : m_categories)
 	{
-		if (GTK_TOGGLE_BUTTON((*i)->get_button()->get_widget()) == togglebutton)
+		if (GTK_TOGGLE_BUTTON(test_category->get_button()->get_widget()) == togglebutton)
 		{
-			category = *i;
+			category = test_category;
 			break;
 		}
 	}
@@ -199,9 +199,9 @@ bool ApplicationsPage::load_applications()
 
 void ApplicationsPage::reload_category_icon_size()
 {
-	for (std::vector<Category*>::const_iterator i = m_categories.begin(), end = m_categories.end(); i != end; ++i)
+	for (auto category : m_categories)
 	{
-		(*i)->get_button()->reload_icon_size();
+		category->get_button()->reload_icon_size();
 	}
 }
 
@@ -210,9 +210,9 @@ void ApplicationsPage::reload_category_icon_size()
 void ApplicationsPage::clear_applications()
 {
 	// Free categories
-	for (std::vector<Category*>::iterator i = m_categories.begin(), end = m_categories.end(); i != end; ++i)
+	for (auto category : m_categories)
 	{
-		delete *i;
+		delete category;
 	}
 	m_categories.clear();
 
@@ -220,9 +220,9 @@ void ApplicationsPage::clear_applications()
 	get_window()->unset_items();
 	get_view()->unset_model();
 
-	for (std::map<std::string, Launcher*>::iterator i = m_items.begin(), end = m_items.end(); i != end; ++i)
+	for (const auto& i : m_items)
 	{
-		delete i->second;
+		delete i.second;
 	}
 	m_items.clear();
 
@@ -289,18 +289,18 @@ void ApplicationsPage::load_garcon_menu()
 	// Sort items and categories
 	if (!wm_settings->load_hierarchy)
 	{
-		for (std::vector<Category*>::const_iterator i = m_categories.begin(), end = m_categories.end(); i != end; ++i)
+		for (auto category : m_categories)
 		{
-			(*i)->sort();
+			category->sort();
 		}
 		std::sort(m_categories.begin(), m_categories.end(), &Element::less_than);
 	}
 
 	// Create all items category
 	Category* category = new Category(NULL);
-	for (std::map<std::string, Launcher*>::const_iterator i = m_items.begin(), end = m_items.end(); i != end; ++i)
+	for (const auto& i : m_items)
 	{
-		category->append_item(i->second);
+		category->append_item(i.second);
 	}
 	category->sort();
 	m_categories.insert(m_categories.begin(), category);
@@ -325,9 +325,9 @@ void ApplicationsPage::load_contents()
 
 	// Add buttons for categories
 	std::vector<SectionButton*> category_buttons;
-	for (std::vector<Category*>::const_iterator i = m_categories.begin(), end = m_categories.end(); i != end; ++i)
+	for (auto category : m_categories)
 	{
-		SectionButton* category_button = (*i)->get_button();
+		SectionButton* category_button = category->get_button();
 		g_signal_connect_slot(category_button->get_widget(), "toggled", &ApplicationsPage::apply_filter, this);
 		category_buttons.push_back(category_button);
 	}
diff --git a/panel-plugin/category.cpp b/panel-plugin/category.cpp
index 951015a..1a291f2 100644
--- a/panel-plugin/category.cpp
+++ b/panel-plugin/category.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2016, 2020 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -61,9 +61,9 @@ Category::~Category()
 
 	delete m_button;
 
-	for (std::vector<Element*>::const_iterator i = m_items.begin(), end = m_items.end(); i != end; ++i)
+	for (auto element : m_items)
 	{
-		if (Category* category = dynamic_cast<Category*>(*i))
+		if (Category* category = dynamic_cast<Category*>(element))
 		{
 			delete category;
 		}
@@ -119,10 +119,10 @@ GtkTreeModel* Category::get_model()
 
 bool Category::empty() const
 {
-	for (std::vector<Element*>::const_iterator i = m_items.begin(), end = m_items.end(); i != end; ++i)
+	for (auto element : m_items)
 	{
-		Category* category = dynamic_cast<Category*>(*i);
-		if ((!category && *i) || !category->empty())
+		Category* category = dynamic_cast<Category*>(element);
+		if ((!category && element) || !category->empty())
 		{
 			return false;
 		}
@@ -166,9 +166,13 @@ void Category::sort()
 
 void Category::insert_items(GtkTreeStore* model, GtkTreeIter* parent)
 {
-	for (std::vector<Element*>::size_type i = 0, end = m_items.size(); i < end; ++i)
+	if (!m_items.empty() && !m_items.back())
+	{
+		m_items.pop_back();
+	}
+
+	for (auto element : m_items)
 	{
-		Element* element = m_items[i];
 		if (Category* category = dynamic_cast<Category*>(element))
 		{
 			if (category->empty())
@@ -200,7 +204,7 @@ void Category::insert_items(GtkTreeStore* model, GtkTreeIter* parent)
 					LauncherView::COLUMN_LAUNCHER, launcher,
 					-1);
 		}
-		else if ((i + 1) < end)
+		else
 		{
 			gtk_tree_store_insert_with_values(model,
 					NULL, parent, INT_MAX,
@@ -217,9 +221,13 @@ void Category::insert_items(GtkTreeStore* model, GtkTreeIter* parent)
 
 void Category::insert_items(GtkListStore* model)
 {
-	for (std::vector<Element*>::size_type i = 0, end = m_items.size(); i < end; ++i)
+	if (!m_items.empty() && !m_items.back())
+	{
+		m_items.pop_back();
+	}
+
+	for (auto element : m_items)
 	{
-		Element* element = m_items[i];
 		if (Launcher* launcher = dynamic_cast<Launcher*>(element))
 		{
 			gtk_list_store_insert_with_values(model,
@@ -230,7 +238,7 @@ void Category::insert_items(GtkListStore* model)
 					LauncherView::COLUMN_LAUNCHER, launcher,
 					-1);
 		}
-		else if ((i + 1) < end)
+		else
 		{
 			gtk_list_store_insert_with_values(model,
 					NULL, INT_MAX,
diff --git a/panel-plugin/command.cpp b/panel-plugin/command.cpp
index 21b38d8..ef6a022 100644
--- a/panel-plugin/command.cpp
+++ b/panel-plugin/command.cpp
@@ -49,17 +49,15 @@ Command::Command(const gchar* icon, const gchar* text, const gchar* command, con
 	m_shown(true),
 	m_timeout_details({NULL, g_strdup(confirm_question), g_strdup(confirm_status), 0})
 {
-	std::string mnemonic(text ? text : "");
-	for (std::string::size_type i = 0, length = mnemonic.length(); i < length; ++i)
+	std::string tooltip(text ? text : "");
+	for (auto i = tooltip.begin(); i != tooltip.end(); ++i)
 	{
-		if (mnemonic[i] == '_')
+		if (*i == '_')
 		{
-			mnemonic.erase(i, 1);
-			--length;
-			--i;
+			i = tooltip.erase(i);
 		}
 	}
-	m_text = g_strdup(mnemonic.c_str());
+	m_text = g_strdup(tooltip.c_str());
 
 	check();
 }
diff --git a/panel-plugin/configuration-dialog.cpp b/panel-plugin/configuration-dialog.cpp
index fcb1866..b1eef5f 100644
--- a/panel-plugin/configuration-dialog.cpp
+++ b/panel-plugin/configuration-dialog.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2015, 2016, 2017, 2018, 2019, 2020 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -135,9 +135,9 @@ ConfigurationDialog::ConfigurationDialog(Plugin* plugin) :
 
 ConfigurationDialog::~ConfigurationDialog()
 {
-	for (std::vector<CommandEdit*>::size_type i = 0; i < m_commands.size(); ++i)
+	for (auto command : m_commands)
 	{
-		delete m_commands[i];
+		delete command;
 	}
 
 	g_object_unref(m_actions_model);
@@ -579,9 +579,9 @@ void ConfigurationDialog::response(GtkDialog*, int response_id)
 			m_plugin->set_button_title(Plugin::get_button_title_default());
 		}
 
-		for (int i = 0; i < Settings::CountCommands; ++i)
+		for (auto command : wm_settings->command)
 		{
-			wm_settings->command[i]->check();
+			command->check();
 		}
 
 		if (response_id == GTK_RESPONSE_CLOSE)
@@ -742,10 +742,10 @@ GtkWidget* ConfigurationDialog::init_appearance_tab()
 	m_item_icon_size = gtk_combo_box_text_new();
 	gtk_widget_set_halign(m_item_icon_size, GTK_ALIGN_START);
 	gtk_widget_set_hexpand(m_item_icon_size, false);
-	std::vector<std::string> icon_sizes = IconSize::get_strings();
-	for (std::vector<std::string>::const_iterator i = icon_sizes.begin(), end = icon_sizes.end(); i != end; ++i)
+	const std::vector<std::string> icon_sizes = IconSize::get_strings();
+	for (const auto& icon_size : icon_sizes)
 	{
-		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(m_item_icon_size), i->c_str());
+		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(m_item_icon_size), icon_size.c_str());
 	}
 	gtk_combo_box_set_active(GTK_COMBO_BOX(m_item_icon_size), wm_settings->launcher_icon_size + 1);
 	gtk_grid_attach(page, m_item_icon_size, 1, 8, 1, 1);
@@ -760,9 +760,9 @@ GtkWidget* ConfigurationDialog::init_appearance_tab()
 	m_category_icon_size = gtk_combo_box_text_new();
 	gtk_widget_set_halign(m_category_icon_size, GTK_ALIGN_START);
 	gtk_widget_set_hexpand(m_category_icon_size, false);
-	for (std::vector<std::string>::const_iterator i = icon_sizes.begin(), end = icon_sizes.end(); i != end; ++i)
+	for (const auto& icon_size : icon_sizes)
 	{
-		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(m_category_icon_size), i->c_str());
+		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(m_category_icon_size), icon_size.c_str());
 	}
 	gtk_combo_box_set_active(GTK_COMBO_BOX(m_category_icon_size), wm_settings->category_icon_size + 1);
 	gtk_grid_attach(page, m_category_icon_size, 1, 9, 1, 1);
@@ -940,9 +940,9 @@ GtkWidget* ConfigurationDialog::init_commands_tab()
 	GtkSizeGroup* label_size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
 
 	// Add command entries
-	for (int i = 0; i < Settings::CountCommands; ++i)
+	for (auto command : wm_settings->command)
 	{
-		CommandEdit* command_edit = new CommandEdit(wm_settings->command[i], label_size_group);
+		CommandEdit* command_edit = new CommandEdit(command, label_size_group);
 		gtk_box_pack_start(page, command_edit->get_widget(), false, false, 0);
 		m_commands.push_back(command_edit);
 	}
@@ -965,9 +965,8 @@ GtkWidget* ConfigurationDialog::init_search_actions_tab()
 			G_TYPE_STRING,
 			G_TYPE_STRING,
 			G_TYPE_POINTER);
-	for (std::vector<SearchAction*>::size_type i = 0, end = wm_settings->search_actions.size(); i < end; ++i)
+	for (auto action : wm_settings->search_actions)
 	{
-		SearchAction* action = wm_settings->search_actions[i];
 		gtk_list_store_insert_with_values(m_actions_model,
 				NULL, G_MAXINT,
 				COLUMN_NAME, action->get_name(),
diff --git a/panel-plugin/favorites-page.cpp b/panel-plugin/favorites-page.cpp
index d46bd88..b5e5bf3 100644
--- a/panel-plugin/favorites-page.cpp
+++ b/panel-plugin/favorites-page.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2015, 2016, 2019, 2020 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -119,9 +119,9 @@ void FavoritesPage::set_menu_items()
 	g_signal_connect_slot(model, "row-deleted", &FavoritesPage::on_row_deleted, this);
 	g_object_unref(model);
 
-	for (std::vector<std::string>::size_type i = 0, end = wm_settings->favorites.size(); i < end; ++i)
+	for (const auto& favorite : wm_settings->favorites)
 	{
-		Launcher* launcher = get_window()->get_applications()->get_application(wm_settings->favorites[i]);
+		Launcher* launcher = get_window()->get_applications()->get_application(favorite);
 		if (launcher)
 		{
 			launcher->set_flag(Launcher::FavoriteFlag, true);
@@ -221,9 +221,9 @@ void FavoritesPage::on_row_deleted(GtkTreeModel*, GtkTreePath* path)
 
 void FavoritesPage::sort(std::vector<Launcher*>& items) const
 {
-	for (std::vector<std::string>::const_iterator i = wm_settings->favorites.begin(), end = wm_settings->favorites.end(); i != end; ++i)
+	for (const auto& favorite : wm_settings->favorites)
 	{
-		Launcher* launcher = get_window()->get_applications()->get_application(*i);
+		Launcher* launcher = get_window()->get_applications()->get_application(favorite);
 		if (!launcher)
 		{
 			continue;
@@ -240,12 +240,11 @@ void FavoritesPage::sort_ascending()
 	std::vector<Launcher*> items;
 	sort(items);
 
-	std::vector<std::string> desktop_ids;
-	for (std::vector<Launcher*>::const_iterator i = items.begin(), end = items.end(); i != end; ++i)
+	wm_settings->favorites.clear();
+	for (auto launcher : items)
 	{
-		desktop_ids.push_back((*i)->get_desktop_id());
+		wm_settings->favorites.push_back(launcher->get_desktop_id());
 	}
-	wm_settings->favorites = desktop_ids;
 	wm_settings->set_modified();
 	set_menu_items();
 }
@@ -257,12 +256,11 @@ void FavoritesPage::sort_descending()
 	std::vector<Launcher*> items;
 	sort(items);
 
-	std::vector<std::string> desktop_ids;
+	wm_settings->favorites.clear();
 	for (std::vector<Launcher*>::const_reverse_iterator i = items.rbegin(), end = items.rend(); i != end; ++i)
 	{
-		desktop_ids.push_back((*i)->get_desktop_id());
+		wm_settings->favorites.push_back((*i)->get_desktop_id());
 	}
-	wm_settings->favorites = desktop_ids;
 	wm_settings->set_modified();
 	set_menu_items();
 }
diff --git a/panel-plugin/launcher.cpp b/panel-plugin/launcher.cpp
index 0f9c2aa..52dfbc7 100644
--- a/panel-plugin/launcher.cpp
+++ b/panel-plugin/launcher.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2014, 2015, 2016, 2019, 2020 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -188,9 +188,9 @@ Launcher::Launcher(GarconMenuItem* item) :
 
 Launcher::~Launcher()
 {
-	for (std::vector<DesktopAction*>::size_type i = 0, end = m_actions.size(); i < end; ++i)
+	for (auto action : m_actions)
 	{
-		delete m_actions[i];
+		delete action;
 	}
 }
 
@@ -422,9 +422,9 @@ guint Launcher::search(const Query& query)
 	}
 
 	// Sort matches in keywords next
-	for (std::vector<std::string>::size_type i = 0, end = m_search_keywords.size(); i < end; ++i)
+	for (const auto& keyword : m_search_keywords)
 	{
-		match = query.match(m_search_keywords[i]);
+		match = query.match(keyword);
 		if (match != G_MAXUINT)
 		{
 			return match | flags | 0x2000;
diff --git a/panel-plugin/page.cpp b/panel-plugin/page.cpp
index 421d08b..c68ff65 100644
--- a/panel-plugin/page.cpp
+++ b/panel-plugin/page.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -366,9 +366,8 @@ void Page::create_context_menu(GtkTreePath* path, GdkEvent* event)
 	const std::vector<DesktopAction*> actions = m_selected_launcher->get_actions();
 	if (!actions.empty())
 	{
-		for (std::vector<DesktopAction*>::size_type i = 0, end = actions.size(); i < end; ++i)
+		for (auto action : actions)
 		{
-			DesktopAction* action = actions[i];
 			menuitem = whiskermenu_image_menu_item_new(action->get_icon(), action->get_name());
 			g_signal_connect_slot(menuitem, "activate", &Page::launcher_action_activated, this, action);
 			gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
diff --git a/panel-plugin/query.cpp b/panel-plugin/query.cpp
index f2e1da1..6b98c12 100644
--- a/panel-plugin/query.cpp
+++ b/panel-plugin/query.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -79,9 +79,9 @@ unsigned int Query::match(const std::string& haystack) const
 	{
 		// Check if haystack contains query as words
 		std::string::size_type search_pos = 0;
-		for (std::vector<std::string>::const_iterator i = m_query_words.begin(), end = m_query_words.end(); i != end; ++i)
+		for (const auto& word : m_query_words)
 		{
-			search_pos = haystack.find(*i, search_pos);
+			search_pos = haystack.find(word, search_pos);
 			if ((search_pos == std::string::npos) || !is_start_word(haystack, search_pos))
 			{
 				search_pos = std::string::npos;
@@ -95,9 +95,9 @@ unsigned int Query::match(const std::string& haystack) const
 
 		// Check if haystack contains query as words in any order
 		std::vector<std::string>::size_type found_words = 0;
-		for (std::vector<std::string>::const_iterator i = m_query_words.begin(), end = m_query_words.end(); i != end; ++i)
+		for (const auto& word : m_query_words)
 		{
-			search_pos = haystack.find(*i);
+			search_pos = haystack.find(word);
 			if ((search_pos != std::string::npos) && is_start_word(haystack, search_pos))
 			{
 				++found_words;
diff --git a/panel-plugin/recent-page.cpp b/panel-plugin/recent-page.cpp
index be47672..6bbdffb 100644
--- a/panel-plugin/recent-page.cpp
+++ b/panel-plugin/recent-page.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2015, 2016, 2020 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -134,9 +134,9 @@ void RecentPage::enforce_item_count()
 
 void RecentPage::flag_items(bool enabled)
 {
-	for (std::vector<std::string>::size_type i = 0, end = wm_settings->recent.size(); i < end; ++i)
+	for (const auto& recent : wm_settings->recent)
 	{
-		Launcher* launcher = get_window()->get_applications()->get_application(wm_settings->recent[i]);
+		Launcher* launcher = get_window()->get_applications()->get_application(recent);
 		if (launcher)
 		{
 			launcher->set_flag(Launcher::RecentFlag, enabled);
diff --git a/panel-plugin/resizer-widget.cpp b/panel-plugin/resizer-widget.cpp
index bcda941..9cede9f 100644
--- a/panel-plugin/resizer-widget.cpp
+++ b/panel-plugin/resizer-widget.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2016 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -145,9 +145,9 @@ gboolean ResizerWidget::on_draw_event(GtkWidget* widget, cairo_t* cr)
 	gdk_cairo_set_source_rgba(cr, &color);
 
 	cairo_move_to(cr, m_shape.back().x, m_shape.back().y);
-	for (std::vector<GdkPoint>::const_iterator point = m_shape.begin(), end = m_shape.end(); point != end; ++point)
+	for (const auto& point : m_shape)
 	{
-		cairo_line_to(cr, point->x, point->y);
+		cairo_line_to(cr, point.x, point.y);
 	}
 	cairo_fill(cr);
 
diff --git a/panel-plugin/search-page.cpp b/panel-plugin/search-page.cpp
index 267d574..9a16bc2 100644
--- a/panel-plugin/search-page.cpp
+++ b/panel-plugin/search-page.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2016, 2019, 2020 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -72,9 +72,9 @@ void SearchPage::set_filter(const gchar* filter)
 	{
 		m_matches.clear();
 		m_matches.push_back(&m_run_action);
-		for (std::vector<Launcher*>::size_type i = 0, end = m_launchers.size(); i < end; ++i)
+		for (auto launcher : m_launchers)
 		{
-			m_matches.push_back(m_launchers[i]);
+			m_matches.push_back(launcher);
 		}
 	}
 	else if (std::find(m_matches.begin(), m_matches.end(), &m_run_action) == m_matches.end())
@@ -86,9 +86,9 @@ void SearchPage::set_filter(const gchar* filter)
 	// Create search results
 	std::vector<Match> search_action_matches;
 	search_action_matches.reserve(wm_settings->search_actions.size());
-	for (std::vector<SearchAction*>::size_type i = 0, end = wm_settings->search_actions.size(); i < end; ++i)
+	for (auto action : wm_settings->search_actions)
 	{
-		Match match(wm_settings->search_actions[i]);
+		Match match(action);
 		match.update(m_query);
 		if (!Match::invalid(match))
 		{
@@ -98,9 +98,9 @@ void SearchPage::set_filter(const gchar* filter)
 	std::stable_sort(search_action_matches.begin(), search_action_matches.end());
 	std::reverse(search_action_matches.begin(), search_action_matches.end());
 
-	for (std::vector<Match>::size_type i = 0, end = m_matches.size(); i < end; ++i)
+	for (auto& match : m_matches)
 	{
-		m_matches[i].update(m_query);
+		match.update(m_query);
 	}
 	m_matches.erase(std::remove_if(m_matches.begin(), m_matches.end(), &Match::invalid), m_matches.end());
 	std::stable_sort(m_matches.begin(), m_matches.end());
@@ -113,9 +113,9 @@ void SearchPage::set_filter(const gchar* filter)
 			G_TYPE_STRING,
 			G_TYPE_POINTER);
 	Element* element;
-	for (std::vector<Match>::size_type i = 0, end = search_action_matches.size(); i < end; ++i)
+	for (const auto& match : search_action_matches)
 	{
-		element = search_action_matches[i].element();
+		element = match.element();
 		gtk_list_store_insert_with_values(
 				store, NULL, G_MAXINT,
 				LauncherView::COLUMN_ICON, element->get_icon(),
@@ -124,9 +124,9 @@ void SearchPage::set_filter(const gchar* filter)
 				LauncherView::COLUMN_LAUNCHER, element,
 				-1);
 	}
-	for (std::vector<Match>::size_type i = 0, end = m_matches.size(); i < end; ++i)
+	for (const auto& match : m_matches)
 	{
-		element = m_matches[i].element();
+		element = match.element();
 		gtk_list_store_insert_with_values(
 				store, NULL, G_MAXINT,
 				LauncherView::COLUMN_ICON, element->get_icon(),
diff --git a/panel-plugin/settings.cpp b/panel-plugin/settings.cpp
index e346e3e..aa80f2a 100644
--- a/panel-plugin/settings.cpp
+++ b/panel-plugin/settings.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -193,14 +193,14 @@ Settings::Settings() :
 
 Settings::~Settings()
 {
-	for (int i = 0; i < CountCommands; ++i)
+	for (auto i : command)
 	{
-		delete command[i];
+		delete i;
 	}
 
-	for (std::vector<SearchAction*>::size_type i = 0, end = search_actions.size(); i < end; ++i)
+	for (auto action : search_actions)
 	{
-		delete search_actions[i];
+		delete action;
 	}
 }
 
@@ -277,9 +277,9 @@ void Settings::load(char* file)
 	int actions_count = xfce_rc_read_int_entry(rc, "search-actions", -1);
 	if (actions_count > -1)
 	{
-		for (std::vector<SearchAction*>::size_type i = 0, end = search_actions.size(); i < end; ++i)
+		for (auto action : search_actions)
 		{
-			delete search_actions[i];
+			delete action;
 		}
 		search_actions.clear();
 
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index 21f1863..b20abb7 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013, 2014, 2015, 2016, 2017, 2018, 2020 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013-2020 Graeme Gott <graeme at gottcode.org>
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -195,9 +195,9 @@ WhiskerMenu::Window::Window(Plugin* plugin) :
 	m_commands_box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
 	m_commands_spacer = gtk_label_new(NULL);
 	gtk_box_pack_start(m_commands_box, m_commands_spacer, true, true, 0);
-	for (int i = 0; i < 9; ++i)
+	for (auto command : m_commands_button)
 	{
-		gtk_box_pack_start(m_commands_box, m_commands_button[i], false, false, 0);
+		gtk_box_pack_start(m_commands_box, command, false, false, 0);
 	}
 
 	// Create box for packing username, commands, and resize widget
@@ -297,9 +297,9 @@ void WhiskerMenu::Window::hide()
 	unset_pressed_category();
 
 	// Hide command buttons to remove active border
-	for (int i = 0; i < 9; ++i)
+	for (auto command : m_commands_button)
 	{
-		gtk_widget_set_visible(m_commands_button[i], false);
+		gtk_widget_set_visible(command, false);
 	}
 
 	// Hide window
@@ -337,9 +337,9 @@ void WhiskerMenu::Window::show(const Position position)
 	m_profilepic->reset_tooltip();
 
 	// Make sure commands are valid and visible
-	for (int i = 0; i < Settings::CountCommands; ++i)
+	for (auto command : wm_settings->command)
 	{
-		wm_settings->command[i]->check();
+		command->check();
 	}
 
 	// Make sure recent item count is within max
@@ -548,11 +548,11 @@ void WhiskerMenu::Window::on_context_menu_destroyed()
 
 void WhiskerMenu::Window::set_categories(const std::vector<SectionButton*>& categories)
 {
-	SectionButton* button = m_recent_button;
-	for (std::vector<SectionButton*>::const_iterator i = categories.begin(), end = categories.end(); i != end; ++i)
+	SectionButton* last_button = m_recent_button;
+	for (auto button : categories)
 	{
-		(*i)->join_group(button);
-		button = *i;
+		button->join_group(last_button);
+		last_button = button;
 		gtk_box_pack_start(m_sidebar_buttons, button->get_widget(), false, false, 0);
 		g_signal_connect_slot<GtkToggleButton*>(button->get_widget(), "toggled", &Window::category_toggled, this);
 	}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list