// fetch number of unique names on the slot list int getNumUniquePBNames(struct pbSlot *sl = NULL) { if (!sl) return 0; if (sl->pb->CountItems() == 0) return 0; // clone slot list BList *l = new BList(*(sl->pb)); // sort slot list by name l->SortItems(&pbNumCompareByName); int j = l->CountItems(); int n = 1; struct pbNum *c = (struct pbNum*)l->ItemAt(0); BString *last = ((union pbVal*)c->attr->ItemAt(1))->text; BString *cur; // go through the list and ++ on each change for (int i=1;i<j;i++) { c = (struct pbNum*)l->ItemAt(i); cur = ((union pbVal*)c->attr->ItemAt(1))->text; if (cur->Compare(last->String()) != 0) { last = cur; n++; } } delete l; return n; }
void HTGTimeLineView::addUnhandledTweets() { if(unhandledList->IsEmpty()) return; BList *newList = new BList(); newList->AddList(unhandledList); unhandledList->MakeEmpty(); HTGTweetItem *currentItem; while(!listView->IsEmpty()) { currentItem = (HTGTweetItem *)listView->FirstItem(); listView->RemoveItem(currentItem); if(newList->CountItems() < 30) {//Only allow 30 tweets to be displayed at once... for now. newList->AddItem(currentItem); currentItem->ClearView(); //No need to keep everything in memory //if the view is at the bottom of the scrollbar (invisible) } else delete currentItem; } /*Sort tweets by date*/ newList->SortItems(*HTGTweetItem::sortByDateFunc); /*Add our new list*/ listView->AddList(newList); /*Clean up*/ unhandledList->MakeEmpty(); }
// Function taken from Haiku ShowImage, // function originally written by Michael Pfeiffer bool SlideShowSaver::FindNextImage(entry_ref *in_current, entry_ref *out_image, bool next, bool rewind) { // ASSERT(next || !rewind); BEntry curImage(in_current); entry_ref entry, *ref; BDirectory parent; BList entries; bool found = false; int32 cur; if (curImage.GetParent(&parent) != B_OK) return false; while (parent.GetNextRef(&entry) == B_OK) { if (entry != *in_current) { entries.AddItem(new entry_ref(entry)); } else { // insert current ref, so we can find it easily after sorting entries.AddItem(in_current); } } entries.SortItems(CompareEntries); cur = entries.IndexOf(in_current); // ASSERT(cur >= 0); // remove it so FreeEntries() does not delete it entries.RemoveItem(in_current); if (next) { // find the next image in the list if (rewind) cur = 0; // start with first for (; (ref = (entry_ref*)entries.ItemAt(cur)) != NULL; cur ++) { if (IsImage(ref)) { found = true; *out_image = (const entry_ref)*ref; break; } } } else { // find the previous image in the list cur --; for (; cur >= 0; cur --) { ref = (entry_ref*)entries.ItemAt(cur); if (IsImage(ref)) { found = true; *out_image = (const entry_ref)*ref; break; } } } FreeEntries(&entries); return found; }
void Accounts::Create(BListView *listView, BView *configView) { gListView = listView; gConfigView = configView; BList inbound,outbound; GetInboundMailChains(&inbound); GetOutboundMailChains(&outbound); // create inbound accounts and assign matching outbound chains for (int32 i = inbound.CountItems();i-- > 0;) { BMailChain *inChain = (BMailChain *)inbound.ItemAt(i); BMailChain *outChain = NULL; for (int32 j = outbound.CountItems();j-- > 0;) { outChain = (BMailChain *)outbound.ItemAt(j); if (!strcmp(inChain->Name(),outChain->Name())) break; outChain = NULL; } gAccounts.AddItem(new Account(inChain,outChain)); inbound.RemoveItem(i); if (outChain) outbound.RemoveItem(outChain); } // create remaining outbound only accounts for (int32 i = outbound.CountItems();i-- > 0;) { BMailChain *outChain = (BMailChain *)outbound.ItemAt(i); gAccounts.AddItem(new Account(NULL,outChain)); outbound.RemoveItem(i); } // sort the list alphabetically gAccounts.SortItems(Accounts::Compare); for (int32 i = 0;Account *account = (Account *)gAccounts.ItemAt(i);i++) account->AddToListView(); }
//! newExtensionsList contains all the entries (char*) which are to be added. status_t merge_extensions(BMimeType& type, const BList& newExtensionsList, const char* removeExtension) { BMessage extensions; status_t status = type.GetFileExtensions(&extensions); if (status < B_OK) return status; // replace the entry, and remove any equivalent entries BList mergedList; mergedList.AddList(&newExtensionsList); int32 originalCount = mergedList.CountItems(); const char* extension; for (int32 i = 0; extensions.FindString("extensions", i, &extension) == B_OK; i++) { for (int32 j = originalCount; j-- > 0;) { if (!strcmp((const char*)mergedList.ItemAt(j), extension)) { // Do not add this old item again, since it's already // there. mergedList.RemoveItem(j); originalCount--; } } // The item will be added behind "originalCount", so we cannot // remove it accidentally in the next iterations, it's is added // for good. if (removeExtension == NULL || strcmp(removeExtension, extension)) mergedList.AddItem((void *)extension); } mergedList.SortItems(compare_extensions); // Copy them to a new message (their memory is still part of the // original BMessage) BMessage newExtensions; for (int32 i = 0; i < mergedList.CountItems(); i++) { newExtensions.AddString("extensions", (const char*)mergedList.ItemAt(i)); } return type.SetFileExtensions(&newExtensions); }
/*********************************************************** * Build ***********************************************************/ void AddOnMenu::Build() { // Build add addons menus if(!fPath.Path()) return; BDirectory dir(fPath.Path()); entry_ref ref; BEntry entry; BList itemList; itemList.MakeEmpty(); char name[B_FILE_NAME_LENGTH]; char shortcut = 0; BBitmap *bitmap(NULL); while(dir.GetNextEntry(&entry,true) == B_OK) { if(entry.IsFile() && entry.GetRef(&ref) == B_OK) { shortcut = 0; bitmap = NULL; BMessage *msg = new BMessage(fWhat); msg->AddRef("refs",&ref); // make name and shortcut int32 nameLen = ::strlen(ref.name); ::strcpy(name,ref.name); if(name[nameLen-2] == '-') { shortcut = name[nameLen-1]; name[nameLen-2] = '\0'; } if(fUseIcon) bitmap = GetIcon(ref); itemList.AddItem(new IconMenuItem(name,msg,shortcut,0,bitmap)); } } // sort items itemList.SortItems(SortItems); int32 count = itemList.CountItems(); for(int32 i = 0;i < count;i++) AddItem((IconMenuItem*)itemList.ItemAt(i)); }
void BootPromptWindow::_PopulateKeymaps() { // Get the name of the current keymap, so we can mark the correct entry // in the list view. BString currentName; entry_ref currentRef; if (_GetCurrentKeymapRef(currentRef) == B_OK) { BNode node(¤tRef); node.ReadAttrString("keymap:name", ¤tName); } // TODO: common keymaps! BPath path; if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) != B_OK || path.Append("Keymaps") != B_OK) { return; } // US-International is the default keymap, if we could not found a // matching one BString usInternational("US-International"); // Populate the menu BDirectory directory; if (directory.SetTo(path.Path()) == B_OK) { entry_ref ref; BList itemsList; while (directory.GetNextRef(&ref) == B_OK) { BMessage* message = new BMessage(MSG_KEYMAP_SELECTED); message->AddRef("ref", &ref); BMenuItem* item = new BMenuItem(ref.name, message); itemsList.AddItem(item); if (currentName == ref.name) item->SetMarked(true); if (usInternational == ref.name) fDefaultKeymapItem = item; } itemsList.SortItems(compare_void_menu_items); fKeymapsMenuField->Menu()->AddList(&itemsList, 0); } }
void InstallerWindow::_PublishPackages() { fPackagesView->Clean(); PartitionMenuItem *item = (PartitionMenuItem *)fSrcMenu->FindMarked(); if (!item) return; BPath directory; BDiskDeviceRoster roster; BDiskDevice device; BPartition *partition; if (roster.GetPartitionWithID(item->ID(), &device, &partition) == B_OK) { if (partition->GetMountPoint(&directory) != B_OK) return; } else if (roster.GetDeviceWithID(item->ID(), &device) == B_OK) { if (device.GetMountPoint(&directory) != B_OK) return; } else return; // shouldn't happen directory.Append(PACKAGES_DIRECTORY); BDirectory dir(directory.Path()); if (dir.InitCheck() != B_OK) return; BEntry packageEntry; BList packages; while (dir.GetNextEntry(&packageEntry) == B_OK) { Package* package = Package::PackageFromEntry(packageEntry); if (package != NULL) packages.AddItem(package); } packages.SortItems(_ComparePackages); fPackagesView->AddPackages(packages, new BMessage(PACKAGE_CHECKBOX)); PostMessage(PACKAGE_CHECKBOX); }
void TExpandoMenuBar::AttachedToWindow() { BMessenger self(this); BList teamList; TBarApp::Subscribe(self, &teamList); float width = fVertical ? Frame().Width() : kMinimumWindowWidth; float height = -1.0f; // top or bottom mode, add be menu and sep for menubar tracking consistency if (!fVertical) { TBeMenu *beMenu = new TBeMenu(fBarView); TBarWindow::SetBeMenu(beMenu); fBeMenuItem = new TBarMenuTitle(kBeMenuWidth, Frame().Height(), AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_BeLogoIcon), beMenu, true); AddItem(fBeMenuItem); fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical); AddItem(fSeparatorItem); fSeparatorItem->SetEnabled(false); fFirstApp = 2; } else { fBeMenuItem = NULL; fSeparatorItem = NULL; } desk_settings *settings = ((TBarApp *)be_app)->Settings(); if (settings->sortRunningApps) teamList.SortItems(CompareByName); int32 count = teamList.CountItems(); for (int32 i = 0; i < count; i++) { BarTeamInfo *barInfo = (BarTeamInfo *)teamList.ItemAt(i); if ((barInfo->flags & B_BACKGROUND_APP) == 0 && strcasecmp(barInfo->sig, TASK_BAR_MIME_SIG) != 0) { if ((settings->trackerAlwaysFirst) && (strcmp(barInfo->sig, kTrackerSignature)) == 0) { AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon, barInfo->name, barInfo->sig, width, height, fDrawLabel, fVertical), fFirstApp); } else { AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon, barInfo->name, barInfo->sig, width, height, fDrawLabel, fVertical)); } barInfo->teams = NULL; barInfo->icon = NULL; barInfo->name = NULL; barInfo->sig = NULL; } delete barInfo; } BMenuBar::AttachedToWindow(); if (fVertical) { sDoMonitor = true; sMonThread = spawn_thread(monitor_team_windows, "Expando Window Watcher", B_LOW_PRIORITY, this); resume_thread(sMonThread); } }
BView* AboutView::_CreateCreditsView() { // Begin construction of the credits view fCreditsView = new HyperTextView("credits"); fCreditsView->SetFlags(fCreditsView->Flags() | B_FRAME_EVENTS); fCreditsView->SetStylable(true); fCreditsView->MakeEditable(false); fCreditsView->SetWordWrap(true); fCreditsView->SetInsets(5, 5, 5, 5); BScrollView* creditsScroller = new BScrollView("creditsScroller", fCreditsView, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_PLAIN_BORDER); // Haiku copyright BFont font(be_bold_font); font.SetSize(font.Size() + 4); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen); fCreditsView->Insert("Haiku\n"); char string[1024]; time_t time = ::time(NULL); struct tm* tm = localtime(&time); int32 year = tm->tm_year + 1900; if (year < 2008) year = 2008; snprintf(string, sizeof(string), COPYRIGHT_STRING "2001-%ld The Haiku project. ", year); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert(string); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert(B_TRANSLATE("The copyright to the Haiku code is " "property of Haiku, Inc. or of the respective authors where expressly " "noted in the source. Haiku and the Haiku logo are trademarks of " "Haiku, Inc." "\n\n")); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue); fCreditsView->InsertHyperText("http://www.haiku-os.org", new URLAction("http://www.haiku-os.org")); fCreditsView->Insert("\n\n"); font.SetSize(be_bold_font->Size()); font.SetFace(B_BOLD_FACE | B_ITALIC_FACE); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->Insert(B_TRANSLATE("Current maintainers:\n")); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert( "Ithamar R. Adema\n" "Bruno G. Albuquerque\n" "Stephan Aßmus\n" "Salvatore Benedetto\n" "Stefano Ceccherini\n" "Rudolf Cornelissen\n" "Alexandre Deckner\n" "Adrien Destugues\n" "Oliver Ruiz Dorantes\n" "Axel Dörfler\n" "Jérôme Duval\n" "René Gollent\n" "Bryce Groff\n" "Colin Günther\n" "Karsten Heimrich\n" "Fredrik Holmqvist\n" "Philippe Houdoin\n" "Maurice Kalinowski\n" "Euan Kirkhope\n" "Ryan Leavengood\n" "Michael Lotz\n" "Brecht Machiels\n" "Matt Madia\n" "Scott McCreary\n" "David McPaul\n" "Wim van der Meer\n" "Fredrik Modéen\n" "Marcus Overhagen\n" "Michael Pfeiffer\n" "François Revol\n" "Philippe Saint-Pierre\n" "Andrej Spielmann\n" "Jonas Sundström\n" "Oliver Tappe\n" "Gerasim Troeglazov\n" "Ingo Weinhold\n" "Artur Wyszyński\n" "Clemens Zeidler\n" "Siarzhuk Zharski\n" "\n"); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->Insert(B_TRANSLATE("Past maintainers:\n")); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert( "Andrew Bachmann\n" "Tyler Dauwalder\n" "Daniel Furrer\n" "Andre Alves Garzia\n" "Erik Jaesler\n" "Marcin Konicki\n" "Waldemar Kornewald\n" "Thomas Kurschel\n" "Frans Van Nispen\n" "Adi Oanca\n" "Michael Phipps\n" "Niels Sascha Reedijk\n" "David Reid\n" "Hugo Santos\n" "Alexander G. M. Smith\n" "Bryan Varner\n" "Nathan Whitehorn\n" "Michael Wilber\n" "Jonathan Yoder\n" "Gabe Yoder\n" "\n"); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->Insert(B_TRANSLATE("Website, marketing & documentation:\n")); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert( "Phil Greenway\n" "Gavin James\n" "Jorge G. Mare (aka Koki)\n" "Urias McCullough\n" "Niels Sascha Reedijk\n" "Joachim Seemer (Humdinger)\n" "Jonathan Yoder\n" "\n"); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->Insert(B_TRANSLATE("Contributors:\n")); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert( "Andrea Anzani\n" "Sean Bartell\n" "Andre Braga\n" "Bruce Cameron\n" "Greg Crain\n" "David Dengg\n" "John Drinkwater\n" "Cian Duffy\n" "Vincent Duvert\n" "Fredrik Ekdahl\n" "Joshua R. Elsasser\n" "Atis Elsts\n" "Mark Erben\n" "Christian Fasshauer\n" "Andreas Färber\n" "Janito Ferreira Filho\n" "Marc Flerackers\n" "Michele Frau (zuMi)\n" "Pete Goodeve\n" "Lucian Adrian Grijincu\n" "Matthijs Hollemans\n" "Mathew Hounsell\n" "Morgan Howe\n" "Christophe Huriaux\n" "Ma Jie\n" "Carwyn Jones\n" "Vasilis Kaoutsis\n" "James Kim\n" "Shintaro Kinugawa\n" "Jan Klötzke\n" "Kurtis Kopf\n" "Tomáš Kučera\n" "Luboš Kulič\n" "Elad Lahav\n" "Anthony Lee\n" "Santiago Lema\n" "Raynald Lesieur\n" "Oscar Lesta\n" "Jerome Leveque\n" "Christof Lutteroth\n" "Graham MacDonald\n" "Jan Matějek\n" "Brian Matzon\n" "Christopher ML Zumwalt May\n" "Andrew McCall\n" "Nathan Mentley\n" "Marius Middelthon\n" "Marco Minutoli\n" "Misza\n" "MrSiggler\n" "Alan Murta\n" "Raghuram Nagireddy\n" "Jeroen Oortwijn (idefix)\n" "Pahtz\n" "Michael Paine\n" "Adrian Panasiuk\n" "Romain Picard\n" "Francesco Piccinno\n" "David Powell\n" "Jeremy Rand\n" "Hartmut Reh\n" "Daniel Reinhold\n" "Chris Roberts\n" "Samuel Rodríguez Pérez\n" "Thomas Roell\n" "Rafael Romo\n" "Ralf Schülke\n" "John Scipione\n" "Reznikov Sergei\n" "Zousar Shaker\n" "Caitlin Shaw\n" "Daniel Switkin\n" "Atsushi Takamatsu\n" "James Urquhart\n" "Jason Vandermark\n" "Sandor Vroemisse\n" "Denis Washington\n" "Alex Wilson\n" "Ulrich Wimboeck\n" "Johannes Wischert\n" "James Woodcock\n" "Hong Yul Yang\n" "Gerald Zajac\n" "Łukasz Zemczak\n" "JiSheng Zhang\n" "Zhao Shuai\n"); fCreditsView->Insert( B_TRANSLATE("\n" B_UTF8_ELLIPSIS " and probably some more we forgot to mention (sorry!)" "\n\n")); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->Insert(B_TRANSLATE("Translations:\n")); BLanguage* lang; BString langName; BList sortedTranslations; for (uint32 i = 0; i < kNumberOfTranslations; i ++) { const Translation* translation = &gTranslations[i]; sortedTranslations.AddItem((void*)translation); } sortedTranslations.SortItems(TranslationComparator); for (uint32 i = 0; i < kNumberOfTranslations; i ++) { const Translation& translation = *(const Translation*)sortedTranslations.ItemAt(i); be_locale_roster->GetLanguage(translation.languageCode, &lang); langName.Truncate(0); lang->GetTranslatedName(langName); delete lang; fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen); fCreditsView->Insert("\n"); fCreditsView->Insert(langName); fCreditsView->Insert("\n"); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert( translation.names ); } fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->Insert(B_TRANSLATE("\n\nSpecial thanks to:\n")); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert( B_TRANSLATE("Travis Geiselbrecht (and his NewOS kernel)\n")); fCreditsView->Insert( B_TRANSLATE("Michael Phipps (project founder)\n\n")); fCreditsView->Insert( B_TRANSLATE("The Haiku-Ports team\n")); fCreditsView->Insert( B_TRANSLATE("The Haikuware team and their bounty program\n")); fCreditsView->Insert( B_TRANSLATE("The BeGeistert team\n")); fCreditsView->Insert( B_TRANSLATE("Google & their Google Summer of Code program\n\n")); fCreditsView->Insert( B_TRANSLATE("... and the many people making donations!\n\n")); // copyrights for various projects we use BPath mitPath; _GetLicensePath("MIT", mitPath); font.SetSize(be_bold_font->Size() + 4); font.SetFace(B_BOLD_FACE); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuGreen); fCreditsView->Insert(B_TRANSLATE("\nCopyrights\n\n")); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->Insert(B_TRANSLATE("[Click a license name to read the " "respective license.]\n\n")); // Haiku license fCreditsView->Insert(B_TRANSLATE("The code that is unique to Haiku, " "especially the kernel and all code that applications may link " "against, is distributed under the terms of the ")); fCreditsView->InsertHyperText(B_TRANSLATE("MIT license"), new OpenFileAction(mitPath.Path())); fCreditsView->Insert(B_TRANSLATE(". Some system libraries contain third " "party code distributed under the LGPL license. You can find the " "copyrights to third party code below.\n\n")); // GNU copyrights AddCopyrightEntry("The GNU Project", "Contains software from the GNU Project, " "released under the GPL and LGPL licenses:\n" "GNU C Library, " "GNU coretools, diffutils, findutils, " "sharutils, gawk, bison, m4, make, " "gdb, wget, ncurses, termcap, " "Bourne Again Shell.\n" COPYRIGHT_STRING "The Free Software Foundation.", StringVector("GNU LGPL v2.1", "GNU GPL v2", "GNU GPL v3", NULL), StringVector(), "http://www.gnu.org"); // FreeBSD copyrights AddCopyrightEntry("The FreeBSD Project", "Contains software from the FreeBSD Project, " "released under the BSD license:\n" "cal, ftpd, ping, telnet, " "telnetd, traceroute\n" COPYRIGHT_STRING "1994-2008 The FreeBSD Project. " "All rights reserved.", "http://www.freebsd.org"); // TODO: License! // NetBSD copyrights AddCopyrightEntry("The NetBSD Project", "Contains software developed by the NetBSD, " "Foundation, Inc. and its contributors:\n" "ftp, tput\n" COPYRIGHT_STRING "1996-2008 The NetBSD Foundation, Inc. " "All rights reserved.", "http://www.netbsd.org"); // TODO: License! // FFMpeg copyrights _AddPackageCredit(PackageCredit("FFMpeg libavcodec") .SetCopyright(COPYRIGHT_STRING "2000-2007 Fabrice Bellard, et al.") .SetLicenses("GNU LGPL v2.1", "GNU LGPL v2", NULL) .SetURL("http://www.ffmpeg.org")); // AGG copyrights _AddPackageCredit(PackageCredit("AntiGrain Geometry") .SetCopyright(COPYRIGHT_STRING "2002-2006 Maxim Shemanarev (McSeem).") .SetLicenses("Anti-Grain Geometry", "BSD (3-clause)", "GPC", NULL) .SetURL("http://www.antigrain.com")); // PDFLib copyrights _AddPackageCredit(PackageCredit("PDFLib") .SetCopyright(COPYRIGHT_STRING "1997-2006 PDFlib GmbH and Thomas Merz. " "All rights reserved.\n" "PDFlib and PDFlib logo are registered trademarks of PDFlib GmbH.") .SetLicense("PDFlib Lite") .SetURL("http://www.pdflib.com")); // FreeType copyrights _AddPackageCredit(PackageCredit("FreeType2") .SetCopyright("Portions of this software are copyright " B_UTF8_COPYRIGHT " 1996-2006 " "The FreeType Project. All rights reserved.") .SetLicense("FTL") .SetURL("http://www.freetype.org")); // Mesa3D (http://www.mesa3d.org) copyrights _AddPackageCredit(PackageCredit("Mesa") .SetCopyright(COPYRIGHT_STRING "1999-2006 Brian Paul. " "Mesa3D Project. All rights reserved.") .SetLicense("MIT") .SetURL("http://www.mesa3d.org")); // SGI's GLU implementation copyrights _AddPackageCredit(PackageCredit("GLU") .SetCopyright(COPYRIGHT_STRING "1991-2000 Silicon Graphics, Inc. " "SGI's Software FreeB license. All rights reserved.") .SetLicense("SGI Free B") .SetURL("http://www.sgi.com/products/software/opengl")); // GLUT implementation copyrights _AddPackageCredit(PackageCredit("GLUT") .SetCopyrights(COPYRIGHT_STRING "1994-1997 Mark Kilgard. " "All rights reserved.", COPYRIGHT_STRING "1997 Be Inc.", COPYRIGHT_STRING "1999 Jake Hamby.", NULL) .SetLicense("GLUT (Mark Kilgard)") .SetURL("http://www.opengl.org/resources/libraries/glut")); // OpenGroup & DEC (BRegion backend) copyright _AddPackageCredit(PackageCredit("BRegion backend (XFree86)") .SetCopyrights(COPYRIGHT_STRING "1987, 1988, 1998 The Open Group.", COPYRIGHT_STRING "1987, 1988 Digital Equipment " "Corporation, Maynard, Massachusetts.\n" "All rights reserved.", NULL) .SetLicenses("OpenGroup", "DEC", NULL)); // TODO: URL // VL-Gothic font _AddPackageCredit(PackageCredit("VL-Gothic font") .SetCopyrights(COPYRIGHT_STRING "1990-2003 Wada Laboratory," " the University of Tokyo", COPYRIGHT_STRING "2003-2004 Electronic Font Open Laboratory (/efont/)", COPYRIGHT_STRING "2003-2008 M+ FONTS PROJECT", COPYRIGHT_STRING "2006-2009 Daisuke SUZUKI", COPYRIGHT_STRING "2006-2009 Project Vine", "MIT license. All rights reserved.", NULL)); // TODO: License! // expat copyrights _AddPackageCredit(PackageCredit("expat") .SetCopyrights(COPYRIGHT_STRING "1998, 1999, 2000 Thai Open Source " "Software Center Ltd and Clark Cooper.", COPYRIGHT_STRING "2001, 2002, 2003 Expat maintainers.", NULL) .SetLicense("Expat") .SetURL("http://expat.sourceforge.net")); // zlib copyrights _AddPackageCredit(PackageCredit("zlib") .SetCopyright(COPYRIGHT_STRING "1995-2004 Jean-loup Gailly and Mark Adler.") .SetLicense("Zlib") .SetURL("http://www.zlib.net")); // zip copyrights _AddPackageCredit(PackageCredit("Info-ZIP") .SetCopyright(COPYRIGHT_STRING "1990-2002 Info-ZIP. All rights reserved.") .SetLicense("Info-ZIP") .SetURL("http://www.info-zip.org")); // bzip2 copyrights _AddPackageCredit(PackageCredit("bzip2") .SetCopyright(COPYRIGHT_STRING "1996-2005 Julian R Seward. All rights reserved.") .SetLicense("BSD (4-clause)") .SetURL("http://bzip.org")); // lp_solve copyrights _AddPackageCredit(PackageCredit("lp_solve") .SetCopyright(COPYRIGHT_STRING "Michel Berkelaar, Kjell Eikland, Peter Notebaert") .SetLicense("GNU LGPL v2.1") .SetURL("http://lpsolve.sourceforge.net/")); // OpenEXR copyrights _AddPackageCredit(PackageCredit("OpenEXR") .SetCopyright(COPYRIGHT_STRING "2002-2005 Industrial Light & Magic, " "a division of Lucas Digital Ltd. LLC.") .SetLicense("BSD (3-clause)") .SetURL("http://www.openexr.com")); // Bullet copyrights _AddPackageCredit(PackageCredit("Bullet") .SetCopyright(COPYRIGHT_STRING "2003-2008 Erwin Coumans") .SetLicense("Bullet") .SetURL("http://www.bulletphysics.com")); // atftp copyrights _AddPackageCredit(PackageCredit("atftp") .SetCopyright(COPYRIGHT_STRING "2000 Jean-Pierre ervbefeL and Remi Lefebvre") .SetLicense("GNU GPL v2")); // TODO: URL! // Netcat copyrights _AddPackageCredit(PackageCredit("Netcat") .SetCopyright(COPYRIGHT_STRING "1996 Hobbit")); // TODO: License! // acpica copyrights _AddPackageCredit(PackageCredit("acpica") .SetCopyright(COPYRIGHT_STRING "1999-2006 Intel Corp.") .SetLicense("Intel (ACPICA)") .SetURL("http://www.acpica.org")); // unrar copyrights _AddPackageCredit(PackageCredit("unrar") .SetCopyright(COPYRIGHT_STRING "2002-2008 Alexander L. Roshal. " "All rights reserved.") .SetLicense("UnRAR") .SetURL("http://www.rarlab.com")); // libpng copyrights _AddPackageCredit(PackageCredit("libpng") .SetCopyright(COPYRIGHT_STRING "2004, 2006-2008 Glenn " "Randers-Pehrson.") .SetLicense("LibPNG") .SetURL("http://www.libpng.org")); // libjpeg copyrights _AddPackageCredit(PackageCredit("libjpeg") .SetCopyright(COPYRIGHT_STRING " 1994-2009, Thomas G. Lane," " Guido Vollbeding. This software is based in part on the " "work of the Independent JPEG Group") .SetLicense("LibJPEG") .SetURL("http://www.ijg.org")); // libprint copyrights _AddPackageCredit(PackageCredit("libprint") .SetCopyright(COPYRIGHT_STRING "1999-2000 Y.Takagi. All rights reserved.")); // TODO: License! // cortex copyrights _AddPackageCredit(PackageCredit("Cortex") .SetCopyright(COPYRIGHT_STRING "1999-2000 Eric Moon.") .SetLicense("BSD (3-clause)") .SetURL("http://cortex.sourceforge.net/documentation")); // FluidSynth copyrights _AddPackageCredit(PackageCredit("FluidSynth") .SetCopyright(COPYRIGHT_STRING "2003 Peter Hanappe and others.") .SetLicense("GNU LGPL v2") .SetURL("http://www.fluidsynth.org")); // CannaIM copyrights _AddPackageCredit(PackageCredit("CannaIM") .SetCopyright(COPYRIGHT_STRING "1999 Masao Kawamura.")); // TODO: License! // libxml2, libxslt, libexslt copyrights _AddPackageCredit(PackageCredit("libxml2, libxslt") .SetCopyright(COPYRIGHT_STRING "1998-2003 Daniel Veillard. All rights reserved.") .SetLicense("MIT (no promotion)") .SetURL("http://xmlsoft.org")); _AddPackageCredit(PackageCredit("libexslt") .SetCopyright(COPYRIGHT_STRING "2001-2002 Thomas Broyer, Charlie " "Bozeman and Daniel Veillard. All rights reserved.") .SetLicense("MIT (no promotion)") .SetURL("http://xmlsoft.org")); // Xiph.org Foundation copyrights _AddPackageCredit(PackageCredit("Xiph.org Foundation") .SetCopyrights("libvorbis, libogg, libtheora, libspeex", COPYRIGHT_STRING "1994-2008 Xiph.Org. " "All rights reserved.", NULL) .SetLicense("BSD (3-clause)") .SetURL("http://www.xiph.org")); // The Tcpdump Group _AddPackageCredit(PackageCredit("The Tcpdump Group") .SetCopyright("tcpdump, libpcap") .SetLicense("BSD (3-clause)") .SetURL("http://www.tcpdump.org")); // Matroska _AddPackageCredit(PackageCredit("libmatroska") .SetCopyright(COPYRIGHT_STRING "2002-2003 Steve Lhomme. " "All rights reserved.") .SetLicense("GNU LGPL v2.1") .SetURL("http://www.matroska.org")); // BColorQuantizer (originally CQuantizer code) _AddPackageCredit(PackageCredit("CQuantizer") .SetCopyright(COPYRIGHT_STRING "1996-1997 Jeff Prosise. " "All rights reserved.") .SetLicense("CQuantizer") .SetURL("http://www.xdp.it")); // MAPM (Mike's Arbitrary Precision Math Library) used by DeskCalc _AddPackageCredit(PackageCredit("MAPM") .SetCopyright(COPYRIGHT_STRING "1999-2007 Michael C. Ring. All rights reserved.") .SetLicense("MAPM") .SetURL("http://tc.umn.edu/~ringx004")); // MkDepend 1.7 copyright (Makefile dependency generator) _AddPackageCredit(PackageCredit("MkDepend") .SetCopyright(COPYRIGHT_STRING "1995-2001 Lars Düning. " "All rights reserved.") .SetLicense("MkDepend") .SetURL("http://bearnip.com/lars/be")); // libhttpd copyright (used as Poorman backend) _AddPackageCredit(PackageCredit("libhttpd") .SetCopyright(COPYRIGHT_STRING "1995,1998,1999,2000,2001 by " "Jef Poskanzer. All rights reserved.") .SetLicense("LibHTTPd") .SetURL("http://www.acme.com/software/thttpd/")); #ifdef __INTEL__ // Udis86 copyrights _AddPackageCredit(PackageCredit("Udis86") .SetCopyright(COPYRIGHT_STRING "2002, 2003, 2004 Vivek Mohan. " "All rights reserved.") .SetURL("http://udis86.sourceforge.net")); // TODO: License! #endif #ifdef __INTEL__ // Intel PRO/Wireless 2100 Firmware _AddPackageCredit(PackageCredit("Intel PRO/Wireless 2100 Firmware") .SetCopyright(COPYRIGHT_STRING "2003-2006 by " "Intel Corporation. All rights reserved.") .SetLicense("Intel (2xxx firmware)") .SetURL("http://ipw2100.sourceforge.net/")); #endif #ifdef __INTEL__ // Intel PRO/Wireless 2200BG Firmware _AddPackageCredit(PackageCredit("Intel PRO/Wireless 2200BG Firmware") .SetCopyright(COPYRIGHT_STRING "2004-2005 by " "Intel Corporation. All rights reserved.") .SetLicense("Intel (2xxx firmware)") .SetURL("http://ipw2200.sourceforge.net/")); #endif #ifdef __INTEL__ // Intel PRO/Wireless 3945ABG/BG Network Connection Adapter Firmware _AddPackageCredit( PackageCredit( "Intel PRO/Wireless 3945ABG/BG Network Connection Adapter Firmware") .SetCopyright(COPYRIGHT_STRING "2006 - 2007 by " "Intel Corporation. All rights reserved.") .SetLicense("Intel (firmware)") .SetURL("http://www.intellinuxwireless.org/")); #endif #ifdef __INTEL__ // Intel Wireless WiFi Link 4965AGN Adapter Firmware _AddPackageCredit( PackageCredit("Intel Wireless WiFi Link 4965AGN Adapter Firmware") .SetCopyright(COPYRIGHT_STRING "2006 - 2007 by " "Intel Corporation. All rights reserved.") .SetLicense("Intel (firmware)") .SetURL("http://www.intellinuxwireless.org/")); #endif #ifdef __INTEL__ // Marvell 88w8363 _AddPackageCredit(PackageCredit("Marvell 88w8363") .SetCopyright(COPYRIGHT_STRING "2007-2009 by " "Marvell Semiconductor, Inc. All rights reserved.") .SetLicense("Marvell (firmware)") .SetURL("http://www.marvell.com/")); #endif #ifdef __INTEL__ // Ralink Firmware RT2501/RT2561/RT2661 _AddPackageCredit(PackageCredit("Ralink Firmware RT2501/RT2561/RT2661") .SetCopyright(COPYRIGHT_STRING "2007 by " "Ralink Technology Corporation. All rights reserved.") .SetLicense("Ralink (firmware)") .SetURL("http://www.ralinktech.com/")); #endif // ICU copyrights _AddPackageCredit(PackageCredit( "ICU - International Components for Unicode") .SetCopyright(COPYRIGHT_STRING "1995-2009 International Business Machines Corporation and others") .SetLicense("ICU") .SetURL("http://www.icu-project.org")); _AddCopyrightsFromAttribute(); _AddPackageCreditEntries(); return new CropView(creditsScroller, 0, 1, 1, 1); }
void TExpandoMenuBar::AttachedToWindow() { BMessenger self(this); BList teamList; TBarApp::Subscribe(self, &teamList); float width = fVertical ? Frame().Width() : sMinimumWindowWidth; float height = -1.0f; // top or bottom mode, add deskbar menu and sep for menubar tracking // consistency if (!fVertical) { TDeskbarMenu* beMenu = new TDeskbarMenu(fBarView); TBarWindow::SetDeskbarMenu(beMenu); const BBitmap* logoBitmap = AppResSet()->FindBitmap(B_MESSAGE_TYPE, R_LeafLogoBitmap); if (logoBitmap != NULL) fDeskbarMenuWidth = logoBitmap->Bounds().Width() + 16; fDeskbarMenuItem = new TBarMenuTitle(fDeskbarMenuWidth, Frame().Height(), logoBitmap, beMenu, true); AddItem(fDeskbarMenuItem); fSeparatorItem = new TTeamMenuItem(kSepItemWidth, height, fVertical); AddItem(fSeparatorItem); fSeparatorItem->SetEnabled(false); fFirstApp = 2; } else { fDeskbarMenuItem = NULL; fSeparatorItem = NULL; } desk_settings* settings = ((TBarApp*)be_app)->Settings(); if (settings->sortRunningApps) teamList.SortItems(CompareByName); int32 count = teamList.CountItems(); for (int32 i = 0; i < count; i++) { BarTeamInfo* barInfo = (BarTeamInfo*)teamList.ItemAt(i); if ((barInfo->flags & B_BACKGROUND_APP) == 0 && strcasecmp(barInfo->sig, kDeskbarSignature) != 0) { if (settings->trackerAlwaysFirst && !strcmp(barInfo->sig, kTrackerSignature)) { AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon, barInfo->name, barInfo->sig, width, height, fDrawLabel, fVertical), fFirstApp); } else { AddItem(new TTeamMenuItem(barInfo->teams, barInfo->icon, barInfo->name, barInfo->sig, width, height, fDrawLabel, fVertical)); } barInfo->teams = NULL; barInfo->icon = NULL; barInfo->name = NULL; barInfo->sig = NULL; } delete barInfo; } BMenuBar::AttachedToWindow(); if (CountItems() == 0) { // If we're empty, BMenuBar::AttachedToWindow() resizes us to some // weird value - we just override it again ResizeTo(width, 0); } if (fVertical) { sDoMonitor = true; sMonThread = spawn_thread(monitor_team_windows, "Expando Window Watcher", B_LOW_PRIORITY, this); resume_thread(sMonThread); } }
// _CollectSequence status_t CollectingPlaylist::_CollectSequence(BList& collectables, const ServerObjectManager* library) { collectables.SortItems(compare_collectables); // find the transition clip, if we are supposed to have one Clip* transitionClip = NULL; BString transitionClipID = TransitionClipID(); if (transitionClipID.Length() > 0) { transitionClip = dynamic_cast<Clip*>(library->FindObject( transitionClipID.String())); if (!transitionClip) { print_error("CollectingPlaylist::_CollectSequence() - " "didn't find transition clip: %s (ignoring)\n", transitionClipID.String()); } } BString previousName; int64 startFrame = 0; uint64 maxDuration = Value(PROPERTY_DURATION, (int64)0); uint64 defaultDuration = ItemDuration(); int32 count = collectables.CountItems(); for (int32 i = 0; i < count; i++) { CollectablePlaylist* collectable = (CollectablePlaylist*)collectables.ItemAtFast(i); uint64 itemDuration = collectable->PreferredDuration(); if (itemDuration == 0) itemDuration = defaultDuration; if (maxDuration > 0 && startFrame + itemDuration > maxDuration) { // we would go past our maximum duration, so stop here break; } ClipPlaylistItem* item = new (nothrow) ClipPlaylistItem(collectable); // the item, if it was created, has it's own reference now if (!item) { print_error("CollectingPlaylist::_CollectSequence() - " "no memory to create ClipPlaylistItem\n"); return B_NO_MEMORY; } BString name(collectable->Name()); if (i > 0 && name != previousName && transitionClip) { //printf("new sequence starts at %ld\n", i); // a new sequence starts ClipPlaylistItem* transitionItem = new (nothrow) ClipPlaylistItem(transitionClip); if (!transitionItem || !AddItem(transitionItem)) { delete transitionItem; print_error("CollectingPlaylist::_CollectSequence() - " "no memory to create/add ClipPlaylistItem (transition)\n"); return B_NO_MEMORY; } transitionItem->SetStartFrame(startFrame); int64 transitionDuration = transitionClip->Duration(); transitionItem->SetDuration(transitionDuration); startFrame += transitionDuration; } if (!AddItem(item)) { delete item; print_error("CollectingPlaylist::_CollectSequence() - " "no memory to add ClipPlaylistItem\n"); return B_NO_MEMORY; } item->SetStartFrame(startFrame); item->SetDuration(itemDuration); item->SetTrack(0); startFrame += itemDuration; previousName = name; } return B_OK; }
void AttributeWindow::MessageReceived(BMessage* message) { switch (message->what) { case kMsgAttributeUpdated: case kMsgAlignmentChosen: case kMsgTypeChosen: _CheckDisplayAs(); _CheckAcceptable(); break; case kMsgDisplayAsChosen: fSpecialControl->SetEnabled(!_DefaultDisplayAs()->IsMarked()); _CheckAcceptable(); break; case kMsgVisibilityChanged: { bool enabled = fVisibleCheckBox->Value() != B_CONTROL_OFF; fDisplayAsMenuField->SetEnabled(enabled); fWidthControl->SetEnabled(enabled); fAlignmentMenuField->SetEnabled(enabled); fEditableCheckBox->SetEnabled(enabled); _CheckDisplayAs(); _CheckAcceptable(); break; } case kMsgAccept: { BMessage attributes; status_t status = fMimeType.GetAttrInfo(&attributes); if (status == B_OK) { // replace the entry, and remove any equivalent entries BList list; const char* newAttribute = fAttributeControl->Text(); list.AddItem(_NewItemFromCurrent()); const char* attribute; for (int32 i = 0; attributes.FindString("attr:name", i, &attribute) == B_OK; i++) { if (!strcmp(fAttribute.Name(), attribute) || !strcmp(newAttribute, attribute)) { // remove this item continue; } AttributeItem* item = create_attribute_item(attributes, i); if (item != NULL) list.AddItem(item); } list.SortItems(compare_attributes); // Copy them to a new message (their memory is still part of the // original BMessage) BMessage newAttributes; for (int32 i = 0; i < list.CountItems(); i++) { AttributeItem* item = (AttributeItem*)list.ItemAt(i); newAttributes.AddString("attr:name", item->Name()); newAttributes.AddString("attr:public_name", item->PublicName()); newAttributes.AddInt32("attr:type", (int32)item->Type()); newAttributes.AddString("attr:display_as", item->DisplayAs()); newAttributes.AddInt32("attr:alignment", item->Alignment()); newAttributes.AddInt32("attr:width", item->Width()); newAttributes.AddBool("attr:viewable", item->Visible()); newAttributes.AddBool("attr:editable", item->Editable()); delete item; } status = fMimeType.SetAttrInfo(&newAttributes); } if (status != B_OK) error_alert("Could not change attributes", status); PostMessage(B_QUIT_REQUESTED); break; } default: BWindow::MessageReceived(message); break; } }
/*********************************************************** * InitGUI ***********************************************************/ void HAddressView::InitGUI() { float divider = StringWidth(_("Subject:")) + 20; divider = max_c(divider , StringWidth(_("From:"))+20); divider = max_c(divider , StringWidth(_("To:"))+20); divider = max_c(divider , StringWidth(_("Bcc:"))+20); BRect rect = Bounds(); rect.top += 5; rect.left += 20 + divider; rect.right = Bounds().right - 5; rect.bottom = rect.top + 25; BTextControl *ctrl; ResourceUtils rutils; const char* name[] = {"to","subject","from","cc","bcc"}; for(int32 i = 0;i < 5;i++) { ctrl = new BTextControl(BRect(rect.left,rect.top ,(i == 1)?rect.right+divider:rect.right ,rect.bottom) ,name[i],"","",NULL ,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_WILL_DRAW|B_NAVIGABLE); if(i == 1) { ctrl->SetLabel(_("Subject:")); ctrl->SetDivider(divider); ctrl->MoveBy(-divider,0); }else{ ctrl->SetDivider(0); } BMessage *msg = new BMessage(M_MODIFIED); msg->AddPointer("pointer",ctrl); ctrl->SetModificationMessage(msg); ctrl->SetEnabled(!fReadOnly); AddChild(ctrl); rect.OffsetBy(0,25); switch(i) { case 0: fTo = ctrl; break; case 1: fSubject = ctrl; break; case 2: fFrom = ctrl; fFrom->SetEnabled(false); fFrom->SetFlags(fFrom->Flags() & ~B_NAVIGABLE); break; case 3: fCc = ctrl; break; case 4: fBcc = ctrl; break; } } // BRect menuRect= Bounds(); menuRect.top += 5; menuRect.left += 22; menuRect.bottom = menuRect.top + 25; menuRect.right = menuRect.left + 16; BMenu *toMenu = new BMenu(_("To:")); BMenu *ccMenu = new BMenu(_("Cc:")); BMenu *bccMenu = new BMenu(_("Bcc:")); BQuery query; BVolume volume; BVolumeRoster().GetBootVolume(&volume); query.SetVolume(&volume); query.SetPredicate("((META:email=*)&&(BEOS:TYPE=application/x-person))"); if(!fReadOnly && query.Fetch() == B_OK) { BString addr[4],name,group,nick; entry_ref ref; BList peopleList; while(query.GetNextRef(&ref) == B_OK) { BNode node(&ref); if(node.InitCheck() != B_OK) continue; ReadNodeAttrString(&node,"META:name",&name); ReadNodeAttrString(&node,"META:email",&addr[0]); ReadNodeAttrString(&node,"META:email2",&addr[1]); ReadNodeAttrString(&node,"META:email3",&addr[2]); ReadNodeAttrString(&node,"META:email4",&addr[3]); ReadNodeAttrString(&node,"META:group",&group); ReadNodeAttrString(&node,"META:nickname",&nick); for(int32 i = 0;i < 4;i++) { if(addr[i].Length() > 0) { if(nick.Length() > 0) { nick += " <"; nick += addr[i]; nick += ">"; fAddrList.AddItem(strdup(nick.String())); } fAddrList.AddItem(strdup(addr[i].String())); BString title = name; title << " <" << addr[i] << ">"; AddPersonToList(peopleList,title.String(),group.String()); } } } // Sort people data peopleList.SortItems(HAddressView::SortPeople); // Build menus BTextControl *control[3] = {fTo,fCc,fBcc}; BMenu *menus[3] = {toMenu,ccMenu,bccMenu}; int32 count = peopleList.CountItems(); PersonData *data; bool needSeparator = false; bool hasSeparator = false; for(int32 k = 0;k < 3;k++) { for(int32 i = 0;i < count;i++) { BMessage *msg = new BMessage(M_ADDR_MSG); msg->AddPointer("pointer",control[k]); data = (PersonData*)peopleList.ItemAt(i); msg->AddString("email",data->email); if(needSeparator && !hasSeparator && strlen(data->group) == 0) { menus[k]->AddSeparatorItem(); hasSeparator = true; }else needSeparator = true; AddPerson(menus[k],data->email,data->group,msg,0,0); } hasSeparator = false; needSeparator = false; } // free all data while(count > 0) { data = (PersonData*)peopleList.RemoveItem(--count); free(data->email); free(data->group); delete data; } } BMenuField *field = new BMenuField(menuRect,"ToMenu","",toMenu, B_FOLLOW_TOP|B_FOLLOW_LEFT,B_WILL_DRAW); field->SetDivider(0); field->SetEnabled(!fReadOnly); AddChild(field); rect = menuRect; rect.OffsetBy(0,28); rect.left = Bounds().left + 5; rect.right = rect.left + 16; rect.top += 26; rect.bottom = rect.top + 16; ArrowButton *arrow = new ArrowButton(rect,"addr_arrow" ,new BMessage(M_EXPAND_ADDRESS)); AddChild(arrow); //==================== From menu BMenu *fromMenu = new BMenu(_("From:")); BPath path; ::find_directory(B_USER_SETTINGS_DIRECTORY,&path); path.Append(APP_NAME); path.Append("Accounts"); BDirectory dir(path.Path()); BEntry entry; status_t err = B_OK; int32 account_count = 0; while(err == B_OK) { if((err = dir.GetNextEntry(&entry)) == B_OK && !entry.IsDirectory()) { char name[B_FILE_NAME_LENGTH+1]; entry.GetName(name); BMessage *msg = new BMessage(M_ACCOUNT_CHANGE); msg->AddString("name",name); BMenuItem *item = new BMenuItem(name,msg); fromMenu->AddItem(item); item->SetTarget(this,Window()); account_count++; } } if(account_count != 0) { int32 smtp_account; ((HApp*)be_app)->Prefs()->GetData("smtp_account",&smtp_account); BMenuItem *item(NULL); if(account_count > smtp_account) item = fromMenu->ItemAt(smtp_account); if(!item) item = fromMenu->ItemAt(0); if(item) { ChangeAccount(item->Label()); item->SetMarked(true); } }else{ (new BAlert("",_("Could not find mail accounts"),_("OK"),NULL,NULL,B_WIDTH_AS_USUAL,B_INFO_ALERT))->Go(); Window()->PostMessage(B_QUIT_REQUESTED); } fromMenu->SetRadioMode(true); menuRect.OffsetBy(0,25*2); field = new BMenuField(menuRect,"FromMenu","",fromMenu, B_FOLLOW_TOP|B_FOLLOW_LEFT,B_WILL_DRAW); field->SetDivider(0); AddChild(field); //=================== CC menu menuRect.OffsetBy(0,25); field = new BMenuField(menuRect,"CcMenu","",ccMenu, B_FOLLOW_TOP|B_FOLLOW_LEFT,B_WILL_DRAW); field->SetDivider(0); field->SetEnabled(!fReadOnly); AddChild(field); //=================== BCC menu menuRect.OffsetBy(0,25); field = new BMenuField(menuRect,"BccMenu","",bccMenu, B_FOLLOW_TOP|B_FOLLOW_LEFT,B_WILL_DRAW); field->SetDivider(0); field->SetEnabled(!fReadOnly); AddChild(field); }
// returns true if score is destined for greatness bool Hall::JudgeScore(unsigned long gametime, unsigned long game, int tiles) { bool Yes = false; BList *L; switch(tiles) { case 14 * 6: L = List1; break; case 18 * 8: L = List2; break; case 24 * 12: L = List3; break; case 28 * 16: L = List4; break; case 32 * 20: L = List5; break; default: L = NULL; } if (!L) { //printf("No game size!\n"); return false; } HSList *h = new HSList(); h->SetGameID(game); h->SetGameTime(gametime); h->SetNumberTiles(tiles); h->SetTimeOfGame(time(NULL)); h->SetName(NULL); /* Add the new item */ L->AddItem(h); L->SortItems(cmpFunc); /* * Limit entries to 5 */ if (L->CountItems() > 5) { HSList *hs; hs = (HSList *)L->RemoveItem(5); delete hs; } if (L->HasItem(h)) { AskName *Ask = new AskName(); char *name; name = Ask->Go(); Ask->Lock(); Ask->Quit(); be_app->SetCursor(B_HAND_CURSOR); h->SetName(name); free(name); _changed = true; Yes = true; } return Yes; }
void update_preferred_app_menu(BMenu* menu, BMimeType* type, uint32 what, const char* preferredFrom) { // clear menu (but leave the first entry, ie. "None") for (int32 i = menu->CountItems(); i-- > 1;) { delete menu->RemoveItem(i); } // fill it again menu->ItemAt(0)->SetMarked(true); BMessage applications; if (type == NULL || type->GetSupportingApps(&applications) != B_OK) return; char preferred[B_MIME_TYPE_LENGTH]; if (type->GetPreferredApp(preferred) != B_OK) preferred[0] = '\0'; int32 lastFullSupport; if (applications.FindInt32("be:sub", &lastFullSupport) != B_OK) lastFullSupport = -1; BList subList; BList superList; const char* signature; int32 i = 0; while (applications.FindString("applications", i, &signature) == B_OK) { BMenuItem* item = create_application_item(signature, what); if (i < lastFullSupport) subList.AddItem(item); else superList.AddItem(item); i++; } // sort lists subList.SortItems(compare_menu_items); superList.SortItems(compare_menu_items); // add lists to the menu if (subList.CountItems() != 0 || superList.CountItems() != 0) menu->AddSeparatorItem(); for (int32 i = 0; i < subList.CountItems(); i++) { menu->AddItem((BMenuItem*)subList.ItemAt(i)); } // Add type separator if (superList.CountItems() != 0 && subList.CountItems() != 0) menu->AddSeparatorItem(); for (int32 i = 0; i < superList.CountItems(); i++) { menu->AddItem((BMenuItem*)superList.ItemAt(i)); } // make items unique and select current choice bool lastItemSame = false; const char* lastSignature = NULL; BMenuItem* last = NULL; BMenuItem* select = NULL; for (int32 index = 0; index < menu->CountItems(); index++) { BMenuItem* item = menu->ItemAt(index); if (item == NULL) continue; if (item->Message() == NULL || item->Message()->FindString("signature", &signature) != B_OK) continue; if ((preferredFrom == NULL && !strcasecmp(signature, preferred)) || (preferredFrom != NULL && !strcasecmp(signature, preferredFrom))) { select = item; } if (last == NULL || strcmp(last->Label(), item->Label())) { if (lastItemSame) add_signature(last, lastSignature); lastItemSame = false; last = item; lastSignature = signature; continue; } lastItemSame = true; add_signature(last, lastSignature); last = item; lastSignature = signature; } if (lastItemSame) add_signature(last, lastSignature); if (select != NULL) { // We don't select the item earlier, so that the menu field can // pick up the signature as well as label. select->SetMarked(true); } else if ((preferredFrom == NULL && preferred[0]) || (preferredFrom != NULL && preferredFrom[0])) { // The preferred application is not an application that support // this file type! BMenuItem* item = create_application_item(preferredFrom ? preferredFrom : preferred, what); menu->AddSeparatorItem(); menu->AddItem(item); item->SetMarked(item); } }
void TTeamMenu::AttachedToWindow() { RemoveItems(0, CountItems(), true); // remove all items BMessenger self(this); BList teamList; TBarApp::Subscribe(self, &teamList); TBarView* barview = (dynamic_cast<TBarApp*>(be_app))->BarView(); bool dragging = barview && barview->Dragging(); int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize(); desk_settings* settings = ((TBarApp*)be_app)->Settings(); float width = sMinimumWindowWidth - iconSize - 4; if (settings->sortRunningApps) teamList.SortItems(CompareByName); int32 count = teamList.CountItems(); for (int32 i = 0; i < count; i++) { // add items back BarTeamInfo* barInfo = (BarTeamInfo*)teamList.ItemAt(i); TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams, barInfo->icon, barInfo->name, barInfo->sig, width, -1, !settings->hideLabels, true); if (settings->trackerAlwaysFirst && strcmp(barInfo->sig, kTrackerSignature) == 0) { AddItem(item, 0); } else AddItem(item); if (dragging && item != NULL) { bool canhandle = (dynamic_cast<TBarApp*>(be_app))->BarView()-> AppCanHandleTypes(item->Signature()); if (item->IsEnabled() != canhandle) item->SetEnabled(canhandle); BMenu* menu = item->Submenu(); if (menu) menu->SetTrackingHook(barview->MenuTrackingHook, barview->GetTrackingHookData()); } } if (CountItems() == 0) { BMenuItem* item = new BMenuItem("no application running", NULL); item->SetEnabled(false); AddItem(item); } if (dragging && barview->LockLooper()) { SetTrackingHook(barview->MenuTrackingHook, barview->GetTrackingHookData()); barview->DragStart(); barview->UnlockLooper(); } BMenu::AttachedToWindow(); }