summaryrefslogtreecommitdiffstats
path: root/remoting/host/continue_window_gtk.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-17 01:58:46 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-17 01:58:46 +0000
commit8b8f0b24b1c7a0875732053063030ecb2b20a6af (patch)
tree195e89f3a7fde8c8452435173ea38acb9020b936 /remoting/host/continue_window_gtk.cc
parentdc948982b2a845986bc61e33e5df501ccaea7192 (diff)
downloadchromium_src-8b8f0b24b1c7a0875732053063030ecb2b20a6af.zip
chromium_src-8b8f0b24b1c7a0875732053063030ecb2b20a6af.tar.gz
chromium_src-8b8f0b24b1c7a0875732053063030ecb2b20a6af.tar.bz2
Fix remoting_unittests compilation in aura builds.
Moved gtk-dependent code to files with _gtk suffix that are excluded when compiling without GTK. Also some minor cleanups in remoting.gyp. BUG=114211 Review URL: https://chromiumcodereview.appspot.com/10386181 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137610 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/continue_window_gtk.cc')
-rw-r--r--remoting/host/continue_window_gtk.cc109
1 files changed, 109 insertions, 0 deletions
diff --git a/remoting/host/continue_window_gtk.cc b/remoting/host/continue_window_gtk.cc
new file mode 100644
index 0000000..7301657
--- /dev/null
+++ b/remoting/host/continue_window_gtk.cc
@@ -0,0 +1,109 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/continue_window.h"
+
+#include <gtk/gtk.h>
+
+#include "base/compiler_specific.h"
+#include "base/logging.h"
+#include "base/utf_string_conversions.h"
+#include "remoting/host/chromoting_host.h"
+#include "remoting/host/ui_strings.h"
+#include "ui/base/gtk/gtk_signal.h"
+
+namespace remoting {
+
+class ContinueWindowGtk : public remoting::ContinueWindow {
+ public:
+ ContinueWindowGtk();
+ virtual ~ContinueWindowGtk();
+
+ virtual void Show(remoting::ChromotingHost* host,
+ const ContinueSessionCallback& callback) OVERRIDE;
+ virtual void Hide() OVERRIDE;
+
+ private:
+ CHROMEGTK_CALLBACK_1(ContinueWindowGtk, void, OnResponse, int);
+
+ void CreateWindow(const UiStrings& ui_strings);
+
+ ChromotingHost* host_;
+ ContinueSessionCallback callback_;
+ GtkWidget* continue_window_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContinueWindowGtk);
+};
+
+ContinueWindowGtk::ContinueWindowGtk()
+ : host_(NULL),
+ continue_window_(NULL) {
+}
+
+ContinueWindowGtk::~ContinueWindowGtk() {
+}
+
+void ContinueWindowGtk::CreateWindow(const UiStrings& ui_strings) {
+ if (continue_window_) return;
+
+ continue_window_ = gtk_dialog_new_with_buttons(
+ UTF16ToUTF8(ui_strings.product_name).c_str(),
+ NULL,
+ static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
+ UTF16ToUTF8(ui_strings.stop_sharing_button_text).c_str(),
+ GTK_RESPONSE_CANCEL,
+ UTF16ToUTF8(ui_strings.continue_button_text).c_str(),
+ GTK_RESPONSE_OK,
+ NULL);
+
+ gtk_dialog_set_default_response(GTK_DIALOG(continue_window_),
+ GTK_RESPONSE_OK);
+ gtk_window_set_resizable(GTK_WINDOW(continue_window_), FALSE);
+
+ // Set always-on-top, otherwise this window tends to be obscured by the
+ // DisconnectWindow.
+ gtk_window_set_keep_above(GTK_WINDOW(continue_window_), TRUE);
+
+ g_signal_connect(continue_window_, "response",
+ G_CALLBACK(OnResponseThunk), this);
+
+ GtkWidget* content_area =
+ gtk_dialog_get_content_area(GTK_DIALOG(continue_window_));
+
+ GtkWidget* text_label =
+ gtk_label_new(UTF16ToUTF8(ui_strings.continue_prompt).c_str());
+ gtk_label_set_line_wrap(GTK_LABEL(text_label), TRUE);
+ // TODO(lambroslambrou): Fix magic numbers, as in disconnect_window_linux.cc.
+ gtk_misc_set_padding(GTK_MISC(text_label), 12, 12);
+ gtk_container_add(GTK_CONTAINER(content_area), text_label);
+
+ gtk_widget_show_all(content_area);
+}
+
+void ContinueWindowGtk::Show(remoting::ChromotingHost* host,
+ const ContinueSessionCallback& callback) {
+ host_ = host;
+ callback_ = callback;
+ CreateWindow(host->ui_strings());
+ gtk_window_set_urgency_hint(GTK_WINDOW(continue_window_), TRUE);
+ gtk_window_present(GTK_WINDOW(continue_window_));
+}
+
+void ContinueWindowGtk::Hide() {
+ if (continue_window_) {
+ gtk_widget_destroy(continue_window_);
+ continue_window_ = NULL;
+ }
+}
+
+void ContinueWindowGtk::OnResponse(GtkWidget* dialog, int response_id) {
+ callback_.Run(response_id == GTK_RESPONSE_OK);
+ Hide();
+}
+
+scoped_ptr<ContinueWindow> ContinueWindow::Create() {
+ return scoped_ptr<ContinueWindow>(new ContinueWindowGtk());
+}
+
+} // namespace remoting