From d54a8a85e7edec7e65ad42c9c183384f488a6f1c Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Thu, 18 Oct 2012 00:22:20 +0200 Subject: mate-aboud: code improvements disable gnucat by default install gnucat pixmaps only if enabled translate some spanish comments dropped support for old glib version (now minimun version is increased) add "translator-credits" msgid to show translators --- configure.ac | 15 +++++----- mate-about/Makefile.am | 2 ++ mate-about/mate-about.c | 80 ++++++++++++++++--------------------------------- mate-about/mate-about.h | 68 ++++++++--------------------------------- po/POTFILES.in | 1 + 5 files changed, 49 insertions(+), 117 deletions(-) diff --git a/configure.ac b/configure.ac index 90c95fa..d8e0595 100644 --- a/configure.ac +++ b/configure.ac @@ -63,7 +63,7 @@ MATE_MAINTAINER_MODE_DEFINES # As a special favour for vuntz, support --disable-deprecations AC_ARG_ENABLE([deprecations], - [AS_HELP_STRING([--disable-deprecations],[don't warn about deprecated usages])], + [AS_HELP_STRING([--disable-deprecations],[dont warn about deprecated usages])], [],[enable_deprecations=yes]) if test "$enable_deprecations" = "no"; then DISABLE_DEPRECATED="" @@ -73,7 +73,7 @@ fi # Should we build mate-about or the shared desktop docs? Useful for people who # need to build two mate-desktop using two different versions of GTK+ AC_ARG_ENABLE([mate-about], - [AS_HELP_STRING([--disable-mate-about],[don't build mate-about])], + [AS_HELP_STRING([--disable-mate-about],[dont build mate-about])], [],[enable_mate_about=yes]) AM_CONDITIONAL(MATE_ABOUT_ENABLED, test "x$enable_mate_about" = "xyes") AC_ARG_ENABLE([desktop-docs], @@ -231,12 +231,13 @@ AC_SUBST(GETTEXT_PACKAGE) AM_GLIB_GNU_GETTEXT AC_ARG_ENABLE([gnucat], - [AS_HELP_STRING([--disable-gnucat], [disable the use of gnu cat as logo])], - [disable_gnucat=yes], [disable_gnucat=no]) + [AS_HELP_STRING([--enable-gnucat], [enable the use of gnu cat as logo in mate-about])], + [enable_gnucat=yes], [enable_gnucat=no]) -if test "x$disable_gnucat" = "xyes"; then - MATE_ABOUT_CFLAGS="$MATE_ABOUT_CFLAGS -DDISABLE_GNUCAT=1" +if test "x$enable_gnucat" = "xyes"; then + MATE_ABOUT_CFLAGS="$MATE_ABOUT_CFLAGS -DENABLE_GNUCAT=1" fi +AM_CONDITIONAL(GNUCAT_ENABLED, test "x$enable_gnucat" = "xyes") dnl ============================================================================ dnl | se comprueba unique @@ -342,5 +343,5 @@ mate-desktop $VERSION `echo mate-desktop $VERSION | sed "s/./=/g"` Startup notification support: ${have_startup_notification} XRandr support: ${have_randr} Build gtk-doc documentation: ${enable_gtk_doc} - Disable gnucat: ${disable_gnucat} + Enable gnucat: ${enable_gnucat} " diff --git a/mate-about/Makefile.am b/mate-about/Makefile.am index bd64542..055a031 100644 --- a/mate-about/Makefile.am +++ b/mate-about/Makefile.am @@ -11,8 +11,10 @@ AM_CPPFLAGS = \ @INTLTOOL_DESKTOP_RULE@ +if GNUCAT_ENABLED pixmapdir = $(datadir)/pixmaps pixmap_DATA = gnu-cat_navideno_v3.png gnu-cat.gif +endif desktopdir = $(datadir)/applications desktop_in_files = mate-about.desktop.in diff --git a/mate-about/mate-about.c b/mate-about/mate-about.c index 9626542..8773261 100644 --- a/mate-about/mate-about.c +++ b/mate-about/mate-about.c @@ -32,10 +32,8 @@ textdomain(package); #endif -//class mate_about -//{ // what a mess! - #ifndef DISABLE_GNUCAT + #ifdef ENABLE_GNUCAT // Thanks! http://www.gtkforums.com/viewtopic.php?t=1639 typedef struct _iter_arg { @@ -85,7 +83,8 @@ } #elif GLIB_CHECK_VERSION(2, 26, 0) && !defined(UNIQUE) - // es un callback + + // callback static void mate_about_on_activate(GApplication* app) { if (!mate_about_dialog) @@ -102,16 +101,14 @@ void mate_about_run(void) { - /* Es importante llamar gtk_init, si no, no se puede iniciar bien el dialogo */ mate_about_dialog = (GtkAboutDialog*) gtk_about_dialog_new(); gtk_window_set_default_icon_name(icon); - #ifndef DISABLE_GNUCAT + #ifdef ENABLE_GNUCAT - /* hacemos una comprovacion de la fecha, para mostrar el gnucat - * version navideña. */ - gboolean christmas_is = FALSE; + /* check if it's christmas, to show a different image */ + gboolean is_christmas = FALSE; GDate* d = g_date_new(); g_date_set_time_t(d, (time_t) time(NULL)); @@ -122,14 +119,13 @@ if (day >= 24 && day <=25) { - christmas_is = TRUE; + is_christmas = TRUE; } } g_date_free(d); - - if (christmas_is == TRUE) + if (is_christmas == TRUE) { GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(PIXMAPS_DIR "gnu-cat_navideno_v3.png", NULL); gtk_about_dialog_set_logo(mate_about_dialog, pixbuf); @@ -175,7 +171,7 @@ #endif - //name + // name #if GTK_CHECK_VERSION(3, 0, 0) || GTK_CHECK_VERSION(2, 12, 0) gtk_about_dialog_set_program_name(mate_about_dialog, gettext(program_name)); #else @@ -185,7 +181,7 @@ // version gtk_about_dialog_set_version(mate_about_dialog, version); - // creditos y pagina web + // credits and website gtk_about_dialog_set_copyright(mate_about_dialog, copyright); gtk_about_dialog_set_website(mate_about_dialog, website); @@ -195,12 +191,12 @@ */ gtk_about_dialog_set_comments(mate_about_dialog, gettext(comments_array[g_random_int_range(0, comments_count - 1)])); - // autores gtk_about_dialog_set_authors(mate_about_dialog, authors); - // I comment this because the list is empty gtk_about_dialog_set_artists(mate_about_dialog, artists); gtk_about_dialog_set_documenters(mate_about_dialog, documenters); - gtk_about_dialog_set_translator_credits(mate_about_dialog, translators); + /* Translators should localize the following string which will be + * displayed in the about box to give credit to the translator(s). */ + gtk_about_dialog_set_translator_credits(mate_about_dialog, _("translator-credits")); #if GTK_CHECK_VERSION(3, 0, 0) gtk_about_dialog_set_license_type(mate_about_dialog, GTK_LICENSE_GPL_3_0); @@ -222,44 +218,19 @@ { int status = 0; - /* Con esto se inicia gettext - * GETTEXT_PACKAGE = mate-desktop-2.0 - * LOCALE_DIR = /usr/local/share/locale */ mate_gettext(GETTEXT_PACKAGE, LOCALE_DIR, "UTF-8"); g_type_init(); - - - #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 - - + + /* 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); if (mate_about_nogui == TRUE) { @@ -270,7 +241,7 @@ gtk_init(&argc, &argv); /** - * Ejemplos tomados de: + * Examples taken from: * http://developer.gnome.org/gtk3/3.0/gtk-migrating-GtkApplication.html */ #ifdef USE_UNIQUE @@ -310,12 +281,13 @@ g_object_unref(mate_about_application); #else + mate_about_run(); + #endif } return status; } -//} #endif diff --git a/mate-about/mate-about.h b/mate-about/mate-about.h index a6ec12a..cbb2f5a 100644 --- a/mate-about/mate-about.h +++ b/mate-about/mate-about.h @@ -30,22 +30,6 @@ #include #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 */ -#else - #include -#endif - -//class mate_about -//{ const char* program_name = "MATE Desktop Environment"; const char* version = PACKAGE_VERSION; const char* icon = "desktop"; @@ -55,9 +39,8 @@ "Copyright © 1997-2011 GNOME developers\n" "Copyright © 2011 Perberos"; // egoista! - /* Incrementar el valor de comments_count si se desea agregar nuevos valores - * en comments[]. Porque, este valor es usado en un random para obtener el - * indice de la cadena. */ + /* Increment comments_count if you add other comments. This will be + * used to choose a random comment. */ const int comments_count = 6; const char* comments_array[] = { N_("MATE provides an intuitive and attractive desktop to Linux users " @@ -82,13 +65,13 @@ }; const char* authors[] = { - // MATE start here + // MATE developers "Perberos ", "Stefano Karapetsas ", "Steve Zesch ", "Clement Lefebvre ", "Nelson Marques ", - // GNOME start here + // GNOME developers "Jérôme Abela", "Rob Adams", "Djihed Afifi", @@ -623,28 +606,23 @@ NULL }; - // documentacion + // documentation const char* documenters[] = { "...", // TODO: fillme NULL }; - // artistas + // artists const char* artists[] = { "Rowen Stipe ", "/g/entoomen ", NULL }; - // traductores - const char translators[] = "" \ - "..."; // TODO: fillme - // widget de la unica ventana + // widget for mate-about window GtkAboutDialog* mate_about_dialog = FALSE; // libunique thing #ifdef USE_UNIQUE - //extern UniqueApp* unique; - //UniqueApp* unique = NULL; extern UniqueApp* mate_about_application; UniqueApp* mate_about_application = NULL; #elif GTK_CHECK_VERSION(3, 0, 0) @@ -668,32 +646,10 @@ static void mate_about_on_activate(GApplication* app); #endif - // for command line - #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 - -//} + // arguments definitions + static GOptionEntry command_entries[] = { + {"version", 'v', 0, G_OPTION_ARG_NONE, &mate_about_nogui, "Show MATE version", NULL}, + {NULL} + }; #endif /* __MATE_ABOUT_H__ */ diff --git a/po/POTFILES.in b/po/POTFILES.in index 1b65f27..8304e44 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,6 +1,7 @@ # List of source files containing translatable strings. # Please keep this file sorted alphabetically. mate-about/mate-about.desktop.in.in +mate-about/mate-about.c mate-about/mate-about.h # When adding a file here, make sure that the entry point in the API of this # file calls _mate_desktop_init_i18n () -- cgit v1.2.1