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 "HWindow.h"
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <Locale.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "SoundsHApp"
|
||||||
|
|
||||||
|
|
||||||
HApp::HApp()
|
HApp::HApp()
|
||||||
:
|
:
|
||||||
BApplication("application/x-vnd.Haiku-Sounds")
|
BApplication("application/x-vnd.Haiku-Sounds")
|
||||||
{
|
{
|
||||||
|
be_locale->GetAppCatalog(&fCatalog);
|
||||||
|
|
||||||
BRect rect;
|
BRect rect;
|
||||||
rect.Set(200, 150, 590, 570);
|
rect.Set(200, 150, 590, 570);
|
||||||
|
|
||||||
HWindow* window = new HWindow(rect, "Sounds");
|
HWindow* window = new HWindow(rect, TR("Sounds"));
|
||||||
window->Show();
|
window->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,13 +43,14 @@ HApp::~HApp()
|
|||||||
void
|
void
|
||||||
HApp::AboutRequested()
|
HApp::AboutRequested()
|
||||||
{
|
{
|
||||||
BAlert* alert = new BAlert("About Sounds",
|
BAlert* alert = new BAlert(TR("About Sounds"),
|
||||||
"Sounds\n"
|
TR("Sounds\n"
|
||||||
" Brought to you by :\n"
|
" Brought to you by :\n"
|
||||||
" Oliver Ruiz Dorantes\n"
|
"\tOliver Ruiz Dorantes\n"
|
||||||
" Jérôme DUVAL.\n"
|
"\tJérôme DUVAL.\n"
|
||||||
" Original work from Atsushi Takamatsu.\n"
|
" Original work from Atsushi Takamatsu.\n"
|
||||||
"Copyright " B_UTF8_COPYRIGHT "2003-2006 Haiku", "OK");
|
"Copyright ©2003-2006 Haiku"),
|
||||||
|
TR("OK"));
|
||||||
alert->Go();
|
alert->Go();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <Catalog.h>
|
||||||
|
|
||||||
|
|
||||||
class HApp : public BApplication {
|
class HApp : public BApplication {
|
||||||
@ -19,6 +20,9 @@ public:
|
|||||||
HApp();
|
HApp();
|
||||||
virtual ~HApp();
|
virtual ~HApp();
|
||||||
virtual void AboutRequested();
|
virtual void AboutRequested();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BCatalog fCatalog;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,13 +10,19 @@
|
|||||||
#include "HEventList.h"
|
#include "HEventList.h"
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <ColumnTypes.h>
|
#include <ColumnTypes.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
#include <Locale.h>
|
||||||
#include <MediaFiles.h>
|
#include <MediaFiles.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "HEventList"
|
||||||
|
|
||||||
|
|
||||||
HEventRow::HEventRow(const char* name, const char* path)
|
HEventRow::HEventRow(const char* name, const char* path)
|
||||||
:
|
:
|
||||||
BRow(),
|
BRow(),
|
||||||
@ -37,7 +43,8 @@ HEventRow::SetPath(const char* _path)
|
|||||||
{
|
{
|
||||||
fPath = _path;
|
fPath = _path;
|
||||||
BPath path(_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)
|
fType(NULL)
|
||||||
{
|
{
|
||||||
AddColumn(new BStringColumn("Event", 150, 50, 500, B_TRUNCATE_MIDDLE),
|
AddColumn(new BStringColumn(TR("Event"), 150, 50, 500, B_TRUNCATE_MIDDLE),
|
||||||
kEventColumn);
|
kEventColumn);
|
||||||
AddColumn(new BStringColumn("Sound", 150, 50, 500, B_TRUNCATE_END),
|
AddColumn(new BStringColumn(TR("Sound"), 150, 50, 500, B_TRUNCATE_END),
|
||||||
kSoundColumn);
|
kSoundColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +126,7 @@ HEventList::SelectionChanged()
|
|||||||
printf("name %s\n", ref.name);
|
printf("name %s\n", ref.name);
|
||||||
BMediaFiles().RemoveRefFor(fType, row->Name(), ref);
|
BMediaFiles().RemoveRefFor(fType, row->Name(), ref);
|
||||||
BAlert* alert = new BAlert("alert",
|
BAlert* alert = new BAlert("alert",
|
||||||
"No such file or directory", "OK");
|
TR("No such file or directory"), TR("OK"));
|
||||||
alert->Go();
|
alert->Go();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,7 @@ enum {
|
|||||||
|
|
||||||
class HEventList : public BColumnListView {
|
class HEventList : public BColumnListView {
|
||||||
public:
|
public:
|
||||||
HEventList(BRect rect,
|
HEventList(const char* name = "EventList");
|
||||||
const char* name = "EventList");
|
|
||||||
virtual ~HEventList();
|
virtual ~HEventList();
|
||||||
void RemoveAll();
|
void RemoveAll();
|
||||||
void SetType(const char* type);
|
void SetType(const char* type);
|
||||||
|
@ -19,8 +19,11 @@
|
|||||||
#include <Beep.h>
|
#include <Beep.h>
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
|
#include <GroupLayoutBuilder.h>
|
||||||
|
#include <Locale.h>
|
||||||
#include <MediaFiles.h>
|
#include <MediaFiles.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
@ -34,21 +37,19 @@
|
|||||||
#include <Sound.h>
|
#include <Sound.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "HWindow"
|
||||||
|
|
||||||
static const char kSettingsFile[] = "Sounds_Settings";
|
static const char kSettingsFile[] = "Sounds_Settings";
|
||||||
|
|
||||||
|
|
||||||
HWindow::HWindow(BRect rect, const char* name)
|
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),
|
fFilePanel(NULL),
|
||||||
fPlayer(NULL)
|
fPlayer(NULL)
|
||||||
{
|
{
|
||||||
InitGUI();
|
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 = new BFilePanel();
|
||||||
fFilePanel->SetTarget(this);
|
fFilePanel->SetTarget(this);
|
||||||
@ -91,78 +92,60 @@ HWindow::~HWindow()
|
|||||||
void
|
void
|
||||||
HWindow::InitGUI()
|
HWindow::InitGUI()
|
||||||
{
|
{
|
||||||
BRect rect = Bounds();
|
fEventList = new HEventList();
|
||||||
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->SetType(BMediaFiles::B_SOUNDS);
|
fEventList->SetType(BMediaFiles::B_SOUNDS);
|
||||||
fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);
|
fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);
|
||||||
|
|
||||||
rect = Bounds();
|
BGroupView* view = new BGroupView();
|
||||||
rect.top = rect.bottom - 105;
|
BBox* box = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS
|
||||||
BView* view = new BView(rect, "", B_FOLLOW_NONE,
|
| B_NAVIGABLE_JUMP | B_PULSE_NEEDED);
|
||||||
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;
|
|
||||||
BMenu* menu = new BMenu("file");
|
BMenu* menu = new BMenu("file");
|
||||||
menu->SetRadioMode(true);
|
menu->SetRadioMode(true);
|
||||||
menu->SetLabelFromMarked(true);
|
menu->SetLabelFromMarked(true);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
menu->AddItem(new BMenuItem(TR("<none>"), new BMessage(M_NONE_MESSAGE)));
|
||||||
menu->AddItem(new BMenuItem("<none>", new BMessage(M_NONE_MESSAGE)));
|
menu->AddItem(new BMenuItem(TR("Other" B_UTF8_ELLIPSIS),
|
||||||
menu->AddItem(new BMenuItem("Other" B_UTF8_ELLIPSIS,
|
|
||||||
new BMessage(M_OTHER_MESSAGE)));
|
new BMessage(M_OTHER_MESSAGE)));
|
||||||
BMenuField* menuField = new BMenuField(rect, "filemenu", "Sound file:",
|
BMenuField* menuField = new BMenuField("filemenu", TR("Sound File:"), menu);
|
||||||
menu, B_FOLLOW_TOP | B_FOLLOW_LEFT);
|
menuField->SetDivider(menuField->StringWidth(TR("Sound File:")) + 10);
|
||||||
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);
|
|
||||||
|
|
||||||
rect = button->Frame();
|
BButton* stopbutton = new BButton("stop", TR("Stop"),
|
||||||
view->ResizeTo(view->Bounds().Width(), 24 + rect.bottom + 12);
|
new BMessage(M_STOP_MESSAGE));
|
||||||
box->ResizeTo(box->Bounds().Width(), rect.bottom + 12);
|
stopbutton->SetEnabled(false);
|
||||||
|
|
||||||
button->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
BButton* playbutton = new BButton("play", TR("Play"),
|
||||||
button = new BButton(rect, "play", "Play", new BMessage(M_PLAY_MESSAGE),
|
new BMessage(M_PLAY_MESSAGE));
|
||||||
B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
playbutton->SetEnabled(false);
|
||||||
button->ResizeToPreferred();
|
|
||||||
button->SetEnabled(false);
|
|
||||||
button->MoveTo(rect.left - button->Bounds().Width() - 15, rect.top);
|
|
||||||
box->AddChild(button);
|
|
||||||
|
|
||||||
view->MoveTo(0, listView->Frame().bottom);
|
view->SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
ResizeTo(Bounds().Width(),
|
view->AddChild(BGroupLayoutBuilder(B_VERTICAL, 15)
|
||||||
listView->Frame().bottom + view->Bounds().Height());
|
.AddGroup(B_HORIZONTAL)
|
||||||
listView->SetResizingMode(B_FOLLOW_ALL);
|
.Add(menuField)
|
||||||
view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
|
.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
|
// setup file menu
|
||||||
SetupMenuField();
|
SetupMenuField();
|
||||||
menu->FindItem("<none>")->SetMarked(true);
|
menu->FindItem(TR("<none>"))->SetMarked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -182,7 +165,7 @@ HWindow::MessageReceived(BMessage* message)
|
|||||||
if (row != NULL) {
|
if (row != NULL) {
|
||||||
BPath path(row->Path());
|
BPath path(row->Path());
|
||||||
if (path.InitCheck() != B_OK) {
|
if (path.InitCheck() != B_OK) {
|
||||||
BMenuItem* item = menu->FindItem("<none>");
|
BMenuItem* item = menu->FindItem(TR("<none>"));
|
||||||
if (item != NULL)
|
if (item != NULL)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
} else {
|
} else {
|
||||||
@ -218,8 +201,9 @@ HWindow::MessageReceived(BMessage* message)
|
|||||||
if (superType.Type() == NULL
|
if (superType.Type() == NULL
|
||||||
|| strcmp(superType.Type(), "audio") != 0) {
|
|| strcmp(superType.Type(), "audio") != 0) {
|
||||||
beep();
|
beep();
|
||||||
BAlert* alert = new BAlert("", "This is not a audio file.",
|
BAlert* alert = new BAlert("", TR("This is not an audio "
|
||||||
"OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
|
"file."), TR("OK"), NULL, NULL, B_WIDTH_AS_USUAL,
|
||||||
|
B_STOP_ALERT);
|
||||||
alert->Go();
|
alert->Go();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -280,7 +264,7 @@ HWindow::MessageReceived(BMessage* message)
|
|||||||
if (message->FindString("path", &path) == B_OK) {
|
if (message->FindString("path", &path) == B_OK) {
|
||||||
BPath path(path);
|
BPath path(path);
|
||||||
if (path.InitCheck() != B_OK) {
|
if (path.InitCheck() != B_OK) {
|
||||||
BMenuItem* item = menu->FindItem("<none>");
|
BMenuItem* item = menu->FindItem(TR("<none>"));
|
||||||
if (item != NULL)
|
if (item != NULL)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -8,6 +8,16 @@ Preference Sounds :
|
|||||||
HApp.cpp
|
HApp.cpp
|
||||||
HWindow.cpp
|
HWindow.cpp
|
||||||
HEventList.cpp
|
HEventList.cpp
|
||||||
: be libcolumnlistview.a game tracker libmedia.so $(TARGET_LIBSUPC++)
|
: be libcolumnlistview.a game locale tracker libmedia.so
|
||||||
|
$(TARGET_LIBSUPC++)
|
||||||
: Sounds.rdef
|
: Sounds.rdef
|
||||||
;
|
;
|
||||||
|
|
||||||
|
DoCatalogs Sounds :
|
||||||
|
x-vnd.Haiku-Sounds
|
||||||
|
:
|
||||||
|
HApp.cpp
|
||||||
|
HWindow.cpp
|
||||||
|
HEventList.cpp
|
||||||
|
: en.catalog
|
||||||
|
;
|
||||||
|
Loading…
Reference in New Issue
Block a user