2
* Copyright (C) 2011 Red Hat, Inc.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of the
7
* License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
* The Sushi project hereby grant permission for non-gpl compatible GStreamer
20
* plugins to be used and distributed together with GStreamer and Sushi. This
21
* permission is above and beyond the permissions granted by the GPL license
22
* Sushi is covered by.
24
* Authors: Cosimo Cecchi <cosimoc@redhat.com>
28
let MimeHandler = imports.ui.mimeHandler;
29
let Gtk = imports.gi.Gtk;
30
let Sushi = imports.gi.Sushi;
32
let Gettext = imports.gettext.domain('sushi');
33
let _ = Gettext.gettext;
35
let Constants = imports.util.constants;
36
let Utils = imports.ui.utils;
38
function FolderRenderer(args) {
42
FolderRenderer.prototype = {
44
this._folderLoader = null;
45
this._folderLoaderId = 0;
47
this.moveOnClick = true;
48
this.canFullScreen = false;
51
prepare : function(file, mainWindow, callback) {
52
this._mainWindow = mainWindow;
54
this._callback = callback;
59
this._folderLoader = new Sushi.FileLoader();
60
this._folderLoader.file = file;
61
this._folderLoaderId =
62
this._folderLoader.connect('notify',
63
Lang.bind(this, this._onFolderInfoChanged));
65
this._box = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL,
67
this._image = new Gtk.Image({ icon_name: 'folder',
69
this._box.pack_start(this._image, false, false, 0);
71
let vbox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL,
76
this._box.pack_start(vbox, false, false, 0);
78
let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL,
80
vbox.pack_start(hbox, false, false, 0);
82
this._titleLabel = new Gtk.Label();
83
this._titleLabel.set_halign(Gtk.Align.START);
84
hbox.pack_start(this._titleLabel, false, false, 0);
86
this._spinner = new Gtk.Spinner();
87
hbox.pack_start(this._spinner, false, false, 0);
88
this._spinner.start();
90
this._sizeLabel = new Gtk.Label();
91
this._sizeLabel.set_halign(Gtk.Align.START);
92
vbox.pack_start(this._sizeLabel, false, false, 0);
94
this._dateLabel = new Gtk.Label();
95
this._dateLabel.set_halign(Gtk.Align.START);
96
vbox.pack_start(this._dateLabel, false, false, 0);
100
this._box.show_all();
101
this._actor = new GtkClutter.Actor({ contents: this._box });
106
render : function() {
110
_applyLabels : function() {
111
let name = this._folderLoader.name;
114
name = this._folderLoader.file.get_basename();
120
'<b><big>' + name + '</big></b>';
123
'<small><b>' + _("Size") + ' </b>' +
124
((this._folderLoader.size) ? (this._folderLoader.size) : (_("Loading...")))
128
'<small><b>' + _("Modified") + ' </b>' +
129
((this._folderLoader.time) ? (this._folderLoader.time) : (_("Loading...")))
132
this._titleLabel.set_markup(titleStr);
133
this._sizeLabel.set_markup(sizeStr);
134
this._dateLabel.set_markup(dateStr);
137
_onFolderInfoChanged : function() {
138
if (!this._folderLoader.get_loading()) {
139
this._spinner.stop();
140
this._spinner.hide();
144
this._image.set_from_pixbuf(this._folderLoader.icon);
145
this._mainWindow.refreshSize();
149
if (this._folderLoader) {
150
this._folderLoader.disconnect(this._folderLoaderId);
151
this._folderLoaderId = 0;
153
this._folderLoader.stop();
154
this._folderLoader = null;
158
getSizeForAllocation : function(allocation) {
159
return Utils.getStaticSize(this, this._box);
163
let handler = new MimeHandler.MimeHandler();
164
let renderer = new FolderRenderer();
166
handler.registerMime('inode/directory', renderer);