Commit fba6dcdc authored by Francois Techene's avatar Francois Techene
Browse files

Initial commit

parents
This diff is collapsed.
#!/usr/bin/env python3
from os import environ, path
from subprocess import call
prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = path.join(prefix, 'share')
destdir = environ.get('DESTDIR', '')
# Package managers set this so we don't need to run
if not destdir:
print('Updating icon cache...')
call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')])
print('Updating desktop database...')
call(['update-desktop-database', '-q', path.join(datadir, 'applications')])
print('Compiling GSettings schemas...')
call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')])
desktop_file = i18n.merge_file(
input: 'sm.puri.randomizer.desktop.in',
output: 'sm.puri.randomizer.desktop',
type: 'desktop',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'applications')
)
desktop_utils = find_program('desktop-file-validate', required: false)
if desktop_utils.found()
test('Validate desktop file', desktop_utils,
args: [desktop_file]
)
endif
appstream_file = i18n.merge_file(
input: 'sm.puri.randomizer.appdata.xml.in',
output: 'sm.puri.randomizer.appdata.xml',
po_dir: '../po',
install: true,
install_dir: join_paths(get_option('datadir'), 'appdata')
)
appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
test('Validate appstream file', appstream_util,
args: ['validate', appstream_file]
)
endif
install_data('sm.puri.randomizer.gschema.xml',
install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')
)
compile_schemas = find_program('glib-compile-schemas', required: false)
if compile_schemas.found()
test('Validate schema file', compile_schemas,
args: ['--strict', '--dry-run', meson.current_source_dir()]
)
endif
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>sm.puri.randomizer.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<description>
</description>
</component>
[Desktop Entry]
Name=randomizer
Exec=randomizer
Terminal=false
Type=Application
Categories=GTK;
StartupNotify=true
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="randomizer">
<schema id="sm.puri.randomizer" path="/sm/puri/randomizer/">
</schema>
</schemalist>
project('randomizer', 'c',
version: '0.1.0',
meson_version: '>= 0.50.0',
default_options: [ 'warning_level=2',
'c_std=gnu11',
],
)
i18n = import('i18n')
config_h = configuration_data()
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
config_h.set_quoted('GETTEXT_PACKAGE', 'randomizer')
config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
configure_file(
output: 'randomizer-config.h',
configuration: config_h,
)
add_project_arguments([
'-I' + meson.build_root(),
], language: 'c')
subdir('data')
subdir('src')
subdir('po')
meson.add_install_script('build-aux/meson/postinstall.py')
\ No newline at end of file
data/sm.puri.randomizer.desktop.in
data/sm.puri.randomizer.appdata.xml.in
data/sm.puri.randomizer.gschema.xml
src/randomizer-window.ui
src/main.c
src/randomizer-window.c
i18n.gettext('randomizer', preset: 'glib')
{
"app-id" : "sm.puri.randomizer",
"runtime" : "org.gnome.Platform",
"runtime-version" : "3.38",
"sdk" : "org.gnome.Sdk",
"command" : "randomizer",
"finish-args" : [
"--share=network",
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland"
],
"cleanup" : [
"/include",
"/lib/pkgconfig",
"/man",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"*.la",
"*.a"
],
"modules" : [
{
"name" : "randomizer",
"builddir" : true,
"buildsystem" : "meson",
"sources" : [
{
"type" : "git",
"url" : "file:///home/feeef/dev-l5/randomizer"
}
]
}
]
}
/* main.c
*
* Copyright 2021 francois.techene@puri.sm
*
* 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 3 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 <http://www.gnu.org/licenses/>.
*/
#include <glib/gi18n.h>
#include "randomizer-config.h"
#include "randomizer-window.h"
static void
on_activate (GtkApplication *app)
{
GtkWindow *window;
/* It's good practice to check your parameters at the beginning of the
* function. It helps catch errors early and in development instead of
* by your users.
*/
g_assert (GTK_IS_APPLICATION (app));
/* Get the current window or create one if necessary. */
window = gtk_application_get_active_window (app);
if (window == NULL)
window = g_object_new (RANDOMIZER_TYPE_WINDOW,
"application", app,
"default-width", 600,
"default-height", 300,
NULL);
/* Ask the window manager/compositor to present the window. */
gtk_window_present (window);
}
int
main (int argc,
char *argv[])
{
g_autoptr(GtkApplication) app = NULL;
int ret;
/* Set up gettext translations */
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
/*
* Create a new GtkApplication. The application manages our main loop,
* application windows, integration with the window manager/compositor, and
* desktop features such as file opening and single-instance applications.
*/
app = gtk_application_new ("sm.puri.randomizer", G_APPLICATION_FLAGS_NONE);
/*
* We connect to the activate signal to create a window when the application
* has been lauched. Additionally, this signal notifies us when the user
* tries to launch a "second instance" of the application. When they try
* to do that, we'll just present any existing window.
*
* Because we can't pass a pointer to any function type, we have to cast
* our "on_activate" function to a GCallback.
*/
g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
/*
* Run the application. This function will block until the applicaiton
* exits. Upon return, we have our exit code to return to the shell. (This
* is the code you see when you do `echo $?` after running a command in a
* terminal.
*
* Since GtkApplication inherits from GApplication, we use the parent class
* method "run". But we need to cast, which is what the "G_APPLICATION()"
* macro does.
*/
ret = g_application_run (G_APPLICATION (app), argc, argv);
return ret;
}
randomizer_sources = [
'main.c',
'randomizer-window.c',
]
randomizer_deps = [
dependency('gio-2.0', version: '>= 2.50'),
dependency('gtk+-3.0', version: '>= 3.22'),
]
gnome = import('gnome')
randomizer_sources += gnome.compile_resources('randomizer-resources',
'randomizer.gresource.xml',
c_name: 'randomizer'
)
executable('randomizer', randomizer_sources,
dependencies: randomizer_deps,
install: true,
)
/* randomizer-window.c
*
* Copyright 2021 francois.techene@puri.sm
*
* 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 3 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 <http://www.gnu.org/licenses/>.
*/
#include "randomizer-config.h"
#include "randomizer-window.h"
struct _RandomizerWindow
{
GtkApplicationWindow parent_instance;
/* Template widgets */
GtkHeaderBar *header_bar;
GtkLabel *label;
};
G_DEFINE_TYPE (RandomizerWindow, randomizer_window, GTK_TYPE_APPLICATION_WINDOW)
static void
randomizer_window_class_init (RandomizerWindowClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class, "/sm/puri/randomizer/randomizer-window.ui");
gtk_widget_class_bind_template_child (widget_class, RandomizerWindow, header_bar);
gtk_widget_class_bind_template_child (widget_class, RandomizerWindow, label);
}
static void
randomizer_window_init (RandomizerWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
/* randomizer-window.h
*
* Copyright 2021 francois.techene@puri.sm
*
* 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 3 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define RANDOMIZER_TYPE_WINDOW (randomizer_window_get_type())
G_DECLARE_FINAL_TYPE (RandomizerWindow, randomizer_window, RANDOMIZER, WINDOW, GtkApplicationWindow)
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="RandomizerWindow" parent="GtkApplicationWindow">
<property name="default-width">600</property>
<property name="default-height">300</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header_bar">
<property name="visible">True</property>
<property name="show-close-button">True</property>
<property name="title">Hello, World!</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label">
<property name="label">Hello, World!</property>
<property name="visible">True</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="2"/>
</attributes>
</object>
</child>
</template>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/sm/puri/randomizer">
<file>randomizer-window.ui</file>
</gresource>
</gresources>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment