summaryrefslogtreecommitdiff
path: root/libnautilus
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2000-02-18 22:29:44 +0000
committerDarin Adler <darin@src.gnome.org>2000-02-18 22:29:44 +0000
commitff1efb492d577d439675c3ef6556c8a4ba997b02 (patch)
tree79712e2ac944a8ef1f410816fd4dc4b7425bd15f /libnautilus
parent0653c1cccc33f7ffedf99b0041b41c1a773b8c94 (diff)
downloadnautilus-ff1efb492d577d439675c3ef6556c8a4ba997b02.tar.gz
Hooked up the menu item for using the Eazel Theme Icons so people can try
* src/file-manager/fm-directory-view.c: (use_eazel_theme_icons_cb), (finish_adding_menu_item), (add_menu_item), (add_check_menu_item), (fm_directory_view_real_append_background_context_menu_items): Hooked up the menu item for using the Eazel Theme Icons so people can try out the icons that are tuned at different sizes. * libnautilus/nautilus-icon-factory.h: * libnautilus/nautilus-icon-factory.c, (nautilus_icon_factory_get), (nautilus_icon_factory_new), (nautilus_icon_factory_initialize), (nautilus_icon_factory_initialize_class), (nautilus_icon_factory_get_theme), (nautilus_icon_factory_set_theme): Added a signal "theme_changed" to the icon factory, and had to add a visible icon factory object so clients can connect to the signal. * libnautilus/gnome-icon-container.c, (gnome_icon_container_initialize), (gnome_icon_container_request_update_all): Update all icons when the theme changes. * docs/recommended-books.html: Added this since style-guide.html refers to it.
Diffstat (limited to 'libnautilus')
-rw-r--r--libnautilus/gnome-icon-container.c8
-rw-r--r--libnautilus/nautilus-icon-factory.c101
-rw-r--r--libnautilus/nautilus-icon-factory.h12
3 files changed, 100 insertions, 21 deletions
diff --git a/libnautilus/gnome-icon-container.c b/libnautilus/gnome-icon-container.c
index 118bd3d91..59444ee20 100644
--- a/libnautilus/gnome-icon-container.c
+++ b/libnautilus/gnome-icon-container.c
@@ -2077,6 +2077,12 @@ gnome_icon_container_initialize (GnomeIconContainer *container)
/* Request update. */
add_idle (container);
+
+ /* Make sure that we find out if the theme changes. */
+ gtk_signal_connect_object_while_alive (nautilus_icon_factory_get (),
+ "theme_changed",
+ gnome_icon_container_request_update_all,
+ GTK_OBJECT (container));
}
@@ -2465,6 +2471,8 @@ gnome_icon_container_request_update_all (GnomeIconContainer *container)
{
GList *p;
+ g_return_if_fail (GNOME_IS_ICON_CONTAINER (container));
+
for (p = container->details->icons; p != NULL; p = p->next)
update_icon (container, p->data);
}
diff --git a/libnautilus/nautilus-icon-factory.c b/libnautilus/nautilus-icon-factory.c
index f046b1329..4d68539b7 100644
--- a/libnautilus/nautilus-icon-factory.c
+++ b/libnautilus/nautilus-icon-factory.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <stdio.h>
+#include <gtk/gtksignal.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-mime-info.h>
#include <libgnome/gnome-util.h>
@@ -37,6 +38,7 @@
#include "nautilus-default-file-icon.h"
#include "nautilus-metadata.h"
#include "nautilus-lib-self-check-functions.h"
+#include "nautilus-gtk-macros.h"
#define ICON_NAME_DIRECTORY "i-directory.png"
#define ICON_NAME_DIRECTORY_CLOSED "i-dirclosed.png"
@@ -79,10 +81,13 @@ struct NautilusCircularList {
};
/* The icon factory.
- * These are actually globals, but they're in a structure so we can
- * have multiple icon factories some day if we want to.
+ * These are just globals, but they're in an object so we can
+ * connect signals and have multiple icon factories some day
+ * if we want to.
*/
typedef struct {
+ GtkObject object;
+
char *theme_name;
/* A hash table so we pass out the same scalable icon pointer
@@ -107,6 +112,16 @@ typedef struct {
GdkPixbuf *symbolic_link_overlay;
} NautilusIconFactory;
+typedef struct {
+ GtkObjectClass parent_class;
+} NautilusIconFactoryClass;
+
+enum {
+ THEME_CHANGED,
+ LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL];
+
/* A scalable icon, which is basically the name and path of an icon,
* before we load the actual pixels of the icons's image.
*/
@@ -134,25 +149,30 @@ typedef struct {
/* forward declarations */
-static NautilusIconFactory * nautilus_get_current_icon_factory (void);
-static NautilusIconFactory * nautilus_icon_factory_new (const char *theme_name);
-static NautilusScalableIcon *nautilus_scalable_icon_get (const char *uri,
- const char *name,
- gboolean is_symbolic_link);
-static guint nautilus_scalable_icon_hash (gconstpointer p);
-static gboolean nautilus_scalable_icon_equal (gconstpointer a,
- gconstpointer b);
-static void nautilus_icon_cache_key_destroy (NautilusIconCacheKey *key);
-static guint nautilus_icon_cache_key_hash (gconstpointer p);
-static gboolean nautilus_icon_cache_key_equal (gconstpointer a,
- gconstpointer b);
-static GdkPixbuf * get_image_from_cache (NautilusScalableIcon *scalable_icon,
- guint size_in_pixels,
- gboolean picky,
- gboolean custom);
+static GtkType nautilus_icon_factory_get_type (void);
+static void nautilus_icon_factory_initialize_class (NautilusIconFactoryClass *class);
+static void nautilus_icon_factory_initialize (NautilusIconFactory *factory);
+static NautilusIconFactory * nautilus_get_current_icon_factory (void);
+static NautilusIconFactory * nautilus_icon_factory_new (const char *theme_name);
+static NautilusScalableIcon *nautilus_scalable_icon_get (const char *uri,
+ const char *name,
+ gboolean is_symbolic_link);
+static guint nautilus_scalable_icon_hash (gconstpointer p);
+static gboolean nautilus_scalable_icon_equal (gconstpointer a,
+ gconstpointer b);
+static void nautilus_icon_cache_key_destroy (NautilusIconCacheKey *key);
+static guint nautilus_icon_cache_key_hash (gconstpointer p);
+static gboolean nautilus_icon_cache_key_equal (gconstpointer a,
+ gconstpointer b);
+static GdkPixbuf * get_image_from_cache (NautilusScalableIcon *scalable_icon,
+ guint size_in_pixels,
+ gboolean picky,
+ gboolean custom);
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconFactory, nautilus_icon_factory, GTK_TYPE_OBJECT)
/* Return a pointer to the single global icon factory. */
-NautilusIconFactory *
+static NautilusIconFactory *
nautilus_get_current_icon_factory (void)
{
static NautilusIconFactory *global_icon_factory = NULL;
@@ -161,15 +181,28 @@ nautilus_get_current_icon_factory (void)
return global_icon_factory;
}
+GtkObject *
+nautilus_icon_factory_get (void)
+{
+ return GTK_OBJECT (nautilus_get_current_icon_factory ());
+}
+
/* Create the icon factory. */
static NautilusIconFactory *
nautilus_icon_factory_new (const char *theme_name)
{
NautilusIconFactory *factory;
- factory = g_new0 (NautilusIconFactory, 1);
+ factory = (NautilusIconFactory *) gtk_object_new (nautilus_icon_factory_get_type (), NULL);
factory->theme_name = g_strdup (theme_name);
+
+ return factory;
+}
+
+static void
+nautilus_icon_factory_initialize (NautilusIconFactory *factory)
+{
factory->scalable_icons = g_hash_table_new (nautilus_scalable_icon_hash,
nautilus_scalable_icon_equal);
factory->icon_cache = g_hash_table_new (nautilus_icon_cache_key_hash,
@@ -178,8 +211,24 @@ nautilus_icon_factory_new (const char *theme_name)
/* Empty out the recently-used list. */
factory->recently_used_dummy_head.next = &factory->recently_used_dummy_head;
factory->recently_used_dummy_head.prev = &factory->recently_used_dummy_head;
+}
- return factory;
+static void
+nautilus_icon_factory_initialize_class (NautilusIconFactoryClass *class)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS (class);
+
+ signals[THEME_CHANGED]
+ = gtk_signal_new ("theme_changed",
+ GTK_RUN_LAST,
+ object_class->type,
+ 0,
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
}
/* Destroy one image in the cache. */
@@ -285,6 +334,13 @@ nautilus_icon_factory_schedule_sweep (void)
factory);
}
+/* Get the name of the current theme. */
+char *
+nautilus_icon_factory_get_theme (void)
+{
+ return g_strdup (nautilus_get_current_icon_factory ()->theme_name);
+}
+
/* Change the theme. */
void
nautilus_icon_factory_set_theme (const char *theme_name)
@@ -297,6 +353,9 @@ nautilus_icon_factory_set_theme (const char *theme_name)
g_free (factory->theme_name);
factory->theme_name = g_strdup (theme_name);
+
+ gtk_signal_emit (GTK_OBJECT (factory),
+ signals[THEME_CHANGED]);
}
/* Use the MIME type to get the icon name. */
diff --git a/libnautilus/nautilus-icon-factory.h b/libnautilus/nautilus-icon-factory.h
index 9ee1abbba..46f9151db 100644
--- a/libnautilus/nautilus-icon-factory.h
+++ b/libnautilus/nautilus-icon-factory.h
@@ -69,10 +69,22 @@ typedef enum {
typedef struct _NautilusScalableIcon NautilusScalableIcon;
+/* Instead of a class declaration here, I will just document
+ * the signals.
+ *
+ * "theme_changed", no parameters
+ */
+
+/* There's a single NautilusIconFactory object.
+ * The only thing you need it for is to connect to its signals.
+ */
+GtkObject * nautilus_icon_factory_get (void);
+
/* Relationship between zoom levels and icons sizes. */
guint nautilus_get_icon_size_for_zoom_level (NautilusZoomLevel zoom_level);
/* Switch themes. */
+char * nautilus_icon_factory_get_theme (void);
void nautilus_icon_factory_set_theme (const char *theme_name);
/* Choose the appropriate icon, but don't render it yet. */