2013-01-23 17:28:19 +00:00
#!/usr/bin/env gjs-console
/ *
* Copyright ( C ) 2012 Red Hat , Inc .
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation ; either version 2 of the
* License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful , but
* WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
* /
const Gdk = imports . gi . Gdk ;
const GdkPixbuf = imports . gi . GdkPixbuf ;
const Gio = imports . gi . Gio ;
const GLib = imports . gi . GLib ;
const Gtk = imports . gi . Gtk ;
const Lang = imports . lang ;
const Pango = imports . gi . Pango ;
const Gettext = imports . gettext ;
const _ = imports . gettext . gettext ;
const LOCALE _DIR = '/usr/share/locale' ;
let anacondaApp = null ;
function makeLabel ( label , button ) {
let widget = new Gtk . Label ( ) ;
if ( button )
2015-03-23 11:36:12 +00:00
widget . set _markup ( '<b><span size="x-large">' + label + '</span></b>' ) ;
2013-01-23 17:28:19 +00:00
else {
widget . set _line _wrap ( true ) ;
widget . set _justify ( Gtk . Justification . CENTER ) ;
widget . set _margin _top ( 32 ) ;
widget . set _margin _bottom ( 32 ) ;
2015-03-23 11:36:12 +00:00
widget . set _markup ( '<span size="large">' + label + '</span>' ) ;
2013-01-23 17:28:19 +00:00
}
return widget ;
}
const WelcomeWindow = new Lang . Class ( {
Name : 'WelcomeWindow' ,
_init : function ( application ) {
this . window = new Gtk . ApplicationWindow ( { application : application ,
type : Gtk . WindowType . TOPLEVEL ,
default _width : 600 ,
default _height : 550 ,
2015-03-23 11:36:12 +00:00
skip _taskbar _hint : true ,
2013-01-23 17:28:19 +00:00
title : _ ( "Welcome to Fedora" ) ,
window _position : Gtk . WindowPosition . CENTER } ) ;
this . window . connect ( 'key-press-event' , Lang . bind ( this ,
function ( w , event ) {
let key = event . get _keyval ( ) [ 1 ] ;
if ( key == Gdk . KEY _Escape )
this . window . destroy ( ) ;
return false ;
} ) ) ;
let mainGrid = new Gtk . Grid ( { orientation : Gtk . Orientation . VERTICAL ,
row _spacing : 16 ,
vexpand : true ,
hexpand : true ,
halign : Gtk . Align . CENTER ,
valign : Gtk . Align . CENTER } ) ;
this . window . add ( mainGrid ) ;
let buttonBox = new Gtk . Grid ( { orientation : Gtk . Orientation . HORIZONTAL ,
column _spacing : 16 ,
halign : Gtk . Align . CENTER } ) ;
mainGrid . add ( buttonBox ) ;
let tryContent = new Gtk . Box ( { orientation : Gtk . Orientation . VERTICAL ,
spacing : 16 } ) ;
2015-03-23 11:36:12 +00:00
tryContent . add ( new Gtk . Image ( { icon _name : 'media-optical' ,
2013-01-23 17:28:19 +00:00
pixel _size : 256 } ) ) ;
tryContent . add ( makeLabel ( _ ( "Try Fedora" ) , true ) ) ;
let tryButton = new Gtk . Button ( { child : tryContent } ) ;
buttonBox . add ( tryButton ) ;
let installContent = new Gtk . Box ( { orientation : Gtk . Orientation . VERTICAL ,
spacing : 16 } ) ;
// provided by the 'fedora-logos' package
2015-03-23 11:36:12 +00:00
installContent . add ( new Gtk . Image ( { icon _name : 'anaconda' ,
pixel _size : 256 } ) ) ;
2013-01-23 17:28:19 +00:00
installContent . add ( makeLabel ( anacondaApp . get _name ( ) , true ) ) ;
let installButton = new Gtk . Button ( { child : installContent } ) ;
buttonBox . add ( installButton ) ;
this . _label = makeLabel ( _ ( "You are currently running Fedora from live media.\nYou can install Fedora now, or choose \"Install to Hard Drive\" in the Activities Overview at any later time." ) , false ) ;
mainGrid . add ( this . _label ) ;
installButton . connect ( 'clicked' , Lang . bind ( this ,
function ( ) {
GLib . spawn _command _line _async ( 'liveinst' ) ;
this . window . destroy ( ) ;
} ) ) ;
tryButton . connect ( 'clicked' , Lang . bind ( this ,
function ( ) {
buttonBox . destroy ( ) ;
this . _label . destroy ( ) ;
let image = new Gtk . Image ( { file : '/usr/share/anaconda/gnome/install-button.png' ,
halign : Gtk . Align . CENTER } ) ;
mainGrid . add ( image ) ;
this . _label = makeLabel ( _ ( "You can choose \"Install to Hard Drive\"\nin the Activities Overview at any later time." ) , false ) ;
mainGrid . add ( this . _label ) ;
let closeLabel = makeLabel ( _ ( "Close" ) , true ) ;
closeLabel . margin = 10 ;
let button = new Gtk . Button ( { child : closeLabel ,
halign : Gtk . Align . CENTER } ) ;
button . connect ( 'clicked' , Lang . bind ( this ,
function ( ) {
this . window . destroy ( ) ;
} ) ) ;
mainGrid . add ( button ) ;
mainGrid . show _all ( ) ;
} ) ) ;
}
} ) ;
Gettext . bindtextdomain ( 'anaconda' , LOCALE _DIR ) ;
Gettext . textdomain ( 'anaconda' ) ;
GLib . set _prgname ( 'fedora-welcome' ) ;
Gtk . init ( null , null ) ;
Gtk . Settings . get _default ( ) . gtk _application _prefer _dark _theme = true ;
// provided by the 'anaconda' package
anacondaApp = Gio . DesktopAppInfo . new ( 'anaconda.desktop' ) ;
if ( ! anacondaApp )
anacondaApp = Gio . DesktopAppInfo . new ( 'liveinst.desktop' ) ;
if ( anacondaApp ) {
let application = new Gtk . Application ( { application _id : 'org.fedoraproject.welcome-screen' ,
flags : Gio . ApplicationFlags . FLAGS _NONE } ) ;
let welcomeWindow = null ;
application . connect ( 'startup' , Lang . bind ( this ,
function ( ) {
welcomeWindow = new WelcomeWindow ( application ) ;
} ) ) ;
application . connect ( 'activate' , Lang . bind ( this ,
function ( ) {
welcomeWindow . window . show _all ( ) ;
} ) ) ;
application . run ( ARGV ) ;
}