-
Notifications
You must be signed in to change notification settings - Fork 4
/
startupwizard.py
98 lines (81 loc) · 3.37 KB
/
startupwizard.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
# PiTiVi , Non-linear video editor
#
# pitivi/ui/startupwizard.py
#
# Copyright (c) 2010 Mathieu Duponchelle <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
import os
import gtk
from urllib import unquote
from utils import make_ui_path
class StartUpWizard(object):
"""A Wizard displaying recent projects.
Allows the user to:
- create a new project and open the settings dialog (Create button),
- create a new project with the default settings (dialog close or ESC),
- load a recently opened project (double click recent chooser),
- load a project (Browse button),
- see the quick start manual (User Manual button).
"""
def __init__(self, app):
self.app = app
self.builder = gtk.Builder()
self.builder.add_from_file(make_ui_path("startupwizard"))
self.builder.connect_signals(self)
self.window = self.builder.get_object("window1")
self.window.set_position(gtk.WIN_POS_CENTER_ALWAYS)
self.recent_chooser = self.builder.get_object("recentchooser2")
# FIXME: gtk creates a combo box with only one item, but there is no
# simple way to hide it.
filter = gtk.RecentFilter()
filter.set_name("Projects")
filter.add_pattern("*.krf")
self.recent_chooser.add_filter(filter)
def _newProjectCb(self, unused_button):
"""Handle a click on the New (Project) button."""
self.app.activityView.newProject()
self.window.destroy()
def _loadCb(self, unused_recent_chooser):
"""Handle a double-click on the recent chooser."""
#FIXME : Do it cleaner
self.app.activityView.openProject(self._getFileName()[7:])
self.window.destroy()
def _getFileName(self):
"""Get the URI of the project selected in the recent chooser."""
uri = self.recent_chooser.get_current_uri()
return unquote(uri)
def _keyPressCb(self, widget, event):
"""Handle a key press event on the dialog."""
if event.keyval == gtk.keysyms.Escape:
self.window.destroy()
self.app.activityView.newProject()
def _onBrowseButtonClickedCb(self, unused_button6):
"""Handle a click on the Browse button."""
self.app.activityView.browse(self)
def _userManualCb(self, unused_button):
"""Handle a click on the Help button."""
#show_user_manual()
pass
def _deleteCb(self, unused_widget, event):
"""Handle a click on the X button of the dialog."""
self.app.activityView.newProject()
def show(self):
self.window.set_transient_for(self.app.window)
self.window.show()
self.window.grab_focus()
def hide(self):
self.window.hide()