1
""" This module implements a startup wizard"""
4
# pitivi/dialogs/startupwizard.py
6
# Copyright (c) 2010 Mathieu Duponchelle <seeed@laposte.net>
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of the GNU Lesser General Public
10
# License as published by the Free Software Foundation; either
11
# version 2.1 of the License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
# Lesser General Public License for more details.
18
# You should have received a copy of the GNU Lesser General Public
19
# License along with this program; if not, write to the
20
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21
# Boston, MA 02110-1301, USA.
25
from gi.repository import Gtk
26
from gi.repository import Gdk
27
from gi.repository import GES
29
from gettext import gettext as _
31
from pitivi.configure import get_ui_dir
32
from pitivi.dialogs.depsmanager import DepsManager
33
from pitivi.check import missing_soft_deps
34
from pitivi.utils.misc import show_user_manual
37
class StartUpWizard(object):
38
"""A Wizard displaying recent projects.
41
- create a new project and open the settings dialog (Create button),
42
- create a new project with the default settings (dialog close or ESC),
43
- load a recently opened project (double click recent chooser),
44
- load a project (Browse button),
45
- see the quick start manual (User Manual button).
49
def _userManualCb(unused_button):
50
"""Handle a click on the Help button."""
54
def _cheatsheetCb(unused_button):
55
"""Show the cheatsheet section of the user manual"""
56
show_user_manual("cheatsheet")
58
def __init__(self, app):
60
self.builder = Gtk.Builder()
61
self.builder.add_from_file(os.path.join(get_ui_dir(), "startupwizard.ui"))
62
self.builder.connect_signals(self)
64
self.window = self.builder.get_object("window1")
66
self.recent_chooser = self.builder.get_object("recentchooser2")
67
# FIXME: gtk creates a combo box with only one item, but there is no
68
# simple way to hide it.
69
_filter = Gtk.RecentFilter()
70
_filter.set_name(_("Projects"))
72
for asset in GES.list_assets(GES.Formatter):
73
_filter.add_pattern('*.' + asset.get_meta(GES.META_FORMATTER_EXTENSION))
75
self.recent_chooser.add_filter(_filter)
77
missing_button = self.builder.get_object("missing_deps_button")
79
if not missing_soft_deps:
82
self.app.projectManager.connect("new-project-failed", self._projectFailedCb)
83
self.app.projectManager.connect("new-project-loaded", self._projectLoadedCb)
84
self.app.projectManager.connect("new-project-loading", self._projectLoadingCb)
86
vbox = self.builder.get_object("topvbox")
87
self.infobar = Gtk.InfoBar()
88
vbox.pack_start(self.infobar, True, True, 0)
89
if self.app.getLatest():
90
self._appVersionInfoReceivedCb(self.app, None)
92
self.app.connect("version-info-received", self._appVersionInfoReceivedCb)
94
def _newProjectCb(self, unused_button):
95
"""Handle a click on the New (Project) button."""
96
self.app.projectManager.newBlankProject()
97
self.app.gui.showProjectSettingsDialog()
99
def _loadCb(self, unused_recent_chooser):
101
Handle choosing a project on the recent chooser.
102
This calls the project manager to load the associated URI.
104
uri = self.recent_chooser.get_current_uri()
105
self.app.projectManager.loadProject(uri)
107
def _keyPressCb(self, unused_widget, event):
108
"""Handle a key press event on the dialog."""
109
if event.keyval == Gdk.KEY_Escape:
110
# The user pressed "Esc".
111
self.app.projectManager.newBlankProject()
113
def _onBrowseButtonClickedCb(self, unused_button6):
114
"""Handle a click on the Browse button."""
115
self.app.gui.openProject()
117
def _onMissingDepsButtonClickedCb(self, unused_button):
118
"""Handle a click on the Missing Deps button."""
119
DepsManager(self.app, parent_window=self.window)
121
def _deleteCb(self, unused_widget, unused_event):
122
"""Handle a click on the X button of the dialog."""
123
self.app.projectManager.newBlankProject()
126
"""Will show the interal window and position the wizard"""
127
self.window.set_transient_for(self.app.gui)
128
self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
132
"""Will hide the internal window"""
135
def _projectFailedCb(self, unused_project_manager, unused_uri,
137
"""Handle the failure of a project open operation."""
140
def _projectLoadedCb(self, unused_project_manager, unused_project, fully_loaded):
141
"""Handle the success of a project load operation.
143
All the create or load project usage scenarios must generate
144
a new-project-loaded signal from self.app.projectManager!
147
self.app.projectManager.disconnect_by_function(self._projectFailedCb)
148
self.app.projectManager.disconnect_by_function(self._projectLoadedCb)
149
self.app.projectManager.disconnect_by_function(self._projectLoadingCb)
151
def _projectLoadingCb(self, unused_project_manager, unused_project):
152
"""Handle the start of a project load operation."""
155
def _appVersionInfoReceivedCb(self, app, unused_version_information):
156
"""Handle version info"""
158
# current version, don't show message
161
latest_version = app.getLatest()
162
if self.app.settings.lastCurrentVersion != latest_version:
163
# new latest version, reset counter
164
self.app.settings.lastCurrentVersion = latest_version
165
self.app.settings.displayCounter = 0
167
if self.app.settings.displayCounter >= 5:
168
# current version info already showed 5 times, don't show again
171
# increment counter, create infobar and show info
172
self.app.settings.displayCounter = self.app.settings.displayCounter + 1
173
text = _("Pitivi %s is available." % latest_version)
174
label = Gtk.Label(label=text)
175
self.infobar.get_content_area().add(label)
176
self.infobar.set_message_type(Gtk.MessageType.INFO)
177
self.infobar.show_all()