OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 APP_GTK_SIGNAL_REGISTRAR_H_ | 5 #ifndef UI_BASE_GTK_GTK_SIGNAL_REGISTRAR_H_ |
6 #define APP_GTK_SIGNAL_REGISTRAR_H_ | 6 #define UI_BASE_GTK_GTK_SIGNAL_REGISTRAR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <glib.h> | 9 #include <glib.h> |
10 #include <map> | 10 #include <map> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 | 14 |
15 typedef void (*GCallback) (void); | 15 typedef void (*GCallback) (void); |
16 typedef struct _GObject GObject; | 16 typedef struct _GObject GObject; |
17 typedef struct _GtkWidget GtkWidget; | 17 typedef struct _GtkWidget GtkWidget; |
18 | 18 |
| 19 namespace ui { |
| 20 |
19 // A class that ensures that callbacks don't run on stale owner objects. Similar | 21 // A class that ensures that callbacks don't run on stale owner objects. Similar |
20 // in spirit to NotificationRegistrar. Use as follows: | 22 // in spirit to NotificationRegistrar. Use as follows: |
21 // | 23 // |
22 // class ChromeObject { | 24 // class ChromeObject { |
23 // public: | 25 // public: |
24 // ChromeObject() { | 26 // ChromeObject() { |
25 // ... | 27 // ... |
26 // | 28 // |
27 // signals_.Connect(widget, "event", CallbackThunk, this); | 29 // signals_.Connect(widget, "event", CallbackThunk, this); |
28 // } | 30 // } |
(...skipping 29 matching lines...) Expand all Loading... |
58 void WeakNotify(GObject* where_the_object_was); | 60 void WeakNotify(GObject* where_the_object_was); |
59 | 61 |
60 glong ConnectInternal(gpointer instance, const gchar* detailed_signal, | 62 glong ConnectInternal(gpointer instance, const gchar* detailed_signal, |
61 GCallback signal_handler, gpointer data, bool after); | 63 GCallback signal_handler, gpointer data, bool after); |
62 | 64 |
63 HandlerMap handler_lists_; | 65 HandlerMap handler_lists_; |
64 | 66 |
65 DISALLOW_COPY_AND_ASSIGN(GtkSignalRegistrar); | 67 DISALLOW_COPY_AND_ASSIGN(GtkSignalRegistrar); |
66 }; | 68 }; |
67 | 69 |
68 #endif // APP_GTK_SIGNAL_REGISTRAR_H_ | 70 } // namespace ui |
| 71 |
| 72 #endif // UI_BASE_GTK_GTK_SIGNAL_REGISTRAR_H_ |
OLD | NEW |