summaryrefslogtreecommitdiff
path: root/src/file-manager/fm-tree-model.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-11-16 05:08:48 -0800
committerStefano Karapetsas <[email protected]>2012-11-16 05:08:48 -0800
commitdc66bc40724191f0068869773576dc4edf042c6f (patch)
tree74b9684feea188736b21f2c829f29befaaf2e9da /src/file-manager/fm-tree-model.c
parent935e1fed604f48e68d125d205c890a59f46f8f21 (diff)
parent1466df20591105550738a1d0784a623af9909abf (diff)
downloadcaja-dc66bc40724191f0068869773576dc4edf042c6f.tar.bz2
caja-dc66bc40724191f0068869773576dc4edf042c6f.tar.xz
Merge pull request #42 from jasmineaura/develop
Bring Caja up to speed, stage1
Diffstat (limited to 'src/file-manager/fm-tree-model.c')
-rw-r--r--src/file-manager/fm-tree-model.c132
1 files changed, 45 insertions, 87 deletions
diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c
index 15071b8c..3423e2d1 100644
--- a/src/file-manager/fm-tree-model.c
+++ b/src/file-manager/fm-tree-model.c
@@ -29,7 +29,6 @@
#include <config.h>
#include "fm-tree-model.h"
-#include <eel/eel-glib-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <glib/gi18n.h>
#include <libcaja-private/caja-directory.h>
@@ -67,7 +66,6 @@ struct TreeNode
GMount *mount;
GdkPixbuf *closed_pixbuf;
GdkPixbuf *open_pixbuf;
- GdkPixbuf *emblem_pixbuf;
FMTreeModelRoot *root;
@@ -221,7 +219,6 @@ tree_node_destroy (FMTreeModel *model, TreeNode *node)
object_unref_if_not_NULL (node->icon);
object_unref_if_not_NULL (node->closed_pixbuf);
object_unref_if_not_NULL (node->open_pixbuf);
- object_unref_if_not_NULL (node->emblem_pixbuf);
g_assert (node->done_loading_id == 0);
g_assert (node->files_added_id == 0);
@@ -278,17 +275,59 @@ get_menu_icon_for_file (TreeNode *node,
CajaFileIconFlags flags)
{
CajaIconInfo *info;
+ GIcon *gicon, *emblem_icon, *emblemed_icon;
+ GEmblem *emblem;
GdkPixbuf *pixbuf, *retval;
gboolean highlight;
int size;
FMTreeModel *model;
+ GList *emblem_icons, *l;
+ char *emblems_to_ignore[3];
+ int i;
size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
- info = caja_file_get_icon (file, size, flags);
+ gicon = caja_file_get_gicon (file, flags);
+
+ i = 0;
+ emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_TRASH;
+
+ if (node->parent && node->parent->file) {
+ if (!caja_file_can_write (node->parent->file)) {
+ emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE;
+ }
+ }
+
+ emblems_to_ignore[i++] = NULL;
+
+ emblem = NULL;
+ emblem_icons = caja_file_get_emblem_icons (node->file,
+ emblems_to_ignore);
+
+ /* pick only the first emblem we can render for the tree view */
+ for (l = emblem_icons; l != NULL; l = l->next) {
+ emblem_icon = l->data;
+ if (caja_icon_theme_can_render (G_THEMED_ICON (emblem_icon))) {
+ emblem = g_emblem_new (emblem_icon);
+ emblemed_icon = g_emblemed_icon_new (gicon, emblem);
+
+ g_object_unref (gicon);
+ g_object_unref (emblem);
+ gicon = emblemed_icon;
+
+ break;
+ }
+ }
+
+ g_list_foreach (emblem_icons, (GFunc) g_object_unref, NULL);
+ g_list_free(emblem_icons);
+
+ info = caja_icon_info_lookup (gicon, size);
retval = caja_icon_info_get_pixbuf_nodefault_at_size (info, size);
model = node->root->model;
+ g_object_unref (gicon);
+
highlight = (g_list_find_custom (model->details->highlighted_files,
file, (GCompareFunc) caja_file_compare_location) != NULL);
@@ -353,67 +392,6 @@ tree_node_update_open_pixbuf (TreeNode *node)
return tree_node_update_pixbuf (node, &node->open_pixbuf, CAJA_FILE_ICON_FLAGS_FOR_OPEN_FOLDER);
}
-static GdkPixbuf *
-tree_node_get_emblem_pixbuf_internal (TreeNode *node)
-{
- GdkPixbuf *pixbuf;
- GList *emblem_pixbufs;
- char *emblems_to_ignore[3];
- int i;
-
- i = 0;
- emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_TRASH;
-
- if (node->parent && node->parent->file)
- {
- if (!caja_file_can_write (node->parent->file))
- {
- emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE;
- }
- }
-
- emblems_to_ignore[i++] = NULL;
-
- emblem_pixbufs = caja_file_get_emblem_pixbufs (node->file,
- caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU),
- TRUE,
- emblems_to_ignore);
-
-
- if (emblem_pixbufs != NULL)
- {
- pixbuf = g_object_ref (emblem_pixbufs->data);
- }
- else
- {
- pixbuf = NULL;
- }
-
- eel_gdk_pixbuf_list_free (emblem_pixbufs);
-
- return pixbuf;
-}
-
-static gboolean
-tree_node_update_emblem_pixbuf (TreeNode *node)
-{
- GdkPixbuf *pixbuf;
-
- if (node->emblem_pixbuf == NULL)
- {
- return FALSE;
- }
- pixbuf = tree_node_get_emblem_pixbuf_internal (node);
- if (pixbuf == node->emblem_pixbuf)
- {
- g_object_unref (pixbuf);
- return FALSE;
- }
- g_object_unref (node->emblem_pixbuf);
- node->emblem_pixbuf = pixbuf;
- return TRUE;
-}
-
static gboolean
tree_node_update_display_name (TreeNode *node)
{
@@ -459,16 +437,6 @@ tree_node_get_open_pixbuf (TreeNode *node)
return node->open_pixbuf;
}
-static GdkPixbuf *
-tree_node_get_emblem_pixbuf (TreeNode *node)
-{
- if (node->emblem_pixbuf == NULL)
- {
- node->emblem_pixbuf = tree_node_get_emblem_pixbuf_internal (node);
- }
- return node->emblem_pixbuf;
-}
-
static const char *
tree_node_get_display_name (TreeNode *node)
{
@@ -919,7 +887,6 @@ update_node_without_reporting (FMTreeModel *model, TreeNode *node)
changed |= tree_node_update_display_name (node);
changed |= tree_node_update_closed_pixbuf (node);
changed |= tree_node_update_open_pixbuf (node);
- changed |= tree_node_update_emblem_pixbuf (node);
return changed;
}
@@ -1244,8 +1211,6 @@ fm_tree_model_get_column_type (GtkTreeModel *model, int index)
return GDK_TYPE_PIXBUF;
case FM_TREE_MODEL_OPEN_PIXBUF_COLUMN:
return GDK_TYPE_PIXBUF;
- case FM_TREE_MODEL_EMBLEM_PIXBUF_COLUMN:
- return GDK_TYPE_PIXBUF;
case FM_TREE_MODEL_FONT_STYLE_COLUMN:
return PANGO_TYPE_STYLE;
default:
@@ -1412,18 +1377,11 @@ fm_tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter, int column, GVa
g_value_init (value, GDK_TYPE_PIXBUF);
g_value_set_object (value, node == NULL ? NULL : tree_node_get_open_pixbuf (node));
break;
- case FM_TREE_MODEL_EMBLEM_PIXBUF_COLUMN:
- g_value_init (value, GDK_TYPE_PIXBUF);
- g_value_set_object (value, node == NULL ? NULL : tree_node_get_emblem_pixbuf (node));
- break;
case FM_TREE_MODEL_FONT_STYLE_COLUMN:
g_value_init (value, PANGO_TYPE_STYLE);
- if (node == NULL)
- {
+ if (node == NULL) {
g_value_set_enum (value, PANGO_STYLE_ITALIC);
- }
- else
- {
+ } else {
g_value_set_enum (value, PANGO_STYLE_NORMAL);
}
break;