Use GOption to parse the arguments. Bug #444399.

2007-06-05  Christian Persch  <chpe@gnome.org>

	* typing-break/main.c: (main): Use GOption to parse the arguments. Bug
	#444399.

svn path=/trunk/; revision=7694
This commit is contained in:
Christian Persch 2007-06-05 19:47:16 +00:00 committed by Christian Persch
parent f5fe47e66e
commit a9fee19f43
2 changed files with 29 additions and 21 deletions

View file

@ -1,3 +1,8 @@
2007-06-05 Christian Persch <chpe@gnome.org>
* typing-break/main.c: (main): Use GOption to parse the arguments. Bug
#444399.
2007-06-05 Jens Granseuer <jensgr@gmx.net>
* configure.in: add capplets/appearance/gnome-theme-package.xml

View file

@ -21,6 +21,7 @@
#include <config.h>
#include <string.h>
#include <stdlib.h>
#include <glib/gi18n.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
@ -52,35 +53,37 @@ have_tray (void)
int
main (int argc, char *argv[])
{
gint i;
DrWright *drwright;
DrwSelection *selection;
gboolean no_check = FALSE;
const GOptionEntry options[] = {
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &debug,
N_("Enable debugging code"), NULL },
{ "no-check", 'n', 0, G_OPTION_ARG_NONE, &no_check,
N_("Don't check whether the notification area exists"), NULL },
};
GOptionContext *option_context;
GError *error = NULL;
gboolean retval;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
gtk_init (&argc, &argv);
i = 1;
while (i < argc) {
const gchar *arg = argv[i];
if (strcmp (arg, "--debug") == 0 ||
strcmp (arg, "-d") == 0) {
debug = TRUE;
}
else if (strcmp (arg, "-n") == 0) {
no_check = TRUE;
}
else if (strcmp (arg, "-?") == 0) {
g_printerr ("Usage: %s [--debug]\n", argv[0]);
return 0;
}
++i;
}
option_context = g_option_context_new (NULL);
#if GLIB_CHECK_VERSION (2, 12, 0)
g_option_context_set_translation_domain (option_context, GETTEXT_PACKAGE);
#endif
g_option_context_add_main_entries (option_context, options, GETTEXT_PACKAGE);
g_option_context_add_group (option_context, gtk_get_option_group (TRUE));
retval = g_option_context_parse (option_context, &argc, &argv, &error);
g_option_context_free (option_context);
if (!retval) {
g_print ("%s\n", error->message);
g_error_free (error);
exit (1);
}
g_set_application_name (_("Typing Monitor"));
gtk_window_set_default_icon_name ("typing-monitor");