Merge lp:~aacid/unity-2d/unity-2d_gobject_callback_header into lp:unity-2d

Proposed by Albert Astals Cid
Status: Merged
Approved by: Gerry Boland
Approved revision: 935
Merged at revision: 935
Proposed branch: lp:~aacid/unity-2d/unity-2d_gobject_callback_header
Merge into: lp:unity-2d
Diff against target: 112 lines (+41/-31)
3 files modified
libunity-2d-private/src/gobjectcallback.h (+38/-0)
libunity-2d-private/src/unity2ddeclarativeview.cpp (+2/-8)
libunity-2d-private/src/windowsintersectmonitor.cpp (+1/-23)
To merge this branch: bzr merge lp:~aacid/unity-2d/unity-2d_gobject_callback_header
Reviewer Review Type Date Requested Status
Gerry Boland Pending
Review via email: mp+94532@code.launchpad.net

Description of the change

Move the handy gobject callback macros to a header so we don't copy the code everywhere

To post a comment you must log in.
935. By Albert Astals Cid

Make that 2012 as Gerry suggests

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'libunity-2d-private/src/gobjectcallback.h'
2--- libunity-2d-private/src/gobjectcallback.h 1970-01-01 00:00:00 +0000
3+++ libunity-2d-private/src/gobjectcallback.h 2012-02-24 12:51:19 +0000
4@@ -0,0 +1,38 @@
5+/*
6+ * Copyright (C) 2012 Canonical, Ltd.
7+ *
8+ * This program is free software; you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License as published by
10+ * the Free Software Foundation; version 3.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ */
20+
21+// Handy macros to declare GObject callbacks. The 'n' in CALLBACKn refers to
22+// the number of dummy arguments the callback returns
23+#define GOBJECT_CALLBACK0(callbackName, slot) \
24+static void \
25+callbackName(GObject* src, QObject* dst) \
26+{ \
27+ QMetaObject::invokeMethod(dst, slot); \
28+}
29+
30+#define GOBJECT_CALLBACK1(callbackName, slot) \
31+static void \
32+callbackName(GObject* src, void* dummy1, QObject* dst) \
33+{ \
34+ QMetaObject::invokeMethod(dst, slot); \
35+}
36+
37+#define GOBJECT_CALLBACK2(callbackName, slot) \
38+static void \
39+callbackName(GObject* src, void* dummy1, void* dummy2, QObject* dst) \
40+{ \
41+ QMetaObject::invokeMethod(dst, slot); \
42+}
43
44=== modified file 'libunity-2d-private/src/unity2ddeclarativeview.cpp'
45--- libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-02-09 10:56:45 +0000
46+++ libunity-2d-private/src/unity2ddeclarativeview.cpp 2012-02-24 12:51:19 +0000
47@@ -20,6 +20,7 @@
48 #include <config.h>
49
50 #include "screeninfo.h"
51+#include "gobjectcallback.h"
52
53 #include <QDebug>
54 #include <QGLWidget>
55@@ -36,14 +37,7 @@
56 #include <libwnck/libwnck.h>
57 }
58
59-#define GOBJECT_CALLBACK0(callbackName, slot) \
60-static void \
61-callbackName(GObject* src, void* dummy1, QObject* dst) \
62-{ \
63- QMetaObject::invokeMethod(dst, slot); \
64-}
65-
66-GOBJECT_CALLBACK0(activeWorkspaceChangedCB, "onActiveWorkspaceChanged");
67+GOBJECT_CALLBACK1(activeWorkspaceChangedCB, "onActiveWorkspaceChanged");
68
69 Unity2DDeclarativeView::Unity2DDeclarativeView(QWidget *parent) :
70 QDeclarativeView(parent),
71
72=== modified file 'libunity-2d-private/src/windowsintersectmonitor.cpp'
73--- libunity-2d-private/src/windowsintersectmonitor.cpp 2012-02-08 14:18:37 +0000
74+++ libunity-2d-private/src/windowsintersectmonitor.cpp 2012-02-24 12:51:19 +0000
75@@ -16,6 +16,7 @@
76
77 // libunity-2d
78 #include <debug_p.h>
79+#include "gobjectcallback.h"
80
81 // Qt
82 #include <QCursor>
83@@ -29,29 +30,6 @@
84 #include <libwnck/libwnck.h>
85 }
86
87-// Handy macros to declare GObject callbacks. The 'n' in CALLBACKn refers to
88-// the number of dummy arguments the callback returns
89-#define GOBJECT_CALLBACK0(callbackName, slot) \
90-static void \
91-callbackName(GObject* src, QObject* dst) \
92-{ \
93- QMetaObject::invokeMethod(dst, slot); \
94-}
95-
96-#define GOBJECT_CALLBACK1(callbackName, slot) \
97-static void \
98-callbackName(GObject* src, void* dummy1, QObject* dst) \
99-{ \
100- QMetaObject::invokeMethod(dst, slot); \
101-}
102-
103-#define GOBJECT_CALLBACK2(callbackName, slot) \
104-static void \
105-callbackName(GObject* src, void* dummy1, void* dummy2, QObject* dst) \
106-{ \
107- QMetaObject::invokeMethod(dst, slot); \
108-}
109-
110 // Screen callbacks
111 GOBJECT_CALLBACK1(activeWindowChangedCB, "updateActiveWindowConnections");
112 GOBJECT_CALLBACK1(activeWorkspaceChangedCB, "updateIntersect");

Subscribers

People subscribed via source and target branches