| 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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
| 6 #include <math.h> | 6 #include <math.h> |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 if (disconnect_window_) { | 80 if (disconnect_window_) { |
| 81 gtk_widget_destroy(disconnect_window_); | 81 gtk_widget_destroy(disconnect_window_); |
| 82 disconnect_window_ = NULL; | 82 disconnect_window_ = NULL; |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 void DisconnectWindowGtk::Start( | 86 void DisconnectWindowGtk::Start( |
| 87 const base::WeakPtr<ClientSessionControl>& client_session_control) { | 87 const base::WeakPtr<ClientSessionControl>& client_session_control) { |
| 88 DCHECK(CalledOnValidThread()); | 88 DCHECK(CalledOnValidThread()); |
| 89 DCHECK(!client_session_control_); | 89 DCHECK(!client_session_control_.get()); |
| 90 DCHECK(client_session_control); | 90 DCHECK(client_session_control.get()); |
| 91 DCHECK(!disconnect_window_); | 91 DCHECK(!disconnect_window_); |
| 92 | 92 |
| 93 client_session_control_ = client_session_control; | 93 client_session_control_ = client_session_control; |
| 94 | 94 |
| 95 // Create the window. | 95 // Create the window. |
| 96 disconnect_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 96 disconnect_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 97 GtkWindow* window = GTK_WINDOW(disconnect_window_); | 97 GtkWindow* window = GTK_WINDOW(disconnect_window_); |
| 98 | 98 |
| 99 g_signal_connect(disconnect_window_, "delete-event", | 99 g_signal_connect(disconnect_window_, "delete-event", |
| 100 G_CALLBACK(OnDeleteThunk), this); | 100 G_CALLBACK(OnDeleteThunk), this); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 string16 username = UTF8ToUTF16(client_jid.substr(0, client_jid.find('/'))); | 165 string16 username = UTF8ToUTF16(client_jid.substr(0, client_jid.find('/'))); |
| 166 string16 text = | 166 string16 text = |
| 167 ReplaceStringPlaceholders(ui_strings_.disconnect_message, username, NULL); | 167 ReplaceStringPlaceholders(ui_strings_.disconnect_message, username, NULL); |
| 168 gtk_label_set_text(GTK_LABEL(message_), UTF16ToUTF8(text).c_str()); | 168 gtk_label_set_text(GTK_LABEL(message_), UTF16ToUTF8(text).c_str()); |
| 169 gtk_window_present(window); | 169 gtk_window_present(window); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void DisconnectWindowGtk::OnClicked(GtkWidget* button) { | 172 void DisconnectWindowGtk::OnClicked(GtkWidget* button) { |
| 173 DCHECK(CalledOnValidThread()); | 173 DCHECK(CalledOnValidThread()); |
| 174 | 174 |
| 175 if (client_session_control_) | 175 if (client_session_control_.get()) |
| 176 client_session_control_->DisconnectSession(); | 176 client_session_control_->DisconnectSession(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 gboolean DisconnectWindowGtk::OnDelete(GtkWidget* window, | 179 gboolean DisconnectWindowGtk::OnDelete(GtkWidget* window, |
| 180 GdkEvent* event) { | 180 GdkEvent* event) { |
| 181 DCHECK(CalledOnValidThread()); | 181 DCHECK(CalledOnValidThread()); |
| 182 | 182 |
| 183 if (client_session_control_) | 183 if (client_session_control_.get()) |
| 184 client_session_control_->DisconnectSession(); | 184 client_session_control_->DisconnectSession(); |
| 185 return TRUE; | 185 return TRUE; |
| 186 } | 186 } |
| 187 | 187 |
| 188 gboolean DisconnectWindowGtk::OnConfigure(GtkWidget* widget, | 188 gboolean DisconnectWindowGtk::OnConfigure(GtkWidget* widget, |
| 189 GdkEventConfigure* event) { | 189 GdkEventConfigure* event) { |
| 190 DCHECK(CalledOnValidThread()); | 190 DCHECK(CalledOnValidThread()); |
| 191 | 191 |
| 192 // Only generate bitmaps if the size has actually changed. | 192 // Only generate bitmaps if the size has actually changed. |
| 193 if (event->width == current_width_ && event->height == current_height_) | 193 if (event->width == current_width_ && event->height == current_height_) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 } // namespace | 288 } // namespace |
| 289 | 289 |
| 290 // static | 290 // static |
| 291 scoped_ptr<HostWindow> HostWindow::CreateDisconnectWindow( | 291 scoped_ptr<HostWindow> HostWindow::CreateDisconnectWindow( |
| 292 const UiStrings& ui_strings) { | 292 const UiStrings& ui_strings) { |
| 293 return scoped_ptr<HostWindow>(new DisconnectWindowGtk(ui_strings)); | 293 return scoped_ptr<HostWindow>(new DisconnectWindowGtk(ui_strings)); |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace remoting | 296 } // namespace remoting |
| OLD | NEW |