| OLD | NEW |
| 1 // Copyright (c) 2011 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 UI_BASE_GTK_GTK_SIGNAL_REGISTRAR_H_ | 5 #ifndef UI_BASE_GTK_GTK_SIGNAL_REGISTRAR_H_ |
| 6 #define UI_BASE_GTK_GTK_SIGNAL_REGISTRAR_H_ | 6 #define UI_BASE_GTK_GTK_SIGNAL_REGISTRAR_H_ |
| 7 | 7 |
| 8 #include <glib.h> | 8 #include <glib.h> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 GtkSignalRegistrar(); | 42 GtkSignalRegistrar(); |
| 43 ~GtkSignalRegistrar(); | 43 ~GtkSignalRegistrar(); |
| 44 | 44 |
| 45 // Connect before the default handler. Returns the handler id. | 45 // Connect before the default handler. Returns the handler id. |
| 46 glong Connect(gpointer instance, const gchar* detailed_signal, | 46 glong Connect(gpointer instance, const gchar* detailed_signal, |
| 47 GCallback signal_handler, gpointer data); | 47 GCallback signal_handler, gpointer data); |
| 48 // Connect after the default handler. Returns the handler id. | 48 // Connect after the default handler. Returns the handler id. |
| 49 glong ConnectAfter(gpointer instance, const gchar* detailed_signal, | 49 glong ConnectAfter(gpointer instance, const gchar* detailed_signal, |
| 50 GCallback signal_handler, gpointer data); | 50 GCallback signal_handler, gpointer data); |
| 51 | 51 |
| 52 // Disconnects all signal handlers connected to |instance|. |
| 53 void DisconnectAll(gpointer instance); |
| 54 |
| 52 private: | 55 private: |
| 53 typedef std::vector<glong> HandlerList; | 56 typedef std::vector<glong> HandlerList; |
| 54 typedef std::map<GObject*, HandlerList> HandlerMap; | 57 typedef std::map<GObject*, HandlerList> HandlerMap; |
| 55 | 58 |
| 56 static void WeakNotifyThunk(gpointer data, GObject* where_the_object_was) { | 59 static void WeakNotifyThunk(gpointer data, GObject* where_the_object_was) { |
| 57 reinterpret_cast<GtkSignalRegistrar*>(data)->WeakNotify( | 60 reinterpret_cast<GtkSignalRegistrar*>(data)->WeakNotify( |
| 58 where_the_object_was); | 61 where_the_object_was); |
| 59 } | 62 } |
| 60 void WeakNotify(GObject* where_the_object_was); | 63 void WeakNotify(GObject* where_the_object_was); |
| 61 | 64 |
| 62 glong ConnectInternal(gpointer instance, const gchar* detailed_signal, | 65 glong ConnectInternal(gpointer instance, const gchar* detailed_signal, |
| 63 GCallback signal_handler, gpointer data, bool after); | 66 GCallback signal_handler, gpointer data, bool after); |
| 64 | 67 |
| 65 HandlerMap handler_lists_; | 68 HandlerMap handler_lists_; |
| 66 | 69 |
| 67 DISALLOW_COPY_AND_ASSIGN(GtkSignalRegistrar); | 70 DISALLOW_COPY_AND_ASSIGN(GtkSignalRegistrar); |
| 68 }; | 71 }; |
| 69 | 72 |
| 70 } // namespace ui | 73 } // namespace ui |
| 71 | 74 |
| 72 #endif // UI_BASE_GTK_GTK_SIGNAL_REGISTRAR_H_ | 75 #endif // UI_BASE_GTK_GTK_SIGNAL_REGISTRAR_H_ |
| OLD | NEW |