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