From 4a45e9810135419fe71ef27361e2a7b3b69a1f35 Mon Sep 17 00:00:00 2001 From: "Nickolay V. Shmyrev" Date: Sat, 13 May 2006 04:57:13 +0000 Subject: [PATCH] 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 --- ChangeLog | 9 +++++++++ configure.ac | 4 ++-- shell/Makefile.am | 1 + shell/main.c | 29 +++++++++++++++-------------- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 974c83d2..0e426d7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-05-13 Michael Plump + + * configure.ac: + * shell/Makefile.am: + * shell/main.c: (main): + + Port to GOption command line parsing. Fix for the + bug #327518 + 2006-05-13 Nickolay V. Shmyrev * shell/ev-window.c: (ev_window_cmd_help_about): diff --git a/configure.ac b/configure.ac index 256a871f..88ed5662 100644 --- a/configure.ac +++ b/configure.ac @@ -46,8 +46,8 @@ DBUS_GLIB_REQUIRED=0.33 GTK_REQUIRED=2.8.15 KEYRING_REQUIRED=0.4.0 -LIBGNOMEUI_REQUIRED=2.6.0 -LIBGNOMEPRINTUI_REQUIRED=2.5.1 +LIBGNOMEUI_REQUIRED=2.14.0 +LIBGNOMEPRINTUI_REQUIRED=2.6.0 PKG_CHECK_MODULES(LIB, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED) PKG_CHECK_MODULES(BACKEND, gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0) diff --git a/shell/Makefile.am b/shell/Makefile.am index 4712686e..4ce5bce8 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 480d00e9..d1aabceb 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; } -- 2.43.0