From 1d8f7d665ca1909ef1a1d8398aa8b8e19c3ace4f Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 17 Dec 2019 15:41:03 +0000 Subject: [PATCH] malcontent-control: Add initial skeleton application This does nothing at the moment (not even showing a main window), but it soon will do. Signed-off-by: Philip Withnall --- .gitlab-ci.yml | 2 +- malcontent-control/application.c | 92 ++++++++++++++++++++++++++++++++ malcontent-control/application.h | 37 +++++++++++++ malcontent-control/main.c | 37 +++++++++++++ malcontent-control/meson.build | 22 ++++++++ meson.build | 4 +- po/POTFILES.in | 1 + 7 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 malcontent-control/application.c create mode 100644 malcontent-control/application.h create mode 100644 malcontent-control/main.c create mode 100644 malcontent-control/meson.build diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f2740ec..2240f62 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ before_script: libxml2-devel dbus-daemon glib2-devel dbus-devel gobject-introspection-devel gettext-devel polkit-devel polkit-gnome git - lcov pam-devel + lcov pam-devel gtk3-devel - export LANG=C.UTF-8 stages: diff --git a/malcontent-control/application.c b/malcontent-control/application.c new file mode 100644 index 0000000..94981ca --- /dev/null +++ b/malcontent-control/application.c @@ -0,0 +1,92 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright © 2019 Endless Mobile, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + * Authors: + * - Philip Withnall + */ + +#include "config.h" + +#include +#include +#include +#include +#include + +#include "application.h" + + +/** + * MctApplication: + * + * #MctApplication is a top-level object representing the parental controls + * application. + * + * Since: 0.5.0 + */ +struct _MctApplication +{ + GtkApplication parent_instance; +}; + +G_DEFINE_TYPE (MctApplication, mct_application, GTK_TYPE_APPLICATION) + +static void +mct_application_init (MctApplication *self) +{ + /* Nothing to do here. */ +} + +static void +mct_application_constructed (GObject *object) +{ + GApplication *application = G_APPLICATION (object); + + g_application_set_application_id (application, "org.freedesktop.MalcontentControl"); + + /* Localisation */ + bindtextdomain ("malcontent", PACKAGE_LOCALE_DIR); + bind_textdomain_codeset ("malcontent", "UTF-8"); + textdomain ("malcontent"); + + g_set_application_name (_("Parental Controls")); + gtk_window_set_default_icon_name ("org.freedesktop.MalcontentControl"); + + G_OBJECT_CLASS (mct_application_parent_class)->constructed (object); +} + +static void +mct_application_class_init (MctApplicationClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->constructed = mct_application_constructed; +} + +/** + * mct_application_new: + * + * Create a new #MctApplication. + * + * Returns: (transfer full): a new #MctApplication + * Since: 0.5.0 + */ +MctApplication * +mct_application_new (void) +{ + return g_object_new (MCT_TYPE_APPLICATION, NULL); +} diff --git a/malcontent-control/application.h b/malcontent-control/application.h new file mode 100644 index 0000000..8c0f39a --- /dev/null +++ b/malcontent-control/application.h @@ -0,0 +1,37 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright © 2019 Endless Mobile, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + * Authors: + * - Philip Withnall + */ + +#pragma once + +#include +#include +#include +#include + + +G_BEGIN_DECLS + +#define MCT_TYPE_APPLICATION mct_application_get_type () +G_DECLARE_FINAL_TYPE (MctApplication, mct_application, MCT, APPLICATION, GtkApplication) + +MctApplication *mct_application_new (void); + +G_END_DECLS diff --git a/malcontent-control/main.c b/malcontent-control/main.c new file mode 100644 index 0000000..cce6f70 --- /dev/null +++ b/malcontent-control/main.c @@ -0,0 +1,37 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright © 2019 Endless Mobile, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + * + * Authors: + * - Philip Withnall + */ + +#include +#include +#include + +#include "application.h" + + +int +main (int argc, + char *argv[]) +{ + g_autoptr(MctApplication) app = NULL; + + app = mct_application_new (); + return g_application_run (G_APPLICATION (app), argc, argv); +} diff --git a/malcontent-control/meson.build b/malcontent-control/meson.build new file mode 100644 index 0000000..156cc7e --- /dev/null +++ b/malcontent-control/meson.build @@ -0,0 +1,22 @@ +application_id = 'org.freedesktop.MalcontentControl' + +malcontent_control = executable('malcontent-control', + [ + 'application.c', + 'application.h', + 'main.c', + ], + dependencies: [ + 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'), + libmalcontent_dep, + ], + include_directories: root_inc, + install: true, +) + +# FIXME: Add icons and tests +#subdir('icons') +#subdir('tests') diff --git a/meson.build b/meson.build index 7d73ab1..ea9fea2 100644 --- a/meson.build +++ b/meson.build @@ -48,6 +48,7 @@ libglib_testing_dep = dependency( config_h = configuration_data() config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name()) +config_h.set_quoted('PACKAGE_LOCALE_DIR', join_paths(get_option('localedir'), meson.project_name())) configure_file( output: 'config.h', configuration: config_h, @@ -126,7 +127,8 @@ test_env = [ ] subdir('accounts-service') -subdir('malcontent-client') subdir('libmalcontent') +subdir('malcontent-client') +subdir('malcontent-control') subdir('pam') subdir('po') diff --git a/po/POTFILES.in b/po/POTFILES.in index 18cd688..0b29360 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -2,4 +2,5 @@ # Please keep this file sorted alphabetically. accounts-service/com.endlessm.ParentalControls.policy.in libmalcontent/manager.c +malcontent-control/application.c pam/pam_malcontent.c