diff options
author | George Lebl <jirka@5z.com> | 2000-08-20 04:43:01 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2000-08-20 04:43:01 +0000 |
commit | 8b6aca1a6df97e4461f8dd85dc2b0ad3dd169bd9 (patch) | |
tree | e37cf9a91fbf86fcd9d02e0059b82248a5afab44 | |
parent | e576f941d2b9d17507b4818dece2151a240fc984 (diff) | |
download | nautilus-8b6aca1a6df97e4461f8dd85dc2b0ad3dd169bd9.tar.gz |
use xml memory allocation/deallocation routines for strings which are
Sat Aug 19 23:43:23 2000 George Lebl <jirka@5z.com>
* librsvg/rsvg.c (rsvg_ctx_free_helper) (rsvg_entity_decl):
use xml memory allocation/deallocation routines for strings
which are allocated/deallocated inside libxml to make glib
memory checking not crash
* libnautilus-extentions/nautilus-gnome-extentions.[ch]:
add a function nautilus_gnome_stock_set_icon_or_register which
does the GnomeStock voodoo for setting stock toolbar icons to
arbitrary files
* src/nautilus-window-toolbars.c (set_up_button): Use the
nautilus_gnome_stock_set_icon_or_register function as per Darin's
FIXME which thus got removed.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-gnome-extensions.c | 50 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-gnome-extensions.h | 7 | ||||
-rw-r--r-- | libnautilus-private/nautilus-gnome-extensions.c | 50 | ||||
-rw-r--r-- | libnautilus-private/nautilus-gnome-extensions.h | 7 | ||||
-rw-r--r-- | librsvg/rsvg.c | 7 | ||||
-rw-r--r-- | src/nautilus-window-toolbars.c | 40 |
7 files changed, 140 insertions, 37 deletions
@@ -1,3 +1,19 @@ +Sat Aug 19 23:43:23 2000 George Lebl <jirka@5z.com> + + * librsvg/rsvg.c (rsvg_ctx_free_helper) (rsvg_entity_decl): + use xml memory allocation/deallocation routines for strings + which are allocated/deallocated inside libxml to make glib + memory checking not crash + + * libnautilus-extentions/nautilus-gnome-extentions.[ch]: + add a function nautilus_gnome_stock_set_icon_or_register which + does the GnomeStock voodoo for setting stock toolbar icons to + arbitrary files + + * src/nautilus-window-toolbars.c (set_up_button): Use the + nautilus_gnome_stock_set_icon_or_register function as per Darin's + FIXME which thus got removed. + 2000-08-19 Maciej Stachowiak <mjs@eazel.com> * components/tree/nautilus-tree-model.c: (report_node_added, diff --git a/libnautilus-extensions/nautilus-gnome-extensions.c b/libnautilus-extensions/nautilus-gnome-extensions.c index 2e2bb1c66..c1d43b66d 100644 --- a/libnautilus-extensions/nautilus-gnome-extensions.c +++ b/libnautilus-extensions/nautilus-gnome-extensions.c @@ -542,3 +542,53 @@ nautilus_gnome_open_terminal (const char *command) g_free (shell); g_free (terminal_path); } + + +/* Set an icon on GnomeStock widget. If the setting fails register this + * as a new file. Returns FALSE if even that failed */ +gboolean +nautilus_gnome_stock_set_icon_or_register (GnomeStock *stock, const char *icon) +{ + GnomeStockPixmapEntryPath *new_entry; + + g_return_val_if_fail (stock != NULL, FALSE); + g_return_val_if_fail (GNOME_IS_STOCK (stock), FALSE); + g_return_val_if_fail (icon != NULL, FALSE); + + /* if we can set the icon and everything goes well we have succeeded */ + if (gnome_stock_set_icon (stock, icon)) { + return TRUE; + } + + /* If the icon string is not an existing file then this is just a + * bogus request and we return FALSE */ + if ( ! g_file_exists (icon)) { + return FALSE; + } + + /* If icon exists but gnome_stock_set_icon fails, + * that means this file has NOT been registered with + * gnome stock. Unfortunately gnome_stock is a + * worthless pile of dung and doesn't do this for us. + * Do note however that it DOES register this stuff + * when it first creates the toolbars from + * GnomeUIInfo. Go figure. + * + * Note that all this will be completely different in gnome 2.0 + */ + + new_entry = g_malloc (sizeof (GnomeStockPixmapEntryPath)); + new_entry->type = GNOME_STOCK_PIXMAP_TYPE_PATH; + new_entry->label = NULL; + new_entry->pathname = g_strdup (icon); + new_entry->width = 0; + new_entry->height = 0; + + /* Register this under the "icon" as that's what + * we'll look it up under later. + */ + gnome_stock_pixmap_register (icon, GNOME_STOCK_PIXMAP_REGULAR, + (GnomeStockPixmapEntry *) new_entry); + + return gnome_stock_set_icon (stock, icon); +} diff --git a/libnautilus-extensions/nautilus-gnome-extensions.h b/libnautilus-extensions/nautilus-gnome-extensions.h index 954536550..ea43de5a0 100644 --- a/libnautilus-extensions/nautilus-gnome-extensions.h +++ b/libnautilus-extensions/nautilus-gnome-extensions.h @@ -29,6 +29,7 @@ #include <libgnomeui/gnome-canvas.h> #include <libgnomeui/gnome-dialog.h> +#include <libgnomeui/gnome-stock.h> #include <gtk/gtkbutton.h> #include <gtk/gtkwindow.h> @@ -109,4 +110,10 @@ GtkButton *nautilus_gnome_dialog_get_button_by_index (GnomeDialog /* Open up a new terminal, optionally passing in a command to execute */ void nautilus_gnome_open_terminal (const char *command); + +/* Set an icon on GnomeStock widget. If the setting fails register this + * as a new file. Returns FALSE if even that failed */ +gboolean nautilus_gnome_stock_set_icon_or_register (GnomeStock *stock, + const char *icon); + #endif /* NAUTILUS_GNOME_EXTENSIONS_H */ diff --git a/libnautilus-private/nautilus-gnome-extensions.c b/libnautilus-private/nautilus-gnome-extensions.c index 2e2bb1c66..c1d43b66d 100644 --- a/libnautilus-private/nautilus-gnome-extensions.c +++ b/libnautilus-private/nautilus-gnome-extensions.c @@ -542,3 +542,53 @@ nautilus_gnome_open_terminal (const char *command) g_free (shell); g_free (terminal_path); } + + +/* Set an icon on GnomeStock widget. If the setting fails register this + * as a new file. Returns FALSE if even that failed */ +gboolean +nautilus_gnome_stock_set_icon_or_register (GnomeStock *stock, const char *icon) +{ + GnomeStockPixmapEntryPath *new_entry; + + g_return_val_if_fail (stock != NULL, FALSE); + g_return_val_if_fail (GNOME_IS_STOCK (stock), FALSE); + g_return_val_if_fail (icon != NULL, FALSE); + + /* if we can set the icon and everything goes well we have succeeded */ + if (gnome_stock_set_icon (stock, icon)) { + return TRUE; + } + + /* If the icon string is not an existing file then this is just a + * bogus request and we return FALSE */ + if ( ! g_file_exists (icon)) { + return FALSE; + } + + /* If icon exists but gnome_stock_set_icon fails, + * that means this file has NOT been registered with + * gnome stock. Unfortunately gnome_stock is a + * worthless pile of dung and doesn't do this for us. + * Do note however that it DOES register this stuff + * when it first creates the toolbars from + * GnomeUIInfo. Go figure. + * + * Note that all this will be completely different in gnome 2.0 + */ + + new_entry = g_malloc (sizeof (GnomeStockPixmapEntryPath)); + new_entry->type = GNOME_STOCK_PIXMAP_TYPE_PATH; + new_entry->label = NULL; + new_entry->pathname = g_strdup (icon); + new_entry->width = 0; + new_entry->height = 0; + + /* Register this under the "icon" as that's what + * we'll look it up under later. + */ + gnome_stock_pixmap_register (icon, GNOME_STOCK_PIXMAP_REGULAR, + (GnomeStockPixmapEntry *) new_entry); + + return gnome_stock_set_icon (stock, icon); +} diff --git a/libnautilus-private/nautilus-gnome-extensions.h b/libnautilus-private/nautilus-gnome-extensions.h index 954536550..ea43de5a0 100644 --- a/libnautilus-private/nautilus-gnome-extensions.h +++ b/libnautilus-private/nautilus-gnome-extensions.h @@ -29,6 +29,7 @@ #include <libgnomeui/gnome-canvas.h> #include <libgnomeui/gnome-dialog.h> +#include <libgnomeui/gnome-stock.h> #include <gtk/gtkbutton.h> #include <gtk/gtkwindow.h> @@ -109,4 +110,10 @@ GtkButton *nautilus_gnome_dialog_get_button_by_index (GnomeDialog /* Open up a new terminal, optionally passing in a command to execute */ void nautilus_gnome_open_terminal (const char *command); + +/* Set an icon on GnomeStock widget. If the setting fails register this + * as a new file. Returns FALSE if even that failed */ +gboolean nautilus_gnome_stock_set_icon_or_register (GnomeStock *stock, + const char *icon); + #endif /* NAUTILUS_GNOME_EXTENSIONS_H */ diff --git a/librsvg/rsvg.c b/librsvg/rsvg.c index 35e252d19..8582e94a1 100644 --- a/librsvg/rsvg.c +++ b/librsvg/rsvg.c @@ -48,6 +48,7 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include "SAX.h" +#include "xmlmemory.h" #include "rsvg-bpath-util.h" #include "rsvg-defs.h" @@ -173,8 +174,8 @@ rsvg_ctx_free_helper (gpointer key, gpointer value, gpointer user_data) g_free ((xmlChar *)entval->name); g_free ((xmlChar *)entval->ExternalID); g_free ((xmlChar *)entval->SystemID); - g_free (entval->content); - g_free (entval->orig); + xmlFree (entval->content); + xmlFree (entval->orig); g_free (entval); } @@ -1176,7 +1177,7 @@ rsvg_entity_decl (void *data, const xmlChar *name, int type, entity->name = dupname; entity->ExternalID = g_strdup (publicId); entity->SystemID = g_strdup (systemId); - entity->content = g_strdup (content); + entity->content = xmlMemStrdup (content); entity->length = strlen (content); entity->orig = NULL; g_hash_table_insert (entities, dupname, entity); diff --git a/src/nautilus-window-toolbars.c b/src/nautilus-window-toolbars.c index 988d3c90a..d180516c2 100644 --- a/src/nautilus-window-toolbars.c +++ b/src/nautilus-window-toolbars.c @@ -36,6 +36,7 @@ #include <libnautilus-extensions/nautilus-bookmark.h> #include <libnautilus-extensions/nautilus-global-preferences.h> #include <libnautilus-extensions/nautilus-gtk-extensions.h> +#include <libnautilus-extensions/nautilus-gnome-extensions.h> #include <libnautilus-extensions/nautilus-theme.h> /* forward declarations */ @@ -285,14 +286,9 @@ set_up_button (GtkWidget* button, const char *theme_name, const char *icon_name) { - /* FIXME: This GnomeStock trickery belongs in the - * libnautilus-extensions library. That's where we put - * workarounds like this. - */ GnomeStock *stock_widget; char *full_name; GtkToolbarChild *toolbar_child; - GnomeStockPixmapEntryPath *new_entry; if (theme_name == NULL || strcmp (theme_name, "default") == 0) { full_name = g_strdup (icon_name); @@ -309,35 +305,11 @@ set_up_button (GtkWidget* button, stock_widget = NULL; } - if (stock_widget != NULL - && ! gnome_stock_set_icon (stock_widget, full_name) - && g_file_exists (full_name)) { - /* If full_name exists but gnome_stock_set_icon fails, - * that means this file has NOT been registered with - * gnome stock. Unfortunately gnome_stock is a - * worthless pile of dung and doesn't do this for us. - * Do note however that it DOES register this stuff - * when it first creates the toolbars from - * GnomeUIInfo. - */ - new_entry = g_malloc (sizeof (GnomeStockPixmapEntryPath)); - new_entry->type = GNOME_STOCK_PIXMAP_TYPE_PATH; - new_entry->label = NULL; - new_entry->pathname = full_name; - new_entry->width = 0; - new_entry->height = 0; - - /* Register this under the "full_name" as that's what - * we'll look it up under later. - */ - gnome_stock_pixmap_register (full_name, GNOME_STOCK_PIXMAP_REGULAR, - (GnomeStockPixmapEntry *) new_entry); - gnome_stock_set_icon (stock_widget, full_name); - - /* We used full_name in new_entry, so we just transfer - * ownership. - */ - full_name = NULL; + if (stock_widget != NULL) { + /* We can't just gnome_stock_set_icon here, as that + * doesn't register new pixmaps automatically */ + nautilus_gnome_stock_set_icon_or_register (stock_widget, + full_name); } g_free (full_name); |