Add --version/-v flag

This commit is contained in:
Simon Gomizelj 2012-06-19 18:54:38 -04:00
parent 94f52426d4
commit 422dae672c
2 changed files with 9 additions and 0 deletions

View File

@ -1,3 +1,4 @@
VERSION = $(shell git describe --tags)
PREFIX = /usr/local PREFIX = /usr/local
GTK = gtk+-3.0 GTK = gtk+-3.0
VTE = vte-2.90 VTE = vte-2.90
@ -16,6 +17,7 @@ CFLAGS := -std=c99 -O3 \
-Wbad-function-cast \ -Wbad-function-cast \
-Wunused-macros \ -Wunused-macros \
-Wwrite-strings \ -Wwrite-strings \
-DTERMITE_VERSION=\"${VERSION}\" \
${shell pkg-config --cflags ${GTK} ${VTE}} \ ${shell pkg-config --cflags ${GTK} ${VTE}} \
${CFLAGS} ${CFLAGS}

View File

@ -449,6 +449,7 @@ int main(int argc, char **argv) {
GError *error = NULL; GError *error = NULL;
const char *term = "vte-256color"; const char *term = "vte-256color";
gboolean dynamic_title = FALSE, urgent_on_bell = FALSE, clickable_url = FALSE; gboolean dynamic_title = FALSE, urgent_on_bell = FALSE, clickable_url = FALSE;
gboolean version;
GOptionContext *context = g_option_context_new(NULL); GOptionContext *context = g_option_context_new(NULL);
char *role = NULL, *geometry = NULL, *execute = NULL; char *role = NULL, *geometry = NULL, *execute = NULL;
@ -456,6 +457,7 @@ int main(int argc, char **argv) {
{"role", 'r', 0, G_OPTION_ARG_STRING, &role, "The role to use", "ROLE"}, {"role", 'r', 0, G_OPTION_ARG_STRING, &role, "The role to use", "ROLE"},
{"geometry", 0, 0, G_OPTION_ARG_STRING, &geometry, "Window geometry", "GEOMETRY"}, {"geometry", 0, 0, G_OPTION_ARG_STRING, &geometry, "Window geometry", "GEOMETRY"},
{"exec", 'e', 0, G_OPTION_ARG_STRING, &execute, "Command to execute", "COMMAND"}, {"exec", 'e', 0, G_OPTION_ARG_STRING, &execute, "Command to execute", "COMMAND"},
{"version", 'v', 0, G_OPTION_ARG_NONE, &version, "Version info", NULL },
{NULL} {NULL}
}; };
g_option_context_add_main_entries(context, entries, NULL); g_option_context_add_main_entries(context, entries, NULL);
@ -466,6 +468,11 @@ int main(int argc, char **argv) {
return 1; return 1;
} }
if (version) {
g_print("termite %s\n", TERMITE_VERSION);
return 0;
}
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *overlay = gtk_overlay_new(); GtkWidget *overlay = gtk_overlay_new();
GtkWidget *vte = vte_terminal_new(); GtkWidget *vte = vte_terminal_new();