~ubuntu-branches/ubuntu/trusty/ubuntuone-control-panel/trusty-proposed

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/gui/qt/systray.py

  • Committer: Package Import Robot
  • Author(s): Rodney Dawes
  • Date: 2012-12-10 09:56:24 UTC
  • mfrom: (1.1.41)
  • Revision ID: package-import@ubuntu.com-20121210095624-uqwqrftml2gg2xiq
Tags: 4.1.0-0ubuntu1
* New upstream release.
  - Replace simplejson usage with json. (LP: #1029094)
  - Clear search when clicking (X) icon in search entry. (LP: #1070917)
  - Raise existing window if process already running. (LP: #1063927)
  - Don't auto-publish when selecting a search result. (LP: #1065194)
  - Add a new .desktop file for the GNOME-only remix of Ubuntu.
* debian/control:
  - Switch pylint build dependency to pyflakes.
  - Remove python-simplejson from dependencies.
* debian/ubuntuone-control-panel-qt.install:
  - Add new .desktop file for GNOME remix.
  - Remove the messaging menu integration file.
* debian/watch:
  - Update to use stable-4-2 series for Ubuntu 13.04 releases.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    IN_PROGRESS,
37
37
    IN_PROGRESS_FILE,
38
38
    LOADING,
39
 
    NEW_SHARE_BY,
40
39
    OPEN_UBUNTU_ONE,
41
40
    OPEN_UBUNTU_ONE_FOLDER,
42
41
    PLEASE_WAIT,
43
42
    RECENT_TRANSFERS,
44
43
    RECENTTRANSFERS,
 
44
    SHARE_A_FILE,
45
45
    TRANSFERS,
46
46
    UPLOADING,
47
47
)
122
122
        self.quit = None
123
123
        self.get_help_online = None
124
124
        self.open_u1 = None
 
125
        self.share_a_file = None
125
126
        self.status_action = None
126
127
        self.go_to_web = None
127
128
        self.get_more_storage = None
130
131
        self.backend.add_status_changed_handler(self._process_status)
131
132
 
132
133
        self.load_menu()
133
 
        # Refresh the Shares every five minutes if needed.
134
 
        self._timer_id = self.startTimer(300000)
135
 
 
136
 
    # pylint: disable=C0103
137
 
 
138
 
    def timerEvent(self, event):
139
 
        """Update the menu on each iteration."""
140
 
        self.load_menu()
141
 
 
142
 
    # pylint: enable=C0103
143
 
 
144
 
    @inlineCallbacks
 
134
 
145
135
    def load_menu(self):
146
136
        """Load the content of the menu."""
147
 
        shares_info = yield self.backend.get_shares()
148
 
        shares_info = [share for share in shares_info if not share['accepted']]
149
 
        if shares_info != self._previous_shares:
150
 
            # Items
151
 
            self.context_menu.clear()
152
 
 
153
 
            self.status = self.context_menu.addAction(LOADING)
154
 
            self.status.setEnabled(False)
155
 
            self.status_action = self.context_menu.addAction(PLEASE_WAIT)
156
 
            self.refresh_status()
157
 
            self.context_menu.addSeparator()
158
 
 
159
 
            self.open_u1 = self.context_menu.addAction(OPEN_UBUNTU_ONE)
160
 
            # TODO: Share a file action when the Shares tab is ready in U1-CP
161
 
            self.open_u1_folder = self.context_menu.addAction(
162
 
                OPEN_UBUNTU_ONE_FOLDER)
163
 
            self.go_to_web = self.context_menu.addAction(GO_TO_WEB)
164
 
            self.context_menu.addSeparator()
165
 
 
166
 
            # Shares
167
 
            self._previous_shares = shares_info
168
 
            max_shares = 0
169
 
            for share in self._previous_shares:
170
 
                if max_shares == 3:
171
 
                    break
172
 
                max_shares += 1
173
 
                text = NEW_SHARE_BY % share['other_visible_name']
174
 
                share_action = SharesAction(text, share['volume_id'],
175
 
                    self.context_menu)
176
 
                self.context_menu.addAction(share_action)
177
 
            if self._previous_shares:
178
 
                self.context_menu.addSeparator()
179
 
 
180
 
            # Transfers
181
 
            self.transfers = TransfersMenu(self)
182
 
            self.context_menu.addMenu(self.transfers)
183
 
 
184
 
            self.get_more_storage = self.context_menu.addAction(
185
 
                GET_MORE_STORAGE)
186
 
            self.get_help_online = self.context_menu.addAction(GET_HELP_ONLINE)
187
 
            self.quit = self.context_menu.addAction("Quit")
188
 
 
189
 
            self.setContextMenu(self.context_menu)
190
 
 
191
 
            # Connect Signals
192
 
            self.status_action.triggered.connect(self.change_status)
193
 
            self.open_u1.triggered.connect(self.restore_window)
194
 
            self.open_u1_folder.triggered.connect(self.open_u1_folder_action)
195
 
            self.get_more_storage.triggered.connect(
196
 
                self.get_more_storage_action)
197
 
            self.go_to_web.triggered.connect(self.go_to_web_action)
198
 
            self.get_help_online.triggered.connect(self.get_help_action)
199
 
            self.quit.triggered.connect(self.stop)
200
 
 
201
 
            self._get_volumes_info()
 
137
        # Items
 
138
        self.context_menu.clear()
 
139
 
 
140
        self.status = self.context_menu.addAction(LOADING)
 
141
        self.status.setEnabled(False)
 
142
        self.status_action = self.context_menu.addAction(PLEASE_WAIT)
 
143
        self.refresh_status()
 
144
        self.context_menu.addSeparator()
 
145
 
 
146
        self.open_u1 = self.context_menu.addAction(OPEN_UBUNTU_ONE)
 
147
        self.share_a_file = self.context_menu.addAction(SHARE_A_FILE)
 
148
        self.open_u1_folder = self.context_menu.addAction(
 
149
            OPEN_UBUNTU_ONE_FOLDER)
 
150
        self.go_to_web = self.context_menu.addAction(GO_TO_WEB)
 
151
        self.context_menu.addSeparator()
 
152
 
 
153
        # Transfers
 
154
        self.transfers = TransfersMenu(self)
 
155
        self.context_menu.addMenu(self.transfers)
 
156
 
 
157
        self.get_more_storage = self.context_menu.addAction(
 
158
            GET_MORE_STORAGE)
 
159
        self.get_help_online = self.context_menu.addAction(GET_HELP_ONLINE)
 
160
        self.quit = self.context_menu.addAction("Quit")
 
161
 
 
162
        self.setContextMenu(self.context_menu)
 
163
 
 
164
        # Connect Signals
 
165
        self.status_action.triggered.connect(self.change_status)
 
166
        self.open_u1.triggered.connect(self.restore_window)
 
167
        self.share_a_file.triggered.connect(self.open_share_tab)
 
168
        self.open_u1_folder.triggered.connect(self.open_u1_folder_action)
 
169
        self.get_more_storage.triggered.connect(
 
170
            self.get_more_storage_action)
 
171
        self.go_to_web.triggered.connect(self.go_to_web_action)
 
172
        self.get_help_online.triggered.connect(self.get_help_action)
 
173
        self.quit.triggered.connect(self.stop)
 
174
 
 
175
        self._get_volumes_info()
202
176
 
203
177
    @inlineCallbacks
204
178
    def refresh_status(self):
278
252
        self.window.show()
279
253
        self.window.activateWindow()
280
254
 
 
255
    def open_share_tab(self):
 
256
        """Show the main window in the share tab."""
 
257
        if self.window is None:
 
258
            # pylint: disable=W0404
 
259
            from ubuntuone.controlpanel.gui.qt.gui import MainWindow
 
260
            # pylint: enable=W0404
 
261
            self.window = MainWindow(close_callback=self.delete_window)
 
262
        self.window.switch_to('share_links')
 
263
        self.window.show()
 
264
        self.window.activateWindow()
 
265
 
281
266
    def delete_window(self):
282
267
        """Close and remove the main window."""
283
268
        if self.window is not None: