Back to index

gcompris  8.2.2
about.c
Go to the documentation of this file.
00001 /* gcompris - about.c
00002  *
00003  * Time-stamp: <2006/08/21 23:27:24 bruno>
00004  *
00005  * Copyright (C) 2000 Bruno Coudoin
00006  *
00007  *   This program is free software; you can redistribute it and/or modify
00008  *   it under the terms of the GNU General Public License as published by
00009  *   the Free Software Foundation; either version 2 of the License, or
00010  *   (at your option) any later version.
00011  *
00012  *   This program is distributed in the hope that it will be useful,
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *   GNU General Public License for more details.
00016  *
00017  *   You should have received a copy of the GNU General Public License
00018  *   along with this program; if not, write to the Free Software
00019  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  */
00021 
00026 #include "gcompris.h"
00027 #include "about.h"
00028 #include <string.h>
00029 
00030 static GnomeCanvasItem      *rootitem            = NULL;
00031 static GnomeCanvasItem      *plane_item          = NULL;
00032 static GdkPixbuf     *pixmap_about        = NULL;
00033 static gint           move_plane_id              = 0;
00034 static gint           plane_x             = 0;
00035 static gint           plane_y             = 0;
00036 static gint           plane_speed         = 0;
00037 
00038 static gboolean is_displayed                     = FALSE;
00039 
00040 
00041 static gint item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data);
00042 static gint move_plane (GtkWidget *widget, gpointer item);
00043 
00044 /*
00045  * Do all the bar display and register the events
00046  */
00047 void gc_about_start ()
00048 {
00049   GdkPixbuf   *pixmap = NULL;
00050   gint y_start = 0;
00051   gint x_start = 0;
00052   gint x_text_start = 0;
00053   gint x_flag_start = 0;
00054   gint y = 0;
00055   GnomeCanvasItem *item, *item2;
00056   static gchar *content =
00057     N_("Author: Bruno Coudoin\n"
00058        "Contribution: Pascal Georges, Jose Jorge\n"
00059        "Graphics: Renaud Blanchard, Franck Doucet\n"
00060        "Intro Music: Djilali Sebihi\n"
00061        "Background Music: Rico Da Halvarez\n"
00062        );
00063 
00064   /* TRANSLATORS: Replace this string with your names, one name per line. */
00065   gchar *translators = _("translator_credits");
00066 
00067   /* Pause the board */
00068   gc_board_pause(TRUE);
00069 
00070   if(rootitem)
00071     return;
00072 
00073   gc_bar_hide (TRUE);
00074 
00075   rootitem = \
00076     gnome_canvas_item_new (gnome_canvas_root(gc_get_canvas()),
00077                         gnome_canvas_group_get_type (),
00078                         "x", (double)0,
00079                         "y", (double)0,
00080                         NULL);
00081 
00082   pixmap = gc_skin_pixmap_load("help_bg.png");
00083   y_start = (BOARDHEIGHT - gdk_pixbuf_get_height(pixmap))/2;
00084   x_start = (BOARDWIDTH - gdk_pixbuf_get_width(pixmap))/2;
00085   item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00086                             gnome_canvas_pixbuf_get_type (),
00087                             "pixbuf", pixmap,
00088                             "x", (double) x_start,
00089                             "y", (double) y_start,
00090                             NULL);
00091   y = BOARDHEIGHT - (BOARDHEIGHT - gdk_pixbuf_get_height(pixmap))/2;
00092   gdk_pixbuf_unref(pixmap);
00093 
00094   gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00095                       gnome_canvas_text_get_type (),
00096                       "text", _("About GCompris"),
00097                       "font", gc_skin_font_title,
00098                       "x", (double) BOARDWIDTH/2 + 1.0,
00099                       "y", (double) y_start + 40 + 1.0,
00100                       "anchor", GTK_ANCHOR_CENTER,
00101                       "fill_color_rgba", gc_skin_color_shadow,
00102                       "weight", PANGO_WEIGHT_HEAVY,
00103                       NULL);
00104   gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00105                       gnome_canvas_text_get_type (),
00106                       "text", _("About GCompris"),
00107                       "font", gc_skin_font_title,
00108                       "x", (double) BOARDWIDTH/2,
00109                       "y", (double) y_start + 40,
00110                       "anchor", GTK_ANCHOR_CENTER,
00111                       "fill_color_rgba", gc_skin_color_title,
00112                       "weight", PANGO_WEIGHT_HEAVY,
00113                       NULL);
00114 
00115   gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00116                       gnome_canvas_text_get_type (),
00117                       "text", _("Translators:"),
00118                       "font", gc_skin_font_subtitle,
00119                       "x", (double) BOARDWIDTH/2-320,
00120                       "y", (double) y_start + 90,
00121                       "anchor", GTK_ANCHOR_NORTH_WEST,
00122                       "fill_color_rgba", gc_skin_color_subtitle,
00123                       NULL);
00124 
00125   gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00126                       gnome_canvas_text_get_type (),
00127                       "text", translators,
00128                       "font", gc_skin_font_content,
00129                       "x", (double)  BOARDWIDTH/2-320,
00130                       "y", (double)  y_start + 120,
00131                       "anchor", GTK_ANCHOR_NORTH_WEST,
00132                       "fill_color_rgba", gc_skin_color_content,
00133                       NULL);
00134   // Version
00135   y_start += 100;
00136 
00137   gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00138                       gnome_canvas_text_get_type (),
00139                       "text", "GCompris V" VERSION,
00140                       "font", gc_skin_font_title,
00141                       "x", (double)  BOARDWIDTH/2,
00142                       "y", (double)  y_start,
00143                       "anchor", GTK_ANCHOR_CENTER,
00144                       "fill_color_rgba", gc_skin_color_subtitle,
00145                       NULL);
00146 
00147   y_start += 140;
00148   gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00149                       gnome_canvas_text_get_type (),
00150                       "text", gettext(content),
00151                       "font", gc_skin_font_content,
00152                       "x", (double) BOARDWIDTH/2-320,
00153                       "y", (double)  y_start,
00154                       "anchor", GTK_ANCHOR_NORTH_WEST,
00155                       "fill_color_rgba", gc_skin_color_content,
00156                       NULL);
00157 
00158   y_start += 40;
00159   // FSF Reference
00160   pixmap = gc_skin_pixmap_load("fsflogo.png");
00161   item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00162                             gnome_canvas_pixbuf_get_type (),
00163                             "pixbuf", pixmap,
00164                             "x", (double) (BOARDWIDTH*0.8) - gdk_pixbuf_get_width(pixmap)/2,
00165                             "y", (double) y_start - gdk_pixbuf_get_height(pixmap)/2,
00166                             NULL);
00167   gdk_pixbuf_unref(pixmap);
00168 
00169   item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00170                             gnome_canvas_text_get_type (),
00171                             "text", "Free Software Foundation\nhttp://www.fsf.org",
00172                             "font", gc_skin_font_content,
00173                             "x", (double)  (BOARDWIDTH*0.75),
00174                             "y", (double)  y_start + 80,
00175                             "anchor", GTK_ANCHOR_CENTER,
00176                             "fill_color_rgba", gc_skin_color_subtitle,
00177                             NULL);
00178 
00179   // GCompris Reference
00180   y_start += 80;
00181   pixmap = gc_skin_pixmap_load("gcomprislogo.png");
00182   item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00183                             gnome_canvas_pixbuf_get_type (),
00184                             "pixbuf", pixmap,
00185                             "x", (double) (BOARDWIDTH*0.3) - gdk_pixbuf_get_width(pixmap)/2 -50,
00186                             "y", (double) y_start - gdk_pixbuf_get_height(pixmap)/2,
00187                             NULL);
00188 
00189   gdk_pixbuf_unref(pixmap);
00190 
00191   item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00192                             gnome_canvas_text_get_type (),
00193                             "text", _("GCompris Home Page\nhttp://gcompris.net"),
00194                             "font", gc_skin_font_content,
00195                             "x", (double) BOARDWIDTH/2-320,
00196                             "y", (double)  y_start + 5,
00197                             "anchor", GTK_ANCHOR_NORTH_WEST,
00198                             "fill_color_rgba", gc_skin_color_subtitle,
00199                             NULL);
00200 
00201   // Copyright
00202   item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00203                             gnome_canvas_text_get_type (),
00204                             "text", "Copyright 2000-2005 Bruno Coudoin",
00205                             "font", gc_skin_font_content,
00206                             "x", (double)  BOARDWIDTH/2,
00207                             "y", (double)  y - 95,
00208                             "anchor", GTK_ANCHOR_CENTER,
00209                             "fill_color_rgba", gc_skin_color_content,
00210                             NULL);
00211 
00212   // License
00213   item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00214                             gnome_canvas_text_get_type (),
00215                             "text", _("This software is a GNU Package and is released under the GNU General Public License"),
00216                             "font", gc_skin_font_content,
00217                             "x", (double)  BOARDWIDTH/2,
00218                             "y", (double)  y - 80,
00219                             "anchor", GTK_ANCHOR_CENTER,
00220                             "fill_color_rgba", gc_skin_color_content,
00221                             NULL);
00222 
00223   /* Location for a potential sponsor */
00224   gchar *sponsor_image = gc_file_find_absolute("sponsor.png");
00225   if(sponsor_image)
00226     {
00227       gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00228                           gnome_canvas_text_get_type (),
00229                           "text", "Version parrainée par",
00230                           "font", gc_skin_font_content,
00231                           "x", (double)  BOARDWIDTH*0.85,
00232                           "y", (double)  10,
00233                           "anchor", GTK_ANCHOR_CENTER,
00234                           "fill_color_rgba", gc_skin_color_content,
00235                           NULL);
00236       gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00237                           gnome_canvas_text_get_type (),
00238                           "text", "Version parrainée par",
00239                           "font", gc_skin_font_content,
00240                           "x", (double)  BOARDWIDTH*0.85 + 1,
00241                           "y", (double)  10,
00242                           "anchor", GTK_ANCHOR_CENTER,
00243                           "fill_color", "black",
00244                           NULL);
00245 
00246       pixmap = gc_pixmap_load("sponsor.png");
00247       item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00248                                 gnome_canvas_pixbuf_get_type (),
00249                                 "pixbuf", pixmap,
00250                                 "x", (double) (BOARDWIDTH*0.85) - gdk_pixbuf_get_width(pixmap)/2,
00251                                 "y", (double) 15,
00252                                 NULL);
00253 
00254       gdk_pixbuf_unref(pixmap);
00255       g_free(sponsor_image);
00256     }
00257 
00258   // OK
00259   pixmap = gc_skin_pixmap_load("button_large.png");
00260   item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00261                             gnome_canvas_pixbuf_get_type (),
00262                             "pixbuf", pixmap,
00263                             "x", (double) BOARDWIDTH*0.5 - gdk_pixbuf_get_width(pixmap)/2,
00264                             "y", (double) y - gdk_pixbuf_get_height(pixmap) - 5,
00265                             NULL);
00266 
00267   gtk_signal_connect(GTK_OBJECT(item), "event",
00268                    (GtkSignalFunc) item_event_ok,
00269                    "ok");
00270   gtk_signal_connect(GTK_OBJECT(item), "event",
00271                    (GtkSignalFunc) gc_item_focus_event,
00272                    NULL);
00273   gdk_pixbuf_unref(pixmap);
00274 
00275 
00276   gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00277                       gnome_canvas_text_get_type (),
00278                       "text", _("OK"),
00279                       "font", gc_skin_font_title,
00280                       "x", (double)  BOARDWIDTH*0.5 + 1.0,
00281                       "y", (double)  y - gdk_pixbuf_get_height(pixmap) + 20 + 1.0,
00282                       "anchor", GTK_ANCHOR_CENTER,
00283                       "fill_color_rgba", gc_skin_color_shadow,
00284                       "weight", PANGO_WEIGHT_HEAVY,
00285                       NULL);
00286   item2 = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00287                             gnome_canvas_text_get_type (),
00288                             "text", _("OK"),
00289                             "font", gc_skin_font_title,
00290                             "x", (double)  BOARDWIDTH*0.5,
00291                             "y", (double)  y - gdk_pixbuf_get_height(pixmap) + 20,
00292                             "anchor", GTK_ANCHOR_CENTER,
00293                             "fill_color_rgba", gc_skin_color_text_button,
00294                              "weight", PANGO_WEIGHT_HEAVY,
00295                             NULL);
00296   gtk_signal_connect(GTK_OBJECT(item2), "event",
00297                    (GtkSignalFunc) item_event_ok,
00298                    "ok");
00299   gtk_signal_connect(GTK_OBJECT(item2), "event",
00300                    (GtkSignalFunc) gc_item_focus_event,
00301                    item);
00302 
00303   pixmap_about = gc_skin_pixmap_load("gcompris-about.png");
00304 
00305   plane_x = gdk_pixbuf_get_width(pixmap_about)/2;
00306   plane_y = gdk_pixbuf_get_height(pixmap_about)/2 + 40;
00307   plane_speed = 1;
00308   plane_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP(rootitem),
00309                                   gnome_canvas_pixbuf_get_type (),
00310                                   "pixbuf", pixmap_about,
00311                                   "x", (double) plane_x,
00312                                   "y", (double) plane_y,
00313                                   NULL);
00314   move_plane_id = gtk_timeout_add (500,
00315                                (GtkFunction) move_plane, NULL);
00316 
00317   x_start += 150;
00318   x_flag_start = x_start + 50;
00319   x_text_start = x_start + 120;
00320 
00321   is_displayed = TRUE;
00322 
00323 }
00324 
00325 void gc_about_stop ()
00326 {
00327   if (move_plane_id) {
00328     gtk_timeout_remove (move_plane_id);
00329     move_plane_id = 0;
00330   }
00331 
00332   // Destroy the help box
00333   if(rootitem!=NULL)
00334       gtk_object_destroy(GTK_OBJECT(rootitem));
00335   rootitem = NULL;
00336 
00337   if(pixmap_about)
00338     gdk_pixbuf_unref(pixmap_about);
00339   pixmap_about = NULL;
00340 
00341   /* UnPause the board */
00342   if(is_displayed)
00343     gc_board_pause(FALSE);
00344 
00345   gc_bar_hide (FALSE);
00346 
00347   is_displayed = FALSE;
00348 }
00349 
00350 
00351 /*-------------------------------------------------------------------------------*/
00352 /*-------------------------------------------------------------------------------*/
00353 /*-------------------------------------------------------------------------------*/
00354 /*-------------------------------------------------------------------------------*/
00355 
00356 
00357 /*
00358  * This does the moves of the game items on the play canvas
00359  *
00360  */
00361 static gint move_plane (GtkWidget *widget, gpointer data)
00362 {
00363   GcomprisBoard             *gcomprisBoard = gc_board_get_current();
00364 
00365   /* Manage the wrapping */
00366   if(plane_x>gcomprisBoard->width) {
00367     double x1, y1, x2, y2;
00368     gnome_canvas_item_get_bounds    (plane_item,
00369                                  &x1,
00370                                  &y1,
00371                                  &x2,
00372                                  &y2);
00373     gnome_canvas_item_move(plane_item, (double)-gcomprisBoard->width-(x2-x1), (double)0);
00374     plane_x = plane_x - gcomprisBoard->width - (x2-x1);
00375   }
00376 
00377   plane_x += plane_speed;
00378   gnome_canvas_item_move(plane_item, plane_speed, 0);
00379 
00380   /* Return true to be called again */
00381   return(TRUE);
00382 }
00383 
00384 /* Callback for the OK operations */
00385 static gint
00386 item_event_ok(GnomeCanvasItem *item, GdkEvent *event, gpointer data)
00387 {
00388 
00389   switch (event->type)
00390     {
00391     case GDK_ENTER_NOTIFY:
00392       break;
00393     case GDK_LEAVE_NOTIFY:
00394       break;
00395     case GDK_BUTTON_PRESS:
00396       if(!strcmp((char *)data, "ok"))
00397        {
00398          gc_about_stop();
00399        }
00400     default:
00401       break;
00402     }
00403   return FALSE;
00404 
00405 }