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

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

Issue 10384127: Chromoting: the Me2me host now presents a notification on the console allowing a user to disconnect… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Unix-line endings. The license text. Created 8 years, 7 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
« no previous file with comments | « remoting/host/disconnect_window.h ('k') | remoting/host/disconnect_window_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/disconnect_window.h" 5 #include "remoting/host/disconnect_window.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 #include <math.h> 8 #include <math.h>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "remoting/host/chromoting_host.h" 14 #include "remoting/host/chromoting_host.h"
15 #include "remoting/host/ui_strings.h" 15 #include "remoting/host/ui_strings.h"
16 #include "ui/base/gtk/gtk_signal.h" 16 #include "ui/base/gtk/gtk_signal.h"
17 17
18 namespace remoting { 18 namespace remoting {
19 19
20 class DisconnectWindowLinux : public DisconnectWindow { 20 class DisconnectWindowLinux : public DisconnectWindow {
21 public: 21 public:
22 DisconnectWindowLinux(); 22 DisconnectWindowLinux();
23 virtual ~DisconnectWindowLinux(); 23 virtual ~DisconnectWindowLinux();
24 24
25 virtual void Show(ChromotingHost* host, 25 virtual void Show(ChromotingHost* host,
26 const DisconnectCallback& disconnect_callback,
26 const std::string& username) OVERRIDE; 27 const std::string& username) OVERRIDE;
27 virtual void Hide() OVERRIDE; 28 virtual void Hide() OVERRIDE;
28 29
29 private: 30 private:
30 CHROMEGTK_CALLBACK_1(DisconnectWindowLinux, gboolean, OnDelete, GdkEvent*); 31 CHROMEGTK_CALLBACK_1(DisconnectWindowLinux, gboolean, OnDelete, GdkEvent*);
31 CHROMEGTK_CALLBACK_0(DisconnectWindowLinux, void, OnClicked); 32 CHROMEGTK_CALLBACK_0(DisconnectWindowLinux, void, OnClicked);
32 CHROMEGTK_CALLBACK_1(DisconnectWindowLinux, gboolean, OnConfigure, 33 CHROMEGTK_CALLBACK_1(DisconnectWindowLinux, gboolean, OnConfigure,
33 GdkEventConfigure*); 34 GdkEventConfigure*);
34 CHROMEGTK_CALLBACK_1(DisconnectWindowLinux, gboolean, OnButtonPress, 35 CHROMEGTK_CALLBACK_1(DisconnectWindowLinux, gboolean, OnButtonPress,
35 GdkEventButton*); 36 GdkEventButton*);
36 37
37 void CreateWindow(const UiStrings& ui_strings); 38 void CreateWindow(const UiStrings& ui_strings);
38 39
39 ChromotingHost* host_; 40 DisconnectCallback disconnect_callback_;
40 GtkWidget* disconnect_window_; 41 GtkWidget* disconnect_window_;
41 GtkWidget* message_; 42 GtkWidget* message_;
42 GtkWidget* button_; 43 GtkWidget* button_;
43 44
44 // Used to distinguish resize events from other types of "configure-event" 45 // Used to distinguish resize events from other types of "configure-event"
45 // notifications. 46 // notifications.
46 int current_width_; 47 int current_width_;
47 int current_height_; 48 int current_height_;
48 49
49 DISALLOW_COPY_AND_ASSIGN(DisconnectWindowLinux); 50 DISALLOW_COPY_AND_ASSIGN(DisconnectWindowLinux);
50 }; 51 };
51 52
52 DisconnectWindowLinux::DisconnectWindowLinux() 53 DisconnectWindowLinux::DisconnectWindowLinux()
53 : host_(NULL), 54 : disconnect_window_(NULL),
54 disconnect_window_(NULL),
55 current_width_(0), 55 current_width_(0),
56 current_height_(0) { 56 current_height_(0) {
57 } 57 }
58 58
59 DisconnectWindowLinux::~DisconnectWindowLinux() { 59 DisconnectWindowLinux::~DisconnectWindowLinux() {
60 } 60 }
61 61
62 void DisconnectWindowLinux::CreateWindow(const UiStrings& ui_strings) { 62 void DisconnectWindowLinux::CreateWindow(const UiStrings& ui_strings) {
63 if (disconnect_window_) return; 63 if (disconnect_window_) return;
64 64
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // readable against the window's background pixmap. 123 // readable against the window's background pixmap.
124 PangoAttrList* attributes = pango_attr_list_new(); 124 PangoAttrList* attributes = pango_attr_list_new();
125 PangoAttribute* text_color = pango_attr_foreground_new(0, 0, 0); 125 PangoAttribute* text_color = pango_attr_foreground_new(0, 0, 0);
126 pango_attr_list_insert(attributes, text_color); 126 pango_attr_list_insert(attributes, text_color);
127 gtk_label_set_attributes(GTK_LABEL(message_), attributes); 127 gtk_label_set_attributes(GTK_LABEL(message_), attributes);
128 128
129 gtk_widget_show_all(disconnect_window_); 129 gtk_widget_show_all(disconnect_window_);
130 } 130 }
131 131
132 void DisconnectWindowLinux::Show(ChromotingHost* host, 132 void DisconnectWindowLinux::Show(ChromotingHost* host,
133 const DisconnectCallback& disconnect_callback,
133 const std::string& username) { 134 const std::string& username) {
134 host_ = host; 135 disconnect_callback_ = disconnect_callback;
135 CreateWindow(host->ui_strings()); 136 CreateWindow(host->ui_strings());
136 137
137 string16 text = ReplaceStringPlaceholders( 138 string16 text = ReplaceStringPlaceholders(
138 host->ui_strings().disconnect_message, UTF8ToUTF16(username), NULL); 139 host->ui_strings().disconnect_message, UTF8ToUTF16(username), NULL);
139 gtk_label_set_text(GTK_LABEL(message_), UTF16ToUTF8(text).c_str()); 140 gtk_label_set_text(GTK_LABEL(message_), UTF16ToUTF8(text).c_str());
140 gtk_window_present(GTK_WINDOW(disconnect_window_)); 141 gtk_window_present(GTK_WINDOW(disconnect_window_));
141 } 142 }
142 143
143 void DisconnectWindowLinux::Hide() { 144 void DisconnectWindowLinux::Hide() {
144 if (disconnect_window_) { 145 if (disconnect_window_) {
145 gtk_widget_destroy(disconnect_window_); 146 gtk_widget_destroy(disconnect_window_);
146 disconnect_window_ = NULL; 147 disconnect_window_ = NULL;
147 } 148 }
148 } 149 }
149 150
150 void DisconnectWindowLinux::OnClicked(GtkWidget* button) { 151 void DisconnectWindowLinux::OnClicked(GtkWidget* button) {
151 CHECK(host_); 152 CHECK(!disconnect_callback_.is_null());
152 153
153 host_->Shutdown(base::Closure()); 154 disconnect_callback_.Run();
154 Hide(); 155 Hide();
155 } 156 }
156 157
157 gboolean DisconnectWindowLinux::OnDelete(GtkWidget* window, GdkEvent* event) { 158 gboolean DisconnectWindowLinux::OnDelete(GtkWidget* window, GdkEvent* event) {
158 CHECK(host_); 159 CHECK(!disconnect_callback_.is_null());
159 160
160 host_->Shutdown(base::Closure()); 161 disconnect_callback_.Run();
161 Hide(); 162 Hide();
162 163
163 return TRUE; 164 return TRUE;
164 } 165 }
165 166
166 namespace { 167 namespace {
167 // Helper function for creating a rectangular path with rounded corners, as 168 // Helper function for creating a rectangular path with rounded corners, as
168 // Cairo doesn't have this facility. |radius| is the arc-radius of each 169 // Cairo doesn't have this facility. |radius| is the arc-radius of each
169 // corner. The bounding rectangle extends from (0, 0) to (width, height). 170 // corner. The bounding rectangle extends from (0, 0) to (width, height).
170 void AddRoundRectPath(cairo_t* cairo_context, int width, int height, 171 void AddRoundRectPath(cairo_t* cairo_context, int width, int height,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 event->y_root, 274 event->y_root,
274 event->time); 275 event->time);
275 return FALSE; 276 return FALSE;
276 } 277 }
277 278
278 scoped_ptr<DisconnectWindow> DisconnectWindow::Create() { 279 scoped_ptr<DisconnectWindow> DisconnectWindow::Create() {
279 return scoped_ptr<DisconnectWindow>(new DisconnectWindowLinux()); 280 return scoped_ptr<DisconnectWindow>(new DisconnectWindowLinux());
280 } 281 }
281 282
282 } // namespace remoting 283 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/disconnect_window.h ('k') | remoting/host/disconnect_window_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698