diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 00000000..900ce24f --- /dev/null +++ b/data/meson.build @@ -0,0 +1,96 @@ +portal_dbus_interfaces = [ + desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Request.xml', + desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Session.xml', + desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.FileChooser.xml', + desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Print.xml', + desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Notification.xml', + desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Inhibit.xml', + desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Access.xml', + desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Account.xml', + desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Email.xml', + desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.DynamicLauncher.xml', +] + +fdo_dbus_interfaces = files( + 'org.freedesktop.ScreenSaver.xml', + 'org.freedesktop.Accounts.xml', + 'org.freedesktop.Accounts.User.xml', +) + +gtk_dbus_interfaces = files('org.gtk.Notifications.xml') + +gnome_dbus_interfaces = files( + 'org.gnome.SessionManager.xml', + 'org.gnome.ScreenSaver.xml', +) + +gtk_portal = configuration_data() + +if get_option('wallpaper').allowed() + portal_dbus_interfaces += desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Wallpaper.xml' + gtk_portal.set('wallpaper_iface', 'org.freedesktop.impl.portal.Wallpaper;') +else + gtk_portal.set('wallpaper_iface', '') +endif + +if get_option('settings').allowed() + portal_dbus_interfaces += desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Settings.xml' + gtk_portal.set('settings_iface', 'org.freedesktop.impl.portal.Settings;') +else + gtk_portal.set('settings_iface', '') +endif + +if get_option('appchooser').allowed() + portal_dbus_interfaces += desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.AppChooser.xml' + gtk_portal.set('appchooser_iface', 'org.freedesktop.impl.portal.AppChooser;') +else + gtk_portal.set('appchooser_iface', '') +endif + +if get_option('lockdown').allowed() + portal_dbus_interfaces += desktop_portal_interfaces_dir / 'org.freedesktop.impl.portal.Lockdown.xml' + gtk_portal.set('lockdown_iface', 'org.freedesktop.impl.portal.Lockdown;') +else + gtk_portal.set('lockdown_iface', '') +endif + +configure_file( + input: 'gtk.portal.in', + output: 'gtk.portal', + configuration: gtk_portal, + install: true, + install_dir: datadir / 'xdg-desktop-portal/portals', +) + +service_conf = configuration_data() +service_conf.set('libexecdir', libexecdir) +configure_file( + input: 'org.freedesktop.impl.portal.desktop.gtk.service.in', + output: 'org.freedesktop.impl.portal.desktop.gtk.service', + configuration: service_conf, + install: true, + install_dir: dbus_service_dir, +) +configure_file( + input: 'xdg-desktop-portal-gtk.service.in', + output: 'xdg-desktop-portal-gtk.service', + configuration: service_conf, + install: true, + install_dir: systemd_userunit_dir, +) + +desktop_conf = configuration_data() +desktop_conf.set('libexecdir', libexecdir) +i18n.merge_file( + type: 'desktop', + input: configure_file( + input: 'xdg-desktop-portal-gtk.desktop.in.in', + output: 'xdg-desktop-portal-gtk.desktop.in', + configuration: desktop_conf, + ), + output: 'xdg-desktop-portal-gtk.desktop', + po_dir: '../po', + install: true, + install_dir: datadir / 'applications', +) + diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..dfe7f2dd --- /dev/null +++ b/meson.build @@ -0,0 +1,97 @@ +project( + 'xdg-desktop-portal-gtk', + 'c', + version: '1.14.1', + meson_version: '>= 0.61.2', + license: 'LGPL-2.1-or-later', + default_options: ['warning_level=2'], +) + +prefix = get_option('prefix') +datadir = prefix / get_option('datadir') +libexecdir = prefix / get_option('libexecdir') +sysconfdir = prefix / get_option('sysconfdir') +localedir = prefix / get_option('localedir') +dbus_service_dir = get_option('dbus-service-dir') +if dbus_service_dir == '' + dbus_service_dir = prefix / datadir / 'dbus-1' / 'services' +endif + +systemd_userunit_dir = get_option('systemd-user-unit-dir') +if systemd_userunit_dir == '' + # This is deliberately not ${libdir}: systemd units always go in + # .../lib, never .../lib64 or .../lib/x86_64-linux-gnu + systemd_userunit_dir = prefix / 'lib' / 'systemd' / 'user' +endif + +dataroot_dir = get_option('datarootdir') +if dataroot_dir == '' + dataroot_dir = datadir +endif + +i18n = import('i18n') +gnome = import('gnome') +pkgconfig = import('pkgconfig') + +root_inc = include_directories('.') + +config_h = configuration_data() + +config_h.set_quoted('G_LOG_DOMAIN', 'xdg-desktop-portal-gtk') +config_h.set_quoted('DATADIR', datadir) +config_h.set_quoted('LIBEXECDIR', libexecdir) +config_h.set_quoted('LOCALEDIR', localedir) +config_h.set_quoted('SYSCONFDIR', sysconfdir) +config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name()) +config_h.set_quoted('PACKAGE_NAME', meson.project_name()) +config_h.set_quoted('PACKAGE_VERSION', meson.project_version()) +config_h.set_quoted('PACKAGE_STRING', '@0@ @1@'.format(meson.project_name(), meson.project_version())) + +xdp_dep = dependency('xdg-desktop-portal') +desktop_portal_interfaces_dir = xdp_dep.get_variable(pkgconfig: 'interfaces_dir') + +portal_deps = [ + dependency('xdg-desktop-portal', version: '>=1.14.0'), + dependency('glib-2.0', version: '>=2.44'), + dependency('gio-unix-2.0'), + dependency('gtk+-3.0', version: '>=3.14'), + dependency('gtk+-unix-print-3.0'), +] + +gtkx11_dep = dependency('gtk+-x11-3.0', required: false) +config_h.set('HAVE_GTK_X11', gtkx11_dep.found()) + +gtkwayland_dep = dependency('gtk+-wayland-3.0', version: '>=3.21.5', required: false) +config_h.set('HAVE_GTK_WAYLAND', gtkwayland_dep.found()) + +configure_file(output: 'config.h', configuration: config_h) + +subdir('data') +subdir('src') +subdir('po') + +summary({ + 'DBus service dir': dbus_service_dir, + 'Portal interfaces dir': desktop_portal_interfaces_dir, + 'systemd user unit dir': systemd_userunit_dir, + }, + section: 'Directories', +) + +summary({ + 'X11': gtkx11_dep.found(), + 'Wayland': gtkwayland_dep.found(), + }, + bool_yn: true, + section: 'Dependencies', +) + +summary({ + 'Wallpaper': get_option('wallpaper'), + 'Settings': get_option('settings'), + 'AppChooser': get_option('appchooser'), + 'Lockdown': get_option('lockdown'), + }, + bool_yn: true, + section: 'Portals', +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..91ab8e2b --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,30 @@ +option('dbus-service-dir', + type: 'string', + value: '', + description: 'directory for dbus service files (default: PREFIX/share/dbus-1/services)') +option('systemd-user-unit-dir', + type: 'string', + value: '', + description: 'directory for systemd user service files (default: PREFIX/lib/systemd/user)') +option('datarootdir', + type: 'string', + value: '', + description: 'Define the datarootdir for the pkgconf file') + +# Features +option('wallpaper', + type: 'feature', + value: 'auto', + description: 'Enable Wallpaper portal (requires: gnome-desktop)') +option('settings', + type: 'feature', + value: 'auto', + description: 'Enable Settings portal (requires: fontconfig, gsettings-desktop-schemas)') +option('appchooser', + type: 'feature', + value: 'auto', + description: 'Enable AppChooser portal') +option('lockdown', + type: 'feature', + value: 'auto', + description: 'Enable Lockdown portal') diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 00000000..e9b77d79 --- /dev/null +++ b/po/meson.build @@ -0,0 +1 @@ +i18n.gettext(meson.project_name(), preset: 'glib') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 00000000..e70f520a --- /dev/null +++ b/src/meson.build @@ -0,0 +1,122 @@ +portal_sources = files( + 'utils.c', + 'request.c', + 'session.c', + 'filechooser.c', + 'notification.c', + 'fdonotification.c', + 'inhibit.c', + 'print.c', + 'access.c', + 'account.c', + 'accountdialog.c', + 'email.c', + 'gtkbackports.c', + 'externalwindow.c', + 'dynamic-launcher.c', +) + +if get_option('wallpaper').allowed() + portal_deps += dependency('gnome-desktop-3.0') + portal_sources += files( + 'wallpaper.c', + 'wallpaperpreview.c', + 'wallpaperdialog.c', + ) +endif + +if get_option('settings').allowed() + portal_deps += [ + dependency('gsettings-desktop-schemas'), + dependency('fontconfig'), + ] + portal_sources += files( + 'fc-monitor.c', + 'settings.c', + ) +endif + +if get_option('appchooser').allowed() + portal_sources += files( + 'appchooser.c', + 'appchooserrow.c', + 'appchooserdialog.c', + ) +endif + +if get_option('lockdown').allowed() + portal_sources += files('lockdown.c') +endif + +if gtkx11_dep.found() + portal_sources += files('externalwindow-x11.c') +endif + +if gtkwayland_dep.found() + portal_sources += files('externalwindow-wayland.c') +endif + +portal_resources = gnome.compile_resources( + 'xdg-desktop-portal-gtk-resources', + 'xdg-desktop-portal-gtk.gresource.xml', + c_name: '_xdg_desktop', + source_dir: '.', +) + +portal_built_sources = [ + portal_resources, +] + +portal_built_sources += gnome.gdbus_codegen('xdg-desktop-portal-dbus', + sources: portal_dbus_interfaces, + interface_prefix: 'org.freedesktop.impl.portal.', + namespace: 'XdpImpl', + annotations: [ + [ 'org.freedesktop.impl.portal.Print.Print()', 'org.gtk.GDBus.C.UnixFD', 'true' ], + ], +) + +portal_built_sources += gnome.gdbus_codegen('shell-dbus', + sources: [ + gtk_dbus_interfaces, + fdo_dbus_interfaces, + gnome_dbus_interfaces, + ], +) + +executable('xdg-desktop-portal-gtk', + sources: [ + 'xdg-desktop-portal-gtk.c', + portal_sources, + portal_built_sources, + ], + dependencies: [ + portal_deps, + gtkx11_dep, + gtkwayland_dep, + ], + c_args: [ + '-DLOCALEDIR="@0@"'.format(localedir), + ], + include_directories: [root_inc], + install: true, + install_dir: libexecdir, +) + +executable('testappchooser', + sources: [ + 'testappchooser.c', + 'appchooserrow.c', + 'appchooserdialog.c', + portal_resources, + ], + dependencies: [ + portal_deps, + gtkx11_dep, + ], + c_args: [ + '-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), + '-DLOCALEDIR="@0@"'.format(localedir), + ], + include_directories: [root_inc], +)