From 12d8a9f85b1f6daeeca5a5185d915d5ce3c922a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sundstr=C3=B6m?= Date: Tue, 15 Mar 2011 01:04:41 +0000 Subject: [PATCH] Introducing BAboutMenuItem. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40956 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/shared/AboutMenuItem.h | 18 +++++++++++ src/kits/shared/AboutMenuItem.cpp | 42 ++++++++++++++++++++++++++ src/kits/shared/Jamfile | 1 + 3 files changed, 61 insertions(+) create mode 100644 headers/private/shared/AboutMenuItem.h create mode 100644 src/kits/shared/AboutMenuItem.cpp diff --git a/headers/private/shared/AboutMenuItem.h b/headers/private/shared/AboutMenuItem.h new file mode 100644 index 0000000000..6a1b96c3f6 --- /dev/null +++ b/headers/private/shared/AboutMenuItem.h @@ -0,0 +1,18 @@ +/* + * Copyright 2011 Haiku, Inc. + * Distributed under the terms of the MIT License. + */ +#ifndef B_ABOUT_MENU_ITEM_H +#define B_ABOUT_MENU_ITEM_H + + +#include + + +class BAboutMenuItem : public BMenuItem { +public: + BAboutMenuItem(const char* appName); +}; + + +#endif // B_ABOUT_MENU_ITEM_H diff --git a/src/kits/shared/AboutMenuItem.cpp b/src/kits/shared/AboutMenuItem.cpp new file mode 100644 index 0000000000..15cddd01a8 --- /dev/null +++ b/src/kits/shared/AboutMenuItem.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2007-2011 Haiku, Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Ryan Leavengood, leavengood@gmail.com + * Jonas Sundström, jonas@kirilla.se + */ + + +#include +#include +#include +#include + + +using BPrivate::gLocaleBackend; +using BPrivate::LocaleBackend; + + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "AboutMenuItem" + + +BAboutMenuItem::BAboutMenuItem(const char* appName) + : + BMenuItem("", new BMessage(B_ABOUT_REQUESTED)) +{ + // we need to translate some strings, and in order to do so, we need + // to use the LocaleBackend to reach liblocale.so + if (gLocaleBackend == NULL) + LocaleBackend::LoadBackend(); + + const char* string = B_TRANSLATE_MARK("About %app%" B_UTF8_ELLIPSIS); + if (gLocaleBackend) { + string = gLocaleBackend->GetString(string, "AboutMenuItem"); + } + + BString label = string; + label.ReplaceFirst("%app%", appName); + SetLabel(label.String()); +} diff --git a/src/kits/shared/Jamfile b/src/kits/shared/Jamfile index 9a4007600d..c957f910d3 100644 --- a/src/kits/shared/Jamfile +++ b/src/kits/shared/Jamfile @@ -13,6 +13,7 @@ UsePrivateSystemHeaders ; UsePrivateHeaders kernel libroot ; StaticLibrary libshared.a : + AboutMenuItem.cpp AboutWindow.cpp CalendarView.cpp ColorQuantizer.cpp