Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

splash.cpp File Reference

#include <gtk/gtk.h>
#include "splash.h"
#include "common.h"

Include dependency graph for splash.cpp:

Go to the source code of this file.

Functions

void splashEnd (SplashData *ss)
static gboolean splashExpose (GtkWidget *win, GdkEventExpose *event, SplashData *ss)
void splashSetText (SplashData *ss, const char *text)
SplashDatasplashStart (AppData *app, gboolean showSplash)


Function Documentation

void splashEnd SplashData ss  ) 
 

Definition at line 107 of file splash.cpp.

References _SplashData::notifier.

Referenced by main().

00108 {
00109         if (ss->splash)
00110                 gtk_widget_destroy(ss->splash);
00111 
00112         /* Return the cursor from wait to normal */
00113         gdk_notify_startup_complete();
00114 
00115         delete ss->notifier;
00116         g_free(ss);
00117 }

static gboolean splashExpose GtkWidget *  win,
GdkEventExpose *  event,
SplashData ss
[static]
 

Definition at line 138 of file splash.cpp.

Referenced by splashStart().

00139 {
00140         /* All of this code is only needed at the very first drawing. This
00141          * operation is quite expensive. */
00142         if (ss->redraw != TRUE) return FALSE;
00143 
00144         if (ss->hasARGB)
00145         {
00146                 #ifdef CAIRO
00147                 /* Use cairo for true transparent windows */
00148                 cairo_t *cr = gdk_cairo_create(win->window);    
00149         
00150                 cairo_rectangle(cr, event->area.x,
00151                                     event->area.y,
00152                                     event->area.width,
00153                                     event->area.height);
00154                 cairo_clip(cr);
00155         
00156                 /* Draw a fully transparent rectangle the size of the window */
00157                 cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.0);
00158         
00159                 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
00160                 cairo_paint(cr);
00161         
00162                 cairo_destroy(cr);
00163                 #endif /* CAIRO */
00164         }
00165         else
00166         {
00167                 /* Fall back to compositing a screenshot of whatever is below the
00168                  * area we are drawing in. */
00169                 GdkPixbuf* bg;
00170                 int x, y, w, h;
00171 
00172                 gdk_window_get_root_origin(win->window, &x, &y);
00173                 gdk_drawable_get_size(win->window, &w, &h);
00174 
00175                 bg = gdk_pixbuf_get_from_drawable(NULL,
00176                                                   gtk_widget_get_root_window(win),
00177                                                   NULL, x, y, 0, 0, w, h);
00178                 gdk_draw_pixbuf(win->window, NULL, bg, 0, 0, 0, 0, w, h,
00179                                 GDK_RGB_DITHER_NONE, 0, 0);
00180         }
00181         
00182         /* Never redraw again */
00183         ss->redraw = FALSE;
00184 
00185         return FALSE;
00186 }

void splashSetText SplashData ss,
const char *  text
 

Definition at line 121 of file splash.cpp.

Referenced by main(), and GtkSplashProgressNotifier::update().

00122 {
00123         char message[255];
00124 
00125         if (!ss->splash)
00126                 return;
00127 
00128         sprintf(message, "Version " VERSION "\n%s", text);
00129 
00130         gtk_label_set_text(GTK_LABEL(ss->label), message);
00131 
00132         /* Update the GTK event queue */
00133         while (gtk_events_pending()) gtk_main_iteration();
00134 }

SplashData* splashStart AppData app,
gboolean  showSplash
 

Definition at line 44 of file splash.cpp.

References _SplashData::app, _SplashData::hasARGB, _SplashData::label, _SplashData::notifier, _SplashData::redraw, _SplashData::splash, and splashExpose().

Referenced by main().

00045 {
00046         SplashData* ss = g_new0(SplashData, 1);
00047 
00048         ss->app = app;
00049         ss->notifier = new GtkSplashProgressNotifier(ss);
00050         ss->hasARGB = FALSE;
00051         ss->redraw = TRUE;
00052 
00053         /* Continue the "wait" cursor until the splash is done */
00054         gtk_window_set_auto_startup_notification(FALSE);
00055         
00056         /* Don't do anything else if the splash is not to be shown */
00057         if (showSplash == FALSE) return ss;
00058 
00059         ss->splash = gtk_window_new(GTK_WINDOW_POPUP);
00060         gtk_window_set_position(GTK_WINDOW(ss->splash), GTK_WIN_POS_CENTER);
00061         gtk_widget_set_app_paintable(ss->splash, TRUE);
00062 
00063         #ifdef CAIRO
00064         /* Colormap Magic */
00065         GdkScreen* screen = gtk_widget_get_screen(ss->splash);
00066         GdkColormap* colormap = gdk_screen_get_rgba_colormap(screen);
00067         if (colormap != NULL)
00068         {
00069                 gtk_widget_set_colormap(ss->splash, colormap);
00070                 ss->hasARGB = TRUE;
00071         }
00072         #endif
00073 
00074         GtkWidget* gf = gtk_fixed_new();
00075         gtk_container_add(GTK_CONTAINER(ss->splash), gf);
00076 
00077         GtkWidget* i = gtk_image_new_from_file("splash/splash.png");
00078         gtk_fixed_put(GTK_FIXED(gf), i, 0, 0);
00079 
00080         /* The information label is right-aligned and biased to the lower-right
00081          * of the window. It's designed to be the full width and height of the
00082          * opaque parts of the splash. */
00083         ss->label = gtk_label_new(NULL);
00084         gtk_misc_set_alignment(GTK_MISC(ss->label), 1, 1);
00085         gtk_label_set_justify(GTK_LABEL(ss->label), GTK_JUSTIFY_RIGHT);
00086         gtk_widget_modify_fg(ss->label, GTK_STATE_NORMAL, &ss->label->style->white);
00087 
00088         gtk_widget_show_all(ss->splash);
00089 
00090         /* Size allocations available after showing splash. */
00091         gtk_widget_set_size_request(ss->label, i->allocation.width - 80,
00092                                                i->allocation.height / 2);
00093         gtk_fixed_put(GTK_FIXED(gf), ss->label, 40, i->allocation.height / 2 - 40);
00094         gtk_widget_show(ss->label);
00095 
00096         g_signal_connect (ss->splash, "expose_event",
00097                           G_CALLBACK (splashExpose),
00098                           ss);
00099         
00100         while (gtk_events_pending()) gtk_main_iteration();
00101 
00102         return ss;
00103 }


Generated on Sat Jan 14 22:32:03 2006 for Celestia by  doxygen 1.4.1