malcontent-control: Add initial main window

It’s currently empty, but it’s a start.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall 2019-12-19 13:41:17 +00:00
parent cf6331cac6
commit b0f72c432f
5 changed files with 75 additions and 1 deletions

View File

@ -69,12 +69,42 @@ mct_application_constructed (GObject *object)
G_OBJECT_CLASS (mct_application_parent_class)->constructed (object);
}
static void
mct_application_activate (GApplication *application)
{
GList *windows; /* (element-type GtkWindow) */
GtkWindow *window = NULL;
windows = gtk_application_get_windows (GTK_APPLICATION (application));
if (windows != NULL)
window = windows->data;
if (window == NULL)
{
g_autoptr(GtkBuilder) builder = NULL;
builder = gtk_builder_new_from_resource ("/org/freedesktop/MalcontentControl/ui/main.ui");
gtk_builder_set_translation_domain (builder, "malcontent");
/* Set up the main window. */
window = GTK_WINDOW (gtk_builder_get_object (builder, "main_window"));
gtk_window_set_application (window, GTK_APPLICATION (application));
gtk_widget_show (GTK_WIDGET (window));
}
/* Bring the window to the front. */
gtk_window_present (window);
}
static void
mct_application_class_init (MctApplicationClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GApplicationClass *application_class = G_APPLICATION_CLASS (klass);
object_class->constructed = mct_application_constructed;
application_class->activate = mct_application_activate;
}
/**

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright © 2019 Endless Mobile, Inc. -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkApplicationWindow" id="main_window">
<child>
<object class="GtkBox" id="vbox1">
<property name="orientation">vertical</property>
</object>
</child>
</object>
</interface>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright © 2019 Endless Mobile, Inc. -->
<gresources>
<gresource prefix="/org/freedesktop/MalcontentControl/ui">
<file preprocess="xml-stripblanks">main.ui</file>
</gresource>
</gresources>

View File

@ -1,11 +1,21 @@
application_id = 'org.freedesktop.MalcontentControl'
if not cc.has_function('atexit')
error('atexit() needed for generated GResource files')
endif
resources = gnome.compile_resources(
'resources',
'malcontent-control.gresource.xml',
source_dir: meson.source_root(),
)
malcontent_control = executable('malcontent-control',
[
'application.c',
'application.h',
'main.c',
],
] + resources,
dependencies: [
dependency('gio-2.0', version: '>= 2.44'),
dependency('glib-2.0', version: '>= 2.54.2'),
@ -57,6 +67,20 @@ if appstream_util.found()
)
endif
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('main.ui'),
],
suite: ['malcontent-control'],
)
endif
# FIXME: Add icons and tests
#subdir('icons')
#subdir('tests')

View File

@ -3,6 +3,7 @@
accounts-service/com.endlessm.ParentalControls.policy.in
libmalcontent/manager.c
malcontent-control/application.c
malcontent-control/main.ui
malcontent-control/org.freedesktop.MalcontentControl.appdata.xml.in
malcontent-control/org.freedesktop.MalcontentControl.desktop.in
pam/pam_malcontent.c