void Category::insert_items(GtkListStore* model) { for (std::vector<Element*>::size_type i = 0, end = m_items.size(); i < end; ++i) { Element* element = m_items.at(i); if (element) { Launcher* launcher = static_cast<Launcher*>(element); gtk_list_store_insert_with_values(model, NULL, INT_MAX, LauncherView::COLUMN_ICON, launcher->get_icon(), LauncherView::COLUMN_TEXT, launcher->get_text(), LauncherView::COLUMN_TOOLTIP, launcher->get_tooltip(), LauncherView::COLUMN_LAUNCHER, launcher, -1); } else if ((i + 1) < end) { gtk_list_store_insert_with_values(model, NULL, INT_MAX, LauncherView::COLUMN_ICON, NULL, LauncherView::COLUMN_TEXT, NULL, LauncherView::COLUMN_TOOLTIP, NULL, LauncherView::COLUMN_LAUNCHER, NULL, -1); } } }
void Category::insert_items(GtkTreeStore* model, GtkTreeIter* parent, const gchar* fallback_icon) { for (std::vector<Element*>::size_type i = 0, end = m_items.size(); i < end; ++i) { Element* element = m_items.at(i); if (is_category(element)) { Category* category = static_cast<Category*>(element); if (category->empty()) { continue; } const gchar* icon = category->get_icon(); if (!gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), icon)) { icon = fallback_icon; } gchar* text = g_markup_escape_text(category->get_text(), -1); const gchar* tooltip = category->get_tooltip(); GtkTreeIter iter; gtk_tree_store_insert_with_values(model, &iter, parent, INT_MAX, LauncherView::COLUMN_ICON, icon, LauncherView::COLUMN_TEXT, text, LauncherView::COLUMN_TOOLTIP, tooltip, LauncherView::COLUMN_LAUNCHER, NULL, -1); g_free(text); category->insert_items(model, &iter, icon); } else if (element) { Launcher* launcher = static_cast<Launcher*>(element); gtk_tree_store_insert_with_values(model, NULL, parent, INT_MAX, LauncherView::COLUMN_ICON, launcher->get_icon(), LauncherView::COLUMN_TEXT, launcher->get_text(), LauncherView::COLUMN_TOOLTIP, launcher->get_tooltip(), LauncherView::COLUMN_LAUNCHER, launcher, -1); } else if ((i + 1) < end) { gtk_tree_store_insert_with_values(model, NULL, parent, INT_MAX, LauncherView::COLUMN_ICON, NULL, LauncherView::COLUMN_TEXT, NULL, LauncherView::COLUMN_TOOLTIP, NULL, LauncherView::COLUMN_LAUNCHER, NULL, -1); } } }