-
Notifications
You must be signed in to change notification settings - Fork 58
/
mintWelcome.py
executable file
·223 lines (194 loc) · 9.8 KB
/
mintWelcome.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/usr/bin/env python
import gi
from gi.repository import Gtk, Gdk
from gi.repository import WebKit
from gi.repository.GdkPixbuf import Pixbuf
import sys
import commands
import os
import gettext
from user import home
import string
# i18n
gettext.install("mintwelcome", "/usr/share/linuxmint/locale")
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
class MintWelcome():
def __init__(self):
window = Gtk.Window()
window.set_title(_("Welcome Screen"))
window.set_icon_from_file("/usr/share/linuxmint/logo.png")
window.set_position(Gtk.WindowPosition.CENTER)
window.connect("destroy", Gtk.main_quit)
sys.path.append('/usr/lib/linuxmint/common')
from configobj import ConfigObj
config = ConfigObj("/etc/linuxmint/info")
codename = config['CODENAME'].capitalize()
edition = config['EDITION']
release = config['RELEASE']
desktop = config['DESKTOP']
self.release_notes = config['RELEASE_NOTES_URL']
self.user_guide = config['USER_GUIDE_URL']
self.new_features = config['NEW_FEATURES_URL']
# distro-specific
self.dist_name = "Linux Mint"
self.codec_pkg_name = "mint-meta-codecs"
if os.path.exists("/usr/share/doc/debian-system-adjustments/copyright"):
self.dist_name = "LMDE"
self.codec_pkg_name = "mint-meta-debian-codecs"
bgcolor = Gdk.RGBA()
bgcolor.parse("rgba(0,0,0,0)")
fgcolor = Gdk.RGBA()
fgcolor.parse("#3e3e3e")
main_box = Gtk.VBox()
event_box = Gtk.EventBox()
event_box.set_name("event_box")
event_box.override_background_color(Gtk.StateType.NORMAL, bgcolor)
event_box.override_color(Gtk.StateType.NORMAL, fgcolor)
main_box.pack_start(event_box, True, True, 0)
vbox = Gtk.VBox()
vbox.set_border_width(6)
vbox.set_spacing(0)
event_box.add(vbox)
headerbox = Gtk.VBox()
logo = Gtk.Image()
if "KDE" in desktop:
logo.set_from_file("/usr/lib/linuxmint/mintWelcome/icons/logo_header_kde.png")
else:
logo.set_from_file("/usr/lib/linuxmint/mintWelcome/icons/logo_header.png")
headerbox.pack_start(logo, False, False, 0)
label = Gtk.Label()
if "KDE" in desktop:
label.set_markup("<span font='12.5' fgcolor='#3e3e3e'>%s %s '<span fgcolor='#3267b8'>%s</span>'</span>" % (self.dist_name, release, codename))
else:
label.set_markup("<span font='12.5' fgcolor='#3e3e3e'>%s %s '<span fgcolor='#709937'>%s</span>'</span>" % (self.dist_name, release, codename))
headerbox.pack_start(label, False, False, 0)
label = Gtk.Label()
label.set_markup("<span font='8' fgcolor='#3e3e3e'><i>%s</i></span>" % edition)
headerbox.pack_start(label, False, False, 2)
vbox.pack_start(headerbox, False, False, 10)
welcome_label = Gtk.Label()
welcome_message = _("Welcome and thank you for choosing Linux Mint. We hope you'll enjoy using it as much as we did designing it. The links below will help you get started with your new operating system. Have a great time and don't hesitate to send us your feedback.")
welcome_label.set_markup("<span font='9' fgcolor='#3e3e3e'>%s</span>" % welcome_message)
welcome_label.set_line_wrap(True)
vbox.pack_start(welcome_label, False, False, 10)
separator = Gtk.Image()
separator.set_from_file('/usr/lib/linuxmint/mintWelcome/icons/separator.png')
vbox.pack_start(separator, False, False, 10)
liststore = Gtk.ListStore(Pixbuf, str, str, str)
iconview = Gtk.IconView.new()
iconview.set_model(liststore)
iconview.set_pixbuf_column(0)
iconview.set_text_column(2)
iconview.set_tooltip_column(3)
iconview.set_columns(5)
iconview.set_margin(0)
iconview.set_spacing(6)
iconview.set_item_padding(0)
iconview.set_row_spacing(20)
iconview.set_column_spacing(20)
iconview.override_background_color(Gtk.StateType.NORMAL, bgcolor)
iconview.override_color(Gtk.StateType.NORMAL, fgcolor)
iconview.connect("selection-changed", self.item_activated)
hbox = Gtk.HBox()
hbox.pack_start(iconview, True, True, 30)
vbox.pack_start(hbox, False, False, 10)
actions = []
actions.append(['new_features', _("New features"), _("See what is new in this release")])
actions.append(['known_problems', _("Important information"), _("Find out about important information, limitations, known issues and their solution")])
actions.append(['user_guide', _("User guide"), _("Learn all the basics to get started with Linux Mint")])
actions.append(['restore_data', _("Restore data"), _("Restore data or applications from a previous installation")])
actions.append(['software', _("Software manager"), _("Install additional software")])
actions.append(['chatroom', _("Chat room"), _("Chat live with other users in the chat room")])
actions.append(['forums', _("Forums"), _("Seek help from other users in the Linux Mint forums")])
actions.append(['tutorials', _("Tutorials"), _("Find tutorials about Linux Mint")])
actions.append(['hardware', _("Hardware database"), _("Find hardware that is compatible with Linux, or information about your hardware")])
actions.append(['ideas', _("Idea pool"), _("Submit new ideas to the development team")])
actions.append(['get_involved', _("Get involved"), _("Find out how to get involved in the Linux Mint project")])
actions.append(['donors', _("Donations"), _("Make a donation to the Linux Mint project")])
actions.append(['sponsors', _("Sponsors"), _("Apply to become a Linux Mint sponsor")])
if ("Gnome" in desktop or "MATE" in desktop) and "debian" not in codename:
# Some GNOME editions (Cinnamon, MATE) can come without codecs
import apt
cache = apt.Cache()
if self.codec_pkg_name in cache:
pkg = cache[self.codec_pkg_name]
if not pkg.is_installed:
actions.append(['codecs', _("Install multimedia codecs"), _("Add all the missing multimedia codecs")])
for action in actions:
pixbuf = Pixbuf.new_from_file('/usr/lib/linuxmint/mintWelcome/icons/%s.png' % action[0])
liststore.append([pixbuf, action[0], action[1], action[2]])
hbox = Gtk.HBox()
hbox.set_border_width(6)
main_box.pack_end(hbox, False, False, 0)
checkbox = Gtk.CheckButton()
checkbox.set_label(_("Show this dialog at startup"))
checkbox.override_color(Gtk.StateType.NORMAL, fgcolor)
if not os.path.exists(home + "/.linuxmint/mintWelcome/norun.flag"):
checkbox.set_active(True)
checkbox.connect("toggled", self.on_button_toggled)
hbox.pack_end(checkbox, False, False, 2)
window.add(main_box)
# window.set_size_request(640, 520)
window.set_default_size(640, 520)
css_provider = Gtk.CssProvider()
css = """
#event_box {
background-image: -gtk-gradient (linear,
left top,
left bottom,
from (#cecece),
color-stop (0.1, #f7f7f7),
to (#d6d6d6));
}
"""
css_provider.load_from_data(css.encode('UTF-8'))
screen = Gdk.Screen.get_default()
style_context = window.get_style_context()
style_context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
window.show_all()
def on_button_toggled(self, button):
if button.get_active():
if os.path.exists(home + "/.linuxmint/mintWelcome/norun.flag"):
os.system("rm -rf " + home + "/.linuxmint/mintWelcome/norun.flag")
else:
os.system("mkdir -p " + home + "/.linuxmint/mintWelcome")
os.system("touch " + home + "/.linuxmint/mintWelcome/norun.flag")
def item_activated(self, view):
paths = view.get_selected_items()
if (len(paths) > 0):
path = paths[0]
treeiter = view.get_model().get_iter(path)
value = view.get_model().get_value(treeiter, 1)
if value == "chatroom":
os.system("xdg-open irc://irc.spotchat.org/linuxmint-help")
elif value == "restore_data":
if os.path.exists("/usr/bin/mintbackup"):
os.system("/usr/bin/mintbackup &")
elif value == "new_features":
os.system("xdg-open %s &" % self.new_features)
elif value == "known_problems":
os.system("xdg-open %s &" % self.release_notes)
elif value == "user_guide":
os.system("xdg-open %s &" % self.user_guide)
elif value == "forums":
os.system("xdg-open http://forums.linuxmint.com &")
elif value == "tutorials":
os.system("xdg-open http://community.linuxmint.com/tutorial &")
elif value == "ideas":
os.system("xdg-open http://community.linuxmint.com/idea &")
elif value == "software":
os.system("mintinstall &")
elif value == "hardware":
os.system("xdg-open http://community.linuxmint.com/hardware &")
elif value == "get_involved":
os.system("xdg-open http://www.linuxmint.com/getinvolved.php &")
elif value == "sponsors":
os.system("xdg-open http://www.linuxmint.com/sponsors.php &")
elif value == "donors":
os.system("xdg-open http://www.linuxmint.com/donors.php &")
elif value == "codecs":
os.system("xdg-open apt://%s?refresh=yes &" % self.codec_pkg_name)
if __name__ == "__main__":
MintWelcome()
Gtk.main()