Skip to content

Commit

Permalink
Move glib headers in ui/base/gtk/ to ui/base/glib/.
Browse files Browse the repository at this point in the history
- Moved ui/base/gtk/gtk_integers.h to ui/base/glib/glib_integers.h since the header only contains typedefs in <glib/glibtypes.h> and does not depend Gtk+ at all.
- Moved the first half of ui/base/gtk/gtk_signal.h to ui/base/glib/glib_signal.h since it does not depend on Gtk+ as well.

This CL is part of the Gtk+ removal work (crbug.com/101422)

BUG=chromium:101422
TEST=ran try


Review URL: http://codereview.chromium.org/8494001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108948 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
yusukes@chromium.org committed Nov 8, 2011
1 parent d96ee58 commit 0117a81
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 95 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/ui/gtk/bookmarks/bookmark_editor_gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/string16.h"
#include "chrome/browser/bookmarks/bookmark_editor.h"
#include "chrome/browser/bookmarks/bookmark_model_observer.h"
#include "ui/base/gtk/gtk_integers.h"
#include "ui/base/glib/glib_integers.h"
#include "ui/base/gtk/gtk_signal.h"

class GURL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
#include "chrome/browser/bookmarks/bookmark_context_menu_controller.h"
#include "ui/base/gtk/gtk_integers.h"
#include "ui/base/glib/glib_integers.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/base/gtk/gtk_signal_registrar.h"
#include "ui/base/gtk/owned_widget_gtk.h"
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <vector>

#include "base/string16.h"
#include "ui/base/gtk/gtk_integers.h"
#include "ui/base/glib/glib_integers.h"

class BookmarkModel;
class BookmarkNode;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/gtk/gtk_theme_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "chrome/browser/prefs/pref_change_registrar.h"
#include "chrome/browser/themes/theme_service.h"
#include "content/public/browser/notification_observer.h"
#include "ui/base/gtk/gtk_integers.h"
#include "ui/base/glib/glib_integers.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/base/gtk/owned_widget_gtk.h"
#include "ui/gfx/color_utils.h"
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/gtk/update_recommended_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#pragma once

#include "base/basictypes.h"
#include "ui/base/gtk/gtk_integers.h"
#include "ui/base/glib/glib_integers.h"
#include "ui/base/gtk/gtk_signal.h"

typedef struct _GtkWidget GtkWidget;
Expand Down
12 changes: 6 additions & 6 deletions ui/base/gtk/gtk_integers.h → ui/base/glib/glib_integers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_BASE_GTK_GTK_INTEGERS_H_
#define UI_BASE_GTK_GTK_INTEGERS_H_
#ifndef UI_BASE_GLIB_GLIB_INTEGERS_H_
#define UI_BASE_GLIB_GLIB_INTEGERS_H_
#pragma once

// GLib/Gobject/Gtk all use their own integer typedefs. They are copied here
// for forward declaration reasons so we don't pull in all of gtk.h when we
// just need a gpointer.
// GLib/GObject/Gtk all use their own integer typedefs. They are copied here
// for forward declaration reasons so we don't pull in all of glib/gtypes.h
// when we just need a gpointer.
typedef char gchar;
typedef short gshort;
typedef long glong;
Expand All @@ -25,4 +25,4 @@ typedef unsigned int guint32;
typedef void* gpointer;
typedef const void *gconstpointer;

#endif // UI_BASE_GTK_GTK_INTEGERS_H_
#endif // UI_BASE_GLIB_GLIB_INTEGERS_H_
89 changes: 89 additions & 0 deletions ui/base/glib/glib_signal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright (c) 2011 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 UI_BASE_GLIB_GLIB_SIGNAL_H_
#define UI_BASE_GLIB_GLIB_SIGNAL_H_
#pragma once

typedef void* gpointer;

// 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 CHROMEG_CALLBACK_0(CLASS, RETURN, METHOD, SENDER) \
static RETURN METHOD ## Thunk(SENDER sender, gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)->METHOD(sender); \
} \
\
virtual RETURN METHOD(SENDER);

#define CHROMEG_CALLBACK_1(CLASS, RETURN, METHOD, SENDER, ARG1) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, \
gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)->METHOD(sender, one); \
} \
\
virtual RETURN METHOD(SENDER, ARG1);

#define CHROMEG_CALLBACK_2(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)->METHOD(sender, one, two); \
} \
\
virtual RETURN METHOD(SENDER, ARG1, ARG2);

#define CHROMEG_CALLBACK_3(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
ARG3 three, gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)-> \
METHOD(sender, one, two, three); \
} \
\
virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3);

#define CHROMEG_CALLBACK_4(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3, \
ARG4) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
ARG3 three, ARG4 four, \
gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)-> \
METHOD(sender, one, two, three, four); \
} \
\
virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3, ARG4);

#define CHROMEG_CALLBACK_5(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3, \
ARG4, ARG5) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
ARG3 three, ARG4 four, ARG5 five, \
gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)-> \
METHOD(sender, one, two, three, four, five); \
} \
\
virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3, ARG4, ARG5);

#define CHROMEG_CALLBACK_6(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3, \
ARG4, ARG5, ARG6) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
ARG3 three, ARG4 four, ARG5 five, \
ARG6 six, gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)-> \
METHOD(sender, one, two, three, four, five, six); \
} \
\
virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);

#endif
81 changes: 2 additions & 79 deletions ui/base/gtk/gtk_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,86 +6,9 @@
#define UI_BASE_GTK_GTK_SIGNAL_H_
#pragma once

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 CHROMEG_CALLBACK_0(CLASS, RETURN, METHOD, SENDER) \
static RETURN METHOD ## Thunk(SENDER sender, gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)->METHOD(sender); \
} \
\
virtual RETURN METHOD(SENDER);

#define CHROMEG_CALLBACK_1(CLASS, RETURN, METHOD, SENDER, ARG1) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, \
gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)->METHOD(sender, one); \
} \
\
virtual RETURN METHOD(SENDER, ARG1);
#include "ui/base/glib/glib_signal.h"

#define CHROMEG_CALLBACK_2(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)->METHOD(sender, one, two); \
} \
\
virtual RETURN METHOD(SENDER, ARG1, ARG2);

#define CHROMEG_CALLBACK_3(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
ARG3 three, gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)-> \
METHOD(sender, one, two, three); \
} \
\
virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3);

#define CHROMEG_CALLBACK_4(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3, \
ARG4) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
ARG3 three, ARG4 four, \
gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)-> \
METHOD(sender, one, two, three, four); \
} \
\
virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3, ARG4);

#define CHROMEG_CALLBACK_5(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3, \
ARG4, ARG5) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
ARG3 three, ARG4 four, ARG5 five, \
gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)-> \
METHOD(sender, one, two, three, four, five); \
} \
\
virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3, ARG4, ARG5);

#define CHROMEG_CALLBACK_6(CLASS, RETURN, METHOD, SENDER, ARG1, ARG2, ARG3, \
ARG4, ARG5, ARG6) \
static RETURN METHOD ## Thunk(SENDER sender, ARG1 one, ARG2 two, \
ARG3 three, ARG4 four, ARG5 five, \
ARG6 six, gpointer userdata) { \
return reinterpret_cast<CLASS*>(userdata)-> \
METHOD(sender, one, two, three, four, five, six); \
} \
\
virtual RETURN METHOD(SENDER, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6);
typedef struct _GtkWidget GtkWidget;

// These macros handle the common case where the sender object will be a
// GtkWidget*.
Expand Down
2 changes: 1 addition & 1 deletion ui/base/gtk/tooltip_window_gtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <string>

#include "base/string16.h"
#include "ui/base/gtk/gtk_integers.h"
#include "ui/base/glib/glib_integers.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/base/ui_export.h"

Expand Down
2 changes: 1 addition & 1 deletion views/ime/character_composer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <iterator>

#include "third_party/gtk+/gdk/gdkkeysyms.h"
#include "ui/base/gtk/gtk_integers.h"
#include "ui/base/glib/glib_integers.h"

namespace {

Expand Down
2 changes: 1 addition & 1 deletion views/ime/character_composer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/gtk+/gdk/gdkkeysyms.h"
#include "ui/base/gtk/gtk_integers.h"
#include "ui/base/glib/glib_integers.h"

namespace views {

Expand Down
4 changes: 2 additions & 2 deletions views/ime/input_method_ibus.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "ui/base/gtk/gtk_integers.h"
#include "ui/base/gtk/gtk_signal.h"
#include "ui/base/glib/glib_integers.h"
#include "ui/base/glib/glib_signal.h"
#include "views/events/event.h"
#include "views/ime/character_composer.h"
#include "views/ime/input_method_base.h"
Expand Down

0 comments on commit 0117a81

Please sign in to comment.