6643N/A#!/usr/bin/python2.7
6643N/A# -*- coding: utf-8 -*-
6643N/A
6643N/A#
6643N/A# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
6643N/A#
6643N/A# This program is free software; you can redistribute it and/or modify
6643N/A# it under the terms of the GNU General Public License as published by
6643N/A# the Free Software Foundation; either version 2 of the License, or
6643N/A# (at your option) any later version.
6643N/A#
6643N/A# This program is distributed in the hope that it will be useful,
6643N/A# but WITHOUT ANY WARRANTY; without even the implied warranty of
6643N/A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6643N/A# GNU General Public License for more details.
6643N/A#
6643N/A# You should have received a copy of the GNU General Public License
6643N/A# along with this program; if not, write to the Free Software
6643N/A# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
6643N/A
6643N/Aimport locale
6643N/Aimport gettext
6643N/Afrom gettext import gettext as _
6643N/Aimport os
7077N/Aimport socket
6643N/Aimport string
7077N/Aimport subprocess
6643N/Aimport re
6643N/A
6643N/Aimport gi
6643N/Agi.require_version('Gtk', '3.0')
6643N/Afrom gi.repository import GObject, Gtk, Gdk, GdkPixbuf, Gio
6643N/A
6643N/Adef N_(message): return message
6643N/A
6643N/APACKAGE = "os-next-steps"
6643N/AVERSION = "12"
6643N/AGETTEXT_PACKAGE = "os-welcome"
6643N/ALOCALEDIR = "/usr/share/locale"
6643N/A
6643N/Arelease_string = "Oracle Solaris 12"
6643N/A
6643N/A# There's probably a nicer way of including UTF-8 strings than this
6643N/Abullet_point = u'\u2022'
6643N/A
6643N/Adefault_link_color = Gdk.Color (0, 0, 65535)
6643N/A
7077N/A# This needs to stay in sync with the method in /lib/svc/method/svc-webui-server
7077N/A# for generating the hostname used in the site certificate to avoid TLS errors.
7077N/Adef get_solaris_dashboard_url():
7077N/A hostname = socket.gethostname()
7077N/A if hostname != '':
7077N/A p = subprocess.Popen(["/usr/sbin/host", hostname],
7077N/A stdin=None, stdout=subprocess.PIPE,
7077N/A stderr=None, shell=False, close_fds=True,
7077N/A bufsize=-1)
7077N/A (stdoutdata, stderrdata) = p.communicate()
7077N/A if p.returncode == 0:
7077N/A hostname = stdoutdata.split(' ', 1)[0]
7077N/A if hostname == '':
7077N/A hostname = "localhost"
7077N/A return "https://%s:6787/" % hostname
7077N/A
6643N/Ahelp_link= {
7183N/A 'header' : N_("Learn More about Oracle Solaris"),
6643N/A 'icon' : "resources.png",
7077N/A 'url_links' : [ ["http://docs.oracle.com/cd/E53394_01/pdf/E54847.pdf", N_("##What's new## with <b>Oracle Solaris 11.3</b>")], ["http://www.oracle.com/us/support/systems/index.html", N_("##Get world class support## with <b>Oracle Premier Support</b>")], [get_solaris_dashboard_url(), N_("##Explore## the <b>Oracle Solaris Dashboard</b> with system analytics and more")] ],
6643N/A}
6643N/A
6643N/Apersonalize_link= {
7183N/A 'header' : N_("Use the GNOME Desktop"),
7183N/A 'icon' : "gnome.png",
7183N/A 'program_links' : [ ["yelp.desktop", N_("##Get Help## using the <b>GNOME Desktop</b>")], ["gnome-control-center.desktop", N_("##Change desktop settings## with <b>GNOME Control Center</b>")], ["gnome-universal-access-panel.desktop", N_("##Enable Accessibility## with <b>Settings > Universal Access</b>")] ],
6643N/A}
6643N/A
6643N/Aparticipate_link= {
6643N/A 'header' : N_("Participate"),
6643N/A 'icon' : "participate.png",
6643N/A 'url_links' : [ ["https://community.oracle.com/community/server_%26_storage_systems/solaris", N_("##Join in on the discussion## of the <b>Oracle Solaris Forums</b>")], ["http://www.oracle.com/technetwork/server-storage/solaris11/community/index.html", N_("##Catch the latest## from the <b>Oracle Solaris Community</b>")] ],
6643N/A}
6643N/A
6643N/AICON_PATH = "/usr/share/os-about/"
6643N/ADESKTOP_ITEM_PATH = "/usr/share/applications/"
6643N/A
6643N/Aclass DialogOSNextSteps(Gtk.Dialog):
6643N/A def __init__(self, parent=None):
6643N/A Gtk.Dialog.__init__(self, self.__class__.__name__, parent, 0, None)
6643N/A
6643N/A self.connect('destroy', lambda *w: Gtk.main_quit())
6643N/A
6643N/A Gtk.Window.set_default_icon_from_file ("/usr/share/os-about/about-os-window-icon.png")
6643N/A
6643N/A self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('white'))
6643N/A
6643N/A # Set the dialog default spacing for about
6643N/A self.set_title(_("Start here with Oracle Solaris 12"))
6643N/A self.set_border_width(5)
6643N/A self.set_resizable(False)
6643N/A self.vbox.set_border_width(2)
6643N/A self.action_area.set_border_width(5)
6643N/A
6643N/A vbox = Gtk.VBox(False, 8)
6643N/A vbox.set_border_width(5)
6643N/A self.vbox.pack_start(vbox, False, False, 0)
6643N/A
6643N/A # Logo
6643N/A logo = Gtk.Image()
6643N/A pixbuf = GdkPixbuf.Pixbuf.new_from_file (ICON_PATH + "about-os-logo.png")
6643N/A
6643N/A# scale = 48.0 / pixbuf.get_height()
6643N/A# width_scale = pixbuf.get_width() * scale
6643N/A# height_scale = pixbuf.get_height() * scale
6643N/A# pixbuf = pixbuf.scale_simple (int(width_scale), int(height_scale), GdkPixbuf.InterpType.BILINEAR)
6643N/A logo.set_from_pixbuf (pixbuf)
6643N/A logo_hbox = Gtk.HBox(True, 0)
6643N/A logo_hbox.pack_start(logo, False, False, 0)
6643N/A vbox.pack_start(logo_hbox, False, False, 0)
6643N/A
6643N/A close_button=self.add_button(Gtk.STOCK_CLOSE,Gtk.ResponseType.CANCEL)
6643N/A self.set_default_response (Gtk.ResponseType.CANCEL)
6643N/A close_button.grab_default()
6643N/A close_button.grab_focus()
6643N/A close_button.connect('clicked', lambda *w: Gtk.main_quit())
6643N/A
6643N/A self.create_section(help_link, vbox)
6643N/A self.create_section(personalize_link, vbox)
6643N/A self.create_section(participate_link, vbox)
6643N/A
6643N/A self.show_all()
6643N/A
6643N/A def create_section(self, section_link, vbox):
6643N/A section_hbox = Gtk.HBox(False, 10)
6643N/A vbox.pack_start(section_hbox, True, True, 10)
6643N/A
6643N/A header = Gtk.Image()
6643N/A header.set_from_file (ICON_PATH + section_link['icon'])
6643N/A section_hbox.pack_start(header, False, False, 2)
6643N/A
6643N/A header_vbox = Gtk.VBox(False, 0)
6643N/A section_hbox.pack_start(header_vbox, False, False, 0)
6643N/A
6643N/A label = Gtk.Label()
6643N/A label.set_alignment(0, 0)
6643N/A label.set_markup("<span><b>%s</b></span>" % _(section_link['header']))
6643N/A label.set_justify(Gtk.Justification.LEFT)
6643N/A header_vbox.pack_start(label, False, False, 2)
6643N/A
6643N/A detail_vbox = Gtk.VBox(False, 0)
6643N/A detail_vbox.set_spacing(2)
6643N/A header_vbox.pack_start(detail_vbox, False, False, 0)
6643N/A self.fill_section(section_link, detail_vbox)
6643N/A
7077N/A def launch_app(self,label,uri):
7077N/A try:
7077N/A ditem = Gio.DesktopAppInfo.new (uri)
7077N/A ditem.launch ([])
7077N/A except Exception, e:
7077N/A print '''Warning: could not execute file "%s" : %s''' % (uri, e)
7077N/A
7077N/A return True
7077N/A
6643N/A def fill_section (self, section_link, vbox):
6643N/A
6643N/A if 'program_links' in section_link:
6643N/A for i in section_link['program_links']:
6643N/A hbox = Gtk.HBox(False, 0)
6643N/A label = Gtk.Label()
6643N/A label.set_markup(bullet_point + " ")
6643N/A label.set_justify(Gtk.Justification.LEFT)
6643N/A hbox.pack_start(label, False, False, 0)
6643N/A
6643N/A tmp = _(i[1]).split('##')
6643N/A
6643N/A label = Gtk.Label()
6643N/A label.set_markup(tmp[0])
6643N/A hbox.pack_start(label, False, False, 0)
6643N/A
7077N/A link_button = Gtk.Label()
7077N/A link_button.connect("activate-link", self.launch_app)
7077N/A markup = "<b><a href='%s'>%s</a></b>" % (i[0],tmp[1])
7077N/A link_button.set_markup(markup)
7077N/A
6643N/A hbox.pack_start(link_button, False, False, 0)
6643N/A
6643N/A label = Gtk.Label()
6643N/A label.set_markup(tmp[2])
6643N/A hbox.pack_start(label, False, False, 0)
6643N/A
6643N/A vbox.pack_start(hbox, False, False, 0)
6643N/A
6643N/A if 'url_links' in section_link:
6643N/A for i in section_link['url_links']:
6643N/A hbox = Gtk.HBox(False, 0)
6643N/A label = Gtk.Label()
6643N/A label.set_markup(bullet_point + " ")
6643N/A label.set_justify(Gtk.Justification.LEFT)
6643N/A hbox.pack_start(label, False, False, 0)
6643N/A
6643N/A tmp = _(i[1]).split('##')
6643N/A
6643N/A label = Gtk.Label()
6643N/A label.set_markup(tmp[0])
6643N/A hbox.pack_start(label, False, False, 0)
6643N/A
7077N/A link_button = Gtk.Label()
7077N/A markup = "<b><a href='%s'>%s</a></b>" % (i[0],tmp[1])
7077N/A link_button.set_markup(markup)
6643N/A hbox.pack_start(link_button, False, False, 0)
6643N/A
6643N/A label = Gtk.Label()
6643N/A label.set_markup(tmp[2])
6643N/A hbox.pack_start(label, False, False, 0)
6643N/A
6643N/A vbox.pack_start(hbox, False, False, 0)
6643N/A
6643N/A
6643N/Adef main():
6643N/A locale.setlocale (locale.LC_ALL, "")
6643N/A gettext.textdomain (GETTEXT_PACKAGE)
6643N/A gettext.install (GETTEXT_PACKAGE, LOCALEDIR)
6643N/A
6643N/A style_provider = Gtk.CssProvider()
6643N/A css = """
6643N/A GtkDialog {
6643N/A background-image: url('/usr/share/os-about/about-os-background.jpg');
6643N/A background-position: left top;
6643N/A }
6643N/A """
6643N/A style_provider.load_from_data(css)
6643N/A
6643N/A Gtk.StyleContext.add_provider_for_screen(
6643N/A Gdk.Screen.get_default(),
6643N/A style_provider,
6643N/A Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
6643N/A )
6643N/A
6643N/A DialogOSNextSteps()
6643N/A Gtk.main()
6643N/A
6643N/Aif __name__ == '__main__':
6643N/A main()