summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2000-02-01 05:34:46 +0000
committerDarin Adler <darin@src.gnome.org>2000-02-01 05:34:46 +0000
commit39b26449f4fcdf53f555e8d2ef03522e883c5c06 (patch)
tree9642f60f64a663609c8d7e981381b85ba305113d /src
parent9bef26f2d771ff19272596ecaf6c2b812cf62945 (diff)
downloadnautilus-39b26449f4fcdf53f555e8d2ef03522e883c5c06.tar.gz
Changed the icon factory interface in a few ways: 1) There's no longer a
* libnautilus/nautilus-icon-factory.h: * libnautilus/nautilus-icon-factory.c: (nautilus_icon_factory_new): (nautilus_icon_factory_destroy): (nautilus_get_current_icon_factory): (nautilus_icon_factory_get_icon_for_file): (nautilus_icon_factory_set_theme): (nautilus_icon_factory_get_icon_by_name): (nautilus_icon_factory_get_pixbuf_for_icon): (nautilus_scalable_icon_ref): (nautilus_scalable_icon_unref): (nautilus_scalable_icon_get_name): (scalable_icon_get): (icon_set_possibly_free): (scalable_icon_new): Changed the icon factory interface in a few ways: 1) There's no longer a NautilusIconFactory object. There's just a single global icon factory. If we find that we need multiple factories, we can implement that later. 2) Instead of going straight from a file to a pixbuf, you get a scalable icon, and then get a pixbuf from that. This allows you to choose the icon and then get different-sized versions of it without going through the icon selection process over and over again. There's also a name for each icon which can be stored in the metafile so you can get the same icon again before you have full information on a file. * src/nautilus-bookmark.c: (nautilus_bookmark_get_pixmap_and_mask): * src/file-manager/fm-directory-view-list.c: (install_icon): * src/file-manager/fm-icons-controller.c: (fm_icons_controller_get_icon_image): Changed icon factory clients to use the new interface. Maybe after a while I'll add a convenience function that's as simple as the old interface was for the common case where you want to go straight to the pixbuf, but lets try it this way for a while. * libnautilus/nautilus-string.h: * libnautilus/nautilus-string.c: (nautilus_has_prefix): Added nautilus_has_prefix. This checks to see if a string has a particular prefix. It's both clearer to read and more efficient than Andy's typical trick of calling strstr. * libnautilus/nautilus-lib-self-check-functions.h: * libnautilus/nautilus-string.c: Added self-checks for nautilus-string.c. The tests uncovered a bug in nautilus_string_to_int that I fixed. * nautilus-glib-extensions.c: Just a stray new-line.
Diffstat (limited to 'src')
-rw-r--r--src/file-manager/fm-directory-view-list.c10
-rw-r--r--src/file-manager/fm-icons-controller.c18
-rw-r--r--src/nautilus-bookmark.c14
3 files changed, 26 insertions, 16 deletions
diff --git a/src/file-manager/fm-directory-view-list.c b/src/file-manager/fm-directory-view-list.c
index 5d7d3d25b..8bf53360a 100644
--- a/src/file-manager/fm-directory-view-list.c
+++ b/src/file-manager/fm-directory-view-list.c
@@ -897,6 +897,7 @@ install_icon (FMDirectoryViewList *list_view, guint row)
{
NautilusFile *file;
GtkCList *clist;
+ NautilusScalableIcon *scalable_icon;
GdkPixbuf *pixbuf;
GdkPixmap *pixmap;
GdkBitmap *bitmap;
@@ -909,10 +910,11 @@ install_icon (FMDirectoryViewList *list_view, guint row)
g_assert (file != NULL);
- pixbuf = nautilus_icon_factory_get_icon_for_file (
- nautilus_get_current_icon_factory(),
- file,
- fm_directory_view_list_get_icon_size (list_view));
+ scalable_icon = nautilus_icon_factory_get_icon_for_file (file);
+ pixbuf = nautilus_icon_factory_get_pixbuf_for_icon
+ (scalable_icon,
+ fm_directory_view_list_get_icon_size (list_view));
+ nautilus_scalable_icon_unref (scalable_icon);
/* GtkCList requires a pixmap & mask rather than a pixbuf */
gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &bitmap, 100);
diff --git a/src/file-manager/fm-icons-controller.c b/src/file-manager/fm-icons-controller.c
index 6fa4270e2..40c6f3cd0 100644
--- a/src/file-manager/fm-icons-controller.c
+++ b/src/file-manager/fm-icons-controller.c
@@ -74,13 +74,21 @@ static GdkPixbuf *
fm_icons_controller_get_icon_image (NautilusIconsController *controller,
NautilusControllerIcon *icon)
{
- /* Get the appropriate image and name for the file. For the moment,
+ /* Get the appropriate image for the file. For the moment,
* we always use the standard size of icons.
*/
- return nautilus_icon_factory_get_icon_for_file (
- nautilus_get_current_icon_factory (),
- NAUTILUS_FILE (icon),
- NAUTILUS_ICON_SIZE_STANDARD);
+
+ NautilusScalableIcon *scalable_icon;
+ GdkPixbuf *pixbuf;
+
+ scalable_icon = nautilus_icon_factory_get_icon_for_file
+ (NAUTILUS_FILE (icon));
+ pixbuf = nautilus_icon_factory_get_pixbuf_for_icon
+ (scalable_icon,
+ NAUTILUS_ICON_SIZE_STANDARD);
+ nautilus_scalable_icon_unref (scalable_icon);
+
+ return pixbuf;
}
static char *
diff --git a/src/nautilus-bookmark.c b/src/nautilus-bookmark.c
index 68e011332..8372f6e36 100644
--- a/src/nautilus-bookmark.c
+++ b/src/nautilus-bookmark.c
@@ -171,9 +171,9 @@ nautilus_bookmark_get_pixmap_and_mask (const NautilusBookmark *bookmark,
GdkPixmap **pixmap_return,
GdkBitmap **mask_return)
{
- GdkPixbuf *pixbuf;
NautilusFile *file;
-
+ NautilusScalableIcon *scalable_icon;
+ GdkPixbuf *pixbuf;
file = nautilus_file_get (nautilus_bookmark_get_uri (bookmark));
@@ -185,13 +185,13 @@ nautilus_bookmark_get_pixmap_and_mask (const NautilusBookmark *bookmark,
if (file == NULL)
return FALSE;
- pixbuf = nautilus_icon_factory_get_icon_for_file (
- nautilus_get_current_icon_factory(),
- file,
- icon_size);
-
+ scalable_icon = nautilus_icon_factory_get_icon_for_file (file);
nautilus_file_unref (file);
+ pixbuf = nautilus_icon_factory_get_pixbuf_for_icon
+ (scalable_icon, icon_size);
+ nautilus_scalable_icon_unref (scalable_icon);
+
gdk_pixbuf_render_pixmap_and_mask (pixbuf, pixmap_return, mask_return, 100);
gdk_pixbuf_unref (pixbuf);