diff options
author | Perberos <[email protected]> | 2011-12-07 06:41:31 -0300 |
---|---|---|
committer | Perberos <[email protected]> | 2011-12-07 06:41:31 -0300 |
commit | 720cc9c1a782927bdaf4a6f955d791bbd8c9d2ec (patch) | |
tree | ef71b4b71c2a141bba069248057f1064c138af1c | |
parent | 4f0196a65c5979681b137069deeaec999b3d9355 (diff) | |
download | mate-desktop-720cc9c1a782927bdaf4a6f955d791bbd8c9d2ec.tar.bz2 mate-desktop-720cc9c1a782927bdaf4a6f955d791bbd8c9d2ec.tar.xz |
cleaning code
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | mate-about/Makefile.am | 2 | ||||
-rw-r--r-- | mate-about/mate-about.c | 396 | ||||
-rw-r--r-- | mate-about/mate-about.h | 23 | ||||
-rw-r--r-- | mate-about/nyan-cat_navideno_v3.png | bin | 0 -> 1110 bytes |
5 files changed, 218 insertions, 205 deletions
diff --git a/configure.in b/configure.in index a50f43d..78c36c0 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ m4_define([mate_platform], [2011]) m4_define([mate_minor], [12]) -m4_define([mate_micro], [02]) +m4_define([mate_micro], [06]) m4_define(mate_version, [mate_platform.mate_minor.mate_micro]), diff --git a/mate-about/Makefile.am b/mate-about/Makefile.am index d56ac71..cf7e8c3 100644 --- a/mate-about/Makefile.am +++ b/mate-about/Makefile.am @@ -12,7 +12,7 @@ INCLUDES = \ @INTLTOOL_DESKTOP_RULE@ pixmapdir = $(datadir)/pixmaps -pixmap_DATA = nyan-cat.gif +pixmap_DATA = nyan-cat_navideno_v3.png nyan-cat.gif 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 ce74312..b777a9f 100644 --- a/mate-about/mate-about.c +++ b/mate-about/mate-about.c @@ -32,253 +32,267 @@ textdomain(package); #endif -// what a mess! -#ifndef DISABLE_NYANCAT - -// Thanks! http://www.gtkforums.com/viewtopic.php?t=1639 -typedef struct _iter_arg { - GtkWidget* widget; - GdkPixbufAnimation* animation; - GdkPixbufAnimationIter* iter; -} iter_arg_t; - -gboolean on_animation_frame(iter_arg_t* object) -{ - if (object->widget == NULL) - { - return FALSE; - } +//class mate_about +//{ + // what a mess! + #ifndef DISABLE_NYANCAT - static gint frame = 1; + // Thanks! http://www.gtkforums.com/viewtopic.php?t=1639 + typedef struct _iter_arg { + GtkWidget* widget; + GdkPixbufAnimation* animation; + GdkPixbufAnimationIter* iter; + } iter_arg_t; - if (gdk_pixbuf_animation_iter_advance(object->iter, NULL)) + gboolean on_animation_frame(iter_arg_t* object) { - frame++; + if (object->widget == NULL) + { + return FALSE; + } - gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(object->widget), gdk_pixbuf_animation_iter_get_pixbuf(object->iter)); - } + static gint frame = 1; - return TRUE; -} + if (gdk_pixbuf_animation_iter_advance(object->iter, NULL)) + { + frame++; -#endif + gtk_about_dialog_set_logo((GtkAboutDialog*) object->widget, gdk_pixbuf_animation_iter_get_pixbuf(object->iter)); + } -#if GTK_CHECK_VERSION(3, 0, 0) && !defined(UNIQUE) + return TRUE; + } -static void mate_about_on_activate(GtkApplication* app) -{ - GList* list; - GtkWidget* window; + #endif - list = gtk_application_get_windows(app); + #if GTK_CHECK_VERSION(3, 0, 0) && !defined(UNIQUE) - if (list) + static void mate_about_on_activate(GtkApplication* app) { - gtk_window_present(GTK_WINDOW(list->data)); - } - else - { - mate_about_run(); + GList* list; + GtkWidget* window; + + list = gtk_application_get_windows(app); + + if (list) + { + gtk_window_present(GTK_WINDOW(list->data)); + } + else + { + mate_about_run(); + } } -} -#elif GLIB_CHECK_VERSION(2, 26, 0) && !defined(UNIQUE) -// es un callback -static void mate_about_on_activate(GApplication* app) -{ - if (!mate_about_dialog) + #elif GLIB_CHECK_VERSION(2, 26, 0) && !defined(UNIQUE) + // es un callback + static void mate_about_on_activate(GApplication* app) { - mate_about_run(); + if (!mate_about_dialog) + { + mate_about_run(); + } + else + { + gtk_window_present(GTK_WINDOW(mate_about_dialog)); + } } - else + + #endif + + void mate_about_run(void) { - gtk_window_present(GTK_WINDOW(mate_about_dialog)); - } -} + /* Es importante llamar gtk_init, si no, no se puede iniciar bien el dialogo */ + mate_about_dialog = (GtkAboutDialog*) gtk_about_dialog_new(); -#endif + gtk_window_set_default_icon_name(icon); -void mate_about_run(void) -{ - /** - * Es importante llamar gtk_init, si no, no se puede iniciar bien el dialogo - */ - mate_about_dialog = gtk_about_dialog_new(); + /* logo */ + #ifndef DISABLE_NYANCAT - gtk_window_set_default_icon_name(icon); + /* hacemos una comprovacion de la fecha, para mostrar el nyancat + * version navideña. */ + gboolean christmas_is = FALSE; - // logo - #ifndef DISABLE_NYANCAT - iter_arg_t animation_object; - GdkPixbufAnimation* animation; - GdkPixbufAnimationIter *iter; - GtkWidget* image; + GDate* d = g_date_new(); + g_date_set_time_t(d, (time_t) time(NULL)); - animation = gdk_pixbuf_animation_new_from_file(PIXMAPS_DIR "nyan-cat.gif", NULL); + if (g_date_get_month(d) == G_DATE_DECEMBER) + { + GDateDay day = g_date_get_day(d); - if (animation != NULL) - { - iter = gdk_pixbuf_animation_get_iter(animation, NULL); + if (day >= 24 && day <=25) + { + christmas_is = TRUE; + } + } - animation_object.animation = animation; - animation_object.iter = iter; - animation_object.widget = mate_about_dialog; + g_date_free(d); - gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(mate_about_dialog), gdk_pixbuf_animation_iter_get_pixbuf(iter)); - g_timeout_add(gdk_pixbuf_animation_iter_get_delay_time(iter), (GSourceFunc) on_animation_frame, (gpointer) &animation_object); - } + if (christmas_is == TRUE) + { + GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(PIXMAPS_DIR "nyan-cat_navideno_v3.png", NULL); + gtk_about_dialog_set_logo(mate_about_dialog, pixbuf); + g_object_unref(pixbuf); + } + else + { + iter_arg_t animation_object; + GdkPixbufAnimation* animation; + GdkPixbufAnimationIter *iter; + GtkWidget* image; - #elif GTK_CHECK_VERSION(3, 0, 0) || GTK_CHECK_VERSION(2, 6, 0) + animation = gdk_pixbuf_animation_new_from_file(PIXMAPS_DIR "nyan-cat.gif", NULL); - gtk_about_dialog_set_logo_icon_name(GTK_ABOUT_DIALOG(mate_about_dialog), icon); + if (animation != NULL) + { + iter = gdk_pixbuf_animation_get_iter(animation, NULL); - #else + animation_object.animation = animation; + animation_object.iter = iter; + animation_object.widget = (GtkWidget*) mate_about_dialog; - GtkIconTheme* icon_theme = gtk_icon_theme_get_default(); + gtk_about_dialog_set_logo(mate_about_dialog, gdk_pixbuf_animation_iter_get_pixbuf(iter)); - if (gtk_icon_theme_has_icon(icon_theme, icon)) - { - GdkPixbuf* pixbuf = gtk_icon_theme_load_icon(icon_theme, icon, 64, 0, NULL); - gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(mate_about_dialog), pixbuf); - g_object_unref(pixbuf); - } + g_timeout_add(gdk_pixbuf_animation_iter_get_delay_time(iter), (GSourceFunc) on_animation_frame, (gpointer) &animation_object); + } + } - #endif + #elif GTK_CHECK_VERSION(3, 0, 0) || GTK_CHECK_VERSION(2, 6, 0) - //name - #if GTK_CHECK_VERSION(3, 0, 0) || GTK_CHECK_VERSION(2, 12, 0) - gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(mate_about_dialog), gettext(program_name)); - #else - gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(mate_about_dialog), gettext(program_name)); - #endif + gtk_about_dialog_set_logo_icon_name(mate_about_dialog, icon); - // version - gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(mate_about_dialog), version); + #else - // creditos y pagina web - gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(mate_about_dialog), copyright); - gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(mate_about_dialog), website); + GtkIconTheme* icon_theme = gtk_icon_theme_get_default(); - /** - * This generate a random message. - * The comments index must not be more than comments_count - 1 - */ - gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(mate_about_dialog), gettext(comments_array[g_random_int_range(0, comments_count - 1)])); + if (gtk_icon_theme_has_icon(icon_theme, icon)) + { + GdkPixbuf* pixbuf = gtk_icon_theme_load_icon(icon_theme, icon, 64, 0, NULL); + gtk_about_dialog_set_logo(mate_about_dialog, pixbuf); + g_object_unref(pixbuf); + } - // autores - gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(mate_about_dialog), authors); - // I comment this because the list is empty - gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(mate_about_dialog), artists); - gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(mate_about_dialog), documenters); + #endif - #if GTK_CHECK_VERSION(3, 0, 0) - gtk_about_dialog_set_license_type(GTK_ABOUT_DIALOG(mate_about_dialog), GTK_LICENSE_GPL_3_0); - gtk_about_dialog_set_wrap_license(GTK_ABOUT_DIALOG(mate_about_dialog), TRUE); - #endif + //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 + gtk_about_dialog_set_name(mate_about_dialog, gettext(program_name)); + #endif - #ifdef USE_UNIQUE - unique_app_watch_window(mate_about_application, GTK_WINDOW(mate_about_dialog)); - #elif GTK_CHECK_VERSION(3, 0, 0) && !defined(UNIQUE) - gtk_window_set_application(GTK_WINDOW(mate_about_dialog), mate_about_application); - #endif + // version + gtk_about_dialog_set_version(mate_about_dialog, version); + + // creditos y pagina web + gtk_about_dialog_set_copyright(mate_about_dialog, copyright); + gtk_about_dialog_set_website(mate_about_dialog, website); - // start and destroy - gtk_dialog_run(GTK_DIALOG(mate_about_dialog)); - gtk_widget_destroy(mate_about_dialog); -} - -void mate_about_release_version(void) -{ - g_printf("%s %s\n", gettext(program_name), version); -} - -// ... -gint main(gint argc, gchar** argv) -{ - gint status = 0; - /** - * Solo utilizado para option parse - */ - GError* error = NULL; - - /* 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(); - /** - * 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, &error); - - /** - * Not necesary at all, program just run and die. - * But it free a little memory. - */ - g_option_context_free(context); - - gtk_init(&argc, &argv); - - if (mate_about_nogui == TRUE) - { - mate_about_release_version(); - } - else - { /** - * Ejemplos tomados de: - * http://developer.gnome.org/gtk3/3.0/gtk-migrating-GtkApplication.html + * This generate a random message. + * The comments index must not be more than comments_count - 1 */ - #if defined(UNIQUE) + gtk_about_dialog_set_comments(mate_about_dialog, gettext(comments_array[g_random_int_range(0, comments_count - 1)])); - mate_about_application = unique_app_new("org.mate.about", NULL); + // 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); - if (unique_app_is_running(mate_about_application)) - { - UniqueResponse response = unique_app_send_message(mate_about_application, UNIQUE_ACTIVATE, NULL); + #if GTK_CHECK_VERSION(3, 0, 0) + gtk_about_dialog_set_license_type(mate_about_dialog, GTK_LICENSE_GPL_3_0); + gtk_about_dialog_set_wrap_license(mate_about_dialog, TRUE); + #endif + + #ifdef USE_UNIQUE + unique_app_watch_window(mate_about_application, (GtkWindow*) mate_about_dialog); + #elif GTK_CHECK_VERSION(3, 0, 0) && !defined(UNIQUE) + gtk_window_set_application(GTK_WINDOW(mate_about_dialog), mate_about_application); + #endif + + // start and destroy + gtk_dialog_run((GtkDialog*) mate_about_dialog); + gtk_widget_destroy((GtkWidget*) mate_about_dialog); + } + + int main(int argc, char** argv) + { + int status = 0; - if (response != UNIQUE_RESPONSE_OK) + /* 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(); + /* 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) + { + printf("%s %s\n", gettext(program_name), version); + } + else + { + gtk_init(&argc, &argv); + + /** + * Ejemplos tomados de: + * http://developer.gnome.org/gtk3/3.0/gtk-migrating-GtkApplication.html + */ + #ifdef USE_UNIQUE + + mate_about_application = unique_app_new("org.mate.about", NULL); + + if (unique_app_is_running(mate_about_application)) { - status = 1; + UniqueResponse response = unique_app_send_message(mate_about_application, UNIQUE_ACTIVATE, NULL); + + if (response != UNIQUE_RESPONSE_OK) + { + status = 1; + } + } + else + { + mate_about_run(); } - } - else - { - mate_about_run(); - } - //g_object_unref(mate_about_application); + #elif GTK_CHECK_VERSION(3, 0, 0) && !defined(USE_UNIQUE) - #elif GTK_CHECK_VERSION(3, 0, 0) && !defined(USE_UNIQUE) + mate_about_application = gtk_application_new("org.mate.about", 0); + g_signal_connect(mate_about_application, "activate", G_CALLBACK(mate_about_on_activate), NULL); - mate_about_application = gtk_application_new("org.mate.about", 0); - g_signal_connect(mate_about_application, "activate", G_CALLBACK(mate_about_on_activate), NULL); + status = g_application_run(G_APPLICATION(mate_about_application), argc, argv); - status = g_application_run(G_APPLICATION(mate_about_application), argc, argv); + g_object_unref(mate_about_application); - g_object_unref(mate_about_application); + #elif GLIB_CHECK_VERSION(2, 26, 0) && !defined(USE_UNIQUE) - #elif GLIB_CHECK_VERSION(2, 26, 0) && !defined(USE_UNIQUE) + mate_about_application = g_application_new("org.mate.about", G_APPLICATION_FLAGS_NONE); + g_signal_connect(mate_about_application, "activate", G_CALLBACK(mate_about_on_activate), NULL); - mate_about_application = g_application_new("org.mate.about", G_APPLICATION_FLAGS_NONE); - g_signal_connect(mate_about_application, "activate", G_CALLBACK(mate_about_on_activate), NULL); + status = g_application_run(G_APPLICATION(mate_about_application), argc, argv); - status = g_application_run(G_APPLICATION(mate_about_application), argc, argv); + g_object_unref(mate_about_application); - g_object_unref(mate_about_application); + #else + mate_about_run(); + #endif + } - #else - mate_about_run(); - #endif + return status; } - - return status; -} +//} #endif diff --git a/mate-about/mate-about.h b/mate-about/mate-about.h index fdbb144..86a9812 100644 --- a/mate-about/mate-about.h +++ b/mate-about/mate-about.h @@ -23,17 +23,15 @@ #include <gtk/gtk.h> #include <libintl.h> // for gettext - - #include <config.h> // autogenerated by ./configure #ifdef USE_UNIQUE #include <unique/unique.h> #endif -//mate-about +//class mate_about //{ - const char* program_name = "MATE Desktop Environment"; // MATE @PACKAGE_NAME@ + const char* program_name = "MATE Desktop Environment"; const char* version = PACKAGE_VERSION; const char* icon = "desktop"; const char* website = "http://www.matsusoft.com.ar/projects/mate/"; @@ -42,11 +40,9 @@ "Copyright © 1997-2011 GNOME developers\n" "Copyright © 2011 Perberos"; // egoista! - /** - * Incrementar el valor de comments_count si se desea agregar nuevos valores + /* 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. - */ + * indice de la cadena. */ const int comments_count = 6; const char* comments_array[] = { "MATE also includes a complete development platform for applications " @@ -609,22 +605,25 @@ }; // documentacion - const gchar* documenters[] = { + const char* documenters[] = { "...", // TODO: fillme NULL }; // artistas - const gchar* artists[] = { + const char* artists[] = { "...", // TODO: fillme NULL }; // widget de la unica ventana - GtkWidget* mate_about_dialog = FALSE; + GtkAboutDialog* mate_about_dialog = FALSE; // libunique thing #ifdef USE_UNIQUE - UniqueApp* mate_about_application; + //extern UniqueApp* unique; + //UniqueApp* unique = NULL; + extern UniqueApp* mate_about_application; + UniqueApp* mate_about_application = NULL; #elif GTK_CHECK_VERSION(3, 0, 0) GtkApplication* mate_about_application; #elif GLIB_CHECK_VERSION(2, 26, 0) diff --git a/mate-about/nyan-cat_navideno_v3.png b/mate-about/nyan-cat_navideno_v3.png Binary files differnew file mode 100644 index 0000000..69e35ef --- /dev/null +++ b/mate-about/nyan-cat_navideno_v3.png |