| 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 "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/ui_strings.h" | 14 #include "remoting/host/ui_strings.h" |
| 15 #include "ui/base/gtk/gtk_signal.h" | 15 #include "ui/base/gtk/gtk_signal.h" |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 | 18 |
| 19 class DisconnectWindowGtk : public DisconnectWindow { | 19 class DisconnectWindowGtk : public DisconnectWindow { |
| 20 public: | 20 public: |
| 21 DisconnectWindowGtk(); | 21 DisconnectWindowGtk(); |
| 22 virtual ~DisconnectWindowGtk(); | 22 virtual ~DisconnectWindowGtk(); |
| 23 | 23 |
| 24 virtual bool Show(const UiStrings& ui_strings, | 24 virtual bool Show(const UiStrings& ui_strings, |
| 25 const DisconnectCallback& disconnect_callback, | 25 const base::Closure& disconnect_callback, |
| 26 const std::string& username) OVERRIDE; | 26 const std::string& username) OVERRIDE; |
| 27 virtual void Hide() OVERRIDE; | 27 virtual void Hide() OVERRIDE; |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 CHROMEGTK_CALLBACK_1(DisconnectWindowGtk, gboolean, OnDelete, GdkEvent*); | 30 CHROMEGTK_CALLBACK_1(DisconnectWindowGtk, gboolean, OnDelete, GdkEvent*); |
| 31 CHROMEGTK_CALLBACK_0(DisconnectWindowGtk, void, OnClicked); | 31 CHROMEGTK_CALLBACK_0(DisconnectWindowGtk, void, OnClicked); |
| 32 CHROMEGTK_CALLBACK_1(DisconnectWindowGtk, gboolean, OnConfigure, | 32 CHROMEGTK_CALLBACK_1(DisconnectWindowGtk, gboolean, OnConfigure, |
| 33 GdkEventConfigure*); | 33 GdkEventConfigure*); |
| 34 CHROMEGTK_CALLBACK_1(DisconnectWindowGtk, gboolean, OnButtonPress, | 34 CHROMEGTK_CALLBACK_1(DisconnectWindowGtk, gboolean, OnButtonPress, |
| 35 GdkEventButton*); | 35 GdkEventButton*); |
| 36 | 36 |
| 37 void CreateWindow(const UiStrings& ui_strings); | 37 void CreateWindow(const UiStrings& ui_strings); |
| 38 | 38 |
| 39 DisconnectCallback disconnect_callback_; | 39 base::Closure disconnect_callback_; |
| 40 GtkWidget* disconnect_window_; | 40 GtkWidget* disconnect_window_; |
| 41 GtkWidget* message_; | 41 GtkWidget* message_; |
| 42 GtkWidget* button_; | 42 GtkWidget* button_; |
| 43 | 43 |
| 44 // Used to distinguish resize events from other types of "configure-event" | 44 // Used to distinguish resize events from other types of "configure-event" |
| 45 // notifications. | 45 // notifications. |
| 46 int current_width_; | 46 int current_width_; |
| 47 int current_height_; | 47 int current_height_; |
| 48 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(DisconnectWindowGtk); | 49 DISALLOW_COPY_AND_ASSIGN(DisconnectWindowGtk); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 DisconnectWindowGtk::DisconnectWindowGtk() | 52 DisconnectWindowGtk::DisconnectWindowGtk() |
| 53 : disconnect_window_(NULL), | 53 : disconnect_window_(NULL), |
| 54 current_width_(0), | 54 current_width_(0), |
| 55 current_height_(0) { | 55 current_height_(0) { |
| 56 } | 56 } |
| 57 | 57 |
| 58 DisconnectWindowGtk::~DisconnectWindowGtk() { | 58 DisconnectWindowGtk::~DisconnectWindowGtk() { |
| 59 Hide(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 void DisconnectWindowGtk::CreateWindow(const UiStrings& ui_strings) { | 62 void DisconnectWindowGtk::CreateWindow(const UiStrings& ui_strings) { |
| 62 if (disconnect_window_) return; | 63 if (disconnect_window_) return; |
| 63 | 64 |
| 64 disconnect_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 65 disconnect_window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 65 GtkWindow* window = GTK_WINDOW(disconnect_window_); | 66 GtkWindow* window = GTK_WINDOW(disconnect_window_); |
| 66 | 67 |
| 67 g_signal_connect(disconnect_window_, "delete-event", | 68 g_signal_connect(disconnect_window_, "delete-event", |
| 68 G_CALLBACK(OnDeleteThunk), this); | 69 G_CALLBACK(OnDeleteThunk), this); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // readable against the window's background pixmap. | 123 // readable against the window's background pixmap. |
| 123 PangoAttrList* attributes = pango_attr_list_new(); | 124 PangoAttrList* attributes = pango_attr_list_new(); |
| 124 PangoAttribute* text_color = pango_attr_foreground_new(0, 0, 0); | 125 PangoAttribute* text_color = pango_attr_foreground_new(0, 0, 0); |
| 125 pango_attr_list_insert(attributes, text_color); | 126 pango_attr_list_insert(attributes, text_color); |
| 126 gtk_label_set_attributes(GTK_LABEL(message_), attributes); | 127 gtk_label_set_attributes(GTK_LABEL(message_), attributes); |
| 127 | 128 |
| 128 gtk_widget_show_all(disconnect_window_); | 129 gtk_widget_show_all(disconnect_window_); |
| 129 } | 130 } |
| 130 | 131 |
| 131 bool DisconnectWindowGtk::Show(const UiStrings& ui_strings, | 132 bool DisconnectWindowGtk::Show(const UiStrings& ui_strings, |
| 132 const DisconnectCallback& disconnect_callback, | 133 const base::Closure& disconnect_callback, |
| 133 const std::string& username) { | 134 const std::string& username) { |
| 134 DCHECK(disconnect_callback_.is_null()); | 135 DCHECK(disconnect_callback_.is_null()); |
| 135 DCHECK(!disconnect_callback.is_null()); | 136 DCHECK(!disconnect_callback.is_null()); |
| 136 DCHECK(!disconnect_window_); | 137 DCHECK(!disconnect_window_); |
| 137 | 138 |
| 138 disconnect_callback_ = disconnect_callback; | 139 disconnect_callback_ = disconnect_callback; |
| 139 CreateWindow(ui_strings); | 140 CreateWindow(ui_strings); |
| 140 | 141 |
| 141 string16 text = ReplaceStringPlaceholders( | 142 string16 text = ReplaceStringPlaceholders( |
| 142 ui_strings.disconnect_message, UTF8ToUTF16(username), NULL); | 143 ui_strings.disconnect_message, UTF8ToUTF16(username), NULL); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 event->y_root, | 277 event->y_root, |
| 277 event->time); | 278 event->time); |
| 278 return FALSE; | 279 return FALSE; |
| 279 } | 280 } |
| 280 | 281 |
| 281 scoped_ptr<DisconnectWindow> DisconnectWindow::Create() { | 282 scoped_ptr<DisconnectWindow> DisconnectWindow::Create() { |
| 282 return scoped_ptr<DisconnectWindow>(new DisconnectWindowGtk()); | 283 return scoped_ptr<DisconnectWindow>(new DisconnectWindowGtk()); |
| 283 } | 284 } |
| 284 | 285 |
| 285 } // namespace remoting | 286 } // namespace remoting |
| OLD | NEW |