| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/continue_window.h" | 5 #include "remoting/host/continue_window.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "remoting/host/chromoting_host.h" | 12 #include "remoting/host/chromoting_host.h" |
| 13 #include "remoting/host/ui_strings.h" | 13 #include "remoting/host/ui_strings.h" |
| 14 #include "ui/base/gtk/gtk_signal.h" | 14 #include "ui/base/gtk/gtk_signal.h" |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 | 17 |
| 18 class ContinueWindowLinux : public remoting::ContinueWindow { | 18 class ContinueWindowGtk : public remoting::ContinueWindow { |
| 19 public: | 19 public: |
| 20 ContinueWindowLinux(); | 20 ContinueWindowGtk(); |
| 21 virtual ~ContinueWindowLinux(); | 21 virtual ~ContinueWindowGtk(); |
| 22 | 22 |
| 23 virtual void Show(remoting::ChromotingHost* host, | 23 virtual void Show(remoting::ChromotingHost* host, |
| 24 const ContinueSessionCallback& callback) OVERRIDE; | 24 const ContinueSessionCallback& callback) OVERRIDE; |
| 25 virtual void Hide() OVERRIDE; | 25 virtual void Hide() OVERRIDE; |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 CHROMEGTK_CALLBACK_1(ContinueWindowLinux, void, OnResponse, int); | 28 CHROMEGTK_CALLBACK_1(ContinueWindowGtk, void, OnResponse, int); |
| 29 | 29 |
| 30 void CreateWindow(const UiStrings& ui_strings); | 30 void CreateWindow(const UiStrings& ui_strings); |
| 31 | 31 |
| 32 ChromotingHost* host_; | 32 ChromotingHost* host_; |
| 33 ContinueSessionCallback callback_; | 33 ContinueSessionCallback callback_; |
| 34 GtkWidget* continue_window_; | 34 GtkWidget* continue_window_; |
| 35 | 35 |
| 36 DISALLOW_COPY_AND_ASSIGN(ContinueWindowLinux); | 36 DISALLOW_COPY_AND_ASSIGN(ContinueWindowGtk); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 ContinueWindowLinux::ContinueWindowLinux() | 39 ContinueWindowGtk::ContinueWindowGtk() |
| 40 : host_(NULL), | 40 : host_(NULL), |
| 41 continue_window_(NULL) { | 41 continue_window_(NULL) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 ContinueWindowLinux::~ContinueWindowLinux() { | 44 ContinueWindowGtk::~ContinueWindowGtk() { |
| 45 } | 45 } |
| 46 | 46 |
| 47 void ContinueWindowLinux::CreateWindow(const UiStrings& ui_strings) { | 47 void ContinueWindowGtk::CreateWindow(const UiStrings& ui_strings) { |
| 48 if (continue_window_) return; | 48 if (continue_window_) return; |
| 49 | 49 |
| 50 continue_window_ = gtk_dialog_new_with_buttons( | 50 continue_window_ = gtk_dialog_new_with_buttons( |
| 51 UTF16ToUTF8(ui_strings.product_name).c_str(), | 51 UTF16ToUTF8(ui_strings.product_name).c_str(), |
| 52 NULL, | 52 NULL, |
| 53 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), | 53 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), |
| 54 UTF16ToUTF8(ui_strings.stop_sharing_button_text).c_str(), | 54 UTF16ToUTF8(ui_strings.stop_sharing_button_text).c_str(), |
| 55 GTK_RESPONSE_CANCEL, | 55 GTK_RESPONSE_CANCEL, |
| 56 UTF16ToUTF8(ui_strings.continue_button_text).c_str(), | 56 UTF16ToUTF8(ui_strings.continue_button_text).c_str(), |
| 57 GTK_RESPONSE_OK, | 57 GTK_RESPONSE_OK, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 74 GtkWidget* text_label = | 74 GtkWidget* text_label = |
| 75 gtk_label_new(UTF16ToUTF8(ui_strings.continue_prompt).c_str()); | 75 gtk_label_new(UTF16ToUTF8(ui_strings.continue_prompt).c_str()); |
| 76 gtk_label_set_line_wrap(GTK_LABEL(text_label), TRUE); | 76 gtk_label_set_line_wrap(GTK_LABEL(text_label), TRUE); |
| 77 // TODO(lambroslambrou): Fix magic numbers, as in disconnect_window_linux.cc. | 77 // TODO(lambroslambrou): Fix magic numbers, as in disconnect_window_linux.cc. |
| 78 gtk_misc_set_padding(GTK_MISC(text_label), 12, 12); | 78 gtk_misc_set_padding(GTK_MISC(text_label), 12, 12); |
| 79 gtk_container_add(GTK_CONTAINER(content_area), text_label); | 79 gtk_container_add(GTK_CONTAINER(content_area), text_label); |
| 80 | 80 |
| 81 gtk_widget_show_all(content_area); | 81 gtk_widget_show_all(content_area); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void ContinueWindowLinux::Show(remoting::ChromotingHost* host, | 84 void ContinueWindowGtk::Show(remoting::ChromotingHost* host, |
| 85 const ContinueSessionCallback& callback) { | 85 const ContinueSessionCallback& callback) { |
| 86 host_ = host; | 86 host_ = host; |
| 87 callback_ = callback; | 87 callback_ = callback; |
| 88 CreateWindow(host->ui_strings()); | 88 CreateWindow(host->ui_strings()); |
| 89 gtk_window_set_urgency_hint(GTK_WINDOW(continue_window_), TRUE); | 89 gtk_window_set_urgency_hint(GTK_WINDOW(continue_window_), TRUE); |
| 90 gtk_window_present(GTK_WINDOW(continue_window_)); | 90 gtk_window_present(GTK_WINDOW(continue_window_)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void ContinueWindowLinux::Hide() { | 93 void ContinueWindowGtk::Hide() { |
| 94 if (continue_window_) { | 94 if (continue_window_) { |
| 95 gtk_widget_destroy(continue_window_); | 95 gtk_widget_destroy(continue_window_); |
| 96 continue_window_ = NULL; | 96 continue_window_ = NULL; |
| 97 } | 97 } |
| 98 } | 98 } |
| 99 | 99 |
| 100 void ContinueWindowLinux::OnResponse(GtkWidget* dialog, int response_id) { | 100 void ContinueWindowGtk::OnResponse(GtkWidget* dialog, int response_id) { |
| 101 callback_.Run(response_id == GTK_RESPONSE_OK); | 101 callback_.Run(response_id == GTK_RESPONSE_OK); |
| 102 Hide(); | 102 Hide(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 scoped_ptr<ContinueWindow> ContinueWindow::Create() { | 105 scoped_ptr<ContinueWindow> ContinueWindow::Create() { |
| 106 return scoped_ptr<ContinueWindow>(new ContinueWindowLinux()); | 106 return scoped_ptr<ContinueWindow>(new ContinueWindowGtk()); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace remoting | 109 } // namespace remoting |
| OLD | NEW |