From d4dbd4374f887694e93f9b6604516ee986b769bb Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Fri, 30 Jun 2017 12:34:10 +0200 Subject: [PATCH] Clean up and separate VAPI files. Note to other developers: you might have to do `make clean;./autogen.sh` after this commit. * Use a GtkCheese namespace to be constistent with other vapi's (such as GtkClutter). * Put each library in a separate vapi-file (this will come in handy when porting to Meson). * Clean up config.vapi: * get rid of unused CCode prefix-attribute (removes warning) * be consistent with braces --- configure.ac | 7 ++-- src/main.vala | 2 +- vapi/Makefile.am | 7 +++- vapi/cheese-gtk.vapi | 5 +++ vapi/cheese.vapi | 45 +++++++++++++++++++++++++ vapi/config.vapi | 5 ++- vapi/custom.vapi | 66 ------------------------------------- vapi/gnome-desktop-3.0.vapi | 18 ++++++++++ 8 files changed, 82 insertions(+), 73 deletions(-) create mode 100644 vapi/cheese-gtk.vapi create mode 100644 vapi/cheese.vapi create mode 100644 vapi/gnome-desktop-3.0.vapi diff --git a/configure.ac b/configure.ac index ca85748..b442e65 100644 --- a/configure.ac +++ b/configure.ac @@ -44,8 +44,7 @@ pkg_modules="gtk+-3.0 >= 3.20.0 " PKG_CHECK_MODULES(CONTACTS, [$pkg_modules]) -CONTACTS_PACKAGES="--pkg gtk+-3.0 --pkg gio-2.0 --pkg gio-unix-2.0 --pkg folks --pkg folks-telepathy --pkg folks-eds --pkg clutter-1.0 --pkg clutter-gtk-1.0 --pkg champlain-0.12 --pkg geocode-glib-1.0" -AC_SUBST(CONTACTS_PACKAGES) +CONTACTS_PACKAGES="--pkg gtk+-3.0 --pkg gio-2.0 --pkg gio-unix-2.0 --pkg gnome-desktop-3.0 --pkg folks --pkg folks-telepathy --pkg folks-eds --pkg clutter-1.0 --pkg clutter-gtk-1.0 --pkg champlain-0.12 --pkg geocode-glib-1.0" # Optional dependency for the user accounts panel AC_ARG_WITH([cheese], @@ -56,6 +55,7 @@ if test x"$with_cheese" != x"no" ; then PKG_CHECK_MODULES(CHEESE, cheese-gtk >= 3.3.91 cheese, [have_cheese=yes], [have_cheese=no]) if test x${have_cheese} = xyes; then AC_DEFINE(HAVE_CHEESE, 1, [Define to 1 to enable cheese webcam support]) + CONTACTS_PACKAGES+=" --pkg cheese --pkg cheese-gtk" fi if test x${with_cheese} = xyes && test x${have_cheese} = xno; then AC_MSG_ERROR([Cheese configured but not found]) @@ -65,6 +65,9 @@ else fi AM_CONDITIONAL(BUILD_CHEESE, test x${have_cheese} = xyes) + +AC_SUBST(CONTACTS_PACKAGES) + ############# # Resources # ############# diff --git a/src/main.vala b/src/main.vala index e842aaa..b704249 100644 --- a/src/main.vala +++ b/src/main.vala @@ -26,7 +26,7 @@ main (string[] args) { Intl.textdomain (Config.GETTEXT_PACKAGE); #if HAVE_CHEESE - Cheese.gtk_init (ref args); + GtkCheese.init (ref args); #else GtkClutter.init (ref args); #endif diff --git a/vapi/Makefile.am b/vapi/Makefile.am index 52c64eb..1b0b404 100644 --- a/vapi/Makefile.am +++ b/vapi/Makefile.am @@ -1,4 +1,9 @@ -noinst_DATA = config.vapi custom.vapi +noinst_DATA = \ + cheese.vapi \ + cheese-gtk.vapi \ + config.vapi \ + custom.vapi \ + gnome-desktop-3.0.vapi EXTRA_DIST = $(noinst_DATA) diff --git a/vapi/cheese-gtk.vapi b/vapi/cheese-gtk.vapi new file mode 100644 index 0000000..6bb5053 --- /dev/null +++ b/vapi/cheese-gtk.vapi @@ -0,0 +1,5 @@ +[CCode (cprefix = "Cheese", lower_case_cprefix = "cheese_", cheader_filename = "cheese/cheese-gtk.h")] +namespace GtkCheese { + [CCode (cheader_filename = "cheese/cheese-camera-device.h", cname = "cheese_gtk_init")] + public static void init ([CCode (array_length_pos = 0.9)] ref unowned string[] argv); +} diff --git a/vapi/cheese.vapi b/vapi/cheese.vapi new file mode 100644 index 0000000..46f95de --- /dev/null +++ b/vapi/cheese.vapi @@ -0,0 +1,45 @@ +[CCode (cprefix = "Cheese", lower_case_cprefix = "cheese_", cheader_filename = "cheese/cheese-gtk.h")] +namespace Cheese { + [CCode (cheader_filename = "cheese/cheese-camera-device.h")] + public class CameraDevice : GLib.Object { + [CCode (has_construct_function = false, type = "CheeseCameraDevice*")] + public CameraDevice (string uuid, string device_node, string name, uint v4l_api_version) throws GLib.Error; + } + [CCode (cheader_filename = "cheese/cheese-camera-device-monitor.h")] + public class CameraDeviceMonitor : GLib.Object { + [CCode (has_construct_function = false, type = "CheeseCameraDeviceMonitor*")] + public CameraDeviceMonitor (); + public void coldplug (); + public signal void added (CameraDevice device); + public signal void removed (string uuid); + } + [CCode (cheader_filename = "cheese/cheese-avatar-chooser.h")] + public class AvatarChooser : Gtk.Dialog { + [CCode (has_construct_function = false, type = "CheeseAvatarChooser*")] + public AvatarChooser (); + public Gdk.Pixbuf get_picture (); + } + public enum WidgetState { + NONE, + READY, + ERROR + } + [CCode (cheader_filename = "cheese/cheese-widget.h")] + public class Widget : Gtk.Widget { + [CCode (has_construct_function = false, type = "CheeseWidget*")] + public Widget (); + public WidgetState state { get; } + public unowned GLib.Object get_camera (); + } + [CCode (cheader_filename = "cheese/cheese-camera.h")] + public class Camera : GLib.Object { + public bool take_photo_pixbuf (); + public signal void photo_taken (Gdk.Pixbuf pixbuf); + } + [CCode (cheader_filename = "cheese-flash.h")] + public class Flash : Gtk.Window { + [CCode (has_construct_function = false, type = "CheeseFlash*")] + public Flash (Gtk.Widget parent); + public void fire (); + } +} diff --git a/vapi/config.vapi b/vapi/config.vapi index 576792d..1c1b43f 100644 --- a/vapi/config.vapi +++ b/vapi/config.vapi @@ -1,6 +1,5 @@ -[CCode (prefix = "", lower_case_cprefix = "", cheader_filename = "config.h")] -namespace Config -{ +[CCode (lower_case_cprefix = "", cheader_filename = "config.h")] +namespace Config { /* Package information */ public const string PACKAGE_NAME; public const string PACKAGE_STRING; diff --git a/vapi/custom.vapi b/vapi/custom.vapi index 75a72f6..5fe3561 100644 --- a/vapi/custom.vapi +++ b/vapi/custom.vapi @@ -1,22 +1,3 @@ -namespace Gnome { - [CCode (cheader_filename = "libgnome-desktop/gnome-desktop-thumbnail.h")] - public class DesktopThumbnailFactory : GLib.Object { - [CCode (has_construct_function = false)] - public DesktopThumbnailFactory (Gnome.ThumbnailSize size); - public bool can_thumbnail (string uri, string mime_type, ulong mtime); - public void create_failed_thumbnail (string uri, ulong mtime); - public unowned Gdk.Pixbuf generate_thumbnail (string uri, string mime_type); - public bool has_valid_failed_thumbnail (string uri, ulong mtime); - public unowned string lookup (string uri, ulong mtime); - public void save_thumbnail (Gdk.Pixbuf thumbnail, string uri, ulong original_mtime); - } - [CCode (cheader_filename = "libgnome-desktop/gnome-desktop-thumbnail.h", cprefix = "GNOME_DESKTOP_THUMBNAIL_SIZE_")] - public enum ThumbnailSize { - NORMAL, - LARGE - } -} - [CCode (cprefix = "Contacts", lower_case_cprefix = "contacts_", cheader_filename = "contacts-esd-setup.h")] namespace Contacts { [CCode (cname = "contacts_ensure_eds_accounts")] @@ -46,50 +27,3 @@ namespace Cc { public Gdk.Pixbuf get_picture (); } } - -[CCode (cprefix = "Cheese", lower_case_cprefix = "cheese_", cheader_filename = "cheese/cheese-gtk.h")] -namespace Cheese { - public static void gtk_init ([CCode (array_length_pos = 0.9)] ref unowned string[] argv); - [CCode (cheader_filename = "cheese/cheese-camera-device.h")] - public class CameraDevice : GLib.Object { - [CCode (has_construct_function = false, type = "CheeseCameraDevice*")] - public CameraDevice (string uuid, string device_node, string name, uint v4l_api_version) throws GLib.Error; - } - [CCode (cheader_filename = "cheese/cheese-camera-device-monitor.h")] - public class CameraDeviceMonitor : GLib.Object { - [CCode (has_construct_function = false, type = "CheeseCameraDeviceMonitor*")] - public CameraDeviceMonitor (); - public void coldplug (); - public signal void added (CameraDevice device); - public signal void removed (string uuid); - } - [CCode (cheader_filename = "cheese/cheese-avatar-chooser.h")] - public class AvatarChooser : Gtk.Dialog { - [CCode (has_construct_function = false, type = "CheeseAvatarChooser*")] - public AvatarChooser (); - public Gdk.Pixbuf get_picture (); - } - public enum WidgetState { - NONE, - READY, - ERROR - } - [CCode (cheader_filename = "cheese/cheese-widget.h")] - public class Widget : Gtk.Widget { - [CCode (has_construct_function = false, type = "CheeseWidget*")] - public Widget (); - public WidgetState state { get; } - public unowned GLib.Object get_camera (); - } - [CCode (cheader_filename = "cheese/cheese-camera.h")] - public class Camera : GLib.Object { - public bool take_photo_pixbuf (); - public signal void photo_taken (Gdk.Pixbuf pixbuf); - } - [CCode (cheader_filename = "cheese-flash.h")] - public class Flash : Gtk.Window { - [CCode (has_construct_function = false, type = "CheeseFlash*")] - public Flash (Gtk.Widget parent); - public void fire (); - } -} diff --git a/vapi/gnome-desktop-3.0.vapi b/vapi/gnome-desktop-3.0.vapi new file mode 100644 index 0000000..c24fa53 --- /dev/null +++ b/vapi/gnome-desktop-3.0.vapi @@ -0,0 +1,18 @@ +[CCode (cheader_filename = "libgnome-desktop/gnome-desktop-thumbnail.h")] +namespace Gnome { + public class DesktopThumbnailFactory : GLib.Object { + [CCode (has_construct_function = false)] + public DesktopThumbnailFactory (Gnome.ThumbnailSize size); + public bool can_thumbnail (string uri, string mime_type, ulong mtime); + public void create_failed_thumbnail (string uri, ulong mtime); + public unowned Gdk.Pixbuf generate_thumbnail (string uri, string mime_type); + public bool has_valid_failed_thumbnail (string uri, ulong mtime); + public unowned string lookup (string uri, ulong mtime); + public void save_thumbnail (Gdk.Pixbuf thumbnail, string uri, ulong original_mtime); + } + [CCode (cprefix = "GNOME_DESKTOP_THUMBNAIL_SIZE_")] + public enum ThumbnailSize { + NORMAL, + LARGE + } +}