~timo-jyrinki/ubuntu/trusty/pitivi/backport_utopic_fixes

« back to all changes in this revision

Viewing changes to pitivi/dialogs/startupwizard.py

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2014-03-29 15:22:50 UTC
  • mto: (3.1.23 experimental)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: package-import@ubuntu.com-20140329152250-flg9onx416bqf3e3
Tags: upstream-0.93
Import upstream version 0.93

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
""" This module implements a startup wizard"""
1
2
# Pitivi video editor
2
3
#
3
4
#       pitivi/dialogs/startupwizard.py
44
45
    - see the quick start manual (User Manual button).
45
46
    """
46
47
 
 
48
    @staticmethod
 
49
    def _userManualCb(unused_button):
 
50
        """Handle a click on the Help button."""
 
51
        show_user_manual()
 
52
 
 
53
    @staticmethod
 
54
    def _cheatsheetCb(unused_button):
 
55
        """Show the cheatsheet section of the user manual"""
 
56
        show_user_manual("cheatsheet")
 
57
 
47
58
    def __init__(self, app):
48
59
        self.app = app
49
60
        self.builder = Gtk.Builder()
55
66
        self.recent_chooser = self.builder.get_object("recentchooser2")
56
67
        # FIXME: gtk creates a combo box with only one item, but there is no
57
68
        # simple way to hide it.
58
 
        filter = Gtk.RecentFilter()
59
 
        filter.set_name(_("Projects"))
 
69
        _filter = Gtk.RecentFilter()
 
70
        _filter.set_name(_("Projects"))
60
71
 
61
72
        for asset in GES.list_assets(GES.Formatter):
62
 
            filter.add_pattern('*.' + asset.get_meta(GES.META_FORMATTER_EXTENSION))
63
 
 
64
 
        self.recent_chooser.add_filter(filter)
 
73
            _filter.add_pattern('*.' + asset.get_meta(GES.META_FORMATTER_EXTENSION))
 
74
 
 
75
        self.recent_chooser.add_filter(_filter)
 
76
 
 
77
        missing_button = self.builder.get_object("missing_deps_button")
65
78
 
66
79
        if not missing_soft_deps:
67
 
            self.builder.get_object("missing_deps_button").hide()
 
80
            missing_button.hide()
68
81
 
69
82
        self.app.projectManager.connect("new-project-failed", self._projectFailedCb)
70
83
        self.app.projectManager.connect("new-project-loaded", self._projectLoadedCb)
73
86
        vbox = self.builder.get_object("topvbox")
74
87
        self.infobar = Gtk.InfoBar()
75
88
        vbox.pack_start(self.infobar, True, True, 0)
76
 
        if self.app.version_information:
77
 
            self._appVersionInfoReceivedCb(None, self.app.version_information)
 
89
        if self.app.getLatest():
 
90
            self._appVersionInfoReceivedCb(self.app, None)
78
91
        else:
79
92
            self.app.connect("version-info-received", self._appVersionInfoReceivedCb)
80
93
 
91
104
        uri = self.recent_chooser.get_current_uri()
92
105
        self.app.projectManager.loadProject(uri)
93
106
 
94
 
    def _keyPressCb(self, widget, event):
 
107
    def _keyPressCb(self, unused_widget, event):
95
108
        """Handle a key press event on the dialog."""
96
109
        if event.keyval == Gdk.KEY_Escape:
97
110
            # The user pressed "Esc".
102
115
        self.app.gui.openProject()
103
116
 
104
117
    def _onMissingDepsButtonClickedCb(self, unused_button):
 
118
        """Handle a click on the Missing Deps button."""
105
119
        DepsManager(self.app, parent_window=self.window)
106
120
 
107
 
    def _userManualCb(self, unused_button):
108
 
        """Handle a click on the Help button."""
109
 
        show_user_manual()
110
 
 
111
 
    def _cheatsheetCb(self, unused_button):
112
 
        """Show the cheatsheet section of the user manual"""
113
 
        show_user_manual("cheatsheet")
114
 
 
115
 
    def _deleteCb(self, unused_widget, event):
 
121
    def _deleteCb(self, unused_widget, unused_event):
116
122
        """Handle a click on the X button of the dialog."""
117
123
        self.app.projectManager.newBlankProject()
118
124
 
119
125
    def show(self):
 
126
        """Will show the interal window and position the wizard"""
120
127
        self.window.set_transient_for(self.app.gui)
121
128
        self.window.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
122
129
        self.window.show()
123
130
 
124
131
    def hide(self):
 
132
        """Will hide the internal window"""
125
133
        self.window.hide()
126
134
 
127
135
    def _projectFailedCb(self, unused_project_manager, unused_uri,
129
137
        """Handle the failure of a project open operation."""
130
138
        self.show()
131
139
 
132
 
    def _projectLoadedCb(self, unused_project_manager, project, fully_loaded):
 
140
    def _projectLoadedCb(self, unused_project_manager, unused_project, fully_loaded):
133
141
        """Handle the success of a project load operation.
134
142
 
135
143
        All the create or load project usage scenarios must generate
144
152
        """Handle the start of a project load operation."""
145
153
        self.hide()
146
154
 
147
 
    def _appVersionInfoReceivedCb(self, pitivi, version):
148
 
        # current version, don't show message
149
 
        if version["status"].upper() == "CURRENT":
 
155
    def _appVersionInfoReceivedCb(self, app, unused_version_information):
 
156
        """Handle version info"""
 
157
        if app.isLatest():
 
158
            # current version, don't show message
150
159
            return
151
160
 
152
 
        # new current version, reset counter
153
 
        if self.app.settings.lastCurrentVersion != version["current"]:
154
 
            self.app.settings.lastCurrentVersion = version["current"]
 
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
155
165
            self.app.settings.displayCounter = 0
156
166
 
157
 
        # current version info already showed 5 times, don't show again
158
167
        if self.app.settings.displayCounter >= 5:
 
168
            # current version info already showed 5 times, don't show again
159
169
            return
160
170
 
161
171
        # increment counter, create infobar and show info
162
172
        self.app.settings.displayCounter = self.app.settings.displayCounter + 1
163
 
        text = _("Pitivi %s is available." % version["current"])
 
173
        text = _("Pitivi %s is available." % latest_version)
164
174
        label = Gtk.Label(label=text)
165
175
        self.infobar.get_content_area().add(label)
166
176
        self.infobar.set_message_type(Gtk.MessageType.INFO)