Commit c8c0e7d1 authored by Zander Brown's avatar Zander Brown 🔄

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: 'org.gnome.zbrown.KingsCross.desktop.in',
output: 'org.gnome.zbrown.KingsCross.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: 'org.gnome.zbrown.KingsCross.appdata.xml.in',
output: 'org.gnome.zbrown.KingsCross.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('org.gnome.zbrown.KingsCross.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>org.gnome.zbrown.KingsCross.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-or-later</project_license>
<description>
</description>
</component>
[Desktop Entry]
Name=kgx
Exec=kgx
Terminal=false
Type=Application
Categories=GTK;
StartupNotify=true
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="kgx">
<schema id="org.gnome.zbrown.KingsCross" path="/org/gnome/zbrown/KingsCross/">
</schema>
</schemalist>
project('kgx', 'c', version: '0.1.0',
meson_version: '>= 0.40.0',
)
i18n = import('i18n')
config_h = configuration_data()
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
config_h.set_quoted('GETTEXT_PACKAGE', 'kgx')
config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'), get_option('localedir')))
configure_file(
output: 'kgx-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
{
"app-id": "org.gnome.zbrown.KingsCross",
"runtime": "org.gnome.Platform",
"runtime-version": "3.32",
"sdk": "org.gnome.Sdk",
"command": "kgx",
"finish-args": [
"--share=network",
"--share=ipc",
"--socket=x11",
"--socket=wayland",
"--filesystem=xdg-run/dconf",
"--filesystem=~/.config/dconf:ro",
"--talk-name=ca.desrt.dconf",
"--env=DCONF_USER_CONFIG_DIR=.config/dconf"
],
"build-options": {
"cflags": "-O2 -g",
"cxxflags": "-O2 -g",
"env": {
"V": "1"
}
},
"cleanup": [
"/include",
"/lib/pkgconfig",
"/man",
"/share/doc",
"/share/gtk-doc",
"/share/man",
"/share/pkgconfig",
"*.la",
"*.a"
],
"modules": [
{
"name": "kgx",
"builddir": true,
"buildsystem": "meson",
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/ZanderBrown/kgx"
}
]
}
]
}
data/org.gnome.zbrown.KingsCross.desktop.in
data/org.gnome.zbrown.KingsCross.appdata.xml.in
data/org.gnome.zbrown.KingsCross.gschema.xml
src/kgx-window.ui
src/main.c
src/kgx-window.c
i18n.gettext('kgx', preset: 'glib')
/* kgx-window.c
*
* Copyright 2019 Zander Brown
*
* 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 <vte/vte.h>
#include "kgx-config.h"
#include "kgx-window.h"
struct _KgxWindow
{
GtkApplicationWindow parent_instance;
/* Template widgets */
GtkWidget *header_bar;
GtkWidget *terminal;
};
G_DEFINE_TYPE (KgxWindow, kgx_window, GTK_TYPE_APPLICATION_WINDOW)
static void
kgx_window_class_init (KgxWindowClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/zbrown/KingsCross/kgx-window.ui");
gtk_widget_class_bind_template_child (widget_class, KgxWindow, header_bar);
gtk_widget_class_bind_template_child (widget_class, KgxWindow, terminal);
}
static void
kgx_window_init (KgxWindow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
gchar *shell[2] = {NULL, NULL};
shell[0] = vte_get_user_shell ();
if (shell[0] == NULL) {
shell[0] = "/bin/sh";
g_warning ("Defaulting to /bin/sh");
}
vte_terminal_spawn_async (VTE_TERMINAL (self->terminal),
VTE_PTY_DEFAULT,
NULL,
shell,
NULL,
G_SPAWN_DEFAULT,
NULL,
NULL,
NULL,
-1,
NULL,
NULL,
NULL);
}
/* kgx-window.h
*
* Copyright 2019 Zander Brown
*
* 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 KGX_TYPE_WINDOW (kgx_window_get_type())
G_DECLARE_FINAL_TYPE (KgxWindow, kgx_window, KGX, WINDOW, GtkApplicationWindow)
G_END_DECLS
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<menu id="win-menu">
<section id="help">
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">win.show-help-overlay</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About King's Cross</attribute>
<attribute name="action">win.about</attribute>
</item>
</section>
</menu>
<template class="KgxWindow" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
<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="can_focus">False</property>
<property name="title" bind-source="terminal" bind-property="window-title" bind-flags="sync-create">King's Cross</property>
<property name="subtitle" translatable="yes">/home/user</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkMenuButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="menu_model">win-menu</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="pack_type">end</property>
</packing>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">none</property>
<property name="propagate-natural-width">True</property>
<property name="propagate-natural-height">True</property>
<property name="hscrollbar-policy">never</property>
<child>
<object class="VteTerminal" id="terminal">
<property name="visible">True</property>
<property name="allow-hyperlink">True</property>
</object>
</child>
</object>
</child>
</template>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/zbrown/KingsCross">
<file>kgx-window.ui</file>
</gresource>
</gresources>
/* main.c
*
* Copyright 2019 Zander Brown
*
* 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 <vte/vte.h>
#include "kgx-config.h"
#include "kgx-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 (KGX_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);
g_type_ensure (VTE_TYPE_TERMINAL);
/*
* 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 ("org.gnome.zbrown.KingsCross", 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;
}
kgx_sources = [
'main.c',
'kgx-window.c',
]
kgx_deps = [
dependency('gio-2.0', version: '>= 2.50'),
dependency('gtk+-3.0', version: '>= 3.22'),
dependency('vte-2.91')
]
gnome = import('gnome')
kgx_sources += gnome.compile_resources('kgx-resources',
'kgx.gresource.xml',
c_name: 'kgx'
)
executable('kgx', kgx_sources,
dependencies: kgx_deps,
install: true,
)
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