A typical Django project will often have several files named 'models.py' and 'views.py'.
I started looking at what it would mean to set the view titles to '(parentdir)/(baseName)' but since koIView's title attribute is readonly this isn't possible.
Any chance this could be opened up so macros can modify view titles?
Here's a quick solution. Create a macro that has a startup trigger. Enter the following JS.
var vm = ko.views.manager.topView;
var box = document.getAnonymousNodes(vm)[0];
// get the views-tabbed elements
var tabset1 = box.firstChild;
var tabset2 = box.lastChild;
// replace the updateLeafName implementation to use something different
// for the tab label
tabset1.updateLeafName =
tabset2.updateLeafName = function(view) {
view.parentNode._tab.label = view.title;
if (view.document) {
view.parentNode._tab.setAttribute('crop', 'start');
view.parentNode._tab.label = view.document.displayPath;
view.parentNode._tab.setAttribute('tooltiptext',view.document.displayPath);
this.tabbox.firstChild.scrollBoxObject.ensureElementIsVisible(this.tabbox.firstChild.selectedItem);
}
}
// the "on startup" trigger happens after files
// are opened, so we need to call updateLeafName
// for each opened view. Files opened after startup
// will be fine
var views = ko.views.manager.topView.getViews(true);
for (var i=0; i < views.length; i++) {
if (views[i].document)
views[i].updateLeafName(views[i]);
}
} catch(e) {
alert(e);
}
Perfect, thanks Shane. I've posted an updated version that only shows the parent directory and the filename (and only for python files) here: http://dpaste.com/hold/47625/