Commit 4825a977 authored by tfarina@chromium.org's avatar tfarina@chromium.org

gtk/bookmarks: Update the label of some dialog buttons.

BUG=20053
TEST=see bug
R=sky@chromium.org

Review URL: http://codereview.chromium.org/8372038

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108219 0039d316-1c4b-4281-b951-d872f2087c98
parent 261c0ae2
......@@ -50,7 +50,9 @@ BookmarkFolderEditorController::BookmarkFolderEditorController(
l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_NEW_FOLDER_NAME) :
node_->GetTitle();
dialog_ = InputWindowDialog::Create(wnd, title, label, contents, this);
dialog_ = InputWindowDialog::Create(wnd, title, label, contents, this,
is_new_ ? InputWindowDialog::BUTTON_TYPE_ADD
: InputWindowDialog::BUTTON_TYPE_SAVE);
dialog_->Show();
}
......
......@@ -303,7 +303,7 @@ void BookmarkEditorGtk::Init(GtkWindow* parent_window) {
parent_window,
GTK_DIALOG_MODAL,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
gtk_dialog_set_has_separator(GTK_DIALOG(dialog_), FALSE);
......
......@@ -13,6 +13,11 @@
// Cross platform access to a modal input window.
class InputWindowDialog {
public:
enum ButtonType {
BUTTON_TYPE_ADD,
BUTTON_TYPE_SAVE,
};
class Delegate {
public:
virtual ~Delegate() {}
......@@ -33,7 +38,8 @@ class InputWindowDialog {
const string16& window_title,
const string16& label,
const string16& contents,
Delegate* delegate);
Delegate* delegate,
ButtonType type);
// Displays the window.
virtual void Show() = 0;
......
......@@ -14,13 +14,15 @@ InputWindowDialogGtk::InputWindowDialogGtk(GtkWindow* parent,
const std::string& window_title,
const std::string& label,
const std::string& contents,
Delegate* delegate)
Delegate* delegate,
ButtonType type)
: dialog_(gtk_dialog_new_with_buttons(
window_title.c_str(),
parent,
GTK_DIALOG_MODAL,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
type == BUTTON_TYPE_ADD ? GTK_STOCK_ADD : GTK_STOCK_SAVE,
GTK_RESPONSE_ACCEPT,
NULL)),
delegate_(delegate) {
gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT);
......
......@@ -22,7 +22,8 @@ class InputWindowDialogGtk : public InputWindowDialog {
const std::string& window_title,
const std::string& label,
const std::string& contents,
Delegate* delegate);
Delegate* delegate,
ButtonType type);
virtual ~InputWindowDialogGtk();
virtual void Show();
......
......@@ -16,24 +16,22 @@ InputWindowDialog* InputWindowDialog::Create(gfx::NativeWindow parent,
const string16& window_title,
const string16& label,
const string16& contents,
Delegate* delegate) {
Delegate* delegate,
ButtonType type) {
#if defined(USE_AURA)
return new InputWindowDialogWebUI(window_title,
label,
contents,
delegate);
// TODO(tfarina): Implement ButtonType into WebUI dialog too.
return new InputWindowDialogWebUI(window_title, label, contents, delegate);
#else
if (ChromeWebUI::IsMoreWebUI()) {
return new InputWindowDialogWebUI(window_title,
label,
contents,
delegate);
// TODO(tfarina): Implement ButtonType into WebUI dialog too.
return new InputWindowDialogWebUI(window_title, label, contents, delegate);
} else {
return new InputWindowDialogGtk(parent,
UTF16ToUTF8(window_title),
UTF16ToUTF8(label),
UTF16ToUTF8(contents),
delegate);
delegate,
type);
}
#endif
}
......@@ -25,14 +25,14 @@ const int kTextfieldWidth = 200;
} // namespace
// The Windows implementation of the cross platform input dialog interface.
class WinInputWindowDialog : public InputWindowDialog {
class InputWindowDialogWin : public InputWindowDialog {
public:
WinInputWindowDialog(gfx::NativeWindow parent,
InputWindowDialogWin(gfx::NativeWindow parent,
const string16& window_title,
const string16& label,
const string16& contents,
Delegate* delegate);
virtual ~WinInputWindowDialog();
virtual ~InputWindowDialogWin();
// Overridden from InputWindowDialog:
virtual void Show() OVERRIDE;
......@@ -62,11 +62,11 @@ class WinInputWindowDialog : public InputWindowDialog {
class ContentView : public views::DialogDelegateView,
public views::TextfieldController {
public:
explicit ContentView(WinInputWindowDialog* delegate);
explicit ContentView(InputWindowDialogWin* delegate);
// views::DialogDelegateView:
virtual bool IsDialogButtonEnabled(
MessageBoxFlags::DialogButton button) const OVERRIDE;
ui::MessageBoxFlags::DialogButton button) const OVERRIDE;
virtual bool Accept() OVERRIDE;
virtual bool Cancel() OVERRIDE;
virtual void DeleteDelegate() OVERRIDE;
......@@ -98,7 +98,7 @@ class ContentView : public views::DialogDelegateView,
// The delegate that the ContentView uses to communicate changes to the
// caller.
WinInputWindowDialog* delegate_;
InputWindowDialogWin* delegate_;
// Helps us set focus to the first Textfield in the window.
ScopedRunnableMethodFactory<ContentView> focus_grabber_factory_;
......@@ -108,7 +108,7 @@ class ContentView : public views::DialogDelegateView,
///////////////////////////////////////////////////////////////////////////////
// ContentView
ContentView::ContentView(WinInputWindowDialog* delegate)
ContentView::ContentView(InputWindowDialogWin* delegate)
: delegate_(delegate),
ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)) {
DCHECK(delegate_);
......@@ -118,8 +118,8 @@ ContentView::ContentView(WinInputWindowDialog* delegate)
// ContentView, views::DialogDelegate implementation:
bool ContentView::IsDialogButtonEnabled(
MessageBoxFlags::DialogButton button) const {
if (button == MessageBoxFlags::DIALOGBUTTON_OK &&
ui::MessageBoxFlags::DialogButton button) const {
if (button == ui::MessageBoxFlags::DIALOGBUTTON_OK &&
!delegate_->delegate()->IsValid(text_field_->text())) {
return false;
}
......@@ -180,21 +180,19 @@ void ContentView::ViewHierarchyChanged(bool is_add,
void ContentView::InitControlLayout() {
text_field_ = new views::Textfield;
text_field_->SetText(UTF16ToWideHack(delegate_->contents()));
text_field_->SetText(delegate_->contents());
text_field_->SetController(this);
using views::GridLayout;
// TODO(sky): Vertical alignment should be baseline.
GridLayout* layout = GridLayout::CreatePanel(this);
views::GridLayout* layout = views::GridLayout::CreatePanel(this);
SetLayoutManager(layout);
views::ColumnSet* c1 = layout->AddColumnSet(0);
c1->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0,
GridLayout::USE_PREF, 0, 0);
c1->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0,
views::GridLayout::USE_PREF, 0, 0);
c1->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing);
c1->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
GridLayout::USE_PREF, kTextfieldWidth, kTextfieldWidth);
c1->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 1,
views::GridLayout::USE_PREF, kTextfieldWidth, kTextfieldWidth);
layout->StartRow(0, 0);
views::Label* label = new views::Label(delegate_->label());
......@@ -211,7 +209,7 @@ void ContentView::FocusFirstFocusableControl() {
text_field_->RequestFocus();
}
WinInputWindowDialog::WinInputWindowDialog(gfx::NativeWindow parent,
InputWindowDialogWin::InputWindowDialogWin(gfx::NativeWindow parent,
const string16& window_title,
const string16& label,
const string16& contents,
......@@ -225,14 +223,14 @@ WinInputWindowDialog::WinInputWindowDialog(gfx::NativeWindow parent,
window_->client_view()->AsDialogClientView()->UpdateDialogButtons();
}
WinInputWindowDialog::~WinInputWindowDialog() {
InputWindowDialogWin::~InputWindowDialogWin() {
}
void WinInputWindowDialog::Show() {
void InputWindowDialogWin::Show() {
window_->Show();
}
void WinInputWindowDialog::Close() {
void InputWindowDialogWin::Close() {
window_->Close();
}
......@@ -241,7 +239,8 @@ InputWindowDialog* InputWindowDialog::Create(gfx::NativeWindow parent,
const string16& window_title,
const string16& label,
const string16& contents,
Delegate* delegate) {
return new WinInputWindowDialog(
Delegate* delegate,
ButtonType type) {
return new InputWindowDialogWin(
parent, window_title, label, contents, delegate);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment