Infer appropriate GNU_STACK alignment for a shared library.
[chromium-blink-merge.git] / remoting / host / continue_window_linux.cc
blob9f31d90fb502992af118669a096944a2706f54f2
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
3 // found in the LICENSE file.
5 #include <gtk/gtk.h>
7 #include "base/compiler_specific.h"
8 #include "base/logging.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "remoting/base/string_resources.h"
11 #include "remoting/host/continue_window.h"
12 #include "ui/base/glib/glib_signal.h"
13 #include "ui/base/l10n/l10n_util.h"
15 namespace remoting {
17 class ContinueWindowGtk : public ContinueWindow {
18 public:
19 ContinueWindowGtk();
20 ~ContinueWindowGtk() override;
22 protected:
23 // ContinueWindow overrides.
24 void ShowUi() override;
25 void HideUi() override;
27 private:
28 void CreateWindow();
30 CHROMEG_CALLBACK_1(ContinueWindowGtk, void, OnResponse, GtkDialog*, int);
32 GtkWidget* continue_window_;
34 DISALLOW_COPY_AND_ASSIGN(ContinueWindowGtk);
37 ContinueWindowGtk::ContinueWindowGtk()
38 : continue_window_(nullptr) {
41 ContinueWindowGtk::~ContinueWindowGtk() {
42 if (continue_window_) {
43 gtk_widget_destroy(continue_window_);
44 continue_window_ = nullptr;
48 void ContinueWindowGtk::ShowUi() {
49 DCHECK(CalledOnValidThread());
50 DCHECK(!continue_window_);
52 CreateWindow();
53 gtk_window_set_urgency_hint(GTK_WINDOW(continue_window_), TRUE);
54 gtk_window_present(GTK_WINDOW(continue_window_));
57 void ContinueWindowGtk::HideUi() {
58 DCHECK(CalledOnValidThread());
60 if (continue_window_) {
61 gtk_widget_destroy(continue_window_);
62 continue_window_ = nullptr;
66 void ContinueWindowGtk::CreateWindow() {
67 DCHECK(CalledOnValidThread());
68 DCHECK(!continue_window_);
70 continue_window_ = gtk_dialog_new_with_buttons(
71 l10n_util::GetStringUTF8(IDS_PRODUCT_NAME).c_str(),
72 nullptr,
73 static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
74 l10n_util::GetStringUTF8(IDS_STOP_SHARING_BUTTON).c_str(),
75 GTK_RESPONSE_CANCEL,
76 l10n_util::GetStringUTF8(IDS_CONTINUE_BUTTON).c_str(),
77 GTK_RESPONSE_OK,
78 nullptr);
80 gtk_dialog_set_default_response(GTK_DIALOG(continue_window_),
81 GTK_RESPONSE_OK);
82 gtk_window_set_resizable(GTK_WINDOW(continue_window_), FALSE);
84 // Set always-on-top, otherwise this window tends to be obscured by the
85 // DisconnectWindow.
86 gtk_window_set_keep_above(GTK_WINDOW(continue_window_), TRUE);
88 g_signal_connect(continue_window_, "response",
89 G_CALLBACK(OnResponseThunk), this);
91 GtkWidget* content_area =
92 gtk_dialog_get_content_area(GTK_DIALOG(continue_window_));
94 GtkWidget* text_label =
95 gtk_label_new(l10n_util::GetStringUTF8(IDS_CONTINUE_PROMPT).c_str());
96 gtk_label_set_line_wrap(GTK_LABEL(text_label), TRUE);
97 // TODO(lambroslambrou): Fix magic numbers, as in disconnect_window_gtk.cc.
98 gtk_misc_set_padding(GTK_MISC(text_label), 12, 12);
99 gtk_container_add(GTK_CONTAINER(content_area), text_label);
101 gtk_widget_show_all(content_area);
104 void ContinueWindowGtk::OnResponse(GtkDialog* dialog, int response_id) {
105 DCHECK(CalledOnValidThread());
107 if (response_id == GTK_RESPONSE_OK) {
108 ContinueSession();
109 } else {
110 DisconnectSession();
113 HideUi();
116 // static
117 scoped_ptr<HostWindow> HostWindow::CreateContinueWindow() {
118 return make_scoped_ptr(new ContinueWindowGtk());
121 } // namespace remoting