From 4a45e9810135419fe71ef27361e2a7b3b69a1f35 Mon Sep 17 00:00:00 2001 From: Nickolay V. Shmyrev Date: Sat, 13 May 2006 04:57:13 +0000 Subject: Port to GOption command line parsing. Fix for the bug #327518 * configure.ac: * shell/Makefile.am: * shell/main.c: (main): Port to GOption command line parsing. Fix for the bug #327518 --- (limited to 'shell') diff --git a/shell/Makefile.am b/shell/Makefile.am index 4712686..4ce5bce 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -11,6 +11,7 @@ INCLUDES= \ -DGNOMEICONDIR=\""$(datadir)/pixmaps"\" \ $(SHELL_CFLAGS) \ $(WARN_CFLAGS) \ + $(DISABLE_DEPRECATED) \ $(GNOME_PRINT_CFLAGS) bin_PROGRAMS=evince diff --git a/shell/main.c b/shell/main.c index 480d00e..d1aabce 100644 --- a/shell/main.c +++ b/shell/main.c @@ -44,11 +44,13 @@ #include "ev-file-helpers.h" static char *ev_page_label; +static char **file_arguments = NULL; -static struct poptOption popt_options[] = +static const GOptionEntry goption_options[] = { - { "page-label", 'p', POPT_ARG_STRING, &ev_page_label, 0, N_("The page of the document to display."), N_("PAGE")}, - { NULL, 0, 0, NULL, 0, NULL, NULL } + { "page-label", 'p', 0, G_OPTION_ARG_STRING, &ev_page_label, N_("The page of the document to display."), N_("PAGE")}, + { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &file_arguments, NULL, N_("[FILE...]") }, + { NULL } }; static void @@ -207,32 +209,31 @@ int main (int argc, char *argv[]) { gboolean enable_metadata = FALSE; - poptContext context; - GValue context_as_value = { 0 }; + GOptionContext *context; GnomeProgram *program; + context = g_option_context_new (_("GNOME Document Viewer")); + #ifdef ENABLE_NLS /* Initialize the i18n stuff */ bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); + g_option_context_add_main_entries (context, goption_options, GETTEXT_PACKAGE); +#else + g_option_context_add_main_entries (context, goption_options, NULL); #endif program = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv, - GNOME_PARAM_POPT_TABLE, popt_options, + GNOME_PARAM_GOPTION_CONTEXT, context, GNOME_PARAM_HUMAN_READABLE_NAME, _("Evince"), GNOME_PARAM_APP_DATADIR, GNOMEDATADIR, NULL); - g_object_get_property (G_OBJECT (program), - GNOME_PARAM_POPT_CONTEXT, - g_value_init (&context_as_value, G_TYPE_POINTER)); - context = g_value_get_pointer (&context_as_value); - #ifdef ENABLE_DBUS if (!ev_application_register_service (EV_APP)) { - if (load_files_remote (poptGetArgs (context))) { + if (load_files_remote (file_arguments)) { return 0; } } else { @@ -255,17 +256,17 @@ main (int argc, char *argv[]) ev_stock_icons_init (); gtk_window_set_default_icon_name ("evince"); - load_files (poptGetArgs (context)); + load_files (file_arguments); gtk_main (); gnome_accelerators_sync (); - poptFreeContext (context); ev_file_helpers_shutdown (); if (enable_metadata) { ev_metadata_manager_shutdown (); } + g_object_unref(program); return 0; } -- cgit v0.9.1