~ubuntu-branches/ubuntu/oneiric/ubuntuone-control-panel/oneiric

« back to all changes in this revision

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

* New upstream release:
  [ Alejandro J. Cura <alecu@canonical.com>]
    - Do not throw a webclient error when closing
      (LP: #845105).
  [ Natalia B. Bidart <natalia.bidart@canonical.com> ]
    - Removed all code related to Bookmarks (LP: #850142).
    - Replaces references to "Evolution" by "Thunderbird" (LP: #849494).
  [ Rodney Dawes <rodney.dawes@canonical.com> ]
    - Don't install a .desktop file for control panel
      (part of LP: #838778).
    - Point the indicator/Unity API at the installer .desktop file
      (part of LP: #838778).
    - Set the WMCLASS so Unity will fall back properly
      (part of LP: #838778).
    - Fix a few grammar mistakes (LP: #835093).
    - Don't show the "Get NGB free!" label on "Join now" button at all
      (LP: #819955).
* debian/control:
  - ubuntuone-control-panel-gtk depends now on ubuntuone-installer >= 2.0.0.
  - require ubuntuone-client >= 2.0.0.
  - require ubuntu-sso-client >= 1.4.0.
  - no longer install a .desktop file (will be installed by ubuntuone-installer).

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
from ubuntuone.controlpanel.gui import (
30
30
    ALWAYS_SUBSCRIBED,
31
31
    EXPLORE,
32
 
    FILE_URI_PREFIX,
33
32
    FOLDER_ICON_NAME,
34
33
    FOLDER_OWNED_BY,
35
34
    FOLDER_SHARED_BY,
65
64
    """The Folders Tab Panel widget"""
66
65
 
67
66
    ui_class = folders_ui
 
67
    logger = logger
68
68
 
69
69
    def _setup(self):
70
70
        """Do some extra setupping for the UI."""
71
 
        load_info = lambda *a, **kw: self.load()
72
 
        self.ui.add_folder_button.folderCreated.connect(load_info)
 
71
        super(FoldersPanel, self)._setup()
 
72
        self.ui.add_folder_button.folderCreated.connect(self.on_folder_created)
73
73
 
74
74
        headers = self.ui.folders.header()
75
75
        headers.setResizeMode(FOLDER_NAME_COL, headers.Stretch)
81
81
        icon = icon_from_name('external_icon_orange')
82
82
        self.ui.share_publish_button.setIcon(icon)
83
83
 
84
 
        logger.debug('%s: started.', self.__class__.__name__)
 
84
    @log_call(logger.info)
 
85
    def on_folder_created(self, new_folder):
 
86
        """Reload folder info after folder creation."""
 
87
        self.is_processing = True
 
88
        # hack to ensure that syncdaemon updates the folder list.
 
89
        # pylint: disable=W0404, E1101
 
90
        from twisted.internet import reactor
 
91
        reactor.callLater(2, self.load)
85
92
 
 
93
    # pylint: disable=E0202
86
94
    @defer.inlineCallbacks
87
95
    def load(self):
88
96
        """Load specific tab info."""
124
132
            self.ui.folders.addTopLevelItem(item)
125
133
 
126
134
            for volume in volumes:
 
135
                is_root = volume[u'type'] == self.backend.ROOT_TYPE
 
136
                is_share = volume[u'type'] == self.backend.SHARE_TYPE
 
137
 
127
138
                child = QtGui.QTreeWidgetItem()
128
139
                child.setSizeHint(FOLDER_NAME_COL, QtCore.QSize(-1, 35))
129
 
                child.volume_path = volume['path']
 
140
                if is_share and 'realpath' in volume:
 
141
                    child.volume_path = volume['realpath']
 
142
                else:
 
143
                    child.volume_path = volume['path']
130
144
                child.volume_id = volume['volume_id']
131
145
 
132
146
                name = self._process_name(volume[u'display_name'])
134
148
                child.setToolTip(FOLDER_NAME_COL, name)
135
149
                child.setToolTip(EXPLORE_COL, EXPLORE)
136
150
 
137
 
                is_root = volume[u'type'] == self.backend.ROOT_TYPE
138
 
                is_share = volume[u'type'] == self.backend.SHARE_TYPE
139
 
 
140
151
                icon_name = FOLDER_ICON_NAME
141
152
                if is_share:
142
153
                    icon_name = SHARE_ICON_NAME
173
184
                policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
174
185
                                           QtGui.QSizePolicy.Fixed)
175
186
                button.setSizePolicy(policy)
 
187
                button.setEnabled(bool(volume[u'subscribed']))
176
188
 
177
189
                # Operator not preceded by a space
178
190
                # pylint: disable=C0322
179
 
                cb = lambda item=child: self.on_folders_itemActivated(item)
 
191
                cb = lambda checked, item=child: \
 
192
                    self.on_folders_itemActivated(item)
180
193
                # pylint: enable=C0322
181
 
                QtCore.QObject.connect(button, QtCore.SIGNAL('clicked()'), cb)
 
194
                button.clicked.connect(cb)
182
195
                self.ui.folders.setIndexWidget(model_index, button)
183
196
 
184
197
        self.ui.folders.expandAll()
196
209
            logger.warning('on_folders_itemActivated: stored path %r '
197
210
                           'does not exist.', volume_path)
198
211
        else:
199
 
            uri = FILE_URI_PREFIX + volume_path
 
212
            uri = unicode(QtCore.QUrl.fromLocalFile(volume_path).toString())
200
213
            uri_hook(uri)
201
214
 
202
215
    @defer.inlineCallbacks
230
243
            # user accepted, merge the folder content
231
244
            yield self.backend.change_volume_settings(volume_id,
232
245
                                                {'subscribed': subscribed})
 
246
            self.load()
233
247
        else:
234
248
            # restore old value
235
249
            old = UNCHECKED if subscribed else CHECKED