| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "remoting/host/chromoting_host.h" | 11 #include "remoting/host/chromoting_host.h" |
| 12 #include "remoting/host/ui_strings.h" |
| 12 #include "ui/base/gtk/gtk_signal.h" | 13 #include "ui/base/gtk/gtk_signal.h" |
| 13 | 14 |
| 14 namespace remoting { | 15 namespace remoting { |
| 15 | 16 |
| 16 class ContinueWindowLinux : public remoting::ContinueWindow { | 17 class ContinueWindowLinux : public remoting::ContinueWindow { |
| 17 public: | 18 public: |
| 18 ContinueWindowLinux(); | 19 ContinueWindowLinux(); |
| 19 virtual ~ContinueWindowLinux(); | 20 virtual ~ContinueWindowLinux(); |
| 20 | 21 |
| 21 virtual void Show(remoting::ChromotingHost* host) OVERRIDE; | 22 virtual void Show(remoting::ChromotingHost* host) OVERRIDE; |
| 22 virtual void Hide() OVERRIDE; | 23 virtual void Hide() OVERRIDE; |
| 23 | 24 |
| 24 private: | 25 private: |
| 25 CHROMEGTK_CALLBACK_1(ContinueWindowLinux, void, OnResponse, int); | 26 CHROMEGTK_CALLBACK_1(ContinueWindowLinux, void, OnResponse, int); |
| 26 | 27 |
| 27 void CreateWindow(); | 28 void CreateWindow(UiStrings* ui_strings); |
| 28 | 29 |
| 29 ChromotingHost* host_; | 30 ChromotingHost* host_; |
| 30 GtkWidget* continue_window_; | 31 GtkWidget* continue_window_; |
| 31 | 32 |
| 32 DISALLOW_COPY_AND_ASSIGN(ContinueWindowLinux); | 33 DISALLOW_COPY_AND_ASSIGN(ContinueWindowLinux); |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 ContinueWindowLinux::ContinueWindowLinux() | 36 ContinueWindowLinux::ContinueWindowLinux() |
| 36 : host_(NULL), | 37 : host_(NULL), |
| 37 continue_window_(NULL) { | 38 continue_window_(NULL) { |
| 38 } | 39 } |
| 39 | 40 |
| 40 ContinueWindowLinux::~ContinueWindowLinux() { | 41 ContinueWindowLinux::~ContinueWindowLinux() { |
| 41 } | 42 } |
| 42 | 43 |
| 43 void ContinueWindowLinux::CreateWindow() { | 44 void ContinueWindowLinux::CreateWindow(UiStrings* ui_strings) { |
| 44 if (continue_window_) return; | 45 if (continue_window_) return; |
| 45 | 46 |
| 46 continue_window_ = gtk_dialog_new_with_buttons( | 47 continue_window_ = gtk_dialog_new_with_buttons( |
| 47 kTitle, | 48 ui_strings->productName.c_str(), |
| 48 NULL, | 49 NULL, |
| 49 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), | 50 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), |
| 50 kCancelButtonText, GTK_RESPONSE_CANCEL, | 51 ui_strings->stopSharingButtonText.c_str(), GTK_RESPONSE_CANCEL, |
| 51 kDefaultButtonText, GTK_RESPONSE_OK, | 52 ui_strings->continueButtonText.c_str(), GTK_RESPONSE_OK, |
| 52 NULL); | 53 NULL); |
| 53 | 54 |
| 54 gtk_dialog_set_default_response(GTK_DIALOG(continue_window_), | 55 gtk_dialog_set_default_response(GTK_DIALOG(continue_window_), |
| 55 GTK_RESPONSE_OK); | 56 GTK_RESPONSE_OK); |
| 56 gtk_window_set_resizable(GTK_WINDOW(continue_window_), FALSE); | 57 gtk_window_set_resizable(GTK_WINDOW(continue_window_), FALSE); |
| 57 | 58 |
| 58 // Set always-on-top, otherwise this window tends to be obscured by the | 59 // Set always-on-top, otherwise this window tends to be obscured by the |
| 59 // DisconnectWindow. | 60 // DisconnectWindow. |
| 60 gtk_window_set_keep_above(GTK_WINDOW(continue_window_), TRUE); | 61 gtk_window_set_keep_above(GTK_WINDOW(continue_window_), TRUE); |
| 61 | 62 |
| 62 g_signal_connect(continue_window_, "response", | 63 g_signal_connect(continue_window_, "response", |
| 63 G_CALLBACK(OnResponseThunk), this); | 64 G_CALLBACK(OnResponseThunk), this); |
| 64 | 65 |
| 65 GtkWidget* content_area = | 66 GtkWidget* content_area = |
| 66 gtk_dialog_get_content_area(GTK_DIALOG(continue_window_)); | 67 gtk_dialog_get_content_area(GTK_DIALOG(continue_window_)); |
| 67 | 68 |
| 68 GtkWidget* text_label = gtk_label_new(kMessage); | 69 GtkWidget* text_label = gtk_label_new(ui_strings->continuePrompt.c_str()); |
| 69 gtk_label_set_line_wrap(GTK_LABEL(text_label), TRUE); | 70 gtk_label_set_line_wrap(GTK_LABEL(text_label), TRUE); |
| 70 // TODO(lambroslambrou): Fix magic numbers, as in disconnect_window_linux.cc. | 71 // TODO(lambroslambrou): Fix magic numbers, as in disconnect_window_linux.cc. |
| 71 gtk_misc_set_padding(GTK_MISC(text_label), 12, 12); | 72 gtk_misc_set_padding(GTK_MISC(text_label), 12, 12); |
| 72 gtk_container_add(GTK_CONTAINER(content_area), text_label); | 73 gtk_container_add(GTK_CONTAINER(content_area), text_label); |
| 73 | 74 |
| 74 gtk_widget_show_all(content_area); | 75 gtk_widget_show_all(content_area); |
| 75 } | 76 } |
| 76 | 77 |
| 77 void ContinueWindowLinux::Show(remoting::ChromotingHost* host) { | 78 void ContinueWindowLinux::Show(remoting::ChromotingHost* host) { |
| 78 host_ = host; | 79 host_ = host; |
| 79 CreateWindow(); | 80 CreateWindow(host->ui_strings()); |
| 80 gtk_window_set_urgency_hint(GTK_WINDOW(continue_window_), TRUE); | 81 gtk_window_set_urgency_hint(GTK_WINDOW(continue_window_), TRUE); |
| 81 gtk_window_present(GTK_WINDOW(continue_window_)); | 82 gtk_window_present(GTK_WINDOW(continue_window_)); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void ContinueWindowLinux::Hide() { | 85 void ContinueWindowLinux::Hide() { |
| 85 if (continue_window_) { | 86 if (continue_window_) { |
| 86 gtk_widget_destroy(continue_window_); | 87 gtk_widget_destroy(continue_window_); |
| 87 continue_window_ = NULL; | 88 continue_window_ = NULL; |
| 88 } | 89 } |
| 89 } | 90 } |
| 90 | 91 |
| 91 void ContinueWindowLinux::OnResponse(GtkWidget* dialog, int response_id) { | 92 void ContinueWindowLinux::OnResponse(GtkWidget* dialog, int response_id) { |
| 92 if (response_id == GTK_RESPONSE_OK) { | 93 if (response_id == GTK_RESPONSE_OK) { |
| 93 host_->PauseSession(false); | 94 host_->PauseSession(false); |
| 94 } else { | 95 } else { |
| 95 host_->Shutdown(NULL); | 96 host_->Shutdown(NULL); |
| 96 } | 97 } |
| 97 Hide(); | 98 Hide(); |
| 98 } | 99 } |
| 99 | 100 |
| 100 ContinueWindow* ContinueWindow::Create() { | 101 ContinueWindow* ContinueWindow::Create() { |
| 101 return new ContinueWindowLinux(); | 102 return new ContinueWindowLinux(); |
| 102 } | 103 } |
| 103 | 104 |
| 104 } // namespace remoting | 105 } // namespace remoting |
| OLD | NEW |