[Spice-devel] [PATCH spice-gtk v2 2/4] Gtk applications only include spice-client-gtk.h

Jonathon Jongsma jjongsma at redhat.com
Thu Sep 24 15:20:27 PDT 2015


This header is the single include needed for all gtk-related
functionality, similar to spice-client.h. Generate a compiler error if a
different header is included.
---
 src/Makefile.am          |  1 +
 src/spice-client-gtk.h   | 32 ++++++++++++++++++++++++++++++++
 src/spice-grabsequence.h |  4 ++++
 src/spice-gtk-session.c  |  2 +-
 src/spice-gtk-session.h  |  4 ++++
 src/spice-widget.c       |  2 +-
 src/spice-widget.h       |  4 ++++
 src/usb-device-widget.c  |  2 +-
 src/usb-device-widget.h  |  4 ++++
 9 files changed, 52 insertions(+), 3 deletions(-)
 create mode 100644 src/spice-client-gtk.h

diff --git a/src/Makefile.am b/src/Makefile.am
index a035a2a..9d4ebcc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -176,6 +176,7 @@ endif
 
 libspice_client_gtkincludedir = $(includedir)/spice-client-gtk-$(SPICE_GTK_API_VERSION)
 libspice_client_gtkinclude_HEADERS =	\
+	spice-client-gtk.h		\
 	spice-gtk-session.h		\
 	spice-widget.h			\
 	spice-grabsequence.h		\
diff --git a/src/spice-client-gtk.h b/src/spice-client-gtk.h
new file mode 100644
index 0000000..0667145
--- /dev/null
+++ b/src/spice-client-gtk.h
@@ -0,0 +1,32 @@
+/*
+   Copyright (C) 2015 Red Hat, Inc.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef __SPICE_CLIENT_GTK_H__
+#define __SPICE_CLIENT_GTK_H__
+
+#include "spice-client.h"
+
+#define __SPICE_CLIENT_GTK_H_INSIDE__
+
+#include "spice-grabsequence.h"
+#include "spice-gtk-session.h"
+#include "spice-widget-enums.h"
+#include "spice-widget.h"
+#include "usb-device-widget.h"
+
+#undef __SPICE_CLIENT_GTK_H_INSIDE__
+
+#endif /* __SPICE_CLIENT_GTK_H__ */
diff --git a/src/spice-grabsequence.h b/src/spice-grabsequence.h
index af227b0..16d9908 100644
--- a/src/spice-grabsequence.h
+++ b/src/spice-grabsequence.h
@@ -22,6 +22,10 @@
 #ifndef SPICE_GRAB_SEQUENCE_H
 #define SPICE_GRAB_SEQUENCE_H
 
+#if !defined(__SPICE_CLIENT_GTK_H_INSIDE__) && !defined(SPICE_COMPILATION)
+#error "Only <spice-client-gtk.h> can be included directly"
+#endif
+
 #include <glib.h>
 #include <glib-object.h>
 
diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index 90f5116..5abb16c 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -73,7 +73,7 @@ struct _SpiceGtkSessionPrivate {
  * @section_id:
  * @see_also: #SpiceSession, and the GTK widget #SpiceDisplay
  * @stability: Stable
- * @include: spice-gtk-session.h
+ * @include: spice-client-gtk.h
  *
  * The #SpiceGtkSession class is the spice-client-gtk counter part of
  * #SpiceSession. It contains functionality which should be handled per
diff --git a/src/spice-gtk-session.h b/src/spice-gtk-session.h
index a69c174..08f838d 100644
--- a/src/spice-gtk-session.h
+++ b/src/spice-gtk-session.h
@@ -18,6 +18,10 @@
 #ifndef __SPICE_CLIENT_GTK_SESSION_H__
 #define __SPICE_CLIENT_GTK_SESSION_H__
 
+#if !defined(__SPICE_CLIENT_GTK_H_INSIDE__) && !defined(SPICE_COMPILATION)
+#error "Only <spice-client-gtk.h> can be included directly"
+#endif
+
 #include "spice-client.h"
 
 G_BEGIN_DECLS
diff --git a/src/spice-widget.c b/src/spice-widget.c
index 524263d..503f82a 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -52,7 +52,7 @@
  * @title: Spice Display
  * @section_id:
  * @stability: Stable
- * @include: spice-widget.h
+ * @include: spice-client-gtk.h
  *
  * A GTK widget that displays a SPICE server. It sends keyboard/mouse
  * events and can also share clipboard...
diff --git a/src/spice-widget.h b/src/spice-widget.h
index f180a43..7c3e768 100644
--- a/src/spice-widget.h
+++ b/src/spice-widget.h
@@ -18,6 +18,10 @@
 #ifndef __SPICE_CLIENT_WIDGET_H__
 #define __SPICE_CLIENT_WIDGET_H__
 
+#if !defined(__SPICE_CLIENT_GTK_H_INSIDE__) && !defined(SPICE_COMPILATION)
+#error "Only <spice-client-gtk.h> can be included directly"
+#endif
+
 #include "spice-client.h"
 
 #include <gtk/gtk.h>
diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c
index 84435b2..fe983c9 100644
--- a/src/usb-device-widget.c
+++ b/src/usb-device-widget.c
@@ -33,7 +33,7 @@
  * @section_id:
  * @see_also:
  * @stability: Stable
- * @include: usb-device-widget.h
+ * @include: spice-client-gtk.h
  *
  * #SpiceUsbDeviceWidget is a gtk widget which apps can use to easily
  * add an UI to select USB devices to redirect (or unredirect).
diff --git a/src/usb-device-widget.h b/src/usb-device-widget.h
index 9143d5c..16903b1 100644
--- a/src/usb-device-widget.h
+++ b/src/usb-device-widget.h
@@ -21,6 +21,10 @@
 #ifndef __SPICE_USB_DEVICE_WIDGET_H__
 #define __SPICE_USB_DEVICE_WIDGET_H__
 
+#if !defined(__SPICE_CLIENT_GTK_H_INSIDE__) && !defined(SPICE_COMPILATION)
+#error "Only <spice-client-gtk.h> can be included directly"
+#endif
+
 #include <gtk/gtk.h>
 #include "spice-client.h"
 
-- 
2.1.0



More information about the Spice-devel mailing list