summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mate-about/mate-about.c41
-rw-r--r--mate-about/mate-about.h43
2 files changed, 71 insertions, 13 deletions
diff --git a/mate-about/mate-about.c b/mate-about/mate-about.c
index 67afb72..f40c689 100644
--- a/mate-about/mate-about.c
+++ b/mate-about/mate-about.c
@@ -229,15 +229,38 @@
mate_gettext(GETTEXT_PACKAGE, LOCALE_DIR, "UTF-8");
g_type_init();
- /* http://www.gtk.org/api/2.6/glib/glib-Commandline-option-parser.html */
- GOptionContext* context = g_option_context_new(NULL);
- g_option_context_add_main_entries(context, command_entries, GETTEXT_PACKAGE);
- g_option_context_add_group(context, gtk_get_option_group(TRUE));
- g_option_context_parse(context, &argc, &argv, NULL);
-
- /* Not necesary at all, program just run and die.
- * But it free a little memory. */
- g_option_context_free(context);
+
+
+ #ifdef G_OPTIONS_ENTRY_USE
+ /* http://www.gtk.org/api/2.6/glib/glib-Commandline-option-parser.html */
+ GOptionContext* context = g_option_context_new(NULL);
+ g_option_context_add_main_entries(context, command_entries, GETTEXT_PACKAGE);
+ g_option_context_add_group(context, gtk_get_option_group(TRUE));
+ g_option_context_parse(context, &argc, &argv, NULL);
+
+ /* Not necesary at all, program just run and die.
+ * But it free a little memory. */
+ g_option_context_free(context);
+ #else
+ int opt; /* este valor entrega el tipo de argumento */
+
+ while ((opt = getopt_long(argc, argv, "+", command_entries, NULL)) != -1)
+ {
+ switch (opt)
+ {
+ case '?':
+ return 1;
+ case OPTION_VERSION:
+ mate_about_nogui = TRUE;
+ break;
+ #ifdef CMDLINE_PROCESS
+ CMDLINE_PROCESS
+ #endif
+ }
+ }
+ #endif
+
+
if (mate_about_nogui == TRUE)
{
diff --git a/mate-about/mate-about.h b/mate-about/mate-about.h
index bfa1050..2eb41c8 100644
--- a/mate-about/mate-about.h
+++ b/mate-about/mate-about.h
@@ -29,6 +29,20 @@
#include <unique/unique.h>
#endif
+/* "Commandline option parser" fue introducida a la GLIB a partir de la
+ * version 2.6, esta definicion es para la compatibilidad GTK1.2 */
+#if GLIB_CHECK_VERSION(2, 6, 0)
+ #define G_OPTIONS_ENTRY_USE
+#endif
+
+/* Debido a que GOptions no está disponible en GLIB versiones inferiores a 2.6
+ * voy a utilizar la alternativa de GNU C, */
+#ifdef G_OPTIONS_ENTRY_USE
+ /* No hay nesecidad de incluir nada, viene por defecto en <glib/glib.h> */
+#else
+ #include <getopt.h>
+#endif
+
//class mate_about
//{
const char* program_name = "MATE Desktop Environment";
@@ -649,10 +663,31 @@
#endif
// for command line
- static GOptionEntry command_entries[] = {
- {"version", 'v', 0, G_OPTION_ARG_NONE, &mate_about_nogui, "Show release version", NULL},
- {NULL}
- };
+ #ifdef G_OPTIONS_ENTRY_USE
+ /* GOptionEntry ofrese la posibilidad de acceder a las opciones extras
+ * de GTK desde la linea de comandos. Tambien muestra automaticamente
+ * las opciones al llamar --help o -h */
+ static GOptionEntry command_entries[] = {
+ {"version", 'v', 0, G_OPTION_ARG_NONE, &mate_about_nogui, "Show release version", NULL},
+ {NULL}
+ };
+ #else
+
+
+ /* Quizás hay que agregar una opcion para --help
+ */
+ static struct option command_entries[] = {
+ #ifdef CMDLINE_OPTIONS
+ CMDLINE_OPTIONS
+ #endif
+
+ #define OPTION_VERSION 1000
+ {"version", no_argument, NULL, OPTION_VERSION},
+
+ {NULL, 0, NULL, 0}
+ };
+ #endif
+
//}
#endif /* __MATE_ABOUT_H__ */