initial commit
This commit is contained in:
39
src/meson.build
Normal file
39
src/meson.build
Normal 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
54
src/sernatur-window.vala
Normal 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
47
src/sernatur.vala
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user