Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
gitg
Commits
a74c5661
Commit
a74c5661
authored
Apr 14, 2012
by
Jesse van den Kieboom
Browse files
Initial porting to vala
parent
79905400
Changes
152
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitmodules
0 → 100644
View file @
a74c5661
[submodule "libgit2"]
path = libgit2
url = https://github.com/libgit2/libgit2.git
[submodule "libgit2-glib"]
path = libgit2-glib
url = git@github.com:nacho/libgit2-glib.git
Makefile.am
View file @
a74c5661
...
...
@@ -4,9 +4,6 @@ ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS
=
libgitg gitg data po tests tools
pkgconfigdir
=
$(libdir)
/pkgconfig
pkgconfig_DATA
=
libgitg-1.0.pc
DISTCLEANFILES
=
\
intltool-extract
\
intltool-merge
\
...
...
@@ -17,8 +14,7 @@ EXTRA_DIST = \
MAINTAINERS
\
intltool-extract.in
\
intltool-merge.in
\
intltool-update.in
\
libgitg-1.0.pc.in
intltool-update.in
MAINTAINERCLEANFILES
=
\
aclocal.m4
\
...
...
configure.ac
View file @
a74c5661
...
...
@@ -14,7 +14,7 @@ AC_INIT([gitg],
[http://live.gnome.org/Gitg])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([gitg/gitg.
c
])
AC_CONFIG_SRCDIR([gitg/gitg.
vala
])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
...
...
@@ -36,11 +36,15 @@ AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PATH_PROG(GZIP, gzip)
AM_PATH_PYTHON
AM_PROG_VALAC
AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
# Initialize libtool
LT_PREREQ([2.2])
LT_INIT
LT_INIT
(disable-static)
# i18n stuff
IT_PROG_INTLTOOL([0.40.0])
...
...
@@ -49,47 +53,64 @@ AM_GNU_GETTEXT_VERSION([0.17])
AM_GNU_GETTEXT([external])
GETTEXT_PACKAGE=gitg
dnl adl_RECURSIVE_EVAL(VALUE, RESULT)
dnl =================================
dnl Interpolate the VALUE in loop until it doesn't change,
dnl and set the result to $RESULT.
dnl WARNING: It's easy to get an infinite loop with some unsane input.
AC_DEFUN([adl_RECURSIVE_EVAL],
[_lcl_receval="$1"
$2=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix"
test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
_lcl_receval_old=''
while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do
_lcl_receval_old="[$]_lcl_receval"
eval _lcl_receval="\"[$]_lcl_receval\""
done
echo "[$]_lcl_receval")`])
adl_RECURSIVE_EVAL("$datadir/gitg", [GITG_DATADIR])
adl_RECURSIVE_EVAL("$datadir/locale", [GITG_LOCALEDIR])
adl_RECURSIVE_EVAL("$libdir/gitg", [GITG_LIBDIR])
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
AC_DEFINE_UNQUOTED(GITG_DATADIR,"$GITG_DATADIR", [data dir])
AC_DEFINE_UNQUOTED(GITG_LOCALEDIR,"$GITG_LOCALEDIR", [locale dir])
AC_DEFINE_UNQUOTED(GITG_LIBDIR,"$GITG_LIBDIR", [lib dir])
AC_CHECK_LIB([m], [sinf])
GLIB_REQUIRED_VERSION=2.26
GTK_REQUIRED_VERSION=3.0.0
GTKSOURCEVIEW_REQUIRED_VERSION=3.1.3
INTROSPECTION_REQUIRED=0.10.1
PKG_CHECK_MODULES(GITG, [
gtk+-3.0 >= $GTK_REQUIRED_VERSION
PKG_CHECK_MODULES(LIBGITG, [
gthread-2.0 >= $GLIB_REQUIRED_VERSION
glib-2.0 >= $GLIB_REQUIRED_VERSION
gobject-2.0 >= $GLIB_REQUIRED_VERSION
gmodule-2.0 >= $GLIB_REQUIRED_VERSION
gio-2.0 >= $GLIB_REQUIRED_VERSION
gio-unix-2.0 >= $GLIB_REQUIRED_VERSION
gobject-introspection-1.0 >= $INTROSPECTION_REQUIRED
libgit2-glib-1.0
])
PKG_CHECK_MODULES(PACKAGE, [
gtksourceview-3.0 >= $GTKSOURCEVIEW_REQUIRED_VERSION
gsettings-desktop-schemas
])
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
GNOME_COMPILE_WARNINGS([maximum])
if test "x$USE_MAINTAINER_MODE" = "xyes"; then
PACKAGE_CFLAGS="$PACKAGE_CFLAGS -Wall -Werror -Wuninitialized -Wmissing-declarations"
enable_deprecations="yes"
fi
AC_ARG_ENABLE(deprecations,
[AS_HELP_STRING([--enable-deprecations],
[warn about deprecated usages [default=no]])],
[enable_deprecations=$enableval])
if test "x$USE_MAINTAINER_MODE" = "xyes"; then
LIBGITG_CFLAGS="$LIBGITG_CFLAGS -Wall -Werror -Wuninitialized -Wmissing-declarations"
enable_deprecations="yes"
fi
if test "$enable_deprecations" = "yes"; then
DISABLE_DEPRECATED
_CFLAGS
="
\
LIBGITG_CFLAGS="$LIBGITG
_CFLAGS
\
-DG_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
-DGTK_DISABLE_DEPRECATED \
...
...
@@ -98,36 +119,56 @@ if test "$enable_deprecations" = "yes"; then
-DGSEAL_ENABLE"
fi
PACKAGE_LIBS="$PACKAGE_LIBS -lm"
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--disable-debug],
[disable debug information [default=yes]])],
[enable_debug=$enableval], [enable_debug=yes])
if test "x$enable_debug" = "xyes"; then
PACKAGE
_CFLAGS="$
PACKAGE
_CFLAGS -g"
LIBGITG
_CFLAGS="$
LIBGITG
_CFLAGS -g
-O0
"
AC_DEFINE([ENABLE_DEBUG],[1],[Whether debugging support is enabled])
fi
AM_CONDITIONAL([ENABLE_DEBUG], [test "$enable_debug" = "yes"])
AC_SUBST(LIBGITG_CFLAGS)
AC_SUBST(LIBGITG_LIBS)
PKG_CHECK_MODULES(LIBGITG_GTK, [
gtk+-3.0 >= $GTK_REQUIRED_VERSION
])
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--disable-debug],
[disable debug information [default=yes]])],
[enable_debug=$enableval], [enable_debug=yes])
LIBGITG_GTK_CFLAGS="$LIBGITG_CFLAGS $LIBGITG_GTK_CFLAGS"
LIBGITG_GTK_LIBS="$LIBGITG_LIBS $LIBGITG_GTK_LIBS"
if test "x$enable_debug" = "xyes"; then
PACKAGE_CFLAGS="$PACKAGE_CFLAGS -g"
AC_DEFINE([ENABLE_DEBUG],[1],[Whether debugging support is enabled])
fi
AC_SUBST(LIBGITG_GTK_CFLAGS)
AC_SUBST(LIBGITG_GTK_LIBS)
LIBGITG_EXT_CFLAGS="$LIBGITG_GTK_CFLAGS"
LIBGITG_EXT_LIBS="$LIBGITG_GTK_LIBS"
AM_CONDITIONAL([ENABLE_DEBUG], [test "$enable_debug" = "yes"])
AC_SUBST(LIBGITG_EXT_CFLAGS)
AC_SUBST(LIBGITG_EXT_LIBS)
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)
LIBPEAS_REQUIRED_VERSION=1.2.0
LIBPEAS_GTK_REQUIRED_VERSION=1.2.0
PKG_CHECK_MODULES(GITG, [
gtksourceview-3.0 >= $GTKSOURCEVIEW_REQUIRED_VERSION
gsettings-desktop-schemas
libpeas-1.0 >= $LIBPEAS_REQUIRED_VERSION
libpeas-gtk-1.0 >= $LIBPEAS_GTK_REQUIRED_VERSION
gee-1.0
])
GITG_CFLAGS="$LIBGITG_GTK_CFLAGS $GITG_CFLAGS"
GITG_LIBS="$LIBGITG_GTK_LIBS $GITG_LIBS -lm"
AC_SUBST(GITG_CFLAGS)
AC_SUBST(GITG_LIBS)
GOBJECT_INTROSPECTION_REQUIRE($INTROSPECTION_REQUIRED)
AC_SUBST(INTROSPECTION_REQUIRED)
GNOME_COMPILE_WARNINGS([maximum])
GLIB_GSETTINGS
...
...
@@ -148,10 +189,63 @@ AS_IF([ test "$glade_catalog" = "yes" ],
AC_MSG_RESULT([$GLADE_CATALOG_DIR])
AC_SUBST(GLADE_CATALOG_DIR)])
GITG_PLUGIN_DATADIR="$datadir/gitg/plugins"
AC_SUBST(GITG_PLUGIN_DATADIR)
GITG_PLUGIN_LIBDIR="$libdir/gitg/plugins"
AC_SUBST(GITG_PLUGIN_LIBDIR)
GITG_PLUGIN_CFLAGS="$GITG_CFLAGS"
GITG_PLUGIN_LIBS="$GITG_LIBS"
AC_SUBST(GITG_PLUGIN_CFLAGS)
AC_SUBST(GITG_PLUGIN_LIBS)
GITG_PLUGIN_LIBTOOL_FLAGS="-module -avoid-version"
AC_SUBST(GITG_PLUGIN_LIBTOOL_FLAGS)
GITG_PLUGIN_VALAFLAGS="--pkg GitgExt-1.0 \
--pkg Ggit-1.0 \
--pkg Gitg-1.0 \
--pkg gio-2.0 \
--pkg gtk+-3.0 \
--pkg libpeas-1.0 \
--pkg gee-1.0 \
--vapidir \$(top_srcdir)/vapi \
--pkg config"
AC_SUBST(GITG_PLUGIN_VALAFLAGS)
dnl ===========================================================================
dnl Check for python
dnl ===========================================================================
PYGOBJECT_REQUIRED=3.0.0
AC_ARG_ENABLE([python],
AS_HELP_STRING([--enable-python[=@<:@no/auto/yes@:>@]],[Build with python support]),
[enable_python=$enableval],
[enable_python="auto"])
if test "x$enable_python" = "xauto"; then
PKG_CHECK_EXISTS([pygobject-3.0 >= $PYGOBJECT_REQUIRED],
[enable_python=yes],[enable_python=no])
fi
if test "x$enable_python" = "xyes"; then
PKG_CHECK_MODULES(PYTHON, [pygobject-3.0 >= $PYGOBJECT_REQUIRED])
pyoverridesdir=`$PYTHON -c "import gi; print(gi._overridesdir)"`
AC_SUBST(pyoverridesdir)
fi
AM_CONDITIONAL(ENABLE_PYTHON, test x"$enable_python" = "xyes")
AC_CONFIG_FILES([
Makefile
libgitg-1.0.pc
libgitg/Makefile
libgitg/libgitg-1.0.pc
libgitg-ext/Makefile
libgitg-ext/libgitg-ext-1.0.pc
gitg/Makefile
data/Makefile
data/gitg.desktop.in
...
...
@@ -160,6 +254,9 @@ data/org.gnome.gitg.gschema.xml.in
po/Makefile.in
tests/Makefile
tools/Makefile
plugins/Makefile
plugins/dash/Makefile
plugins/history/Makefile
])
AC_OUTPUT
...
...
@@ -172,4 +269,5 @@ Configuration:
Compiler: ${CC}
Glade catalog: ${glade_catalog}
Debug enabled: ${enable_debug}
Python support: ${enable_python}
"
data/gitg-glade.xml
View file @
a74c5661
...
...
@@ -3,15 +3,8 @@
<glade-catalog
name=
"gitg"
>
<glade-widget-classes>
<glade-widget-class
name=
"GitgWindow"
title=
"GitgWindow"
generic-name=
"gitgwindow"
parent=
"GtkWindow"
/>
<glade-widget-class
name=
"GitgCommitView"
title=
"GitgCommitView"
generic-name=
"gitgcommitview"
parent=
"GtkVPaned"
/>
<glade-widget-class
name=
"GitgCellRendererPath"
title=
"GitgCellRendererPath"
generic-name=
"gitgcellrendererpath"
parent=
"GtkCellRendererText"
/>
<glade-widget-class
name=
"GitgDiffView"
title=
"GitgDiffView"
generic-name=
"gitgdiffview"
parent=
"GtkSourceView"
/>
</glade-widget-classes>
<glade-widget-group
name=
"gitg"
title=
"gitg"
>
<glade-widget-class-ref
name=
"GitgWindow"
/>
<glade-widget-class-ref
name=
"GitgCommitView"
/>
<glade-widget-class-ref
name=
"GitgCellRendererPath"
/>
<glade-widget-class-ref
name=
"GitgDiffView"
/>
</glade-widget-group>
</glade-catalog>
gitg/Makefile.am
View file @
a74c5661
...
...
@@ -4,85 +4,67 @@ AM_CPPFLAGS = \
-I
$(top_srcdir)
\
-I
$(srcdir)
\
$(GITG_CFLAGS)
\
$(PACKAGE_CFLAGS)
\
$(WARN_CFLAGS)
\
$(DISABLE_DEPRECATED_CFLAGS)
\
-DDATADIR
=
\"
"
$(datadir)
"
\"
\
-DGITG_DATADIR
=
\"
"
$(datadir)
/gitg"
\"
\
-DGITG_LOCALEDIR
=
\"
"
$(datadir)
/locale"
\"
NOINST_H_FILES
=
\
gitg-activatable.h
\
gitg-avatar-cache.h
\
gitg-blame-renderer.h
\
gitg-branch-actions.h
\
gitg-cell-renderer-path.h
\
gitg-commit-view.h
\
gitg-diff-line-renderer.h
\
gitg-diff-view.h
\
gitg-dirs.h
\
gitg-dnd.h
\
gitg-label-renderer.h
\
gitg-preferences-dialog.h
\
gitg-repository-dialog.h
\
gitg-revision-panel.h
\
gitg-revision-details-panel.h
\
gitg-revision-files-panel.h
\
gitg-revision-changes-panel.h
\
gitg-stat-view.h
\
gitg-uri.h
\
gitg-utils.h
\
gitg-window.h
VALAFLAGS
=
\
--vapidir
$(top_srcdir)
/vapi
\
--pkg
config
\
--pkg
Ggit-1.0
\
--pkg
Gitg-1.0
\
--pkg
GitgExt-1.0
\
--pkg
gtk+-3.0
\
--pkg
gio-2.0
\
--pkg
libpeas-1.0
\
--pkg
gobject-introspection-1.0
gitg_SOURCES
=
\
$(BUILT_SOURCES)
\
gitg.c
\
gitg-activatable.c
\
gitg-avatar-cache.c
\
gitg-blame-renderer.c
\
gitg-branch-actions.c
\
gitg-cell-renderer-path.c
\
gitg-commit-view.c
\
gitg-diff-line-renderer.c
\
gitg-diff-view.c
\
gitg-dirs.c
\
gitg-dnd.c
\
gitg-label-renderer.c
\
gitg-preferences-dialog.c
\
gitg-repository-dialog.c
\
gitg-revision-panel.c
\
gitg-revision-details-panel.c
\
gitg-revision-files-panel.c
\
gitg-revision-changes-panel.c
\
gitg-stat-view.c
\
gitg-uri.c
\
gitg-utils.c
\
gitg-window.c
\
$(NOINST_H_FILES)
VALASOURCES
=
\
gitg.vala
\
gitg-dirs.vala
\
gitg-window.vala
\
gitg-resource.vala
\
gitg-application.vala
\
gitg-plugins-engine.vala
gitg_LDADD
=
\
$(GITG_LIBS)
\
$(PACKAGE_LIBS)
\
$(top_builddir)
/libgitg/libgitg-1.0.la
BUILT_SOURCES
=
\
gitg-resources.c
\
gitg-resources.h
gitg_SOURCES
=
\
$(VALASOURCES)
\
gitg-resources.c
gitg_LDADD
=
\
$(GITG_LIBS)
\
$(PACKAGE_LIBS)
\
$(top_builddir)
/libgitg/libgitg-1.0.la
\
$(top_builddir)
/libgitg-ext/libgitg-ext-1.0.la
gitg_LDFLAGS
=
-export-dynamic
-no-undefined
-export-symbols-regex
"^[[^_]].*"
uidir
=
$(datadir)
/gitg/ui/
ui_DATA
=
\
gitg-window.ui
\
gitg-commit-menu.ui
\
gitg-ui.xml
\
gitg-
menu
s.xml
\
gitg-preferences.ui
\
gitg-new-branch.ui
\
gitg-tag.ui
\
gitg-repository.ui
\
gitg-revision-details-panel.ui
\
gitg
-revision-changes-panel.ui
\
gitg-revision-files-panel.ui
gitg-resources.c
:
resources/gitg-resources.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir)/resources resources/gitg-resources.xml)
$(GLIB_COMPILE_RESOURCES)
--generate-source
\
--sourcedir
$(srcdir)
/resources
\
--target
"
$@
"
"
$<
"
gitg-
resources.h
:
resources/gitg-resources.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir)/resources resources/gitg-resource
s.xml
)
$(GLIB_COMPILE_RESOURCES)
--generate-header
\
--sourcedir
$(srcdir)
/resources
\
--target
"
$@
"
"
$<
"
# Ignore all warnings for vala code...
gitg
_CFLAGS
=
\
-w
EXTRA_DIST
=
\
$(ui_DATA)
resources/gitg-resources.xml
\
$(
shell
$(GLIB_COMPILE_RESOURCES)
--generate-dependencies
--sourcedir
$(srcdir)
/resources resources/gitg-resources.xml
)
CLEANFILES
=
\
$(VALASOURCES:.vala=.c)
\
$(BUILT_SOURCES)
-include
$(top_srcdir)/git.mk
...
...
gitg/gitg-activatable.c
deleted
100644 → 0
View file @
79905400
/*
* gitg-activatable.c
* This file is part of gitg - git repository viewer
*
* Copyright (C) 2009 - Jesse van den Kieboom
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include
"gitg-activatable.h"
G_DEFINE_INTERFACE
(
GitgActivatable
,
gitg_activatable
,
G_TYPE_OBJECT
)
/* Default implementation */
static
gchar
*
gitg_activatable_get_id_default
(
GitgActivatable
*
panel
)
{
g_return_val_if_reached
(
NULL
);
}
static
gboolean
gitg_activatable_activate_default
(
GitgActivatable
*
panel
,
gchar
const
*
cmd
)
{
return
FALSE
;
}
static
void
gitg_activatable_default_init
(
GitgActivatableInterface
*
iface
)
{
static
gboolean
initialized
=
FALSE
;
iface
->
get_id
=
gitg_activatable_get_id_default
;
iface
->
activate
=
gitg_activatable_activate_default
;
if
(
!
initialized
)
{
initialized
=
TRUE
;
}
}
gchar
*
gitg_activatable_get_id
(
GitgActivatable
*
panel
)
{
g_return_val_if_fail
(
GITG_IS_ACTIVATABLE
(
panel
),
NULL
);
return
GITG_ACTIVATABLE_GET_INTERFACE
(
panel
)
->
get_id
(
panel
);
}
gboolean
gitg_activatable_activate
(
GitgActivatable
*
panel
,
gchar
const
*
action
)
{
g_return_val_if_fail
(
GITG_IS_ACTIVATABLE
(
panel
),
FALSE
);
return
GITG_ACTIVATABLE_GET_INTERFACE
(
panel
)
->
activate
(
panel
,
action
);
}
gitg/gitg-activatable.h
deleted
100644 → 0
View file @
79905400
/*
* gitg-activatable.h
* This file is part of gitg - git repository viewer
*
* Copyright (C) 2009 - Jesse van den Kieboom
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GITG_ACTIVATABLE_H__
#define __GITG_ACTIVATABLE_H__
#include
<glib-object.h>
G_BEGIN_DECLS
#define GITG_TYPE_ACTIVATABLE (gitg_activatable_get_type ())
#define GITG_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_ACTIVATABLE, GitgActivatable))
#define GITG_IS_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_ACTIVATABLE))
#define GITG_ACTIVATABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GITG_TYPE_ACTIVATABLE, GitgActivatableInterface))
typedef
struct
_GitgActivatable
GitgActivatable
;
typedef
struct
_GitgActivatableInterface
GitgActivatableInterface
;
struct
_GitgActivatableInterface
{
GTypeInterface
parent
;
gchar
*
(
*
get_id
)
(
GitgActivatable
*
panel
);
gboolean
(
*
activate
)
(
GitgActivatable
*
panel
,
gchar
const
*
cmd
);
};
GType
gitg_activatable_get_type
(
void
)
G_GNUC_CONST
;
gchar
*
gitg_activatable_get_id
(
GitgActivatable
*
panel
);
gboolean
gitg_activatable_activate
(
GitgActivatable
*
panel
,
gchar
const
*
action
);
G_END_DECLS
#endif
/* __GITG_ACTIVATABLE_H__ */
gitg/gitg-application.vala
0 → 100644
View file @
a74c5661
namespace
Gitg
{
public
class
Application
:
Gtk
.
Application
{
public
Application
()
{
Object
(
application_id
:
"org.gnome.gitg"
,
flags
:
ApplicationFlags
.
HANDLES_OPEN
|
ApplicationFlags
.
HANDLES_COMMAND_LINE
|
ApplicationFlags
.
SEND_ENVIRONMENT
);
}
private
struct
Options
{
public
static
bool
quit
=
false
;
public
static
bool
commit
=
false
;
public
static
string
?
select
=
null
;
public
static
bool
startup
=
false
;
public
static
bool
no_wd
=
false
;
public
static
ApplicationCommandLine
command_line
;
public
static
const
OptionEntry
[]
entries
=
{
{
"version"
,
'v'
,
OptionFlags
.
NO_ARG
,
OptionArg
.
CALLBACK
,
(
void
*)
show_version_and_quit
,
N_
(
"Show the application's version"
),
null
},
{
"commit"
,
'c'
,
0
,
OptionArg
.
NONE
,
ref
commit
,
N_
(
"Start gitg in commit mode"
),
null
},
{
"select"
,
's'
,
0
,
OptionArg
.
STRING
,
ref
select
,
N_
(
"Select commit after loading the repository"
),
null
},
{
"no-wd"
,
0
,
0
,
OptionArg
.
NONE
,
ref
no_wd
,
N_
(
"Do not try to load a repository from the current working directory"
),
null
},
{
null
}
};
}
private
static
Options
options
;
private
static
void
show_version_and_quit
()
{
stdout
.
printf
(
"%s %s\n"
,
Environment
.
get_application_name
(),
Config
.
VERSION
);
options
.
quit
=
true
;
}
private
void
parse_command_line
(
ref
unowned
string
[]
argv
)
throws
OptionError
{
var
ctx
=
new
OptionContext
(
_
(
"- git repository viewer"
));
ctx
.
add_main_entries
(
options
.
entries
,
Config
.
GETTEXT_PACKAGE
);
ctx
.
add_group
(
Gtk
.
get_option_group
(
true
));
ctx
.
parse
(
ref
argv
);
}
protected
override
bool
local_command_line
([
CCode
(
array_length
=
false
,
array_null_terminated
=
true
)]
ref
unowned
string
[]
arguments
,
out
int
exit_status
)
{
// Parse command line just for -v and -h
string
[]
cp
=
arguments
;
unowned
string
[]
argv
=
cp
;
try
{
parse_command_line
(
ref
argv
);
}
catch
(
Error
e
)
{
exit_status
=
1
;
return
true
;
}
if
(
options
.
quit
)
{
exit_status
=
0
;
return
true
;
}
return
base
.
local_command_line
(
ref
arguments
,
out
exit_status
);