Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: remoting/host/disconnect_window_linux.cc

Issue 7669045: Make ChromotingHost::ui_strings() immutable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/disconnect_window.h" 5 #include "remoting/host/disconnect_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"
(...skipping 18 matching lines...) Expand all
29 DisconnectWindowLinux(); 29 DisconnectWindowLinux();
30 virtual ~DisconnectWindowLinux(); 30 virtual ~DisconnectWindowLinux();
31 31
32 virtual void Show(ChromotingHost* host, 32 virtual void Show(ChromotingHost* host,
33 const std::string& username) OVERRIDE; 33 const std::string& username) OVERRIDE;
34 virtual void Hide() OVERRIDE; 34 virtual void Hide() OVERRIDE;
35 35
36 private: 36 private:
37 CHROMEGTK_CALLBACK_1(DisconnectWindowLinux, void, OnResponse, int); 37 CHROMEGTK_CALLBACK_1(DisconnectWindowLinux, void, OnResponse, int);
38 38
39 void CreateWindow(UiStrings* ui_strings); 39 void CreateWindow(const UiStrings& ui_strings);
40 40
41 ChromotingHost* host_; 41 ChromotingHost* host_;
42 GtkWidget* disconnect_window_; 42 GtkWidget* disconnect_window_;
43 GtkWidget* message_; 43 GtkWidget* message_;
44 44
45 DISALLOW_COPY_AND_ASSIGN(DisconnectWindowLinux); 45 DISALLOW_COPY_AND_ASSIGN(DisconnectWindowLinux);
46 }; 46 };
47 47
48 DisconnectWindowLinux::DisconnectWindowLinux() 48 DisconnectWindowLinux::DisconnectWindowLinux()
49 : host_(NULL), 49 : host_(NULL),
50 disconnect_window_(NULL) { 50 disconnect_window_(NULL) {
51 } 51 }
52 52
53 DisconnectWindowLinux::~DisconnectWindowLinux() { 53 DisconnectWindowLinux::~DisconnectWindowLinux() {
54 } 54 }
55 55
56 void DisconnectWindowLinux::CreateWindow(UiStrings* ui_strings) { 56 void DisconnectWindowLinux::CreateWindow(const UiStrings& ui_strings) {
57 if (disconnect_window_) return; 57 if (disconnect_window_) return;
58 58
59 disconnect_window_ = gtk_dialog_new_with_buttons( 59 disconnect_window_ = gtk_dialog_new_with_buttons(
60 ui_strings->product_name.c_str(), 60 ui_strings.product_name.c_str(),
61 NULL, 61 NULL,
62 GTK_DIALOG_NO_SEPARATOR, 62 GTK_DIALOG_NO_SEPARATOR,
63 ui_strings->disconnect_button_text_plus_shortcut.c_str(), GTK_RESPONSE_OK, 63 ui_strings.disconnect_button_text_plus_shortcut.c_str(), GTK_RESPONSE_OK,
64 NULL); 64 NULL);
65 65
66 GtkWindow* window = GTK_WINDOW(disconnect_window_); 66 GtkWindow* window = GTK_WINDOW(disconnect_window_);
67 gtk_window_set_resizable(window, FALSE); 67 gtk_window_set_resizable(window, FALSE);
68 // Try to keep the window always visible. 68 // Try to keep the window always visible.
69 gtk_window_stick(window); 69 gtk_window_stick(window);
70 gtk_window_set_keep_above(window, TRUE); 70 gtk_window_set_keep_above(window, TRUE);
71 // Utility windows have no minimize button or taskbar presence. 71 // Utility windows have no minimize button or taskbar presence.
72 gtk_window_set_type_hint(window, GDK_WINDOW_TYPE_HINT_UTILITY); 72 gtk_window_set_type_hint(window, GDK_WINDOW_TYPE_HINT_UTILITY);
73 gtk_window_set_deletable(window, FALSE); 73 gtk_window_set_deletable(window, FALSE);
(...skipping 17 matching lines...) Expand all
91 gtk_container_add(GTK_CONTAINER(message_row), message_); 91 gtk_container_add(GTK_CONTAINER(message_row), message_);
92 92
93 gtk_widget_show_all(content_area); 93 gtk_widget_show_all(content_area);
94 } 94 }
95 95
96 void DisconnectWindowLinux::Show(ChromotingHost* host, 96 void DisconnectWindowLinux::Show(ChromotingHost* host,
97 const std::string& /* unused */) { 97 const std::string& /* unused */) {
98 host_ = host; 98 host_ = host;
99 CreateWindow(host->ui_strings()); 99 CreateWindow(host->ui_strings());
100 gtk_label_set_text(GTK_LABEL(message_), 100 gtk_label_set_text(GTK_LABEL(message_),
101 host->ui_strings()->disconnect_message.c_str()); 101 host->ui_strings().disconnect_message.c_str());
102 gtk_window_present(GTK_WINDOW(disconnect_window_)); 102 gtk_window_present(GTK_WINDOW(disconnect_window_));
103 } 103 }
104 104
105 void DisconnectWindowLinux::Hide() { 105 void DisconnectWindowLinux::Hide() {
106 if (disconnect_window_) { 106 if (disconnect_window_) {
107 gtk_widget_destroy(disconnect_window_); 107 gtk_widget_destroy(disconnect_window_);
108 disconnect_window_ = NULL; 108 disconnect_window_ = NULL;
109 } 109 }
110 } 110 }
111 111
112 void DisconnectWindowLinux::OnResponse(GtkWidget* dialog, int response_id) { 112 void DisconnectWindowLinux::OnResponse(GtkWidget* dialog, int response_id) {
113 // |response_id| is ignored, because there is only one button, and pressing 113 // |response_id| is ignored, because there is only one button, and pressing
114 // it should have the same effect as closing the window (if the window Close 114 // it should have the same effect as closing the window (if the window Close
115 // button were visible). 115 // button were visible).
116 CHECK(host_); 116 CHECK(host_);
117 117
118 host_->Shutdown(NULL); 118 host_->Shutdown(NULL);
119 Hide(); 119 Hide();
120 } 120 }
121 121
122 DisconnectWindow* DisconnectWindow::Create() { 122 DisconnectWindow* DisconnectWindow::Create() {
123 return new DisconnectWindowLinux; 123 return new DisconnectWindowLinux;
124 } 124 }
125 125
126 } // namespace remoting 126 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698