1 --- trunk/app/app_procs.c 2007/10/28 10:23:23 3838 2 +++ trunk/app/app_procs.c 2008/03/04 20:32:19 3897 3 @@ -37,27 +37,8 @@ 4 #include <gtk/gtk.h> 5 #include <gmodule.h> 6 7 -#if (defined (HAVE_LIBPOPT) && defined (HAVE_POPT_H)) || defined (GNOME) 8 -#define HAVE_POPT 9 -#endif 10 - 11 #ifdef GNOME 12 #include <gnome.h> 13 -#else 14 -# ifdef HAVE_POPT_H 15 -# include <popt.h> 16 -# else 17 -/* sorry about the mess, but one should not use conditional defined types in 18 - * unconditional function call in the first place ... --hb */ 19 -typedef void* poptContext; 20 -# endif 21 -#endif 22 - 23 -/* apparently there is no clean way to use glib-2.6 GOption with gnome */ 24 -#if GLIB_CHECK_VERSION(2,5,5) && !defined GNOME 25 -# define USE_GOPTION 1 26 -#else 27 -# define USE_GOPTION 0 28 #endif 29 30 #ifdef HAVE_FREETYPE 31 @@ -114,12 +95,8 @@ 32 33 static void create_user_dirs(void); 34 static PluginInitResult internal_plugin_init(PluginInfo *info); 35 -static void process_opts(int argc, char **argv, 36 -#if USE_GOPTION 37 +static void process_opts(int *argc, char **argv, 38 GOptionContext* context, GOptionEntry options[], 39 -#elif defined HAVE_POPT 40 - poptContext poptCtx, struct poptOption options[], 41 -#endif 42 GSList **files, char **export_file_name, 43 char **export_file_format, char **size, 44 char **show_layers, gboolean *nosplash); 45 @@ -697,7 +674,6 @@ 46 "shape, svg, tex, " WMF 47 "wpg"); 48 49 -#if USE_GOPTION 50 GOptionContext *context = NULL; 51 static GOptionEntry options[] = 52 { 53 @@ -724,49 +700,12 @@ 54 N_("Display version and exit"), NULL }, 55 { NULL } 56 }; 57 -#elif defined HAVE_POPT 58 - poptContext context = NULL; 59 - struct poptOption options[] = 60 - { 61 - {"export", 'e', POPT_ARG_STRING, NULL /* &export_file_name */, 0, 62 - N_("Export loaded file and exit"), N_("OUTPUT")}, 63 - {"filter",'t', POPT_ARG_STRING, NULL /* &export_file_format */, 64 - 0, export_format_string, N_("TYPE") 65 - }, 66 - {"size", 's', POPT_ARG_STRING, NULL, 0, 67 - N_("Export graphics size"), N_("WxH")}, 68 - {"show-layers", 'L', POPT_ARG_STRING, NULL, 0, /* 13.3.2004 sampo (a] iki.fi */ 69 - N_("Show only specified layers (e.g. when exporting). Can be either the layer name or a range of layer numbers (X-Y)"), 70 - N_("LAYER,LAYER,...")}, 71 - {"nosplash", 'n', POPT_ARG_NONE, &nosplash, 0, 72 - N_("Don't show the splash screen"), NULL }, 73 - {"nonew", 'n', POPT_ARG_NONE, &nonew, 0, 74 - N_("Don't create empty diagram"), NULL }, 75 - {"log-to-stderr", 'l', POPT_ARG_NONE, &log_to_stderr, 0, 76 - N_("Send error messages to stderr instead of showing dialogs."), NULL }, 77 - {"credits", 'c', POPT_ARG_NONE, &credits, 0, 78 - N_("Display credits list and exit"), NULL }, 79 - {"verbose", 0, POPT_ARG_NONE, &verbose, 0, 80 - N_("Generate verbose output"), NULL }, 81 - {"version", 'v', POPT_ARG_NONE, &version, 0, 82 - N_("Display version and exit"), NULL }, 83 - {"help", 'h', POPT_ARG_NONE, 0, 1, N_("Show this help message") }, 84 - {(char *) NULL, '\0', 0, NULL, 0} 85 - }; 86 -#endif 87 88 -#if USE_GOPTION 89 options[0].arg_data = &export_file_name; 90 options[1].arg_data = &export_file_format; 91 options[1].description = export_format_string; 92 options[2].arg_data = &size; 93 options[3].arg_data = &show_layers; 94 -#elif defined HAVE_POPT 95 - options[0].arg = &export_file_name; 96 - options[1].arg = &export_file_format; 97 - options[2].arg = &size; 98 - options[3].arg = &show_layers; 99 -#endif 100 101 argv0 = (argc > 0) ? argv[0] : "(none)"; 102 103 @@ -786,12 +725,10 @@ 104 #endif 105 textdomain(GETTEXT_PACKAGE); 106 107 - process_opts(argc, argv, 108 -#if defined HAVE_POPT || USE_GOPTION 109 + process_opts(&argc, argv, 110 context, options, 111 -#endif 112 &files, 113 - &export_file_name, &export_file_format, &size, &show_layers, &nosplash); 114 + &export_file_name, &export_file_format, &size, &show_layers, &nosplash); 115 116 #if defined ENABLE_NLS && defined HAVE_BIND_TEXTDOMAIN_CODESET 117 bind_textdomain_codeset(GETTEXT_PACKAGE,"UTF-8"); 118 @@ -804,10 +741,9 @@ 119 gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, 120 argc, argv, 121 /* haven't found a quick way to pass GOption here */ 122 - GNOME_PARAM_POPT_TABLE, options, 123 + GNOME_PARAM_GOPTION_CONTEXT, context, 124 GNOME_PROGRAM_STANDARD_PROPERTIES, 125 GNOME_PARAM_NONE); 126 - g_object_get(program, "popt-context", &context, NULL); 127 client = gnome_master_client(); 128 if(client == NULL) { 129 g_warning(_("Can't connect to session manager!\n")); 130 @@ -1214,53 +1150,20 @@ 131 132 /* Note: running in locale encoding */ 133 static void 134 -process_opts(int argc, char **argv, 135 -#if USE_GOPTION 136 +process_opts(int *argc, char **argv, 137 GOptionContext *context, GOptionEntry options[], 138 -#elif defined HAVE_POPT 139 - poptContext poptCtx, struct poptOption options[], 140 -#endif 141 GSList **files, char **export_file_name, 142 char **export_file_format, char **size, 143 char **show_layers, gboolean* nosplash) 144 { 145 -#if defined HAVE_POPT && !USE_GOPTION 146 - int rc = 0; 147 - poptCtx = poptGetContext(PACKAGE, argc, (const char **)argv, options, 0); 148 - poptSetOtherOptionHelp(poptCtx, _("[OPTION...] [FILE...]")); 149 - while (rc >= 0) { 150 - if((rc = poptGetNextOpt(poptCtx)) < -1) { 151 - fprintf(stderr,_("Error on option %s: %s.\nRun '%s --help' to see a full list of available command line options.\n"), 152 - poptBadOption(poptCtx, 0), 153 - poptStrerror(rc), 154 - argv[0]); 155 - exit(1); 156 - } 157 - if(rc == 1) { 158 - poptPrintHelp(poptCtx, stderr, 0); 159 - exit(0); 160 - } 161 - } 162 -#endif 163 if (argv) { 164 -#if defined HAVE_POPT && !USE_GOPTION 165 - while (poptPeekArg(poptCtx)) { 166 - char *in_file_name = (char *)poptGetArg(poptCtx); 167 - if (*in_file_name != '\0') 168 - *files = g_slist_append(*files, in_file_name); 169 - } 170 - poptFreeContext(poptCtx); 171 -#elif USE_GOPTION 172 GError *error = NULL; 173 int i; 174 175 context = g_option_context_new(_("[FILE...]")); 176 g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); 177 -# if GTK_CHECK_VERSION(2,5,7) 178 - /* at least Gentoo was providing GLib-2.6 but Gtk+-2.4.14 */ 179 - g_option_context_add_group (context, gtk_get_option_group (FALSE)); 180 -# endif 181 - if (!g_option_context_parse (context, &argc, &argv, &error)) { 182 + 183 + if (!g_option_context_parse (context, argc, &argv, &error)) { 184 if (error) { /* IMO !error here is a bug upstream, triggered with --gdk-debug=updates */ 185 g_print ("%s", error->message); 186 g_error_free (error); 187 @@ -1271,11 +1174,11 @@ 188 g_option_context_free(context); 189 exit(0); 190 } 191 - if (argc < 2) { 192 + if (*argc < 2) { 193 g_option_context_free(context); 194 return; 195 } 196 - for (i = 1; i < argc; i++) { 197 + for (i = 1; i < *argc; i++) { 198 if (!g_file_test (argv[i], G_FILE_TEST_IS_REGULAR)) { 199 g_print (_("'%s' not found!\n"), argv[i]); 200 g_option_context_free(context); 201 @@ -1284,43 +1187,6 @@ 202 *files = g_slist_append(*files, argv[i]); 203 } 204 g_option_context_free(context); 205 -#else 206 - int i; 207 - 208 - for (i=1; i<argc; i++) { 209 - char *in_file_name = argv[i]; /* unless it's an option... */ 210 - 211 - if (0==strcmp(argv[i],"-t")) { 212 - if (i < (argc-1)) { 213 - i++; 214 - *export_file_format = argv[i]; 215 - continue; 216 - } 217 - } else if (0 == strcmp(argv[i],"-e")) { 218 - if (i < (argc-1)) { 219 - i++; 220 - *export_file_name = argv[i]; 221 - continue; 222 - } 223 - } else if (0 == strcmp(argv[i],"-s")) { 224 - if (i < (argc-1)) { 225 - i++; 226 - *size = argv[i]; 227 - continue; 228 - } 229 - } else if (0 == strcmp(argv[i],"-L")) { 230 - if (i < (argc-1)) { 231 - i++; 232 - *show_layers = argv[i]; 233 - continue; 234 - } 235 - } else if (0 == strcmp(argv[i],"-n")) { 236 - *nosplash = 1; 237 - continue; 238 - } 239 - *files = g_slist_append(*files, in_file_name); 240 - } 241 -#endif 242 } 243 if (*export_file_name || *export_file_format || *size) 244 dia_is_interactive = FALSE; 245