splash.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <sys/ioctl.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include "log.h"
#include "i18n.h"
#include "dialog.h"
Include dependency graph for splash.c:

Go to the source code of this file.

Defines

#define LOGGING_ON   1

Functions

static gboolean on_splash_expose (GtkWidget *widget, GdkEventExpose *event, gpointer data)
static void change_splash (const char *filename, const char *title, const char *message)
static void create_splash ()
static gboolean on_timeout (gpointer data)
int main (int argc, char *argv[])

Variables

static GtkWidget * splash_window = NULL
static GtkWidget * splash_title = NULL
static GtkWidget * splash_message = NULL
static GdkPixbuf * splash_pixbuf = NULL

Define Documentation

#define LOGGING_ON   1

Copyright (C) 2010 IREX Technologies B.V. All rights reserved.

Definition at line 27 of file splash.c.


Function Documentation

static void change_splash ( const char *  filename,
const char *  title,
const char *  message 
) [static]

Definition at line 99 of file splash.c.

References LOGPRINTF, splash_message, splash_pixbuf, splash_title, and splash_window.

Referenced by main(), and on_timeout().

00100 {
00101     LOGPRINTF("entry");
00102     
00103     if (splash_pixbuf) g_object_unref(splash_pixbuf);
00104     splash_pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
00105     gtk_widget_show_all(splash_window);
00106     
00107     gtk_label_set_text(GTK_LABEL(splash_title), title);
00108     gtk_label_set_text(GTK_LABEL(splash_message), message);
00109     
00110     GdkRectangle rect;
00111     rect.x = 0;
00112     rect.y = 0;
00113     rect.width  = 1024;
00114     rect.height = 1268;
00115 
00116     gdk_window_invalidate_rect(splash_window->window, &rect, TRUE);
00117 }

Here is the caller graph for this function:

static void create_splash ( void   )  [static]

Definition at line 120 of file splash.c.

References LOGPRINTF, on_splash_expose(), splash_message, splash_title, splash_window, and widget.

Referenced by main().

00121 {
00122     LOGPRINTF("entry");
00123     
00124     GtkWidget *window     = NULL;
00125     GtkWidget *widget     = NULL;
00126     GtkBox    *vbox       = NULL;
00127     GtkWidget *alignment  = NULL;
00128 
00129     // object hierarchy:
00130     //    
00131     // window
00132     //  |
00133     widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00134     window = widget;
00135     splash_window = GTK_WIDGET(widget);
00136     gtk_window_set_resizable(GTK_WINDOW(splash_window), FALSE);
00137     gtk_window_fullscreen(GTK_WINDOW(splash_window)); 
00138     gtk_window_set_type_hint(GTK_WINDOW(splash_window), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
00139     gtk_widget_set_app_paintable(splash_window, TRUE); 
00140 
00141 #if MACHINE_IS_DR800SG || MACHINE_IS_DR800S || MACHINE_IS_DR800SW
00142     //    |--alignment
00143     //       |
00144     widget = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
00145     gtk_alignment_set_padding(GTK_ALIGNMENT(widget),
00146             TEXT_TOP_PADDING,
00147             TEXT_BOTTOM_PADDING,
00148             TEXT_LEFT_PADDING,
00149             TEXT_RIGHT_PADDING);
00150     gtk_container_add(GTK_CONTAINER(window), widget);
00151     gtk_widget_show(widget);
00152     alignment = widget;
00153     //       |
00154     //       |-- vbox
00155     //             |
00156     widget = gtk_vbox_new(FALSE, 0);
00157     gtk_container_add(GTK_CONTAINER(alignment), widget);
00158     gtk_widget_show(widget);
00159     vbox = GTK_BOX(widget);   
00160 #elif MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00161     //       |
00162     //       |-- vbox
00163     //             |
00164     widget = gtk_vbox_new(FALSE, 0);
00165     gtk_container_add(GTK_CONTAINER(window), widget);
00166     gtk_widget_show(widget);
00167     vbox = GTK_BOX(widget);   
00168     //             |
00169     //             |-- alignment (filler)
00170     //             |    
00171     widget = gtk_alignment_new(0.0, 0.0, 0.0, 0.0);
00172     gtk_box_pack_start(vbox, widget, TRUE, TRUE, 0);
00173     gtk_widget_show(widget);
00174 #else
00175 #error "Unhandled machine type"
00176 #endif     
00177     //             |
00178     //             |-- alignment
00179     //             |     |
00180     widget = gtk_alignment_new(0.5, 0.5, 0.5, 0.5);
00181     gtk_alignment_set_padding( GTK_ALIGNMENT(widget),
00182                                TITLE_TOP_PADDING,
00183                                TITLE_BOTTOM_PADDING,
00184                                TITLE_LEFT_PADDING,
00185                                TITLE_RIGHT_PADDING);
00186     gtk_box_pack_start(vbox, widget, FALSE, FALSE, 0);
00187     gtk_widget_show(widget);
00188     alignment = widget;
00189     
00190     //             |     |    
00191     //             |     |-- title
00192     //             |        
00193     widget = gtk_label_new(NULL);
00194 #if MACHINE_IS_DR800SG || MACHINE_IS_DR800S || MACHINE_IS_DR800SW
00195     int LABEL_WIDTH = 768 - TEXT_LEFT_PADDING - TEXT_RIGHT_PADDING 
00196                           - TITLE_LEFT_PADDING - TITLE_RIGHT_PADDING; 
00197     gtk_widget_set_size_request(widget, LABEL_WIDTH, -1);
00198     gtk_label_set_justify(GTK_LABEL(widget), GTK_JUSTIFY_CENTER);
00199     gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
00200 #endif    
00201     gtk_widget_set_name(widget, "irex-splash-title");
00202     gtk_container_add(GTK_CONTAINER(alignment), widget);
00203     gtk_widget_show(widget);
00204     splash_title = widget;
00205 
00206     //             |
00207     //             |-- alignment
00208     //                   |
00209     widget = gtk_alignment_new(0.5, 0.5, 0.5, 0.5);
00210     gtk_alignment_set_padding( GTK_ALIGNMENT(widget),
00211                                MESSAGE_TOP_PADDING,
00212                                MESSAGE_BOTTOM_PADDING,
00213                                MESSAGE_LEFT_PADDING,
00214                                MESSAGE_RIGHT_PADDING);
00215     gtk_box_pack_start(vbox, widget, FALSE, FALSE, 0);
00216     gtk_widget_show(widget);
00217     alignment = widget;
00218     
00219     //                   |    
00220     //                   |-- message
00221     //                     
00222     widget = gtk_label_new(NULL);
00223 #if MACHINE_IS_DR800SG || MACHINE_IS_DR800S || MACHINE_IS_DR800SW
00224     LABEL_WIDTH = 768 - TEXT_LEFT_PADDING - TEXT_RIGHT_PADDING 
00225                       - MESSAGE_LEFT_PADDING - MESSAGE_RIGHT_PADDING; 
00226     gtk_widget_set_size_request(widget, LABEL_WIDTH, -1);
00227 #elif MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00228     gtk_widget_set_size_request(widget, 1024, -1);
00229 #else
00230 #error "Unhandled machine type"
00231 #endif    
00232     gtk_widget_set_name(widget, "irex-splash-message");
00233     gtk_label_set_justify(GTK_LABEL(widget), GTK_JUSTIFY_CENTER);
00234     gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
00235     gtk_container_add(GTK_CONTAINER(alignment), widget);
00236     gtk_widget_show(widget);   
00237     splash_message = widget;
00238 
00239     // force non-decorated full screen splash
00240     gint w, h;
00241     gdk_window_get_geometry(gdk_get_default_root_window(), NULL, NULL, &w, &h, NULL);
00242     gtk_widget_set_size_request(splash_window, w,  h);
00243     
00244     g_signal_connect(GTK_OBJECT(splash_window), "expose_event", G_CALLBACK (on_splash_expose), NULL);
00245 }

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Definition at line 256 of file splash.c.

References change_splash(), create_splash(), GETTEXT_PACKAGE, LOGPRINTF, and on_timeout().

00257 {
00258     LOGPRINTF("entry");
00259     
00260     // init domain for translations
00261     textdomain(GETTEXT_PACKAGE);
00262 
00263     // Initialise
00264     gtk_init(&argc, &argv);
00265 
00266     create_splash();
00267     change_splash("/usr/share/popupmenu/background_usbconnect.png", "First splash", "Next in a few seconds");
00268 
00269     g_timeout_add_seconds(4, on_timeout, NULL);
00270     
00271     gtk_main();
00272     
00273     return 0;
00274 }

Here is the call graph for this function:

static gboolean on_splash_expose ( GtkWidget *  widget,
GdkEventExpose *  event,
gpointer  data 
) [static]

Definition at line 83 of file splash.c.

References LOGPRINTF, and splash_pixbuf.

Referenced by create_splash().

00086 { 
00087     LOGPRINTF("entry [%p]", splash_pixbuf);
00088     gdk_draw_pixbuf(widget->window, NULL, splash_pixbuf, 0, 0, 0, 0, -1, -1, GDK_RGB_DITHER_MAX, 0, 0);
00089     
00090     GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget));
00091     if (child)
00092     {
00093         gtk_container_propagate_expose(GTK_CONTAINER(widget), child, event);
00094     }
00095     return TRUE;
00096 }

Here is the caller graph for this function:

static gboolean on_timeout ( gpointer  data  )  [static]

Definition at line 248 of file splash.c.

References change_splash(), and LOGPRINTF.

Referenced by main().

00249 {
00250     LOGPRINTF("entry");
00251     change_splash("/usr/share/popupmenu/background_general.png", "Second splash", "Break to exit");
00252     return FALSE;
00253 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

GtkWidget* splash_message = NULL [static]

Definition at line 79 of file splash.c.

Referenced by change_splash(), and create_splash().

GdkPixbuf* splash_pixbuf = NULL [static]

Definition at line 80 of file splash.c.

Referenced by change_splash(), and on_splash_expose().

GtkWidget* splash_title = NULL [static]

Definition at line 78 of file splash.c.

Referenced by change_splash(), and create_splash().

GtkWidget* splash_window = NULL [static]

Definition at line 77 of file splash.c.

Referenced by change_splash(), and create_splash().

Generated by  doxygen 1.6.2-20100208