| 1 |
#include "part_browser_window.hpp" |
| 2 |
#include "util/util.hpp" |
| 3 |
#include "widgets/part_preview.hpp" |
| 4 |
#include "widgets/pool_browser_part.hpp" |
| 5 |
#include "widgets/pool_browser_parametric.hpp" |
| 6 |
#include "util/stock_info_provider.hpp" |
| 7 |
#include "preferences/preferences_provider.hpp" |
| 8 |
#include "util/win32_undef.hpp" |
| 9 |
#include "preferences/preferences.hpp" |
| 10 |
#include "util/gtk_util.hpp" |
| 11 |
#include "pool/pool_cache_status.hpp" |
| 12 |
|
| 13 |
namespace horizon { |
| 14 |
|
| 15 |
static void header_fun(Gtk::ListBoxRow *row, Gtk::ListBoxRow *before) |
| 16 |
{ |
| 17 |
if (before && !row->get_header()) { |
| 18 |
auto ret = Gtk::manage(new Gtk::Separator); |
| 19 |
row->set_header(*ret); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
class UUIDBox : public Gtk::Box { |
| 24 |
public: |
| 25 |
using Gtk::Box::Box; |
| 26 |
UUID uuid; |
| 27 |
}; |
| 28 |
|
| 29 |
PartBrowserWindow::PartBrowserWindow(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &x, |
| 30 |
const std::string &pool_path, std::deque<UUID> &favs) |
| 31 |
: Gtk::Window(cobject), pool(pool_path), pool_parametric(pool_path), favorites(favs), |
| 32 |
state_store(this, "part-browser") |
| 33 |
{ |
| 34 |
x->get_widget("notebook", notebook); |
| 35 |
x->get_widget("menu1", add_search_menu); |
| 36 |
x->get_widget("place_part_button", place_part_button); |
| 37 |
x->get_widget("assign_part_button", assign_part_button); |
| 38 |
x->get_widget("fav_button", fav_button); |
| 39 |
x->get_widget("lb_favorites", lb_favorites); |
| 40 |
x->get_widget("lb_recent", lb_recent); |
| 41 |
x->get_widget("out_of_date_info_bar", out_of_date_info_bar); |
| 42 |
x->get_widget("entity_label", entity_label); |
| 43 |
x->get_widget("entity_info_bar", entity_info_bar); |
| 44 |
info_bar_hide(out_of_date_info_bar); |
| 45 |
info_bar_hide(entity_info_bar); |
| 46 |
|
| 47 |
lb_favorites->set_header_func(sigc::ptr_fun(header_fun)); |
| 48 |
lb_recent->set_header_func(sigc::ptr_fun(header_fun)); |
| 49 |
lb_favorites->signal_row_selected().connect(sigc::mem_fun(*this, &PartBrowserWindow::handle_favorites_selected)); |
| 50 |
lb_favorites->signal_row_activated().connect(sigc::mem_fun(*this, &PartBrowserWindow::handle_favorites_activated)); |
| 51 |
lb_recent->signal_row_selected().connect(sigc::mem_fun(*this, &PartBrowserWindow::handle_favorites_selected)); |
| 52 |
lb_recent->signal_row_activated().connect(sigc::mem_fun(*this, &PartBrowserWindow::handle_favorites_activated)); |
| 53 |
|
| 54 |
{ |
| 55 |
Gtk::Button *pool_cache_button; |
| 56 |
x->get_widget("pool_cache_button", pool_cache_button); |
| 57 |
pool_cache_button->signal_clicked().connect( |
| 58 |
[this] { s_signal_open_pool_cache_window.emit(items_out_of_date); }); |
| 59 |
} |
| 60 |
|
| 61 |
{ |
| 62 |
auto la = Gtk::manage(new Gtk::MenuItem("MPN Search")); |
| 63 |
la->signal_activate().connect([this] { |
| 64 |
auto ch = add_search(); |
| 65 |
ch->search_once(); |
| 66 |
}); |
| 67 |
la->show(); |
| 68 |
add_search_menu->append(*la); |
| 69 |
} |
| 70 |
for (const auto &it : pool_parametric.get_tables()) { |
| 71 |
auto la = Gtk::manage(new Gtk::MenuItem(it.second.display_name)); |
| 72 |
std::string table_name = it.first; |
| 73 |
la->signal_activate().connect([this, table_name] { |
| 74 |
auto ch = add_search_parametric(table_name); |
| 75 |
ch->search_once(); |
| 76 |
}); |
| 77 |
la->show(); |
| 78 |
add_search_menu->append(*la); |
| 79 |
} |
| 80 |
fav_toggled_conn = |
| 81 |
fav_button->signal_toggled().connect(sigc::mem_fun(*this, &PartBrowserWindow::handle_fav_toggled)); |
| 82 |
place_part_button->signal_clicked().connect(sigc::mem_fun(*this, &PartBrowserWindow::handle_place_part)); |
| 83 |
assign_part_button->signal_clicked().connect(sigc::mem_fun(*this, &PartBrowserWindow::handle_assign_part)); |
| 84 |
|
| 85 |
preview = Gtk::manage(new PartPreview(pool, false, "part_browser")); |
| 86 |
{ |
| 87 |
Gtk::Box *box; |
| 88 |
x->get_widget("box", box); |
| 89 |
box->pack_start(*preview, true, true, 0); |
| 90 |
} |
| 91 |
preview->show(); |
| 92 |
|
| 93 |
update_part_current(); |
| 94 |
update_favorites(); |
| 95 |
|
| 96 |
auto ch_search = add_search(); |
| 97 |
for (const auto &it : pool_parametric.get_tables()) { |
| 98 |
add_search_parametric(it.first); |
| 99 |
} |
| 100 |
notebook->set_current_page(notebook->page_num(*ch_search)); |
| 101 |
signal_show().connect(sigc::track_obj([ch_search] { ch_search->search_once(); }, *ch_search)); |
| 102 |
signal_show().connect([this] { |
| 103 |
if (needs_reload) { |
| 104 |
needs_reload = false; |
| 105 |
reload(); |
| 106 |
} |
| 107 |
}); |
| 108 |
|
| 109 |
notebook->signal_switch_page().connect(sigc::mem_fun(*this, &PartBrowserWindow::handle_switch_page)); |
| 110 |
|
| 111 |
entity_info_bar->signal_response().connect([this](auto r) { set_entity({}, ""); }); |
| 112 |
|
| 113 |
{ |
| 114 |
Gtk::Paned *paned; |
| 115 |
GET_WIDGET(paned); |
| 116 |
paned_state_store.emplace(paned, "part_browser"); |
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
void PartBrowserWindow::reload() |
| 121 |
{ |
| 122 |
pool.clear(); |
| 123 |
auto current_page = notebook->get_nth_page(notebook->get_current_page()); |
| 124 |
for (auto page : notebook->get_children()) { |
| 125 |
if (auto ch = dynamic_cast<PoolBrowser *>(page)) { |
| 126 |
ch->reload_pools(); |
| 127 |
if (current_page == ch) |
| 128 |
ch->search(); |
| 129 |
else |
| 130 |
ch->clear_search_once(); |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
void PartBrowserWindow::pool_updated(const std::string &p) |
| 136 |
{ |
| 137 |
for (const auto &[it_path, it_uu] : pool.get_actually_included_pools(true)) { |
| 138 |
if (it_path == p) { |
| 139 |
if (!is_visible()) { |
| 140 |
needs_reload = true; |
| 141 |
return; |
| 142 |
} |
| 143 |
|
| 144 |
pool_updated_conn.disconnect(); |
| 145 |
// debounce since we might receive multiple updated signals in short succession |
| 146 |
pool_updated_conn = Glib::signal_timeout().connect(sigc::track_obj( |
| 147 |
[this] { |
| 148 |
reload(); |
| 149 |
return false; |
| 150 |
}, |
| 151 |
*this), |
| 152 |
500); |
| 153 |
|
| 154 |
return; |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
void PartBrowserWindow::handle_favorites_selected(Gtk::ListBoxRow *row) |
| 160 |
{ |
| 161 |
update_part_current(); |
| 162 |
} |
| 163 |
|
| 164 |
void PartBrowserWindow::handle_favorites_activated(Gtk::ListBoxRow *row) |
| 165 |
{ |
| 166 |
handle_activate_part(); |
| 167 |
} |
| 168 |
|
| 169 |
void PartBrowserWindow::handle_place_part() |
| 170 |
{ |
| 171 |
if (part_current) { |
| 172 |
s_signal_place_part.emit(part_current); |
| 173 |
set_entity(entity_uuid, ""); // clear hint |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
void PartBrowserWindow::handle_assign_part() |
| 178 |
{ |
| 179 |
if (part_current) { |
| 180 |
s_signal_assign_part.emit(part_current); |
| 181 |
set_entity(entity_uuid, ""); // clear hint |
| 182 |
} |
| 183 |
} |
| 184 |
|
| 185 |
void PartBrowserWindow::handle_activate_part() |
| 186 |
{ |
| 187 |
if (entity_uuid) |
| 188 |
handle_assign_part(); |
| 189 |
else |
| 190 |
handle_place_part(); |
| 191 |
} |
| 192 |
|
| 193 |
void PartBrowserWindow::handle_fav_toggled() |
| 194 |
{ |
| 195 |
if (part_current) { |
| 196 |
if (fav_button->get_active()) { |
| 197 |
assert(std::count(favorites.begin(), favorites.end(), part_current) == 0); |
| 198 |
favorites.push_front(part_current); |
| 199 |
} |
| 200 |
else { |
| 201 |
assert(std::count(favorites.begin(), favorites.end(), part_current) == 1); |
| 202 |
auto it = std::find(favorites.begin(), favorites.end(), part_current); |
| 203 |
favorites.erase(it); |
| 204 |
} |
| 205 |
update_favorites(); |
| 206 |
} |
| 207 |
} |
| 208 |
|
| 209 |
void PartBrowserWindow::handle_switch_page(Gtk::Widget *page, guint index) |
| 210 |
{ |
| 211 |
update_part_current(); |
| 212 |
if (notebook->in_destruction()) |
| 213 |
return; |
| 214 |
if (auto ch = dynamic_cast<PoolBrowser *>(page)) |
| 215 |
ch->search_once(); |
| 216 |
} |
| 217 |
|
| 218 |
void PartBrowserWindow::placed_part(const UUID &uu) |
| 219 |
{ |
| 220 |
auto ncount = std::count(recents.begin(), recents.end(), uu); |
| 221 |
assert(ncount < 2); |
| 222 |
if (ncount) { |
| 223 |
auto it = std::find(recents.begin(), recents.end(), uu); |
| 224 |
recents.erase(it); |
| 225 |
} |
| 226 |
recents.push_front(uu); |
| 227 |
update_recents(); |
| 228 |
} |
| 229 |
|
| 230 |
void PartBrowserWindow::go_to_part(const UUID &uu) |
| 231 |
{ |
| 232 |
auto page = notebook->get_nth_page(notebook->get_current_page()); |
| 233 |
auto br = dynamic_cast<PoolBrowserPart *>(page); |
| 234 |
if (br) |
| 235 |
br->go_to(uu); |
| 236 |
else { |
| 237 |
auto br_new = add_search(uu); |
| 238 |
br_new->search_once(); |
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
void PartBrowserWindow::update_favorites() |
| 243 |
{ |
| 244 |
auto children = lb_favorites->get_children(); |
| 245 |
for (auto it : children) { |
| 246 |
delete it; |
| 247 |
} |
| 248 |
|
| 249 |
for (const auto &it : favorites) { |
| 250 |
const Part *part = nullptr; |
| 251 |
try { |
| 252 |
part = pool.get_part(it).get(); |
| 253 |
} |
| 254 |
catch (const std::runtime_error &e) { |
| 255 |
part = nullptr; |
| 256 |
} |
| 257 |
if (part) { |
| 258 |
auto box = Gtk::manage(new UUIDBox(Gtk::ORIENTATION_VERTICAL, 4)); |
| 259 |
box->uuid = it; |
| 260 |
auto la_MPN = Gtk::manage(new Gtk::Label()); |
| 261 |
la_MPN->set_xalign(0); |
| 262 |
la_MPN->set_markup("<b>" + part->get_MPN() + "</b>"); |
| 263 |
box->pack_start(*la_MPN, false, false, 0); |
| 264 |
|
| 265 |
auto la_mfr = Gtk::manage(new Gtk::Label()); |
| 266 |
la_mfr->set_xalign(0); |
| 267 |
la_mfr->set_text(part->get_manufacturer()); |
| 268 |
box->pack_start(*la_mfr, false, false, 0); |
| 269 |
|
| 270 |
box->set_margin_top(4); |
| 271 |
box->set_margin_bottom(4); |
| 272 |
box->set_margin_start(4); |
| 273 |
box->set_margin_end(4); |
| 274 |
lb_favorites->append(*box); |
| 275 |
box->show_all(); |
| 276 |
} |
| 277 |
} |
| 278 |
} |
| 279 |
|
| 280 |
void PartBrowserWindow::update_recents() |
| 281 |
{ |
| 282 |
auto children = lb_recent->get_children(); |
| 283 |
for (auto it : children) { |
| 284 |
delete it; |
| 285 |
} |
| 286 |
|
| 287 |
for (const auto &it : recents) { |
| 288 |
auto part = pool.get_part(it); |
| 289 |
if (part) { |
| 290 |
auto box = Gtk::manage(new UUIDBox(Gtk::ORIENTATION_VERTICAL, 4)); |
| 291 |
box->uuid = it; |
| 292 |
auto la_MPN = Gtk::manage(new Gtk::Label()); |
| 293 |
la_MPN->set_xalign(0); |
| 294 |
la_MPN->set_markup("<b>" + part->get_MPN() + "</b>"); |
| 295 |
box->pack_start(*la_MPN, false, false, 0); |
| 296 |
|
| 297 |
auto la_mfr = Gtk::manage(new Gtk::Label()); |
| 298 |
la_mfr->set_xalign(0); |
| 299 |
la_mfr->set_text(part->get_manufacturer()); |
| 300 |
box->pack_start(*la_mfr, false, false, 0); |
| 301 |
|
| 302 |
box->set_margin_top(4); |
| 303 |
box->set_margin_bottom(4); |
| 304 |
box->set_margin_start(4); |
| 305 |
box->set_margin_end(4); |
| 306 |
lb_recent->append(*box); |
| 307 |
box->show_all(); |
| 308 |
} |
| 309 |
} |
| 310 |
} |
| 311 |
|
| 312 |
void PartBrowserWindow::update_part_current() |
| 313 |
{ |
| 314 |
if (in_destruction()) |
| 315 |
return; |
| 316 |
auto page = notebook->get_nth_page(notebook->get_current_page()); |
| 317 |
SelectionProvider *prv = nullptr; |
| 318 |
prv = dynamic_cast<SelectionProvider *>(page); |
| 319 |
|
| 320 |
if (prv) { |
| 321 |
part_current = prv->get_selected(); |
| 322 |
} |
| 323 |
else { |
| 324 |
if (page->get_name() == "fav") { |
| 325 |
auto row = lb_favorites->get_selected_row(); |
| 326 |
if (row) { |
| 327 |
part_current = dynamic_cast<UUIDBox *>(row->get_child())->uuid; |
| 328 |
} |
| 329 |
else { |
| 330 |
part_current = UUID(); |
| 331 |
} |
| 332 |
} |
| 333 |
else if (page->get_name() == "recent") { |
| 334 |
auto row = lb_recent->get_selected_row(); |
| 335 |
if (row) { |
| 336 |
part_current = dynamic_cast<UUIDBox *>(row->get_child())->uuid; |
| 337 |
} |
| 338 |
else { |
| 339 |
part_current = UUID(); |
| 340 |
} |
| 341 |
} |
| 342 |
else { |
| 343 |
part_current = UUID(); |
| 344 |
} |
| 345 |
} |
| 346 |
auto ncount = std::count(favorites.begin(), favorites.end(), part_current); |
| 347 |
assert(ncount < 2); |
| 348 |
fav_toggled_conn.block(); |
| 349 |
fav_button->set_active(ncount > 0); |
| 350 |
fav_toggled_conn.unblock(); |
| 351 |
|
| 352 |
place_part_button->set_sensitive(part_current); |
| 353 |
assign_part_button->set_sensitive(part_current && can_assign); |
| 354 |
fav_button->set_sensitive(part_current); |
| 355 |
if (part_current) { |
| 356 |
auto part = pool.get_part(part_current).get(); |
| 357 |
preview->load(part); |
| 358 |
} |
| 359 |
else { |
| 360 |
preview->load(nullptr); |
| 361 |
} |
| 362 |
update_out_of_date_info_bar(); |
| 363 |
} |
| 364 |
|
| 365 |
void PartBrowserWindow::set_pool_cache_status(const PoolCacheStatus &st) |
| 366 |
{ |
| 367 |
pool_cache_status = &st; |
| 368 |
update_out_of_date_info_bar(); |
| 369 |
} |
| 370 |
|
| 371 |
void PartBrowserWindow::update_out_of_date_info_bar() |
| 372 |
{ |
| 373 |
info_bar_hide(out_of_date_info_bar); |
| 374 |
items_out_of_date.clear(); |
| 375 |
if (!part_current || !pool_cache_status) { |
| 376 |
return; |
| 377 |
} |
| 378 |
SQLite::Query q(pool.db, |
| 379 |
"WITH RECURSIVE deps(typex, uuidx) AS " |
| 380 |
"( SELECT 'part', ? UNION " |
| 381 |
"SELECT dep_type, dep_uuid FROM dependencies, deps " |
| 382 |
"WHERE dependencies.type = deps.typex AND dependencies.uuid = deps.uuidx) " |
| 383 |
"SELECT * FROM deps UNION SELECT 'symbol', symbols.uuid FROM symbols " |
| 384 |
"INNER JOIN deps ON (symbols.unit = uuidx AND typex = 'unit')"); |
| 385 |
q.bind(1, part_current); |
| 386 |
while (q.step()) { |
| 387 |
auto type = q.get<ObjectType>(0); |
| 388 |
UUID uu(q.get<std::string>(1)); |
| 389 |
|
| 390 |
auto r = std::find_if(pool_cache_status->items.begin(), pool_cache_status->items.end(), |
| 391 |
[type, uu](const PoolCacheStatus::Item &it) { return it.type == type && it.uuid == uu; }); |
| 392 |
if (r != pool_cache_status->items.end()) { |
| 393 |
if (r->state == PoolCacheStatus::Item::State::OUT_OF_DATE) { |
| 394 |
items_out_of_date.emplace(type, uu); |
| 395 |
} |
| 396 |
} |
| 397 |
} |
| 398 |
if (items_out_of_date.size()) { |
| 399 |
info_bar_show(out_of_date_info_bar); |
| 400 |
} |
| 401 |
} |
| 402 |
|
| 403 |
void PartBrowserWindow::set_can_assign(bool v) |
| 404 |
{ |
| 405 |
can_assign = v; |
| 406 |
assign_part_button->set_sensitive(part_current && can_assign); |
| 407 |
} |
| 408 |
|
| 409 |
PoolBrowserPart *PartBrowserWindow::add_search(const UUID &part) |
| 410 |
{ |
| 411 |
auto ch = Gtk::manage(new PoolBrowserPart(pool, UUID(), "part_browser")); |
| 412 |
ch->set_include_base_parts(false); |
| 413 |
ch->set_entity_uuid(entity_uuid); |
| 414 |
if (auto prv = StockInfoProvider::create(pool.get_base_path())) { |
| 415 |
ch->add_stock_info_provider(std::move(prv)); |
| 416 |
} |
| 417 |
ch->get_style_context()->add_class("background"); |
| 418 |
auto tab_label = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0)); |
| 419 |
auto la = Gtk::manage(new Gtk::Label("MPN Search")); |
| 420 |
la->set_xalign(1); |
| 421 |
auto close_button = Gtk::manage(new Gtk::Button()); |
| 422 |
close_button->set_relief(Gtk::RELIEF_NONE); |
| 423 |
close_button->set_image_from_icon_name("window-close-symbolic"); |
| 424 |
close_button->signal_clicked().connect([ch] { delete ch; }); |
| 425 |
tab_label->pack_start(*close_button, false, false, 0); |
| 426 |
tab_label->pack_start(*la, true, true, 0); |
| 427 |
ch->show_all(); |
| 428 |
tab_label->show_all(); |
| 429 |
auto index = notebook->append_page(*ch, *tab_label); |
| 430 |
notebook->set_current_page(index); |
| 431 |
|
| 432 |
search_views.insert(ch); |
| 433 |
ch->signal_selected().connect(sigc::mem_fun(*this, &PartBrowserWindow::update_part_current)); |
| 434 |
ch->signal_activated().connect(sigc::mem_fun(*this, &PartBrowserWindow::handle_activate_part)); |
| 435 |
if (part) |
| 436 |
ch->go_to(part); |
| 437 |
ch->focus_search(); |
| 438 |
return ch; |
| 439 |
} |
| 440 |
|
| 441 |
PoolBrowserParametric *PartBrowserWindow::add_search_parametric(const std::string &table_name) |
| 442 |
{ |
| 443 |
auto ch = Gtk::manage(new PoolBrowserParametric(pool, pool_parametric, table_name, "part_browser")); |
| 444 |
if (auto prv = StockInfoProvider::create(pool.get_base_path())) { |
| 445 |
ch->add_stock_info_provider(std::move(prv)); |
| 446 |
} |
| 447 |
ch->add_copy_name_context_menu_item(); |
| 448 |
ch->set_entity_uuid(entity_uuid); |
| 449 |
ch->get_style_context()->add_class("background"); |
| 450 |
auto tab_label = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0)); |
| 451 |
auto la = Gtk::manage(new Gtk::Label(pool_parametric.get_tables().at(table_name).display_name)); |
| 452 |
la->set_xalign(1); |
| 453 |
auto close_button = Gtk::manage(new Gtk::Button()); |
| 454 |
close_button->set_relief(Gtk::RELIEF_NONE); |
| 455 |
close_button->set_image_from_icon_name("window-close-symbolic"); |
| 456 |
close_button->signal_clicked().connect([ch] { delete ch; }); |
| 457 |
tab_label->pack_start(*close_button, false, false, 0); |
| 458 |
tab_label->pack_start(*la, true, true, 0); |
| 459 |
ch->show_all(); |
| 460 |
tab_label->show_all(); |
| 461 |
auto index = notebook->append_page(*ch, *tab_label); |
| 462 |
notebook->set_current_page(index); |
| 463 |
|
| 464 |
search_views.insert(ch); |
| 465 |
ch->signal_selected().connect(sigc::mem_fun(*this, &PartBrowserWindow::update_part_current)); |
| 466 |
ch->signal_activated().connect(sigc::mem_fun(*this, &PartBrowserWindow::handle_activate_part)); |
| 467 |
|
| 468 |
return ch; |
| 469 |
} |
| 470 |
|
| 471 |
void PartBrowserWindow::focus_search() |
| 472 |
{ |
| 473 |
auto page = notebook->get_nth_page(notebook->get_current_page()); |
| 474 |
if (auto br = dynamic_cast<PoolBrowserPart *>(page)) { |
| 475 |
br->focus_search(); |
| 476 |
} |
| 477 |
} |
| 478 |
|
| 479 |
void PartBrowserWindow::set_entity(const UUID &uu, const std::string &hint) |
| 480 |
{ |
| 481 |
entity_uuid = uu; |
| 482 |
if (entity_uuid) { |
| 483 |
auto entity = pool.get_entity(entity_uuid); |
| 484 |
std::string label = "Only showing parts for Entity “" + entity->name + "”"; |
| 485 |
if (hint.size()) |
| 486 |
label += ", " + hint; |
| 487 |
entity_label->set_text(label); |
| 488 |
info_bar_show(entity_info_bar); |
| 489 |
place_part_button->get_style_context()->remove_class("suggested-action"); |
| 490 |
assign_part_button->get_style_context()->add_class("suggested-action"); |
| 491 |
} |
| 492 |
else { |
| 493 |
info_bar_hide(entity_info_bar); |
| 494 |
assign_part_button->get_style_context()->remove_class("suggested-action"); |
| 495 |
place_part_button->get_style_context()->add_class("suggested-action"); |
| 496 |
} |
| 497 |
for (auto page : notebook->get_children()) { |
| 498 |
if (auto ch = dynamic_cast<PoolBrowserPart *>(page)) { |
| 499 |
ch->set_entity_uuid(entity_uuid); |
| 500 |
} |
| 501 |
else if (auto ch_para = dynamic_cast<PoolBrowserParametric *>(page)) { |
| 502 |
ch_para->set_entity_uuid(entity_uuid); |
| 503 |
} |
| 504 |
} |
| 505 |
if (auto ch = dynamic_cast<PoolBrowser *>(notebook->get_nth_page(notebook->get_current_page()))) { |
| 506 |
ch->search_once(); |
| 507 |
} |
| 508 |
} |
| 509 |
|
| 510 |
PartBrowserWindow *PartBrowserWindow::create(Gtk::Window *p, const std::string &pool_path, std::deque<UUID> &favs) |
| 511 |
{ |
| 512 |
PartBrowserWindow *w; |
| 513 |
Glib::RefPtr<Gtk::Builder> x = Gtk::Builder::create(); |
| 514 |
x->add_from_resource( |
| 515 |
"/org/horizon-eda/horizon/pool-prj-mgr/prj-mgr/part_browser/" |
| 516 |
"part_browser.ui"); |
| 517 |
x->get_widget_derived("window", w, pool_path, favs); |
| 518 |
|
| 519 |
return w; |
| 520 |
} |
| 521 |
} // namespace horizon |