From 7063ad77e3418c9b6480d58bcb608472c15bc421 Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Sat, 24 Jun 2017 16:56:42 +0300 Subject: [PATCH] Add initial support for GOBJECT-INTROSPECTION GOjbect Introspection allows various other languages to automatically generate bindings they can use. For details see: https://wiki.gnome.org/action/show/Projects/GObjectIntrospection --- .gitignore | 3 ++ Makefile.am | 3 +- configure.ac.in | 7 ++- libxfce4panel/Makefile.am | 42 ++++++++++++++- libxfce4panel/libxfce4panel-enums.h | 4 +- libxfce4panel/xfce-arrow-button.h | 4 +- libxfce4panel/xfce-panel-convenience.c | 12 ++--- libxfce4panel/xfce-panel-convenience.h | 4 +- libxfce4panel/xfce-panel-image.c | 8 +-- libxfce4panel/xfce-panel-macros-46.h | 4 +- libxfce4panel/xfce-panel-macros.h | 8 ++- libxfce4panel/xfce-panel-plugin.c | 14 ++--- libxfce4panel/xfce-panel-plugin.h | 4 +- m4/introspection.m4 | 96 ++++++++++++++++++++++++++++++++++ 14 files changed, 173 insertions(+), 40 deletions(-) create mode 100644 m4/introspection.m4 diff --git a/.gitignore b/.gitignore index b3607d19..64194fc8 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,9 @@ libxfce4panel/libxfce4panel-aliasdef.c libxfce4panel/libxfce4panel-enum-types.c libxfce4panel/libxfce4panel-enum-types.h libxfce4panel/libxfce4panel-config.h +libxfce4panel/libxfce4panel-2.0.gir +libxfce4panel/libxfce4panel-2.0.typelib +m4/* migrate/migrate panel/xfce4-panel plugins/applicationsmenu/xfce4-popup-applicationsmenu diff --git a/Makefile.am b/Makefile.am index e4e67957..8720a59d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -47,6 +47,7 @@ DISTCLEANFILES = \ intltool-update-tmp DISTCHECK_CONFIGURE_FLAGS = \ - --enable-gtk-doc + --enable-gtk-doc \ + --enable-introspection # vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/configure.ac.in b/configure.ac.in index 18c0df79..2f21d4d1 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -33,7 +33,7 @@ AC_COPYRIGHT([Copyright (c) 2002 - 2011 Written for Xfce by Jasper Huijsmans and Nick Schermer .]) AC_INIT([xfce4-panel], [xfce4_panel_version], [http://bugzilla.xfce.org/], [xfce4-panel]) -AC_PREREQ([2.50]) +AC_PREREQ([2.60]) AC_REVISION([xfce4_panel_version_build]) dnl *************************** @@ -156,6 +156,11 @@ dnl ********************************** XDT_CHECK_OPTIONAL_PACKAGE([GIO_UNIX], [gio-unix-2.0], [2.24.0], [gio-unix], [GIO UNIX features]) +dnl *************************************** +dnl *** Check for gobject-introspection *** +dnl *************************************** +GOBJECT_INTROSPECTION_CHECK([1.30.0]) + dnl ************************* dnl *** Check for gtk-doc *** dnl ************************* diff --git a/libxfce4panel/Makefile.am b/libxfce4panel/Makefile.am index 029e7f4b..070d6170 100644 --- a/libxfce4panel/Makefile.am +++ b/libxfce4panel/Makefile.am @@ -1,3 +1,4 @@ +DISTCLEANFILES = AM_CPPFLAGS = \ -I$(top_srcdir) \ @@ -155,7 +156,7 @@ libxfce4panel-enum-types.c: $(libxfce4panel_headers) Makefile --ftail "\n#define __LIBXFCE4PANEL_ENUM_TYPES_C__\n#include \n" \ $(libxfce4panel_headers) ) > $@ -DISTCLEANFILES = \ +DISTCLEANFILES += \ $(libxfce4panel_built_sources) BUILT_SOURCES = \ @@ -166,6 +167,45 @@ CLEANFILES = \ expected-abi endif +# endif MAINTAINER_MODE + + +# GObject Introspection +include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ENV = CC="$(CC)" +INTROSPECTION_SCANNER_ARGS = \ + --add-include-path=$(srcdir) \ + --warn-all \ + --identifier-prefix=Xfce \ + --identifier-prefix=xfce \ + --identifier-prefix=LIBXFCE4PANEL \ + --identifier-prefix=libxfce4panel \ + --identifier-prefix=Plugin +INTROSPECTION_COMPILER_ARGS = \ + --includedir=$(srcdir) \ + --includedir=. + +if HAVE_INTROSPECTION +introspection_sources = $(libxfce4panel_2_0_la_SOURCES) + +libxfce4panel-2.0.gir: libxfce4panel-2.0.la Makefile +libxfce4panel_2_0_gir_INCLUDES = GObject-2.0 GLib-2.0 Gtk-3.0 libxfce4util-1.0 +libxfce4panel_2_0_gir_CFLAGS = $(AM_CPPFLAGS) +libxfce4panel_2_0_gir_LIBS = libxfce4panel-2.0.la +libxfce4panel_2_0_gir_FILES = $(introspection_sources) +libxfce4panel_2_0_gir_EXPORT_PACKAGES = libxfce4panel-2.0 +INTROSPECTION_GIRS += libxfce4panel-2.0.gir + +girdir = $(datadir)/gir-1.0 +gir_DATA = $(INTROSPECTION_GIRS) + +typelibdir = $(libdir)/girepository-1.0 +typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) + +DISTCLEANFILES += $(gir_DATA) $(typelib_DATA) +endif +# endif HAVE_INTROSPECTION EXTRA_DIST = \ abicheck.sh \ diff --git a/libxfce4panel/libxfce4panel-enums.h b/libxfce4panel/libxfce4panel-enums.h index f4208782..d2e587f5 100644 --- a/libxfce4panel/libxfce4panel-enums.h +++ b/libxfce4panel/libxfce4panel-enums.h @@ -17,9 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* #if !defined(LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H) && !defined(LIBXFCE4PANEL_COMPILATION) -#error "Only can be included directly, this file may disappear or change contents" -#endif */ + #ifndef __LIBXFCE4PANEL_ENUMS_H__ #define __LIBXFCE4PANEL_ENUMS_H__ diff --git a/libxfce4panel/xfce-arrow-button.h b/libxfce4panel/xfce-arrow-button.h index 082415ff..d267d65f 100644 --- a/libxfce4panel/xfce-arrow-button.h +++ b/libxfce4panel/xfce-arrow-button.h @@ -17,9 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* #if !defined(LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H) && !defined(LIBXFCE4PANEL_COMPILATION) -#error "Only can be included directly, this file may disappear or change contents" -#endif */ + #ifndef __XFCE_ARROW_BUTTON_H__ #define __XFCE_ARROW_BUTTON_H__ diff --git a/libxfce4panel/xfce-panel-convenience.c b/libxfce4panel/xfce-panel-convenience.c index 597dbb73..be8679de 100644 --- a/libxfce4panel/xfce-panel-convenience.c +++ b/libxfce4panel/xfce-panel-convenience.c @@ -50,7 +50,7 @@ * Create regular #GtkButton with a few properties set to be useful in the * Xfce panel: Flat (%GTK_RELIEF_NONE), no focus on click and minimal padding. * - * Returns: newly created #GtkButton. + * Returns: (transfer full): newly created #GtkButton. **/ GtkWidget * xfce_panel_create_button (void) @@ -93,7 +93,7 @@ xfce_panel_create_button (void) * Create regular #GtkToggleButton with a few properties set to be useful in * Xfce panel: Flat (%GTK_RELIEF_NONE), no focus on click and minimal padding. * - * Returns: newly created #GtkToggleButton. + * Returns: (transfer full): newly created #GtkToggleButton. **/ GtkWidget * xfce_panel_create_toggle_button (void) @@ -166,7 +166,7 @@ xfce_panel_get_channel_name (void) /** * xfce_panel_pixbuf_from_source_at_size: * @source: string that contains the location of an icon - * @icon_theme: icon theme or %NULL to use the default icon theme + * @icon_theme: (allow-none): icon theme or %NULL to use the default icon theme * @dest_width: the maximum returned width of the GdkPixbuf * @dest_height: the maximum returned height of the GdkPixbuf * @@ -181,7 +181,7 @@ xfce_panel_get_channel_name (void) * If it is when loaded from the disk, the pixbuf is scaled * preserving the aspect ratio. * - * Returns: a GdkPixbuf or %NULL if nothing was found. The value should + * Returns: (transfer full): a GdkPixbuf or %NULL if nothing was found. The value should * be released with g_object_unref when no longer used. * * See also: XfcePanelImage @@ -296,12 +296,12 @@ xfce_panel_pixbuf_from_source_at_size (const gchar *source, /** * xfce_panel_pixbuf_from_source: * @source: string that contains the location of an icon - * @icon_theme: icon theme or %NULL to use the default icon theme + * @icon_theme: (allow-none): icon theme or %NULL to use the default icon theme * @size: size the icon that should be loaded * * See xfce_panel_pixbuf_from_source_at_size * - * Returns: a GdkPixbuf or %NULL if nothing was found. The value should + * Returns: (transfer full): a GdkPixbuf or %NULL if nothing was found. The value should * be released with g_object_unref when no longer used. * * See also: XfcePanelImage diff --git a/libxfce4panel/xfce-panel-convenience.h b/libxfce4panel/xfce-panel-convenience.h index 364556b7..a16ee24e 100644 --- a/libxfce4panel/xfce-panel-convenience.h +++ b/libxfce4panel/xfce-panel-convenience.h @@ -17,9 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* #if !defined(LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H) && !defined(LIBXFCE4PANEL_COMPILATION) -#error "Only can be included directly, this file may disappear or change contents" -#endif */ + #ifndef __XFCE_PANEL_CONVENIENCE_H__ #define __XFCE_PANEL_CONVENIENCE_H__ diff --git a/libxfce4panel/xfce-panel-image.c b/libxfce4panel/xfce-panel-image.c index 80730400..306d914d 100644 --- a/libxfce4panel/xfce-panel-image.c +++ b/libxfce4panel/xfce-panel-image.c @@ -792,7 +792,7 @@ xfce_panel_image_new (void) /** * xfce_panel_image_new_from_pixbuf: - * @pixbuf : a #GdkPixbuf, or %NULL. + * @pixbuf : (allow-none): a #GdkPixbuf, or %NULL. * * Creates a new #XfcePanelImage displaying @pixbuf. #XfcePanelImage * will add its own reference rather than adopting yours. You don't @@ -817,7 +817,7 @@ xfce_panel_image_new_from_pixbuf (GdkPixbuf *pixbuf) /** * xfce_panel_image_new_from_source: - * @source : source of the image. This can be an absolute path or + * @source : (allow-none): source of the image. This can be an absolute path or * an icon-name or %NULL. * * Creates a new #XfcePanelImage displaying @source. #XfcePanelImage @@ -844,7 +844,7 @@ xfce_panel_image_new_from_source (const gchar *source) /** * xfce_panel_image_set_from_pixbuf: * @image : an #XfcePanelImage. - * @pixbuf : a #GdkPixbuf, or %NULL. + * @pixbuf : (allow-none): a #GdkPixbuf, or %NULL. * * See xfce_panel_image_new_from_pixbuf() for details. * @@ -871,7 +871,7 @@ xfce_panel_image_set_from_pixbuf (XfcePanelImage *image, /** * xfce_panel_image_set_from_source: * @image : an #XfcePanelImage. - * @source : source of the image. This can be an absolute path or + * @source : (allow-none): source of the image. This can be an absolute path or * an icon-name or %NULL. * * See xfce_panel_image_new_from_source() for details. diff --git a/libxfce4panel/xfce-panel-macros-46.h b/libxfce4panel/xfce-panel-macros-46.h index 6b472e3d..210a949d 100644 --- a/libxfce4panel/xfce-panel-macros-46.h +++ b/libxfce4panel/xfce-panel-macros-46.h @@ -16,9 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* #if !defined(LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H) && !defined(LIBXFCE4PANEL_COMPILATION) -#error "Only can be included directly, this file may disappear or change contents" -#endif */ + #ifndef __LIBXFCE4PANEL_DEPRECATED_H__ #define __LIBXFCE4PANEL_DEPRECATED_H__ diff --git a/libxfce4panel/xfce-panel-macros.h b/libxfce4panel/xfce-panel-macros.h index 33ea3b98..b4859a28 100644 --- a/libxfce4panel/xfce-panel-macros.h +++ b/libxfce4panel/xfce-panel-macros.h @@ -16,9 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* #if !defined(LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H) && !defined(LIBXFCE4PANEL_COMPILATION) -#error "Only can be included directly, this file may disappear or change contents" -#endif */ + #ifndef __XFCE_PANEL_MACROS_H__ #define __XFCE_PANEL_MACROS_H__ @@ -110,7 +108,7 @@ typedef GTypeModule XfcePanelTypeModule; * XFCE_PANEL_DEFINE_PLUGIN: * @TypeName : The name of the new type, in Camel case. * @type_name : The name of the new type, in lowercase, with words separated by '_'. - * @args... : Optional list of *_register_type() function from other + * @... : Optional list of *_register_type() function from other * objects in the plugin created with #XFCE_PANEL_DEFINE_TYPE. * * Define a new (resident) GObject panel plugin, the parent type of the object @@ -127,7 +125,7 @@ typedef GTypeModule XfcePanelTypeModule; * XFCE_PANEL_DEFINE_PLUGIN_RESIDENT: * @TypeName : The name of the new type, in Camel case. * @type_name : The name of the new type, in lowercase, with words separated by '_'. - * @args... : Optional list of *_register_type() function from other + * @... : Optional list of *_register_type() function from other * objects in the plugin created with #XFCE_PANEL_DEFINE_TYPE. * * Same as #XFCE_PANEL_DEFINE_PLUGIN, but if you use special libraries or objects, diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c index d4e05972..8e6e1753 100644 --- a/libxfce4panel/xfce-panel-plugin.c +++ b/libxfce4panel/xfce-panel-plugin.c @@ -2473,9 +2473,9 @@ xfce_panel_plugin_arrow_type (XfcePanelPlugin *plugin) * xfce_panel_plugin_position_widget: * @plugin : an #XfcePanelPlugin. * @menu_widget : a #GtkWidget that will be used as popup menu. - * @attach_widget : a #GtkWidget relative to which the menu should be positioned. - * @x : return location for the x coordinate. - * @y : return location for the x coordinate. + * @attach_widget : (allow-none): a #GtkWidget relative to which the menu should be positioned. + * @x : (out): return location for the x coordinate. + * @y : (out): return location for the x coordinate. * * The menu widget is positioned relative to @attach_widget. * If @attach_widget is NULL, the menu widget is instead positioned @@ -2622,8 +2622,8 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin, /** * xfce_panel_plugin_position_menu: * @menu : a #GtkMenu. - * @x : return location for the x coordinate. - * @y : return location for the y coordinate. + * @x : (out): return location for the x coordinate. + * @y : (out): return location for the y coordinate. * @push_in : keep inside the screen (see #GtkMenuPositionFunc) * @panel_plugin : an #XfcePanelPlugin. * @@ -2779,7 +2779,7 @@ xfce_panel_plugin_block_autohide (XfcePanelPlugin *plugin, * * See also: xfce_panel_plugin_save_location() and xfce_resource_lookup() * - * Returns: The path to a config file or %NULL if no file was found. + * Returns: (transfer full): The path to a config file or %NULL if no file was found. * The returned string must be freed using g_free() **/ gchar * @@ -2810,7 +2810,7 @@ xfce_panel_plugin_lookup_rc_file (XfcePanelPlugin *plugin) * * See also: xfce_panel_plugin_lookup_rc_file() and xfce_resource_save_location() * - * Returns: The path to a config file or %NULL if no file was found. + * Returns: (transfer full): The path to a config file or %NULL if no file was found. * The returned string must be freed u sing g_free(). **/ gchar * diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h index 89c18abb..19be9762 100644 --- a/libxfce4panel/xfce-panel-plugin.h +++ b/libxfce4panel/xfce-panel-plugin.h @@ -16,9 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* #if !defined(LIBXFCE4PANEL_INSIDE_LIBXFCE4PANEL_H) && !defined(LIBXFCE4PANEL_COMPILATION) -#error "Only can be included directly, this file may disappear or change contents" -#endif */ + #ifndef __XFCE_PANEL_PLUGIN_H__ #define __XFCE_PANEL_PLUGIN_H__ diff --git a/m4/introspection.m4 b/m4/introspection.m4 new file mode 100644 index 00000000..d89c3d90 --- /dev/null +++ b/m4/introspection.m4 @@ -0,0 +1,96 @@ +dnl -*- mode: autoconf -*- +dnl Copyright 2009 Johan Dahlin +dnl +dnl This file is free software; the author(s) gives unlimited +dnl permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl + +# serial 1 + +m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], +[ + AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([LT_INIT],[$0])dnl setup libtool first + + dnl enable/disable introspection + m4_if([$2], [require], + [dnl + enable_introspection=yes + ],[dnl + AC_ARG_ENABLE(introspection, + AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], + [Enable introspection for this build]),, + [enable_introspection=auto]) + ])dnl + + AC_MSG_CHECKING([for gobject-introspection]) + + dnl presence/version checking + AS_CASE([$enable_introspection], + [no], [dnl + found_introspection="no (disabled, use --enable-introspection to enable)" + ],dnl + [yes],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0],, + AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], + found_introspection=yes, + AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) + ],dnl + [auto],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) + dnl Canonicalize enable_introspection + enable_introspection=$found_introspection + ],dnl + [dnl + AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) + ])dnl + + AC_MSG_RESULT([$found_introspection]) + + INTROSPECTION_SCANNER= + INTROSPECTION_COMPILER= + INTROSPECTION_GENERATE= + INTROSPECTION_GIRDIR= + INTROSPECTION_TYPELIBDIR= + if test "x$found_introspection" = "xyes"; then + INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` + INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` + INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` + INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` + INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" + INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` + INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` + INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection + fi + AC_SUBST(INTROSPECTION_SCANNER) + AC_SUBST(INTROSPECTION_COMPILER) + AC_SUBST(INTROSPECTION_GENERATE) + AC_SUBST(INTROSPECTION_GIRDIR) + AC_SUBST(INTROSPECTION_TYPELIBDIR) + AC_SUBST(INTROSPECTION_CFLAGS) + AC_SUBST(INTROSPECTION_LIBS) + AC_SUBST(INTROSPECTION_MAKEFILE) + + AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") +]) + + +dnl Usage: +dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) + +AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) +]) + +dnl Usage: +dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) + + +AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) +]) -- 2.11.0