Patch by mt:
* Convert Sounds to use layout API * Localization Thanks a lot! Closes ticket #5111. I've had to apply the patch manually because someone committed a coding style cleanup without looking up pending patches (and the patch also contained mostly the same cleanup). This is the second time this happened, would be nice to avoid this in the future. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36642 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
bfa1c029c0
commit
404b95c410
@ -13,16 +13,24 @@
|
||||
#include "HWindow.h"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
|
||||
|
||||
#undef TR_CONTEXT
|
||||
#define TR_CONTEXT "SoundsHApp"
|
||||
|
||||
|
||||
HApp::HApp()
|
||||
:
|
||||
BApplication("application/x-vnd.Haiku-Sounds")
|
||||
{
|
||||
be_locale->GetAppCatalog(&fCatalog);
|
||||
|
||||
BRect rect;
|
||||
rect.Set(200, 150, 590, 570);
|
||||
|
||||
HWindow* window = new HWindow(rect, "Sounds");
|
||||
HWindow* window = new HWindow(rect, TR("Sounds"));
|
||||
window->Show();
|
||||
}
|
||||
|
||||
@ -35,13 +43,14 @@ HApp::~HApp()
|
||||
void
|
||||
HApp::AboutRequested()
|
||||
{
|
||||
BAlert* alert = new BAlert("About Sounds",
|
||||
"Sounds\n"
|
||||
" Brought to you by :\n"
|
||||
" Oliver Ruiz Dorantes\n"
|
||||
" Jérôme DUVAL.\n"
|
||||
" Original work from Atsushi Takamatsu.\n"
|
||||
"Copyright " B_UTF8_COPYRIGHT "2003-2006 Haiku", "OK");
|
||||
BAlert* alert = new BAlert(TR("About Sounds"),
|
||||
TR("Sounds\n"
|
||||
" Brought to you by :\n"
|
||||
"\tOliver Ruiz Dorantes\n"
|
||||
"\tJérôme DUVAL.\n"
|
||||
" Original work from Atsushi Takamatsu.\n"
|
||||
"Copyright ©2003-2006 Haiku"),
|
||||
TR("OK"));
|
||||
alert->Go();
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
|
||||
#include <Application.h>
|
||||
#include <Catalog.h>
|
||||
|
||||
|
||||
class HApp : public BApplication {
|
||||
@ -19,6 +20,9 @@ public:
|
||||
HApp();
|
||||
virtual ~HApp();
|
||||
virtual void AboutRequested();
|
||||
|
||||
private:
|
||||
BCatalog fCatalog;
|
||||
};
|
||||
|
||||
|
||||
|
@ -10,13 +10,19 @@
|
||||
#include "HEventList.h"
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Catalog.h>
|
||||
#include <ColumnTypes.h>
|
||||
#include <Entry.h>
|
||||
#include <Locale.h>
|
||||
#include <MediaFiles.h>
|
||||
#include <Path.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#undef TR_CONTEXT
|
||||
#define TR_CONTEXT "HEventList"
|
||||
|
||||
|
||||
HEventRow::HEventRow(const char* name, const char* path)
|
||||
:
|
||||
BRow(),
|
||||
@ -37,7 +43,8 @@ HEventRow::SetPath(const char* _path)
|
||||
{
|
||||
fPath = _path;
|
||||
BPath path(_path);
|
||||
SetField(new BStringField(_path ? path.Leaf() : "<none>"), kSoundColumn);
|
||||
SetField(new BStringField(_path ? path.Leaf() : TR("<none>")),
|
||||
kSoundColumn);
|
||||
}
|
||||
|
||||
|
||||
@ -48,14 +55,14 @@ HEventRow::Remove(const char* type)
|
||||
}
|
||||
|
||||
|
||||
HEventList::HEventList(BRect rect, const char* name)
|
||||
HEventList::HEventList(const char* name)
|
||||
:
|
||||
BColumnListView(rect, name, B_FOLLOW_ALL, 0, B_PLAIN_BORDER, true),
|
||||
BColumnListView(name, 0, B_PLAIN_BORDER, true),
|
||||
fType(NULL)
|
||||
{
|
||||
AddColumn(new BStringColumn("Event", 150, 50, 500, B_TRUNCATE_MIDDLE),
|
||||
AddColumn(new BStringColumn(TR("Event"), 150, 50, 500, B_TRUNCATE_MIDDLE),
|
||||
kEventColumn);
|
||||
AddColumn(new BStringColumn("Sound", 150, 50, 500, B_TRUNCATE_END),
|
||||
AddColumn(new BStringColumn(TR("Sound"), 150, 50, 500, B_TRUNCATE_END),
|
||||
kSoundColumn);
|
||||
}
|
||||
|
||||
@ -119,7 +126,7 @@ HEventList::SelectionChanged()
|
||||
printf("name %s\n", ref.name);
|
||||
BMediaFiles().RemoveRefFor(fType, row->Name(), ref);
|
||||
BAlert* alert = new BAlert("alert",
|
||||
"No such file or directory", "OK");
|
||||
TR("No such file or directory"), TR("OK"));
|
||||
alert->Go();
|
||||
return;
|
||||
}
|
||||
|
@ -45,8 +45,7 @@ enum {
|
||||
|
||||
class HEventList : public BColumnListView {
|
||||
public:
|
||||
HEventList(BRect rect,
|
||||
const char* name = "EventList");
|
||||
HEventList(const char* name = "EventList");
|
||||
virtual ~HEventList();
|
||||
void RemoveAll();
|
||||
void SetType(const char* type);
|
||||
|
@ -19,8 +19,11 @@
|
||||
#include <Beep.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <fs_attr.h>
|
||||
#include <GroupLayoutBuilder.h>
|
||||
#include <Locale.h>
|
||||
#include <MediaFiles.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuField.h>
|
||||
@ -34,21 +37,19 @@
|
||||
#include <Sound.h>
|
||||
|
||||
|
||||
#undef TR_CONTEXT
|
||||
#define TR_CONTEXT "HWindow"
|
||||
|
||||
static const char kSettingsFile[] = "Sounds_Settings";
|
||||
|
||||
|
||||
HWindow::HWindow(BRect rect, const char* name)
|
||||
:
|
||||
BWindow(rect, name, B_TITLED_WINDOW, 0),
|
||||
BWindow(rect, name, B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS),
|
||||
fFilePanel(NULL),
|
||||
fPlayer(NULL)
|
||||
{
|
||||
InitGUI();
|
||||
float min_width, min_height, max_width, max_height;
|
||||
GetSizeLimits(&min_width, &max_width, &min_height, &max_height);
|
||||
min_width = 300;
|
||||
min_height = 200;
|
||||
SetSizeLimits(min_width, max_width, min_height, max_height);
|
||||
|
||||
fFilePanel = new BFilePanel();
|
||||
fFilePanel->SetTarget(this);
|
||||
@ -91,78 +92,60 @@ HWindow::~HWindow()
|
||||
void
|
||||
HWindow::InitGUI()
|
||||
{
|
||||
BRect rect = Bounds();
|
||||
rect.bottom -= 106;
|
||||
BView* listView = new BView(rect, "", B_FOLLOW_NONE,
|
||||
B_WILL_DRAW | B_PULSE_NEEDED);
|
||||
listView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(listView);
|
||||
|
||||
rect.left += 13;
|
||||
rect.right -= 13;
|
||||
rect.top += 28;
|
||||
rect.bottom -= 7;
|
||||
fEventList = new HEventList(rect);
|
||||
listView->AddChild(fEventList);
|
||||
fEventList = new HEventList();
|
||||
fEventList->SetType(BMediaFiles::B_SOUNDS);
|
||||
fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);
|
||||
|
||||
rect = Bounds();
|
||||
rect.top = rect.bottom - 105;
|
||||
BView* view = new BView(rect, "", B_FOLLOW_NONE,
|
||||
B_WILL_DRAW | B_PULSE_NEEDED);
|
||||
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(view);
|
||||
rect = view->Bounds().InsetBySelf(12, 12);
|
||||
BBox* box = new BBox(rect, "", B_FOLLOW_ALL);
|
||||
view->AddChild(box);
|
||||
rect = box->Bounds();
|
||||
rect.top += 10;
|
||||
rect.left += 15;
|
||||
rect.right -= 10;
|
||||
rect.bottom = rect.top + 20;
|
||||
BGroupView* view = new BGroupView();
|
||||
BBox* box = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS
|
||||
| B_NAVIGABLE_JUMP | B_PULSE_NEEDED);
|
||||
|
||||
BMenu* menu = new BMenu("file");
|
||||
menu->SetRadioMode(true);
|
||||
menu->SetLabelFromMarked(true);
|
||||
menu->AddSeparatorItem();
|
||||
|
||||
menu->AddItem(new BMenuItem("<none>", new BMessage(M_NONE_MESSAGE)));
|
||||
menu->AddItem(new BMenuItem("Other" B_UTF8_ELLIPSIS,
|
||||
menu->AddItem(new BMenuItem(TR("<none>"), new BMessage(M_NONE_MESSAGE)));
|
||||
menu->AddItem(new BMenuItem(TR("Other" B_UTF8_ELLIPSIS),
|
||||
new BMessage(M_OTHER_MESSAGE)));
|
||||
BMenuField* menuField = new BMenuField(rect, "filemenu", "Sound file:",
|
||||
menu, B_FOLLOW_TOP | B_FOLLOW_LEFT);
|
||||
menuField->SetDivider(menuField->StringWidth("Sound file:") + 10);
|
||||
box->AddChild(menuField);
|
||||
rect.OffsetBy(-2, menuField->Bounds().Height() + 15);
|
||||
BButton* button = new BButton(rect, "stop", "Stop",
|
||||
new BMessage(M_STOP_MESSAGE), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||
button->ResizeToPreferred();
|
||||
button->SetEnabled(false);
|
||||
button->MoveTo(box->Bounds().right - button->Bounds().Width() - 15,
|
||||
rect.top);
|
||||
box->AddChild(button);
|
||||
BMenuField* menuField = new BMenuField("filemenu", TR("Sound File:"), menu);
|
||||
menuField->SetDivider(menuField->StringWidth(TR("Sound File:")) + 10);
|
||||
|
||||
rect = button->Frame();
|
||||
view->ResizeTo(view->Bounds().Width(), 24 + rect.bottom + 12);
|
||||
box->ResizeTo(box->Bounds().Width(), rect.bottom + 12);
|
||||
BButton* stopbutton = new BButton("stop", TR("Stop"),
|
||||
new BMessage(M_STOP_MESSAGE));
|
||||
stopbutton->SetEnabled(false);
|
||||
|
||||
button->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||
button = new BButton(rect, "play", "Play", new BMessage(M_PLAY_MESSAGE),
|
||||
B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||
button->ResizeToPreferred();
|
||||
button->SetEnabled(false);
|
||||
button->MoveTo(rect.left - button->Bounds().Width() - 15, rect.top);
|
||||
box->AddChild(button);
|
||||
BButton* playbutton = new BButton("play", TR("Play"),
|
||||
new BMessage(M_PLAY_MESSAGE));
|
||||
playbutton->SetEnabled(false);
|
||||
|
||||
view->MoveTo(0, listView->Frame().bottom);
|
||||
ResizeTo(Bounds().Width(),
|
||||
listView->Frame().bottom + view->Bounds().Height());
|
||||
listView->SetResizingMode(B_FOLLOW_ALL);
|
||||
view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
|
||||
view->SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
view->AddChild(BGroupLayoutBuilder(B_VERTICAL, 15)
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
.Add(menuField)
|
||||
.AddGlue()
|
||||
.End()
|
||||
.AddGroup(B_HORIZONTAL, 15)
|
||||
.AddGlue()
|
||||
.Add(playbutton)
|
||||
.Add(stopbutton)
|
||||
.End()
|
||||
.SetInsets(15, 15, 15, 15)
|
||||
);
|
||||
|
||||
box->AddChild(view);
|
||||
|
||||
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||
AddChild(BGroupLayoutBuilder(B_VERTICAL)
|
||||
.AddGroup(B_VERTICAL, 20)
|
||||
.Add(fEventList)
|
||||
.Add(box)
|
||||
.End()
|
||||
.SetInsets(12, 28, 12, 12)
|
||||
);
|
||||
|
||||
// setup file menu
|
||||
SetupMenuField();
|
||||
menu->FindItem("<none>")->SetMarked(true);
|
||||
menu->FindItem(TR("<none>"))->SetMarked(true);
|
||||
}
|
||||
|
||||
|
||||
@ -182,7 +165,7 @@ HWindow::MessageReceived(BMessage* message)
|
||||
if (row != NULL) {
|
||||
BPath path(row->Path());
|
||||
if (path.InitCheck() != B_OK) {
|
||||
BMenuItem* item = menu->FindItem("<none>");
|
||||
BMenuItem* item = menu->FindItem(TR("<none>"));
|
||||
if (item != NULL)
|
||||
item->SetMarked(true);
|
||||
} else {
|
||||
@ -218,8 +201,9 @@ HWindow::MessageReceived(BMessage* message)
|
||||
if (superType.Type() == NULL
|
||||
|| strcmp(superType.Type(), "audio") != 0) {
|
||||
beep();
|
||||
BAlert* alert = new BAlert("", "This is not a audio file.",
|
||||
"OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
|
||||
BAlert* alert = new BAlert("", TR("This is not an audio "
|
||||
"file."), TR("OK"), NULL, NULL, B_WIDTH_AS_USUAL,
|
||||
B_STOP_ALERT);
|
||||
alert->Go();
|
||||
break;
|
||||
}
|
||||
@ -280,7 +264,7 @@ HWindow::MessageReceived(BMessage* message)
|
||||
if (message->FindString("path", &path) == B_OK) {
|
||||
BPath path(path);
|
||||
if (path.InitCheck() != B_OK) {
|
||||
BMenuItem* item = menu->FindItem("<none>");
|
||||
BMenuItem* item = menu->FindItem(TR("<none>"));
|
||||
if (item != NULL)
|
||||
item->SetMarked(true);
|
||||
} else {
|
||||
|
@ -8,6 +8,16 @@ Preference Sounds :
|
||||
HApp.cpp
|
||||
HWindow.cpp
|
||||
HEventList.cpp
|
||||
: be libcolumnlistview.a game tracker libmedia.so $(TARGET_LIBSUPC++)
|
||||
: be libcolumnlistview.a game locale tracker libmedia.so
|
||||
$(TARGET_LIBSUPC++)
|
||||
: Sounds.rdef
|
||||
;
|
||||
|
||||
DoCatalogs Sounds :
|
||||
x-vnd.Haiku-Sounds
|
||||
:
|
||||
HApp.cpp
|
||||
HWindow.cpp
|
||||
HEventList.cpp
|
||||
: en.catalog
|
||||
;
|
||||
|
Loading…
Reference in New Issue
Block a user