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

Side by Side Diff: ui/base/gtk/focus_store_gtk.cc

Issue 231733005: Delete the GTK+ port of Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remerge to ToT Created 6 years, 8 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/base/gtk/focus_store_gtk.h"
6
7 #include <gtk/gtk.h>
8
9 namespace ui {
10
11 FocusStoreGtk::FocusStoreGtk()
12 : widget_(NULL),
13 destroy_handler_id_(0) {
14 }
15
16 FocusStoreGtk::~FocusStoreGtk() {
17 DisconnectDestroyHandler();
18 }
19
20 void FocusStoreGtk::Store(GtkWidget* widget) {
21 GtkWidget* focus_widget = NULL;
22 if (widget) {
23 // A detached widget won't have a toplevel window as an ancestor, so we
24 // can't assume that the query for toplevel will return a window.
25 GtkWidget* toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
26 GtkWindow* window = GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL;
27 if (window)
28 focus_widget = gtk_window_get_focus(window);
29 }
30
31 SetWidget(focus_widget);
32 }
33
34 void FocusStoreGtk::SetWidget(GtkWidget* widget) {
35 DisconnectDestroyHandler();
36
37 // We don't add a ref. The signal handler below effectively gives us a weak
38 // reference.
39 widget_ = widget;
40 if (widget_) {
41 // When invoked, |gtk_widget_destroyed| will set |widget_| to NULL.
42 destroy_handler_id_ = g_signal_connect(widget_, "destroy",
43 G_CALLBACK(gtk_widget_destroyed),
44 &widget_);
45 }
46 }
47
48 void FocusStoreGtk::DisconnectDestroyHandler() {
49 if (widget_) {
50 g_signal_handler_disconnect(widget_, destroy_handler_id_);
51 widget_ = NULL;
52 }
53 }
54
55 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698