1 /*  dvdisaster: Additional error correction for optical media.
2  *  Copyright (C) 2004-2015 Carsten Gnoerlich.
3  *
4  *  Email: carsten@dvdisaster.org  -or-  cgnoerlich@fsfe.org
5  *  Project homepage: http://www.dvdisaster.org
6  *
7  *  This file is part of dvdisaster.
8  *
9  *  dvdisaster is free software: you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation, either version 3 of the License, or
12  *  (at your option) any later version.
13  *
14  *  dvdisaster is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #include "dvdisaster.h"
24 
25 /***
26  *** Creates the welcome window shown after startup.
27  ***/
28 
29 /*
30  * The welcome window is shown first,
31  * so it is convenient to initialize our GC when it is exposed.
32  */
33 
toggle_cb(GtkWidget * widget,gpointer data)34 static void toggle_cb(GtkWidget *widget, gpointer data)
35 {  int state  = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
36 
37    Closure->welcomeMessage = state;
38 }
39 
expose_cb(GtkWidget * widget,GdkEventExpose * event,gpointer data)40 static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
41 {  GtkWidget *box = (GtkWidget*)data;
42 
43    if(!Closure->drawGC)
44    {  GdkColor *bg = &widget->style->bg[0];
45       GdkColormap *cmap = gdk_colormap_get_system();
46 
47       Closure->drawGC = gdk_gc_new(widget->window);
48 
49       memcpy(Closure->background, bg, sizeof(GdkColor));
50 
51       gdk_colormap_alloc_color(cmap, Closure->foreground, FALSE, TRUE);
52 
53       Closure->grid->red = bg->red-bg->red/8;
54       Closure->grid->green = bg->green-bg->green/8;
55       Closure->grid->blue = bg->blue-bg->blue/8;
56       gdk_colormap_alloc_color(cmap, Closure->grid, FALSE, TRUE);
57 
58       /* This can't be done at closure.c */
59 
60       gdk_colormap_alloc_color(cmap, Closure->redText, FALSE, TRUE);
61       gdk_colormap_alloc_color(cmap, Closure->greenText, FALSE, TRUE);
62       gdk_colormap_alloc_color(cmap, Closure->barColor, FALSE, TRUE);
63       gdk_colormap_alloc_color(cmap, Closure->logColor, FALSE, TRUE);
64       gdk_colormap_alloc_color(cmap, Closure->curveColor, FALSE, TRUE);
65       gdk_colormap_alloc_color(cmap, Closure->redSector, FALSE, TRUE);
66       gdk_colormap_alloc_color(cmap, Closure->yellowSector, FALSE, TRUE);
67       gdk_colormap_alloc_color(cmap, Closure->greenSector, FALSE, TRUE);
68       gdk_colormap_alloc_color(cmap, Closure->blueSector, FALSE, TRUE);
69       gdk_colormap_alloc_color(cmap, Closure->whiteSector, FALSE, TRUE);
70       gdk_colormap_alloc_color(cmap, Closure->darkSector, FALSE, TRUE);
71 
72       /* Dirty trick for indenting the list:
73 	 draw an invisible dash before each indented line */
74 
75       if(Closure->welcomeMessage || Closure->version != Closure->dotFileVersion)
76       {  GtkWidget *button;
77 
78 	 Closure->invisibleDash = g_strdup_printf("<span color=\"#%02x%02x%02x\">-</span>",
79 						  bg->red>>8, bg->green>>8, bg->blue>>8);
80 	 AboutText(box, _("- New multithreaded codec (RS03)."));
81 	 AboutText(box, _("- Completely reworked online manual."));
82 	 AboutText(box, _("- Switched license to GPLv3.\n"));
83 
84 	 AboutText(box, _("<i>Please note:</i>\n"
85 			  "Adaptive reading is <span color=\"#800000\">unavailable</span> in this version.\n"
86 			  "It will be re-introduced in one of the next releases."));
87 
88 	 gtk_box_pack_start(GTK_BOX(box), gtk_hseparator_new(), FALSE, FALSE, 10);
89 
90 	 button = gtk_check_button_new_with_label(_utf("Show this message again"));
91 	 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), Closure->welcomeMessage);
92 	 g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(toggle_cb), NULL);
93 	 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
94 
95 	 gtk_widget_show_all(box);
96       }
97    }
98 
99    Closure->dotFileVersion = Closure->version;
100 
101    return FALSE;
102 }
103 
104 /*
105  * Create the window
106  */
107 
CreateWelcomePage(GtkNotebook * notebook)108 void CreateWelcomePage(GtkNotebook *notebook)
109 {  GtkWidget *box,*align,*ignore;
110    int show_msg;
111 
112    show_msg = Closure->welcomeMessage || Closure->version != Closure->dotFileVersion;
113 
114    align = gtk_alignment_new(0.5, 0.5, 0.0, 0.0);
115    ignore = gtk_label_new("welcome_tab");
116    box = show_msg ? gtk_vbox_new(FALSE, 0) : gtk_hbox_new(FALSE, 10);
117 
118    g_signal_connect(G_OBJECT(align), "expose_event", G_CALLBACK(expose_cb), box);
119    gtk_notebook_append_page(notebook, align, ignore);
120 
121    gtk_container_add(GTK_CONTAINER(align), box);
122 
123    if(!show_msg)
124      {  return;  // simply leave the window blank
125 #if 0            // would print a centered dvdisaster logo
126       GtkWidget *widget;
127 
128       widget  = gtk_image_new_from_stock("dvdisaster-create", GTK_ICON_SIZE_LARGE_TOOLBAR);
129       gtk_box_pack_start(GTK_BOX(box), widget, FALSE, FALSE, 0);
130 
131       AboutText(box, "<span weight=\"bold\" size=\"xx-large\">dvdisaster</span>");
132       return;
133 #endif
134    }
135 
136    AboutText(box, _("<span weight=\"bold\" size=\"xx-large\">Welcome to dvdisaster!</span>"));
137 
138    AboutText(box, _("\ndvdisaster creates error correction data to protect\n"
139 		    "optical media (CD,DVD,BD) against data loss.\n"));
140 
141    AboutTextWithLink(box, _("Please see the [manual] for typical uses of dvdisaster.\n\n"),
142 		     "manual.pdf");
143 
144    AboutText(box, _("<i>New in this Version:</i>"));
145 
146    /* actual list is generated in the expose event handler */
147 
148 }
149 
150