[sushi] viewers: unify file and folder viewers
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sushi] viewers: unify file and folder viewers
- Date: Tue, 3 Jul 2012 17:59:38 +0000 (UTC)
commit faba9e057aac5cf70006762bc148c53c6c622168
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Jul 3 13:05:44 2012 -0400
viewers: unify file and folder viewers
There's no need to have both, since they're basically identical. Add to
SushiFileLoader the bits missing to be able to get rid of one.
src/Makefile-js.am | 1 -
src/js/ui/fallbackRenderer.js | 26 +++---
src/js/viewers/folder.js | 166 --------------------------------------
src/libsushi/sushi-file-loader.c | 30 +++++++
src/libsushi/sushi-file-loader.h | 1 +
5 files changed, 45 insertions(+), 179 deletions(-)
---
diff --git a/src/Makefile-js.am b/src/Makefile-js.am
index 27abb98..c71c685 100644
--- a/src/Makefile-js.am
+++ b/src/Makefile-js.am
@@ -15,7 +15,6 @@ dist_jsviewers_DATA = \
js/viewers/gst.js \
js/viewers/audio.js \
js/viewers/evince.js \
- js/viewers/folder.js \
js/viewers/font.js \
js/viewers/html.js \
js/viewers/text.js
diff --git a/src/js/ui/fallbackRenderer.js b/src/js/ui/fallbackRenderer.js
index 3cd897b..66aaf86 100644
--- a/src/js/ui/fallbackRenderer.js
+++ b/src/js/ui/fallbackRenderer.js
@@ -99,6 +99,7 @@ FallbackRenderer.prototype = {
this._box.show_all();
this._actor = new GtkClutter.Actor({ contents: this._box });
+ Utils.alphaGtkWidget(this._actor.get_widget());
callback();
},
@@ -112,25 +113,28 @@ FallbackRenderer.prototype = {
'<b><big>' +
((this._fileLoader.name) ? (this._fileLoader.name) : (this._fileLoader.file.get_basename()))
+ '</big></b>';
+ this._titleLabel.set_markup(titleStr);
- let typeStr =
- '<small><b>' + _("Type") + ' </b>' +
- ((this._fileLoader.contentType) ? (this._fileLoader.contentType) : (_("Loading...")))
- + '</small>';
+ if (this._fileLoader.get_file_type() != Gio.FileType.DIRECTORY) {
+ let typeStr =
+ '<small><b>' + _("Type") + ' </b>' +
+ ((this._fileLoader.contentType) ? (this._fileLoader.contentType) : (_("Loading...")))
+ + '</small>';
+ this._typeLabel.set_markup(typeStr);
+ } else {
+ this._typeLabel.hide();
+ }
let sizeStr =
'<small><b>' + _("Size") + ' </b>' +
((this._fileLoader.size) ? (this._fileLoader.size) : (_("Loading...")))
+ '</small>';
+ this._sizeLabel.set_markup(sizeStr);
let dateStr =
'<small><b>' + _("Modified") + ' </b>' +
((this._fileLoader.time) ? (this._fileLoader.time) : (_("Loading...")))
+ '</small>';
-
- this._titleLabel.set_markup(titleStr);
- this._typeLabel.set_markup(typeStr);
- this._sizeLabel.set_markup(sizeStr);
this._dateLabel.set_markup(dateStr);
},
@@ -142,15 +146,13 @@ FallbackRenderer.prototype = {
if (this._fileLoader.icon)
this._image.set_from_pixbuf(this._fileLoader.icon);
+ else
+ this._setImageFromType();
this._applyLabels();
this._mainWindow.refreshSize();
},
- createToolbar : function() {
- return null;
- },
-
clear : function() {
if (this._fileLoader) {
this._fileLoader.disconnect(this._fileLoaderId);
diff --git a/src/libsushi/sushi-file-loader.c b/src/libsushi/sushi-file-loader.c
index 91972f8..b076621 100644
--- a/src/libsushi/sushi-file-loader.c
+++ b/src/libsushi/sushi-file-loader.c
@@ -57,6 +57,7 @@ enum {
PROP_TIME,
PROP_FILE,
PROP_CONTENT_TYPE,
+ PROP_FILE_TYPE
};
typedef struct {
@@ -358,6 +359,7 @@ query_info_async_ready_cb (GObject *source,
g_object_notify (G_OBJECT (self), "name");
g_object_notify (G_OBJECT (self), "time");
g_object_notify (G_OBJECT (self), "content-type");
+ g_object_notify (G_OBJECT (self), "file-type");
if (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY) {
self->priv->loading = FALSE;
@@ -440,6 +442,9 @@ sushi_file_loader_get_property (GObject *object,
case PROP_CONTENT_TYPE:
g_value_take_string (value, sushi_file_loader_get_content_type_string (self));
break;
+ case PROP_FILE_TYPE:
+ g_value_set_enum (value, sushi_file_loader_get_file_type (self));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -518,6 +523,16 @@ sushi_file_loader_class_init (SushiFileLoaderClass *klass)
"The content type",
NULL,
G_PARAM_READABLE));
+
+ g_object_class_install_property
+ (oclass,
+ PROP_CONTENT_TYPE,
+ g_param_spec_enum ("file-type",
+ "File Type",
+ "The file type",
+ G_TYPE_FILE_TYPE,
+ G_FILE_TYPE_UNKNOWN,
+ G_PARAM_READABLE));
g_object_class_install_property
(oclass,
@@ -703,6 +718,21 @@ sushi_file_loader_get_content_type_string (SushiFileLoader *self)
return g_content_type_get_description (g_file_info_get_content_type (self->priv->info));
}
+/**
+ * sushi_file_loader_get_file_type:
+ * @self:
+ *
+ * Returns:
+ */
+GFileType
+sushi_file_loader_get_file_type (SushiFileLoader *self)
+{
+ if (self->priv->info == NULL)
+ return G_FILE_TYPE_UNKNOWN;
+
+ return g_file_info_get_file_type (self->priv->info);
+}
+
void
sushi_file_loader_stop (SushiFileLoader *self)
{
diff --git a/src/libsushi/sushi-file-loader.h b/src/libsushi/sushi-file-loader.h
index 90ca11e..0b7f146 100644
--- a/src/libsushi/sushi-file-loader.h
+++ b/src/libsushi/sushi-file-loader.h
@@ -66,6 +66,7 @@ gchar *sushi_file_loader_get_size_string (SushiFileLoader *self);
gchar *sushi_file_loader_get_date_string (SushiFileLoader *self);
gchar *sushi_file_loader_get_content_type_string (SushiFileLoader *self);
GdkPixbuf *sushi_file_loader_get_icon (SushiFileLoader *self);
+GFileType sushi_file_loader_get_file_type (SushiFileLoader *self);
gboolean sushi_file_loader_get_loading (SushiFileLoader *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]