Initial version

This commit is contained in:
2014-10-13 16:13:52 +02:00
commit 5469e9a5a0
12 changed files with 318 additions and 0 deletions

36
src/Makefile.am Normal file
View File

@@ -0,0 +1,36 @@
res_dir = $(srcdir)/resources
res_src = $(res_dir)/gnome-gitlab.gresource.xml
resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir=$(res_dir) $(res_src))
AM_CPPFLAGS = \
-DGETTEXT_PACKAGE=\""$(GETTEXT_PACKAGE)"\" \
-DGNOMELOCALEDIR=\""$(localedir)"\"
AM_VALAFLAGS = \
--target-glib=2.38 \
--pkg gtk+-3.0 \
--gresources $(res_src)
bin_PROGRAMS = gnome-gitlab
BUILT_SOURCES = \
gl-resources.c
gl-resources.c: $(res_src) $(resource_files)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir)/resources --generate-source $<
VALA_SOURCES = \
application.vala \
window.vala \
main.vala
gnome_gitlab_SOURCES = \
$(BUILT_SOURCES) \
$(VALA_SOURCES) \
$(srcdir)/config.vapi
AM_CFLAGS = \
$(GITLAB_CFLAGS) \
-Wall
gnome_gitlab_LDADD = \
$(GITLAB_LIBS) \
-lm

63
src/application.vala Normal file
View File

@@ -0,0 +1,63 @@
namespace GnomeGitlab
{
public class Application : Gtk.Application
{
const OptionEntry[] option_entries = {
{ "version", 'v', 0, OptionArg.NONE, null, N_("Print version information and exit"), null },
{ null }
};
const GLib.ActionEntry[] action_entries = {
{ "quit", on_quit_activate }
};
private Window window;
private void ensure_window ()
{
if (window == null) {
window = new Window (this);
window.destroy.connect (() => {
window = null;
});
}
}
public Application ()
{
Object (application_id: "eu.polonkai.gergely.gnome-gitlab");
add_main_option_entries (option_entries);
add_action_entries (action_entries, this);
}
protected override void activate ()
{
ensure_window ();
window.present ();
}
protected override void startup ()
{
base.startup ();
add_accelerator ("<Primary>n", "win.new", null);
}
protected override int handle_local_options (GLib.VariantDict options)
{
if (options.contains("version")) {
print ("%s %s\n", Environment.get_application_name (), Config.VERSION);
return 0;
}
return -1;
}
void on_quit_activate ()
{
quit ();
}
}
}

8
src/config.vapi Normal file
View File

@@ -0,0 +1,8 @@
[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
namespace Config {
public const string VERSION;
public const string GETTEXT_PACKAGE;
public const string GNOMELOCALEDIR;
public const string DATADIR;
}

9
src/main.vala Normal file
View File

@@ -0,0 +1,9 @@
int
main (string[] args)
{
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR);
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
var app = new GnomeGitlab.Application ();
return app.run (args);
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/eu/polonkai/gergely/gnome-gitlab">
<file>ui/gg-window.ui</file>
</gresource>
</gresources>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<template class="GnomeGitlabWindow" parent="GtkApplicationWindow">
<property name="can_focus">False</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header_bar">
</object>
</child>
</template>
</interface>

55
src/window.vala Normal file
View File

@@ -0,0 +1,55 @@
namespace GnomeGitlab
{
[GtkTemplate (ui = "/eu/polonkai/gergely/gnome-gitlab/ui/gg-window.ui")]
public class Window : Gtk.ApplicationWindow
{
private const GLib.ActionEntry[] action_entries = {
{ "help", on_help_activate },
{ "about", on_about_activate },
};
[GtkChild]
private Gtk.HeaderBar header_bar;
public Window (Application app)
{
Object (application: app);
add_action_entries (action_entries, this);
show_all ();
}
private void on_help_activate ()
{
try {
Gtk.show_uri (get_screen (), "help:gnome-gitlab", Gtk.get_current_event_time ());
} catch (Error e) {
warning (_("Failed to show help: %s"), e.message);
}
}
private void on_about_activate ()
{
const string copyright = "Copyright \xc2\xa9 2014 Gergely Polonkai\n";
const string authors[] = {
"Gergely Polonkai",
null
};
Gtk.show_about_dialog (this,
"program-name", _("Gnome Gitlab"),
"logo-icon-name", "gnome-gitlab",
"version", Config.VERSION,
"comments", _("GitLab frontend"),
"copyright", copyright,
"authors", authors,
"license-type", Gtk.License.GPL_3_0,
"wrap-license", false,
"translator-credits", _("translator-credits"),
null);
}
}
}