From c6a51c24e7f81171740883f53a0cea31865874cf Mon Sep 17 00:00:00 2001 From: Michael Pfeiffer Date: Mon, 1 Nov 2010 19:38:02 +0000 Subject: [PATCH] * Fixed bug. If a transport add-on returned an empty port list, the transport add-on could be selected, altough later using it would fail. In that case now a sub menu item is created containing the text "No printer found!" and selecting it won't work. TODO the contents of the sub menu should be refreshed before the sub menu is opened, so that only currently connected and turned on printers are shown. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39258 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/print/AddPrinterDialog.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/preferences/print/AddPrinterDialog.cpp b/src/preferences/print/AddPrinterDialog.cpp index 160f6c8375..a32b2d0291 100644 --- a/src/preferences/print/AddPrinterDialog.cpp +++ b/src/preferences/print/AddPrinterDialog.cpp @@ -364,25 +364,37 @@ AddPrinterDialog::_FillTransportMenu(BMenu* menu) // Now get ports... BString portId, portName; + int32 error; msg.MakeEmpty(); msg.what = B_GET_PROPERTY; msg.AddSpecifier("Ports"); if (transport.SendMessage(&msg, &reply) != B_OK || - reply.FindString("port_id", &portId) != B_OK) { - // Can't find ports; so just show transport item, no menu + reply.FindInt32("error", &error) != B_OK || + error != B_OK) { + // Transport does not provide list of ports BMessage* menuMsg = new BMessage(kTransportSelectedMsg); menuMsg->AddString("name", transportName); menu->AddItem(new BMenuItem(transportName.String(), menuMsg)); continue; } - // We have at least one port; so create submenu + // Create submenu BMenu* transportMenu = new BMenu(transportName.String()); menu->AddItem(transportMenu); transportMenu->SetRadioMode(true); menu->ItemAt(menu->IndexOf(transportMenu))-> SetMessage(new BMessage(kTransportSelectedMsg)); + + if (reply.FindString("port_id", &portId) != B_OK) { + // Show error message in submenu + BMessage* portMsg = new BMessage(kTransportSelectedMsg); + transportMenu->AddItem(new BMenuItem( + B_TRANSLATE("No printer found!"), portMsg)); + continue; + } + + // Add ports to submenu for (int32 i = 0; reply.FindString("port_id", i, &portId) == B_OK; i++) { if (reply.FindString("port_name", i, &portName) != B_OK