diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 23:21:40 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 23:21:40 +0000 |
commit | 015c0e105861f82fbbbbd0fa6380742f66ae6247 (patch) | |
tree | 73660128223fe5d68417455f596872abec377d37 /app | |
parent | f28316f0fa06f6b7d3919d41d4e6cef61105cc99 (diff) | |
download | chromium_src-015c0e105861f82fbbbbd0fa6380742f66ae6247.zip chromium_src-015c0e105861f82fbbbbd0fa6380742f66ae6247.tar.gz chromium_src-015c0e105861f82fbbbbd0fa6380742f66ae6247.tar.bz2 |
GTK: Move chrome/common/gtk_signal.h to app/ so views-gtk can use it.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/856003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41341 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r-- | app/app_base.gypi | 2 | ||||
-rw-r--r-- | app/gtk_signal.h | 91 |
2 files changed, 93 insertions, 0 deletions
diff --git a/app/app_base.gypi b/app/app_base.gypi index c69593b..77ce707 100644 --- a/app/app_base.gypi +++ b/app/app_base.gypi @@ -49,6 +49,7 @@ 'gfx/gtk_util.h', 'gtk_dnd_util.cc', 'gtk_dnd_util.h', + 'gtk_signal.h', 'gtk_util.cc', 'gtk_util.h', ], @@ -160,6 +161,7 @@ 'gfx/text_elider.h', 'gtk_dnd_util.cc', 'gtk_dnd_util.h', + 'gtk_signal.h', 'gtk_util.cc', 'gtk_util.h', 'l10n_util.cc', diff --git a/app/gtk_signal.h b/app/gtk_signal.h new file mode 100644 index 0000000..e56c75d --- /dev/null +++ b/app/gtk_signal.h @@ -0,0 +1,91 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef APP_GTK_SIGNAL_H_ +#define APP_GTK_SIGNAL_H_ + +typedef void* gpointer; +typedef struct _GtkWidget GtkWidget; + +// At the time of writing this, there were two common ways of binding our C++ +// code to the gobject C system. We either defined a whole bunch of "static +// MethodThunk()" which just called nonstatic Method()s on a class (which hurt +// readability of the headers and signal connection code) OR we declared +// "static Method()" and passed in the current object as the gpointer (and hurt +// readability in the implementation by having "context->" before every +// variable). + +// The hopeful result of using these macros is that the code will be more +// readable and regular. There shouldn't be a bunch of static Thunks visible in +// the headers and the implementations shouldn't be filled with "context->" +// de-references. + +#define CHROMEGTK_CALLBACK_0(TYPE, RETURN, METHOD) \ + static RETURN METHOD ## Thunk(GtkWidget* widget, gpointer userdata) { \ + return reinterpret_cast<TYPE*>(userdata)->METHOD(widget); \ + } \ + \ + RETURN METHOD(GtkWidget* widget); + +#define CHROMEGTK_CALLBACK_1(TYPE, RETURN, METHOD, ARG1) \ + static RETURN METHOD ## Thunk(GtkWidget* widget, ARG1 one, \ + gpointer userdata) { \ + return reinterpret_cast<TYPE*>(userdata)->METHOD(widget, one); \ + } \ + \ + RETURN METHOD(GtkWidget* widget, ARG1 one); + +#define CHROMEGTK_CALLBACK_2(TYPE, RETURN, METHOD, ARG1, ARG2) \ + static RETURN METHOD ## Thunk(GtkWidget* widget, ARG1 one, ARG2 two, \ + gpointer userdata) { \ + return reinterpret_cast<TYPE*>(userdata)->METHOD(widget, one, two); \ + } \ + \ + RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two); + +#define CHROMEGTK_CALLBACK_3(TYPE, RETURN, METHOD, ARG1, ARG2, ARG3) \ + static RETURN METHOD ## Thunk(GtkWidget* widget, ARG1 one, ARG2 two, \ + ARG3 three, gpointer userdata) { \ + return reinterpret_cast<TYPE*>(userdata)-> \ + METHOD(widget, one, two, three); \ + } \ + \ + RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three); + +#define CHROMEGTK_CALLBACK_4(TYPE, RETURN, METHOD, ARG1, ARG2, ARG3, ARG4) \ + static RETURN METHOD ## Thunk(GtkWidget* widget, ARG1 one, ARG2 two, \ + ARG3 three, ARG4 four, \ + gpointer userdata) { \ + return reinterpret_cast<TYPE*>(userdata)-> \ + METHOD(widget, one, two, three, four); \ + } \ + \ + RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three, \ + ARG4 four); + +#define CHROMEGTK_CALLBACK_5(TYPE, RETURN, METHOD, ARG1, ARG2, ARG3, ARG4, \ + ARG5) \ + static RETURN METHOD ## Thunk(GtkWidget* widget, ARG1 one, ARG2 two, \ + ARG3 three, ARG4 four, ARG5 five, \ + gpointer userdata) { \ + return reinterpret_cast<TYPE*>(userdata)-> \ + METHOD(widget, one, two, three, four, five); \ + } \ + \ + RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three, \ + ARG4 four, ARG5 five); + +#define CHROMEGTK_CALLBACK_6(TYPE, RETURN, METHOD, ARG1, ARG2, ARG3, ARG4, \ + ARG5, ARG6) \ + static RETURN METHOD ## Thunk(GtkWidget* widget, ARG1 one, ARG2 two, \ + ARG3 three, ARG4 four, ARG5 five, \ + ARG6 six, gpointer userdata) { \ + return reinterpret_cast<TYPE*>(userdata)-> \ + METHOD(widget, one, two, three, four, five, six); \ + } \ + \ + RETURN METHOD(GtkWidget* widget, ARG1 one, ARG2 two, ARG3 three, \ + ARG4 four, ARG5 five, ARG6 six); + +#endif // APP_GTK_SIGNAL_H_ |