initial commit

This commit is contained in:
Chris Cromer 2018-10-18 16:31:50 -03:00
commit 482d52e96f
Signed by: cromer
GPG Key ID: 39CC813FF3C8708A
26 changed files with 376 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
build
sernatur.tar.gz

11
LICENSE Normal file
View File

@ -0,0 +1,11 @@
Copyright 2018 Chris Cromer
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

27
README.md Normal file
View File

@ -0,0 +1,27 @@
# SERNATUR
Este proyecto es para conectar a un base de datos de Postgresql para el ramo de Base de Datos.
## Profesora
Valeria Beratto
## Requisitos
- Vala
- Meson
- Ninja
- Gtk+-3
- Libpq
- Valadoc (opcional para compilar valadoc del proyecto)
## Compilar
meson --prefix=/usr build
cd build
ninja
## Opciones de compilación
>-D valadocs=true
>
> Este opción va a compilar la documentación de codiǵo fuente usando valadoc
>-D valadocs_dep=true
>
> Si ambos valadocs y esta opción están en uso se va a compilar la documentación del proyecto y tambien la documentación de todos los dependencies. Este opción es caro y hace mucho mas lento la compilación.

13
build_linux_package.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh -eu
curdir=`pwd`
rm -rf buildtmp
mkdir buildtmp
LDFLAGS=-static-libstdc++ meson buildtmp --buildtype=release --prefix=/tmp/sernatur --libdir=lib --strip
ninja -C buildtmp install
rm -rf buildtmp
cp README.md /tmp/sernatur
cd /tmp/
tar czf sernatur.tar.gz sernatur
mv sernatur.tar.gz "$curdir"
rm -rf sernatur

3
data/meson.build Normal file
View File

@ -0,0 +1,3 @@
install_data('sernatur.desktop', install_dir: join_paths(get_option('datadir'), 'applications'))
install_data('sernatur.png', install_dir: join_paths(get_option('datadir'), 'icons/hicolor/48x48/apps'))
subdir('ui')

7
data/sernatur.desktop Normal file
View File

@ -0,0 +1,7 @@
[Desktop Entry]
Type=Application
Name=Glade Template
Icon=glade-template
StartupNotify=true
Exec=@bindir@/glade-template
Name[en_US]=sernatur.desktop

BIN
data/sernatur.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

8
data/ui/meson.build Normal file
View File

@ -0,0 +1,8 @@
gen = generator(
find_program('glib-compile-resources'),
arguments: [ '--sourcedir=@SOURCE_DIR@/data/ui',
'--generate-source',
'--target=@OUTPUT@',
'@INPUT@'],
output: '@PLAINNAME@.c')
sernatur_gresource_c = gen.process(['sernatur.gresource.xml'])

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/cl/cromer/ubb/sernatur">
<file preprocess="xml-stripblanks">sernatur.window.ui</file>
</gresource>
</gresources>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<template class="SernaturMainWindow" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
<property name="title" translatable="no">SERNATUR</property>
<property name="icon_name">sernatur</property>
<property name="show_menubar">False</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</template>
</interface>

BIN
docs/MER.dia Normal file

Binary file not shown.

48
docs/meson.build Normal file
View File

@ -0,0 +1,48 @@
docs_deps = get_option('valadocs_deps')
if docs_enabled
if docs_deps
custom_target('valadoc',
input: vala_sources,
output: 'valadoc',
command: [ valadoc,
'--deps',
'--use-svg-images',
'--doclet=html',
'--force',
'--package-name=@0@'.format(meson.project_name()),
'--package-version=@0@'.format(meson.project_version()),
'--pkg=gtk+-3.0',
'--pkg=libpq',
'--vapidir=@0@'.format(join_paths(meson.source_root(), 'src/vapi')),
'--directory=@OUTDIR@/valadoc',
vala_sources,
],
build_by_default: true,
install: true,
install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name())
)
else
custom_target('valadoc',
input: vala_sources,
output: 'valadoc',
command: [ valadoc,
'--use-svg-images',
'--doclet=html',
'--force',
'--package-name=@0@'.format(meson.project_name()),
'--package-version=@0@'.format(meson.project_version()),
'--pkg=gtk+-3.0',
'--pkg=libpq',
'--vapidir=@0@'.format(join_paths(meson.source_root(), 'src/vapi')),
'--directory=@OUTDIR@/valadoc',
vala_sources,
],
build_by_default: true,
install: true,
install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name())
)
endif
endif
install_data('trabajoSemestral(E1).pdf', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('MER.dia', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))

Binary file not shown.

23
meson.build Normal file
View File

@ -0,0 +1,23 @@
project('sernatur',
['c', 'vala'],
version: '1.0.0',
license: 'BSD-3',
default_options: [
'b_ofast=if-release',
'b_march_native=if-release',
'b_ndebug=if-release'
]
)
add_global_arguments('-DGETTEXT_PACKAGE="sernatur"', language: 'c')
docs_enabled = get_option('valadocs')
valadoc = find_program('valadoc', required: docs_enabled)
subdir('po')
subdir('data')
subdir('src')
subdir('script')
subdir('docs')
install_data('LICENSE', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))
install_data('README.md', install_dir: join_paths(get_option('datadir'), 'doc', meson.project_name()))

2
meson_options.txt Normal file
View File

@ -0,0 +1,2 @@
option('valadocs', type: 'boolean', value: true, description: 'Build valadocs for sernatur')
option('valadocs_deps', type: 'boolean', value: false, description: 'Build the valadocs of the deps of sernatur')

1
po/LINGUAS Normal file
View File

@ -0,0 +1 @@
es

3
po/POTFILES Normal file
View File

@ -0,0 +1,3 @@
src/sernatur.vala
src/sernatur-window.vala
data/ui/sernatur.window.ui

23
po/es.po Normal file
View File

@ -0,0 +1,23 @@
# Spanish translations for sernatur package.
# Copyright (C) 2018 THE sernatur'S COPYRIGHT HOLDER
# This file is distributed under the same license as the sernatur package.
# Automatically generated, 2018.
#
msgid ""
msgstr ""
"Project-Id-Version: sernatur\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-18 16:05-0300\n"
"PO-Revision-Date: 2018-10-18 14:58-0300\n"
"Last-Translator: Chris Cromer <chris@cromer.cl>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.0.6\n"
#: src/sernatur-window.vala:51
msgid "Server version:"
msgstr "Versión del servidor:"

4
po/meson.build Normal file
View File

@ -0,0 +1,4 @@
i18n = import('i18n')
i18n.gettext(meson.project_name(),
args: '--directory=' + meson.source_root()
)

22
po/sernatur.pot Normal file
View File

@ -0,0 +1,22 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the sernatur package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: sernatur\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-18 16:05-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/sernatur-window.vala:51
msgid "Server version:"
msgstr ""

8
script/linux_bundler.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh -eu
libdir="${MESON_INSTALL_PREFIX}/lib"
mkdir -p $libdir
libfile=`ldd ${MESON_INSTALL_PREFIX}/bin/sernatur | grep libpq | cut -d ' ' -f 3`
cp $libfile "${libdir}"
strip "${libdir}/libpq"*

2
script/meson.build Normal file
View File

@ -0,0 +1,2 @@
install_data('sernatur.sh', install_dir: '.')
meson.add_install_script('linux_bundler.sh')

6
script/sernatur.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
cd "${0%/*}"
export LD_LIBRARY_PATH="`pwd`/lib"
bin/sernatur

39
src/meson.build Normal file
View File

@ -0,0 +1,39 @@
gtk_dep = dependency('gtk+-3.0', version: '>=3.0.0')
# gmodule-export-2.0 is needed to connect the handlers
gmodule_dep = dependency('gmodule-2.0', version: '>=2.0')
libpq_dep = dependency('libpq')
# this is how to link against a c lib
#libsystemd_lib = meson.get_compiler('c').find_library('libsystemd')
cc = meson.get_compiler('c')
# -no-pie so that the executable is double clickable in gui
if cc.get_id() == 'gcc'
c_args = ['-no-pie']
link_args = ['-no-pie']
else
c_args = ''
link_args = ''
endif
vala_sources = files(
'sernatur.vala',
'sernatur-window.vala'
)
sources = vala_sources
c_sources = [sernatur_gresource_c]
sources = vala_sources
sources += c_sources
vala_args = ['--vapidir='+join_paths(meson.source_root(),'src/vapi')]
vala_args += ['--gresources='+join_paths(meson.source_root(),'data/ui/sernatur.gresource.xml')]
exe = executable('sernatur',
sources,
c_args: c_args,
link_args: link_args,
vala_args: vala_args,
dependencies: [gtk_dep, gmodule_dep, libpq_dep],
install: true)

54
src/sernatur-window.vala Normal file
View File

@ -0,0 +1,54 @@
/**
* The main Sernatur namespace
*/
namespace Sernatur {
using Postgres;
/**
* The MainWindow class
*/
[GtkTemplate (ui = "/cl/cromer/ubb/sernatur/sernatur.window.ui")]
public class MainWindow : Gtk.ApplicationWindow {
/**
* Initialize the main window class
* @param application The application used to make the GLib object
*/
public MainWindow (Gtk.Application application) {
GLib.Object (application: application);
Database conn;
conn = set_db_login ("localhost", "", "", "", "postgres", "bdd", "bdd");
if (conn.get_status () != ConnectionStatus.OK) {
stderr.printf ("%s\n", conn.get_error_message ());
application.quit ();
return;
}
/*Result res = conn.exec ("CREATE DATABASE bdd;");
if (res.get_status () != ExecStatus.COMMAND_OK) {
stderr.printf ("%s\n", conn.get_error_message ());
application.quit ();
return;
}
string password = encrypt_password ("bdd", "bdd");
res = conn.exec ("CREATE USER bdd WITH ENCRYPTED PASSWORD '" + password + "';");
if (res.get_status () != ExecStatus.COMMAND_OK) {
stderr.printf ("%s\n", conn.get_error_message ());
application.quit ();
return;
}
res = conn.exec ("GRANT ALL PRIVILEGES ON DATABASE bdd TO bdd;");
if (res.get_status () != ExecStatus.COMMAND_OK) {
stderr.printf ("%s\n", conn.get_error_message ());
application.quit ();
return;
}*/
GLib.print (dgettext (null, "Server version:") + " %d\n", conn.get_server_version ());
}
}
}

47
src/sernatur.vala Normal file
View File

@ -0,0 +1,47 @@
/**
* The main Sernatur namespace
*/
namespace Sernatur {
/**
* The application class
*/
public class Application : global::Gtk.Application {
/**
* The main application window
*/
private MainWindow window;
/**
* Initialize the application
*/
public Application () {
application_id = "cl.cromer.ubb.sernatur";
}
/**
* Run when the application is activated
*/
public override void activate () {
window = new MainWindow (this);
window.present ();
}
/**
* Run when the application starts
*/
public override void startup () {
Intl.textdomain ("sernatur");
Intl.setlocale (LocaleCategory.ALL, "");
base.startup ();
}
}
/**
* The main function
* @param args Arguments passed from the command line
*/
public static int main (string[] args) {
var application = new Application ();
return application.run (args);
}
}