[gnome-commander/gcmd-1-3] Do not call IMAGE_get_pixmap_and_mask() twice when displaying file icons



commit ca59b74cbbad9924667c6db6beec38a91b4472bd
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sat Sep 12 13:42:14 2009 +0200

    Do not call IMAGE_get_pixmap_and_mask() twice when displaying file icons
    
    That should spare a few cpu cycles when in file icon mode.

 src/gnome-cmd-file-list.cc |   10 +++++++---
 src/gnome-cmd-file.cc      |    9 +++++++++
 src/gnome-cmd-file.h       |    1 +
 3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index ae8511b..194dbcd 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -1595,9 +1595,13 @@ void GnomeCmdFileList::update_file(GnomeCmdFile *f)
         gtk_clist_set_text (*this, row, i, data.text[i]);
 
     if (gnome_cmd_data.layout != GNOME_CMD_LAYOUT_TEXT)
-        gtk_clist_set_pixmap (*this, row, 0,
-                              gnome_cmd_file_get_type_pixmap (f),
-                              gnome_cmd_file_get_type_mask (f));
+    {
+        GdkPixmap *pixmap;
+        GdkBitmap *mask;
+
+        if (gnome_cmd_file_get_type_pixmap_and_mask (f, &pixmap, &mask))
+            gtk_clist_set_pixmap (*this, row, 0, pixmap, mask);
+    }
 }
 
 
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index d8bb37b..ec6bb69 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -646,6 +646,15 @@ const gchar *gnome_cmd_file_get_type_desc (GnomeCmdFile *f)
 }
 
 
+gboolean gnome_cmd_file_get_type_pixmap_and_mask (GnomeCmdFile *f, GdkPixmap **pixmap, GdkBitmap **mask)
+{
+    g_return_val_if_fail (f != NULL, NULL);
+    g_return_val_if_fail (f->info != NULL, NULL);
+
+    return IMAGE_get_pixmap_and_mask (f->info->type, f->info->mime_type, f->info->symlink_name != NULL, pixmap, mask);
+}
+
+
 GdkPixmap *gnome_cmd_file_get_type_pixmap (GnomeCmdFile *f)
 {
     g_return_val_if_fail (f != NULL, NULL);
diff --git a/src/gnome-cmd-file.h b/src/gnome-cmd-file.h
index ee7a860..7f10bc6 100644
--- a/src/gnome-cmd-file.h
+++ b/src/gnome-cmd-file.h
@@ -106,6 +106,7 @@ gboolean gnome_cmd_file_mime_begins_with (GnomeCmdFile *f, const gchar *mime_typ
 
 const gchar *gnome_cmd_file_get_type_string (GnomeCmdFile *f);
 const gchar *gnome_cmd_file_get_type_desc (GnomeCmdFile *f);
+gboolean gnome_cmd_file_get_type_pixmap_and_mask (GnomeCmdFile *f, GdkPixmap **pixmap, GdkBitmap **mask);
 GdkPixmap *gnome_cmd_file_get_type_pixmap (GnomeCmdFile *f);
 GdkBitmap *gnome_cmd_file_get_type_mask (GnomeCmdFile *f);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]