| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_GTK_FOCUS_STORE_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_FOCUS_STORE_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_FOCUS_STORE_GTK_H_ | 6 #define CHROME_BROWSER_GTK_FOCUS_STORE_GTK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 | 10 |
| 11 typedef struct _GtkWidget GtkWidget; | 11 typedef struct _GtkWidget GtkWidget; |
| 12 | 12 |
| 13 class FocusStoreGtk { | 13 class FocusStoreGtk { |
| 14 public: | 14 public: |
| 15 FocusStoreGtk(); | 15 FocusStoreGtk(); |
| 16 | 16 |
| 17 virtual ~FocusStoreGtk(); | 17 virtual ~FocusStoreGtk(); |
| 18 | 18 |
| 19 GtkWidget* widget() const { return widget_; } | 19 GtkWidget* widget() const { return widget_; } |
| 20 | 20 |
| 21 // Save the widget that is currently focused for |widget|'s toplevel (NOT | 21 // Save the widget that is currently focused for |widget|'s toplevel (NOT |
| 22 // |widget|). Call with NULL to clear |widget_|. | 22 // |widget|). |
| 23 void Store(GtkWidget* widget); | 23 void Store(GtkWidget* widget); |
| 24 | 24 |
| 25 // Save |widget| as the focus widget. Call with NULL to clear |widget_|. |
| 26 void SetWidget(GtkWidget* widget); |
| 27 |
| 25 private: | 28 private: |
| 26 // Disconnect the previous destroy handler (if any). | 29 // Disconnect the previous destroy handler (if any). |
| 27 void DisconnectDestroyHandler(); | 30 void DisconnectDestroyHandler(); |
| 28 | 31 |
| 29 // The widget which last had focus. | 32 // The widget which last had focus. |
| 30 GtkWidget* widget_; | 33 GtkWidget* widget_; |
| 31 | 34 |
| 32 // The widget for which we've stored focus might be destroyed by the time we | 35 // The widget for which we've stored focus might be destroyed by the time we |
| 33 // want to restore focus. Thus we connect to the "destroy" signal on that | 36 // want to restore focus. Thus we connect to the "destroy" signal on that |
| 34 // widget. This is the ID for the destroy handler. | 37 // widget. This is the ID for the destroy handler. |
| 35 unsigned int destroy_handler_id_; | 38 unsigned int destroy_handler_id_; |
| 36 | 39 |
| 37 DISALLOW_COPY_AND_ASSIGN(FocusStoreGtk); | 40 DISALLOW_COPY_AND_ASSIGN(FocusStoreGtk); |
| 38 }; | 41 }; |
| 39 | 42 |
| 40 #endif // CHROME_BROWSER_GTK_FOCUS_STORE_GTK_H_ | 43 #endif // CHROME_BROWSER_GTK_FOCUS_STORE_GTK_H_ |
| OLD | NEW |