GNOME Bugzilla – Bug 327986
replace popt with goption
Last modified: 2006-01-26 12:53:43 UTC
This patch replaces the use of popt with GOption which is in since gtk2.6 Makes the code simpler, the default help text shorter and clearer and the gtk-only-evince diff smaller. The first part is unrelated but does not deserve a bug by itself. That #include is no longer needed there. === modified file 'shell/ev-view.c' --- shell/ev-view.c +++ shell/ev-view.c @@ -26,7 +26,6 @@ #include <gtk/gtkselection.h> #include <gtk/gtkclipboard.h> #include <gdk/gdkkeysyms.h> -#include <libgnomevfs/gnome-vfs-utils.h> #include "ev-marshal.h" #include "ev-view.h" === modified file 'shell/main.c' --- shell/main.c +++ shell/main.c @@ -28,8 +28,6 @@ #include <gtk/gtkmain.h> #include <stdlib.h> #include <string.h> -#include <libgnome/gnome-program.h> -#include <libgnomeui/gnome-ui-init.h> #include <libgnomeui/gnome-app-helper.h> #include <libgnomeui/gnome-authentication-manager.h> #include <libgnomevfs/gnome-vfs-utils.h> @@ -44,11 +42,13 @@ #include "ev-file-helpers.h" static char *ev_page_label; - -static struct poptOption popt_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 } +static const char **files; + +static GOptionEntry options[] = +{ + { "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, &files, NULL, NULL}, + { NULL, 0, 0, 0, NULL, NULL, NULL } }; static void @@ -242,9 +242,6 @@ main (int argc, char *argv[]) { gboolean enable_metadata = FALSE; - poptContext context; - GValue context_as_value = { 0 }; - GnomeProgram *program; #ifdef ENABLE_NLS /* Initialize the i18n stuff */ @@ -253,21 +250,11 @@ textdomain(GETTEXT_PACKAGE); #endif - program = gnome_program_init (PACKAGE, VERSION, - LIBGNOMEUI_MODULE, argc, argv, - GNOME_PARAM_POPT_TABLE, popt_options, - 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); - + gtk_init_with_args(&argc, &argv, NULL, options, NULL, NULL); #ifdef ENABLE_DBUS if (!ev_application_register_service (EV_APP)) { - if (load_files_remote (poptGetArgs (context))) { + if (load_files_remote (files)){ return 0; } } else { @@ -290,12 +277,11 @@ ev_stock_icons_init (); gtk_window_set_default_icon_name ("postscript-viewer"); - load_files (poptGetArgs (context)); + load_files (files); gtk_main (); gnome_accelerators_sync (); - poptFreeContext (context); ev_file_helpers_shutdown (); if (enable_metadata) {
sorry wrong patch, ignore for now
Thanks for working on it, Jani, but this problem was already discussed earlier *** This bug has been marked as a duplicate of 327518 ***
oh, I wasn't aware switching to goption has been discussed already. Then please apply the first bit of the patch only :) .thanks
Jani, can you please attach corrected patch to the bug 327518 (There is "Create a New Attachment" link below). Also I am not sure, probably we'd like to keep gnome_program_init, read the comments there.
actually the patch was correct only when building with --disable-gnome, as other parts rely on info initialized by gnome_program_init(). They can be replaced (i.e gnome_user_dir_get() with g_get_home_dir() + '.gnome2') but are probably not considered clean solutions. So as it is the patch is not that useful but when you start relying on newer libgnomeui I'll update it.