From 2a3f0fd741e639a62385b205f75a270c438cb17e Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 31 Jan 2020 18:11:34 +0000 Subject: [PATCH 1/4] libmalcontent: Rework pkg-config file generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Meson 0.49 has matured its pkg-config file generation a little, and the API has subtly changed. The main library we’re building a pkg-config file for is now passed as the first argument; and all dependencies can be passed to `libraries`/`libraries_private`. Any dependencies which provide pkg-config files will automatically be moved into the pkg-config file’s `Requires`/`Requires.private` sections. See https://mesonbuild.com/Pkgconfig-module.html#implicit-dependencies This bumps our Meson dependency to ≥ 0.49.0. Signed-off-by: Philip Withnall --- libmalcontent/meson.build | 7 +++---- meson.build | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libmalcontent/meson.build b/libmalcontent/meson.build index e592f11..1aa0c45 100644 --- a/libmalcontent/meson.build +++ b/libmalcontent/meson.build @@ -46,15 +46,14 @@ install_headers(libmalcontent_headers, subdir: libmalcontent_include_subdir, ) -pkgconfig.generate( - libraries: [ libmalcontent ], +pkgconfig.generate(libmalcontent, subdirs: libmalcontent_api_name, version: meson.project_version(), name: 'libmalcontent', filebase: libmalcontent_api_name, description: 'Library providing access to parental control settings.', - requires: libmalcontent_public_deps, - requires_private: libmalcontent_private_deps, + libraries: libmalcontent_public_deps, + libraries_private: libmalcontent_private_deps, ) gnome.generate_gir(libmalcontent, diff --git a/meson.build b/meson.build index ea9fea2..d39a95f 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('malcontent', 'c', version : '0.4.0', - meson_version : '>= 0.47.0', + meson_version : '>= 0.49.0', license: 'LGPLv2.1+', default_options : [ 'buildtype=debugoptimized', From 0607bfa1964eba63bdf8d3e07aad474c19671e1d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 30 Jan 2020 18:24:20 +0000 Subject: [PATCH 2/4] build: Bump version to 0.5.0 So the versioning is right for developing against this unreleased version. Signed-off-by: Philip Withnall --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index d39a95f..666d434 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('malcontent', 'c', - version : '0.4.0', + version : '0.5.0', meson_version : '>= 0.49.0', license: 'LGPLv2.1+', default_options : [ From 3289a3731713b05ee973cf41cd139553fd25bcd7 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 30 Jan 2020 11:31:00 +0000 Subject: [PATCH 3/4] libmalcontent-ui: Add initial skeleton for separate UI library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moving the widgets out of malcontent-control means they can be reused in other projects. In particular, I’m interested in reusing them in gnome-initial-setup. The new library will not build yet, but this introduces all the build framework necessary for moving the source files over. Signed-off-by: Philip Withnall --- libmalcontent-ui/malcontent-ui.gresource.xml | 6 ++ libmalcontent-ui/malcontent-ui.h | 24 +++++ libmalcontent-ui/meson.build | 93 ++++++++++++++++++++ meson.build | 1 + 4 files changed, 124 insertions(+) create mode 100644 libmalcontent-ui/malcontent-ui.gresource.xml create mode 100644 libmalcontent-ui/malcontent-ui.h create mode 100644 libmalcontent-ui/meson.build diff --git a/libmalcontent-ui/malcontent-ui.gresource.xml b/libmalcontent-ui/malcontent-ui.gresource.xml new file mode 100644 index 0000000..8736c19 --- /dev/null +++ b/libmalcontent-ui/malcontent-ui.gresource.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/libmalcontent-ui/malcontent-ui.h b/libmalcontent-ui/malcontent-ui.h new file mode 100644 index 0000000..4977a50 --- /dev/null +++ b/libmalcontent-ui/malcontent-ui.h @@ -0,0 +1,24 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright © 2020 Endless Mobile, 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: + * - Philip Withnall + */ + +#pragma once + diff --git a/libmalcontent-ui/meson.build b/libmalcontent-ui/meson.build new file mode 100644 index 0000000..ac196c6 --- /dev/null +++ b/libmalcontent-ui/meson.build @@ -0,0 +1,93 @@ +libmalcontent_ui_api_version = '0' +libmalcontent_ui_api_name = 'malcontent-ui-' + libmalcontent_ui_api_version + +if not cc.has_function('atexit') + error('atexit() needed for generated GResource files') +endif + +resources = gnome.compile_resources( + 'resources', + 'malcontent-ui.gresource.xml', + source_dir: meson.source_root(), +) + +libmalcontent_ui_sources = [ +] + resources +libmalcontent_ui_headers = [ + 'malcontent-ui.h', +] +libmalcontent_ui_private_headers = [ +] + +libmalcontent_ui_public_deps = [ + dependency('accountsservice', version: '>= 0.6.39'), + dependency('gio-2.0', version: '>= 2.44'), + dependency('glib-2.0', version: '>= 2.54.2'), + dependency('gobject-2.0', version: '>= 2.54'), + dependency('gtk+-3.0', version: '>= 3.24'), + libmalcontent_dep, +] +libmalcontent_ui_private_deps = [ + dependency('flatpak'), +] + +# FIXME: Would be good to use subdir here: https://github.com/mesonbuild/meson/issues/2969 +libmalcontent_ui_include_subdir = join_paths(libmalcontent_ui_api_name, 'libmalcontent-ui') + +libmalcontent_ui = library(libmalcontent_ui_api_name, + libmalcontent_ui_sources + libmalcontent_ui_headers + libmalcontent_ui_private_headers, + dependencies: libmalcontent_ui_public_deps + libmalcontent_ui_private_deps, + include_directories: root_inc, + install: true, + version: meson.project_version(), + soversion: libmalcontent_ui_api_version, +) +libmalcontent_ui_dep = declare_dependency( + link_with: libmalcontent_ui, + include_directories: root_inc, +) + +# Public library bits. +install_headers(libmalcontent_ui_headers, + subdir: libmalcontent_ui_include_subdir, +) + +pkgconfig.generate(libmalcontent_ui, + subdirs: libmalcontent_ui_api_name, + version: meson.project_version(), + name: 'libmalcontent-ui', + filebase: libmalcontent_ui_api_name, + description: 'Library providing widgets for parental control settings.', + libraries: libmalcontent_ui_public_deps, + libraries_private: libmalcontent_ui_private_deps, +) + +gnome.generate_gir(libmalcontent_ui, + sources: libmalcontent_ui_sources + libmalcontent_ui_headers + libmalcontent_ui_private_headers, + nsversion: libmalcontent_ui_api_version, + namespace: 'MalcontentUi', + symbol_prefix: 'mct_', + identifier_prefix: 'Mct', + export_packages: 'libmalcontent-ui', + includes: ['AccountsService-1.0', 'Gio-2.0', 'GObject-2.0', 'Gtk-3.0'], + install: true, + dependencies: libmalcontent_ui_dep, +) + +xmllint = find_program('xmllint', required: false) +if xmllint.found() + gtk_prefix = dependency('gtk+-3.0').get_pkgconfig_variable('prefix') + test( + 'validate-ui', xmllint, + args: [ + '--nonet', '--noblanks', '--noout', + '--relaxng', join_paths(gtk_prefix, 'share', 'gtk-3.0', 'gtkbuilder.rng'), + files( + ), + ], + suite: ['libmalcontent-ui'], + ) +endif + +# FIXME: Add tests +#subdir('tests') diff --git a/meson.build b/meson.build index 666d434..301a10b 100644 --- a/meson.build +++ b/meson.build @@ -128,6 +128,7 @@ test_env = [ subdir('accounts-service') subdir('libmalcontent') +subdir('libmalcontent-ui') subdir('malcontent-client') subdir('malcontent-control') subdir('pam') From 1f3f0a4560d895cd5040289018e80623aeb35fc8 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 30 Jan 2020 11:43:46 +0000 Subject: [PATCH 4/4] libmalcontent-ui: Move widgets over from malcontent-control MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They need to be re-used in gnome-initial-setup. The other widgets which remain in malcontent-control don’t need to be used in g-i-s so can stay where they are for now. They might move across to libmalcontent-ui later if there’s a need for it. Signed-off-by: Philip Withnall --- .../gs-content-rating.c | 0 .../gs-content-rating.h | 0 libmalcontent-ui/malcontent-ui.gresource.xml | 3 +++ libmalcontent-ui/malcontent-ui.h | 3 +++ libmalcontent-ui/meson.build | 11 +++++++++++ .../restrict-applications-dialog.c | 2 +- .../restrict-applications-dialog.h | 0 .../restrict-applications-dialog.ui | 0 .../restrict-applications-selector.c | 2 +- .../restrict-applications-selector.h | 0 .../restrict-applications-selector.ui | 0 .../user-controls.c | 2 +- .../user-controls.h | 0 .../user-controls.ui | 0 malcontent-control/application.c | 2 +- .../malcontent-control.gresource.xml | 3 --- malcontent-control/meson.build | 12 +----------- po/POTFILES.in | 14 +++++++------- 18 files changed, 29 insertions(+), 25 deletions(-) rename {malcontent-control => libmalcontent-ui}/gs-content-rating.c (100%) rename {malcontent-control => libmalcontent-ui}/gs-content-rating.h (100%) rename {malcontent-control => libmalcontent-ui}/restrict-applications-dialog.c (99%) rename {malcontent-control => libmalcontent-ui}/restrict-applications-dialog.h (100%) rename {malcontent-control => libmalcontent-ui}/restrict-applications-dialog.ui (100%) rename {malcontent-control => libmalcontent-ui}/restrict-applications-selector.c (99%) rename {malcontent-control => libmalcontent-ui}/restrict-applications-selector.h (100%) rename {malcontent-control => libmalcontent-ui}/restrict-applications-selector.ui (100%) rename {malcontent-control => libmalcontent-ui}/user-controls.c (99%) rename {malcontent-control => libmalcontent-ui}/user-controls.h (100%) rename {malcontent-control => libmalcontent-ui}/user-controls.ui (100%) diff --git a/malcontent-control/gs-content-rating.c b/libmalcontent-ui/gs-content-rating.c similarity index 100% rename from malcontent-control/gs-content-rating.c rename to libmalcontent-ui/gs-content-rating.c diff --git a/malcontent-control/gs-content-rating.h b/libmalcontent-ui/gs-content-rating.h similarity index 100% rename from malcontent-control/gs-content-rating.h rename to libmalcontent-ui/gs-content-rating.h diff --git a/libmalcontent-ui/malcontent-ui.gresource.xml b/libmalcontent-ui/malcontent-ui.gresource.xml index 8736c19..cbdaa9f 100644 --- a/libmalcontent-ui/malcontent-ui.gresource.xml +++ b/libmalcontent-ui/malcontent-ui.gresource.xml @@ -2,5 +2,8 @@ + restrict-applications-dialog.ui + restrict-applications-selector.ui + user-controls.ui diff --git a/libmalcontent-ui/malcontent-ui.h b/libmalcontent-ui/malcontent-ui.h index 4977a50..d573c3f 100644 --- a/libmalcontent-ui/malcontent-ui.h +++ b/libmalcontent-ui/malcontent-ui.h @@ -22,3 +22,6 @@ #pragma once +#include +#include +#include diff --git a/libmalcontent-ui/meson.build b/libmalcontent-ui/meson.build index ac196c6..06208a3 100644 --- a/libmalcontent-ui/meson.build +++ b/libmalcontent-ui/meson.build @@ -12,11 +12,19 @@ resources = gnome.compile_resources( ) libmalcontent_ui_sources = [ + 'gs-content-rating.c', + 'restrict-applications-dialog.c', + 'restrict-applications-selector.c', + 'user-controls.c', ] + resources libmalcontent_ui_headers = [ 'malcontent-ui.h', + 'restrict-applications-dialog.h', + 'restrict-applications-selector.h', + 'user-controls.h', ] libmalcontent_ui_private_headers = [ + 'gs-content-rating.h', ] libmalcontent_ui_public_deps = [ @@ -83,6 +91,9 @@ if xmllint.found() '--nonet', '--noblanks', '--noout', '--relaxng', join_paths(gtk_prefix, 'share', 'gtk-3.0', 'gtkbuilder.rng'), files( + 'restrict-applications-dialog.ui', + 'restrict-applications-selector.ui', + 'user-controls.ui', ), ], suite: ['libmalcontent-ui'], diff --git a/malcontent-control/restrict-applications-dialog.c b/libmalcontent-ui/restrict-applications-dialog.c similarity index 99% rename from malcontent-control/restrict-applications-dialog.c rename to libmalcontent-ui/restrict-applications-dialog.c index 7d20ff1..98f663a 100644 --- a/malcontent-control/restrict-applications-dialog.c +++ b/libmalcontent-ui/restrict-applications-dialog.c @@ -186,7 +186,7 @@ mct_restrict_applications_dialog_class_init (MctRestrictApplicationsDialogClass g_object_class_install_properties (object_class, G_N_ELEMENTS (properties), properties); - gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/MalcontentControl/ui/restrict-applications-dialog.ui"); + gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/MalcontentUi/ui/restrict-applications-dialog.ui"); gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsDialog, selector); gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsDialog, description); diff --git a/malcontent-control/restrict-applications-dialog.h b/libmalcontent-ui/restrict-applications-dialog.h similarity index 100% rename from malcontent-control/restrict-applications-dialog.h rename to libmalcontent-ui/restrict-applications-dialog.h diff --git a/malcontent-control/restrict-applications-dialog.ui b/libmalcontent-ui/restrict-applications-dialog.ui similarity index 100% rename from malcontent-control/restrict-applications-dialog.ui rename to libmalcontent-ui/restrict-applications-dialog.ui diff --git a/malcontent-control/restrict-applications-selector.c b/libmalcontent-ui/restrict-applications-selector.c similarity index 99% rename from malcontent-control/restrict-applications-selector.c rename to libmalcontent-ui/restrict-applications-selector.c index 6fb9d4b..b203bee 100644 --- a/malcontent-control/restrict-applications-selector.c +++ b/libmalcontent-ui/restrict-applications-selector.c @@ -209,7 +209,7 @@ mct_restrict_applications_selector_class_init (MctRestrictApplicationsSelectorCl g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/MalcontentControl/ui/restrict-applications-selector.ui"); + gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/MalcontentUi/ui/restrict-applications-selector.ui"); gtk_widget_class_bind_template_child (widget_class, MctRestrictApplicationsSelector, listbox); } diff --git a/malcontent-control/restrict-applications-selector.h b/libmalcontent-ui/restrict-applications-selector.h similarity index 100% rename from malcontent-control/restrict-applications-selector.h rename to libmalcontent-ui/restrict-applications-selector.h diff --git a/malcontent-control/restrict-applications-selector.ui b/libmalcontent-ui/restrict-applications-selector.ui similarity index 100% rename from malcontent-control/restrict-applications-selector.ui rename to libmalcontent-ui/restrict-applications-selector.ui diff --git a/malcontent-control/user-controls.c b/libmalcontent-ui/user-controls.c similarity index 99% rename from malcontent-control/user-controls.c rename to libmalcontent-ui/user-controls.c index a4bb8f4..e9310fb 100644 --- a/malcontent-control/user-controls.c +++ b/libmalcontent-ui/user-controls.c @@ -749,7 +749,7 @@ mct_user_controls_class_init (MctUserControlsClass *klass) g_object_class_install_properties (object_class, N_PROPS, properties); - gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/MalcontentControl/ui/user-controls.ui"); + gtk_widget_class_set_template_from_resource (widget_class, "/org/freedesktop/MalcontentUi/ui/user-controls.ui"); gtk_widget_class_bind_template_child (widget_class, MctUserControls, age_menu); gtk_widget_class_bind_template_child (widget_class, MctUserControls, allow_system_installation_switch); diff --git a/malcontent-control/user-controls.h b/libmalcontent-ui/user-controls.h similarity index 100% rename from malcontent-control/user-controls.h rename to libmalcontent-ui/user-controls.h diff --git a/malcontent-control/user-controls.ui b/libmalcontent-ui/user-controls.ui similarity index 100% rename from malcontent-control/user-controls.ui rename to libmalcontent-ui/user-controls.ui diff --git a/malcontent-control/application.c b/malcontent-control/application.c index e97db71..77fbae0 100644 --- a/malcontent-control/application.c +++ b/malcontent-control/application.c @@ -27,10 +27,10 @@ #include #include #include +#include #include #include "application.h" -#include "user-controls.h" #include "user-selector.h" diff --git a/malcontent-control/malcontent-control.gresource.xml b/malcontent-control/malcontent-control.gresource.xml index 8f4d8e9..62ef12c 100644 --- a/malcontent-control/malcontent-control.gresource.xml +++ b/malcontent-control/malcontent-control.gresource.xml @@ -5,9 +5,6 @@ carousel.css carousel.ui main.ui - restrict-applications-dialog.ui - restrict-applications-selector.ui - user-controls.ui user-selector.ui diff --git a/malcontent-control/meson.build b/malcontent-control/meson.build index 528ed3c..2ee2415 100644 --- a/malcontent-control/meson.build +++ b/malcontent-control/meson.build @@ -16,15 +16,7 @@ malcontent_control = executable('malcontent-control', 'application.h', 'carousel.c', 'carousel.h', - 'gs-content-rating.c', - 'gs-content-rating.h', 'main.c', - 'restrict-applications-dialog.c', - 'restrict-applications-dialog.h', - 'restrict-applications-selector.c', - 'restrict-applications-selector.h', - 'user-controls.c', - 'user-controls.h', 'user-image.c', 'user-image.h', 'user-selector.c', @@ -39,6 +31,7 @@ malcontent_control = executable('malcontent-control', dependency('flatpak'), dependency('polkit-gobject-1'), libmalcontent_dep, + libmalcontent_ui_dep, ], include_directories: root_inc, install: true, @@ -95,9 +88,6 @@ if xmllint.found() files( 'carousel.ui', 'main.ui', - 'restrict-applications-dialog.ui', - 'restrict-applications-selector.ui', - 'user-controls.ui', 'user-selector.ui', ), ], diff --git a/po/POTFILES.in b/po/POTFILES.in index d26b86e..51f8d6d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -2,16 +2,16 @@ # Please keep this file sorted alphabetically. accounts-service/com.endlessm.ParentalControls.policy.in libmalcontent/manager.c +libmalcontent-ui/gs-content-rating.c +libmalcontent-ui/restrict-applications-dialog.c +libmalcontent-ui/restrict-applications-dialog.ui +libmalcontent-ui/restrict-applications-selector.c +libmalcontent-ui/restrict-applications-selector.ui +libmalcontent-ui/user-controls.c +libmalcontent-ui/user-controls.ui malcontent-control/application.c -malcontent-control/gs-content-rating.c malcontent-control/main.ui malcontent-control/org.freedesktop.MalcontentControl.appdata.xml.in malcontent-control/org.freedesktop.MalcontentControl.desktop.in malcontent-control/org.freedesktop.MalcontentControl.policy.in -malcontent-control/restrict-applications-dialog.c -malcontent-control/restrict-applications-dialog.ui -malcontent-control/restrict-applications-selector.c -malcontent-control/restrict-applications-selector.ui -malcontent-control/user-controls.c -malcontent-control/user-controls.ui pam/pam_malcontent.c