Commit 2630769d authored by Darin Adler's avatar Darin Adler
Browse files

libxml2 complains about NULL path, which libxml1 just handled by returning

	* libnautilus-private/nautilus-find-icon-image.c: (read_details):
	libxml2 complains about NULL path, which libxml1 just handled by
	returning NULL, so check for NULL path.

	* libnautilus-private/nautilus-icon-canvas-item.c:
	(nautilus_icon_canvas_item_finalize),
	(nautilus_icon_canvas_item_class_init): Change destroy to finalize.
	(nautilus_icon_canvas_item_set_arg),
	(nautilus_icon_canvas_item_get_arg): Use pointer instead of boxed
	type for font.

	* src/nautilus-window-menus.c: (create_menu_item_from_node),
	(append_static_bookmarks): In the old days, all nodes were elements,
	but now we have nodes for text too. Change code to skip over non-
	element nodes.
parent 52b329b1
2001-11-06 Darin Adler <darin@bentspoon.com>
* libnautilus-private/nautilus-find-icon-image.c: (read_details):
libxml2 complains about NULL path, which libxml1 just handled by
returning NULL, so check for NULL path.
* libnautilus-private/nautilus-icon-canvas-item.c:
(nautilus_icon_canvas_item_finalize),
(nautilus_icon_canvas_item_class_init): Change destroy to finalize.
(nautilus_icon_canvas_item_set_arg),
(nautilus_icon_canvas_item_get_arg): Use pointer instead of boxed
type for font.
* src/nautilus-window-menus.c: (create_menu_item_from_node),
(append_static_bookmarks): In the old days, all nodes were elements,
but now we have nodes for text too. Change code to skip over non-
element nodes.
2001-11-06 Darin Adler <darin@bentspoon.com>
* Lots of files.
......
......@@ -128,6 +128,10 @@ read_details (const char *path,
memset (&details->text_rect, 0, sizeof (details->text_rect));
if (path == NULL) {
return;
}
doc = xmlParseFile (path);
size_as_string = g_strdup_printf ("%u", icon_size);
......
......@@ -157,72 +157,40 @@ static int click_policy_auto_value;
/* GtkObject */
static void nautilus_icon_canvas_item_class_init (NautilusIconCanvasItemClass *class);
static void nautilus_icon_canvas_item_init (NautilusIconCanvasItem *item);
static void nautilus_icon_canvas_item_destroy (GtkObject *object);
static int nautilus_icon_canvas_item_event (GnomeCanvasItem *item,
GdkEvent *event);
static void nautilus_icon_canvas_item_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void nautilus_icon_canvas_item_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
/* GnomeCanvasItem */
static void nautilus_icon_canvas_item_update (GnomeCanvasItem *item,
double *affine,
ArtSVP *clip_path,
int flags);
static void nautilus_icon_canvas_item_draw (GnomeCanvasItem *item,
GdkDrawable *drawable,
int x,
int y,
int width,
int height);
static void nautilus_icon_canvas_item_render (GnomeCanvasItem *item,
GnomeCanvasBuf *buffer);
static double nautilus_icon_canvas_item_point (GnomeCanvasItem *item,
double x,
double y,
int cx,
int cy,
GnomeCanvasItem **actual_item);
static void nautilus_icon_canvas_item_bounds (GnomeCanvasItem *item,
double *x1,
double *y1,
double *x2,
double *y2);
/* private */
static void draw_or_measure_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
int icon_left,
int icon_bottom);
static void draw_or_measure_label_text_aa (NautilusIconCanvasItem *item,
GdkPixbuf *destination_pixbuf,
int icon_left,
int icon_bottom);
static void draw_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
int icon_left,
int icon_bottom);
static void measure_label_text (NautilusIconCanvasItem *item);
static void get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
ArtIRect *rect);
static void emblem_layout_reset (EmblemLayout *layout,
NautilusIconCanvasItem *icon_item,
ArtIRect icon_rect);
static gboolean emblem_layout_next (EmblemLayout *layout,
GdkPixbuf **emblem_pixbuf,
ArtIRect *emblem_rect);
static void draw_pixbuf (GdkPixbuf *pixbuf,
GdkDrawable *drawable,
int x,
int y);
static gboolean hit_test_stretch_handle (NautilusIconCanvasItem *item,
ArtIRect canvas_rect);
static gboolean icon_canvas_item_is_smooth (const NautilusIconCanvasItem *icon_item);
EEL_CLASS_BOILERPLATE (NautilusIconCanvasItem, nautilus_icon_canvas_item, GNOME_TYPE_CANVAS_ITEM)
static void draw_or_measure_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
int icon_left,
int icon_bottom);
static void draw_or_measure_label_text_aa (NautilusIconCanvasItem *item,
GdkPixbuf *destination_pixbuf,
int icon_left,
int icon_bottom);
static void draw_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
int icon_left,
int icon_bottom);
static void measure_label_text (NautilusIconCanvasItem *item);
static void get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
ArtIRect *rect);
static void emblem_layout_reset (EmblemLayout *layout,
NautilusIconCanvasItem *icon_item,
ArtIRect icon_rect);
static gboolean emblem_layout_next (EmblemLayout *layout,
GdkPixbuf **emblem_pixbuf,
ArtIRect *emblem_rect);
static void draw_pixbuf (GdkPixbuf *pixbuf,
GdkDrawable *drawable,
int x,
int y);
static gboolean hit_test_stretch_handle (NautilusIconCanvasItem *item,
ArtIRect canvas_rect);
static gboolean icon_canvas_item_is_smooth (const NautilusIconCanvasItem *icon_item);
EEL_CLASS_BOILERPLATE (NautilusIconCanvasItem,
nautilus_icon_canvas_item,
GNOME_TYPE_CANVAS_ITEM)
static EelSmoothTextLayoutCache *layout_cache;
......@@ -232,63 +200,6 @@ free_layout_cache (void)
g_object_unref (G_OBJECT (layout_cache));
}
/* Class initialization function for the icon canvas item. */
static void
nautilus_icon_canvas_item_class_init (NautilusIconCanvasItemClass *class)
{
GtkObjectClass *object_class;
GnomeCanvasItemClass *item_class;
if (layout_cache == NULL) {
layout_cache = eel_smooth_text_layout_cache_new ();
g_atexit (free_layout_cache);
}
object_class = GTK_OBJECT_CLASS (class);
item_class = GNOME_CANVAS_ITEM_CLASS (class);
gtk_object_add_arg_type ("NautilusIconCanvasItem::editable_text",
G_TYPE_STRING, GTK_ARG_READWRITE, ARG_EDITABLE_TEXT);
gtk_object_add_arg_type ("NautilusIconCanvasItem::additional_text",
G_TYPE_STRING, GTK_ARG_READWRITE, ARG_ADDITIONAL_TEXT);
gtk_object_add_arg_type ("NautilusIconCanvasItem::font",
GTK_TYPE_BOXED, GTK_ARG_READWRITE, ARG_FONT);
gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_for_selection",
G_TYPE_BOOLEAN, GTK_ARG_READWRITE, ARG_HIGHLIGHTED_FOR_SELECTION);
gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_as_keyboard_focus",
G_TYPE_BOOLEAN, GTK_ARG_READWRITE, ARG_HIGHLIGHTED_AS_KEYBOARD_FOCUS);
gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_for_drop",
G_TYPE_BOOLEAN, GTK_ARG_READWRITE, ARG_HIGHLIGHTED_FOR_DROP);
gtk_object_add_arg_type ("NautilusIconCanvasItem::smooth_font_size",
G_TYPE_INT, GTK_ARG_READWRITE, ARG_SMOOTH_FONT_SIZE);
gtk_object_add_arg_type ("NautilusIconCanvasItem::smooth_font",
GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_SMOOTH_FONT);
object_class->destroy = nautilus_icon_canvas_item_destroy;
object_class->set_arg = nautilus_icon_canvas_item_set_arg;
object_class->get_arg = nautilus_icon_canvas_item_get_arg;
signals[BOUNDS_CHANGED]
= g_signal_new ("bounds_changed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusIconCanvasItemClass,
bounds_changed),
NULL, NULL,
gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
item_class->update = nautilus_icon_canvas_item_update;
item_class->draw = nautilus_icon_canvas_item_draw;
item_class->render = nautilus_icon_canvas_item_render;
item_class->point = nautilus_icon_canvas_item_point;
item_class->bounds = nautilus_icon_canvas_item_bounds;
item_class->event = nautilus_icon_canvas_item_event;
eel_preferences_add_auto_integer (NAUTILUS_PREFERENCES_CLICK_POLICY,
&click_policy_auto_value);
}
/* Object initialization function for the icon item. */
static void
nautilus_icon_canvas_item_init (NautilusIconCanvasItem *icon_item)
......@@ -309,21 +220,14 @@ nautilus_icon_canvas_item_init (NautilusIconCanvasItem *icon_item)
icon_item->details->smooth_font = eel_scalable_font_get_default_font ();
}
/* Destroy handler for the icon canvas item. */
static void
nautilus_icon_canvas_item_destroy (GtkObject *object)
nautilus_icon_canvas_item_finalize (GObject *object)
{
GnomeCanvasItem *item;
NautilusIconCanvasItem *icon_item;
NautilusIconCanvasItemDetails *details;
g_return_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (object));
item = GNOME_CANVAS_ITEM (object);
icon_item = (NAUTILUS_ICON_CANVAS_ITEM (object));
details = icon_item->details;
gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2);
details = NAUTILUS_ICON_CANVAS_ITEM (object)->details;
if (details->pixbuf != NULL) {
g_object_unref (G_OBJECT (details->pixbuf));
......@@ -337,8 +241,7 @@ nautilus_icon_canvas_item_destroy (GtkObject *object)
gdk_font_unref (details->font);
}
g_object_unref (G_OBJECT (icon_item->details->smooth_font));
icon_item->details->smooth_font = NULL;
g_object_unref (G_OBJECT (details->smooth_font));
if (details->rendered_pixbuf != NULL) {
g_object_unref (G_OBJECT (details->rendered_pixbuf));
......@@ -346,7 +249,7 @@ nautilus_icon_canvas_item_destroy (GtkObject *object)
g_free (details);
EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
/* Currently we require pixbufs in this format (for hit testing).
......@@ -408,7 +311,7 @@ nautilus_icon_canvas_item_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
break;
case ARG_FONT:
font = GTK_VALUE_BOXED (*arg);
font = GTK_VALUE_POINTER (*arg);
if (eel_gdk_font_equal (font, details->font)) {
return;
}
......@@ -483,7 +386,7 @@ nautilus_icon_canvas_item_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
break;
case ARG_FONT:
GTK_VALUE_BOXED (*arg) = details->font;
GTK_VALUE_POINTER (*arg) = details->font;
break;
case ARG_HIGHLIGHTED_FOR_SELECTION:
......@@ -2229,3 +2132,61 @@ nautilus_icon_canvas_item_set_smooth_font_size (NautilusIconCanvasItem *icon_ite
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (icon_item));
}
}
/* Class initialization function for the icon canvas item. */
static void
nautilus_icon_canvas_item_class_init (NautilusIconCanvasItemClass *class)
{
GtkObjectClass *object_class;
GnomeCanvasItemClass *item_class;
if (layout_cache == NULL) {
layout_cache = eel_smooth_text_layout_cache_new ();
g_atexit (free_layout_cache);
}
object_class = GTK_OBJECT_CLASS (class);
item_class = GNOME_CANVAS_ITEM_CLASS (class);
gtk_object_add_arg_type ("NautilusIconCanvasItem::editable_text",
G_TYPE_STRING, GTK_ARG_READWRITE, ARG_EDITABLE_TEXT);
gtk_object_add_arg_type ("NautilusIconCanvasItem::additional_text",
G_TYPE_STRING, GTK_ARG_READWRITE, ARG_ADDITIONAL_TEXT);
gtk_object_add_arg_type ("NautilusIconCanvasItem::font",
GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_FONT);
gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_for_selection",
G_TYPE_BOOLEAN, GTK_ARG_READWRITE, ARG_HIGHLIGHTED_FOR_SELECTION);
gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_as_keyboard_focus",
G_TYPE_BOOLEAN, GTK_ARG_READWRITE, ARG_HIGHLIGHTED_AS_KEYBOARD_FOCUS);
gtk_object_add_arg_type ("NautilusIconCanvasItem::highlighted_for_drop",
G_TYPE_BOOLEAN, GTK_ARG_READWRITE, ARG_HIGHLIGHTED_FOR_DROP);
gtk_object_add_arg_type ("NautilusIconCanvasItem::smooth_font_size",
G_TYPE_INT, GTK_ARG_READWRITE, ARG_SMOOTH_FONT_SIZE);
gtk_object_add_arg_type ("NautilusIconCanvasItem::smooth_font",
GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_SMOOTH_FONT);
G_OBJECT_CLASS (class)->finalize = nautilus_icon_canvas_item_finalize;
object_class->set_arg = nautilus_icon_canvas_item_set_arg;
object_class->get_arg = nautilus_icon_canvas_item_get_arg;
signals[BOUNDS_CHANGED]
= g_signal_new ("bounds_changed",
G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusIconCanvasItemClass,
bounds_changed),
NULL, NULL,
gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
item_class->update = nautilus_icon_canvas_item_update;
item_class->draw = nautilus_icon_canvas_item_draw;
item_class->render = nautilus_icon_canvas_item_render;
item_class->point = nautilus_icon_canvas_item_point;
item_class->bounds = nautilus_icon_canvas_item_bounds;
item_class->event = nautilus_icon_canvas_item_event;
eel_preferences_add_auto_integer (NAUTILUS_PREFERENCES_CLICK_POLICY,
&click_policy_auto_value);
}
......@@ -986,9 +986,9 @@ append_separator (NautilusWindow *window, const char *path)
static void
create_menu_item_from_node (NautilusWindow *window,
xmlNodePtr node,
const char *menu_path,
int index)
xmlNodePtr node,
const char *menu_path,
int *index)
{
NautilusBookmark *bookmark;
xmlChar *xml_folder_name;
......@@ -997,11 +997,15 @@ create_menu_item_from_node (NautilusWindow *window,
g_assert (NAUTILUS_IS_WINDOW (window));
if (node->type != XML_ELEMENT_NODE) {
return;
}
nautilus_window_ui_freeze (window);
if (strcmp (node->name, "bookmark") == 0) {
bookmark = nautilus_bookmark_new_from_node (node);
append_bookmark_to_menu (window, bookmark, menu_path, index, TRUE);
append_bookmark_to_menu (window, bookmark, menu_path, *index, TRUE);
g_object_unref (G_OBJECT (bookmark));
} else if (strcmp (node->name, "separator") == 0) {
append_separator (window, menu_path);
......@@ -1016,15 +1020,17 @@ create_menu_item_from_node (NautilusWindow *window,
for (node = eel_xml_get_children (node), sub_index = 0;
node != NULL;
node = node->next, ++sub_index) {
create_menu_item_from_node (window, node, sub_menu_path, sub_index);
node = node->next) {
create_menu_item_from_node (window, node, sub_menu_path, &sub_index);
}
g_free (sub_menu_path);
xmlFree (xml_folder_name);
} else {
g_message ("found unknown node '%s', ignoring", node->name);
g_warning ("found unknown node '%s', ignoring", node->name);
}
(*index)++;
nautilus_window_ui_thaw (window);
}
......@@ -1049,8 +1055,8 @@ append_static_bookmarks (NautilusWindow *window, const char *menu_path)
node = eel_xml_get_root_children (doc);
index = 0;
for (index = 0; node != NULL; node = node->next, ++index) {
create_menu_item_from_node (window, node, menu_path, index);
for (index = 0; node != NULL; node = node->next) {
create_menu_item_from_node (window, node, menu_path, &index);
}
xmlFreeDoc(doc);
......
......@@ -986,9 +986,9 @@ append_separator (NautilusWindow *window, const char *path)
static void
create_menu_item_from_node (NautilusWindow *window,
xmlNodePtr node,
const char *menu_path,
int index)
xmlNodePtr node,
const char *menu_path,
int *index)
{
NautilusBookmark *bookmark;
xmlChar *xml_folder_name;
......@@ -997,11 +997,15 @@ create_menu_item_from_node (NautilusWindow *window,
g_assert (NAUTILUS_IS_WINDOW (window));
if (node->type != XML_ELEMENT_NODE) {
return;
}
nautilus_window_ui_freeze (window);
if (strcmp (node->name, "bookmark") == 0) {
bookmark = nautilus_bookmark_new_from_node (node);
append_bookmark_to_menu (window, bookmark, menu_path, index, TRUE);
append_bookmark_to_menu (window, bookmark, menu_path, *index, TRUE);
g_object_unref (G_OBJECT (bookmark));
} else if (strcmp (node->name, "separator") == 0) {
append_separator (window, menu_path);
......@@ -1016,15 +1020,17 @@ create_menu_item_from_node (NautilusWindow *window,
for (node = eel_xml_get_children (node), sub_index = 0;
node != NULL;
node = node->next, ++sub_index) {
create_menu_item_from_node (window, node, sub_menu_path, sub_index);
node = node->next) {
create_menu_item_from_node (window, node, sub_menu_path, &sub_index);
}
g_free (sub_menu_path);
xmlFree (xml_folder_name);
} else {
g_message ("found unknown node '%s', ignoring", node->name);
g_warning ("found unknown node '%s', ignoring", node->name);
}
(*index)++;
nautilus_window_ui_thaw (window);
}
......@@ -1049,8 +1055,8 @@ append_static_bookmarks (NautilusWindow *window, const char *menu_path)
node = eel_xml_get_root_children (doc);
index = 0;
for (index = 0; node != NULL; node = node->next, ++index) {
create_menu_item_from_node (window, node, menu_path, index);
for (index = 0; node != NULL; node = node->next) {
create_menu_item_from_node (window, node, menu_path, &index);
}
xmlFreeDoc(doc);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment