The benefit of the icon.c routines is that you can load an xpm, png or svg with the same call. You can replace all your .xpm images with svg and you don't need to change any code. It would certainly be cool if inkscape had all svg icons since it is an svg editor.
The problem with icon.c is in sp_icon_new_full where we have: static iconlib = g_hash_table_new (g_str_hash, g_str_equal); but iconlib is never freed. I assume it is used to speed up the retrieval/loading of images/icons.
Also every time an object is added to the hash table, the key is strduped: g_hash_table_insert (iconlib, g_strdup (c), icon->px); That key is never freed either.
You create and destroy a few icons and inkscape/spdipodi goes kablooy! These things would be easier to manage if inkscape had true objects and classes.
I almost have a fix for icon.c, but in the mean time, if you just want to have a stable 0.35, this patch should stop the transformation dialog from crashing:
Index: transformation.c =================================================================== RCS file: /cvsroot/inkscape/inkscape/src/dialogs/transformation.c,v retrieving revision 1.3 diff -u -p -r1.3 transformation.c --- transformation.c 31 Oct 2003 06:28:39 -0000 1.3 +++ transformation.c 10 Nov 2003 04:02:58 -0000 @@ -226,7 +226,7 @@ sp_transformation_dialog_new (void) g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (sp_transformation_dialog_close), dlg);
/* Move page */ - img = sp_icon_new (SP_ICON_SIZE_NOTEBOOK, "move"); + img = gtk_image_new_from_file (INKSCAPE_GLADEDIR "/move.xpm"); gtk_widget_show (img); page = sp_transformation_page_move_new (G_OBJECT (dlg)); gtk_widget_show (page); @@ -234,7 +234,7 @@ sp_transformation_dialog_new (void) g_object_set_data (G_OBJECT (dlg), "move", page);
/* Scale page */ - img = sp_icon_new (SP_ICON_SIZE_NOTEBOOK, "scale"); + img = gtk_image_new_from_file (INKSCAPE_GLADEDIR "/scale.xpm"); gtk_widget_show (img); page = sp_transformation_page_scale_new (G_OBJECT (dlg)); gtk_widget_show (page); @@ -242,7 +242,7 @@ sp_transformation_dialog_new (void) g_object_set_data (G_OBJECT (dlg), "scale", page);
/* Rotate page */ - img = sp_icon_new (SP_ICON_SIZE_NOTEBOOK, "rotate"); + img = gtk_image_new_from_file (INKSCAPE_GLADEDIR "/rotate.xpm"); gtk_widget_show (img); page = sp_transformation_page_rotate_new (G_OBJECT (dlg)); gtk_widget_show (page); @@ -380,7 +380,7 @@ sp_transformation_page_move_new (GObject sp_unit_selector_set_unit (SP_UNIT_SELECTOR (us), sp_desktop_get_default_unit (SP_ACTIVE_DESKTOP)); } /* Horizontal */ - img = sp_icon_new (SP_ICON_SIZE_BUTTON, "arrows_hor"); + img = gtk_image_new_from_file (INKSCAPE_GLADEDIR "/arrows_hor.xpm"); gtk_table_attach (GTK_TABLE (tbl), img, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0); adj = (GtkAdjustment *) gtk_adjustment_new (0.0, -1e6, 1e6, 0.01, 0.1, 0.1); g_object_set_data (obj, "move_position_x", adj); @@ -389,7 +389,7 @@ sp_transformation_page_move_new (GObject sb = gtk_spin_button_new (adj, 0.1, 2); gtk_table_attach (GTK_TABLE (tbl), sb, 1, 2, 0, 1, (GtkAttachOptions)( (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ) ), (GtkAttachOptions)( (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ) ), 0, 0); /* Vertical */ - img = sp_icon_new (SP_ICON_SIZE_BUTTON, "arrows_ver"); + img = gtk_image_new_from_file (INKSCAPE_GLADEDIR "/arrows_ver.xpm"); gtk_table_attach (GTK_TABLE (tbl), img, 0, 1, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0); adj = (GtkAdjustment *) gtk_adjustment_new (0.0, -1e6, 1e6, 0.01, 0.1, 0.1); g_object_set_data (obj, "move_position_y", adj); @@ -555,7 +555,7 @@ sp_transformation_page_scale_new (GObjec sp_unit_selector_set_unit (SP_UNIT_SELECTOR (us), sp_unit_get_by_abbreviation ("%")); g_signal_connect (G_OBJECT (us), "set_unit", G_CALLBACK (sp_transformation_scale_set_unit), obj); /* Horizontal */ - img = sp_icon_new (SP_ICON_SIZE_BUTTON, "scale_hor"); + img = gtk_image_new_from_file (INKSCAPE_GLADEDIR "/scale_hor.xpm"); gtk_table_attach (GTK_TABLE (tbl), img, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0); adj = (GtkAdjustment *) gtk_adjustment_new (0.0, -1e6, 1e6, 0.01, 0.1, 0.1); g_object_set_data (obj, "scale_dimension_x", adj); @@ -564,7 +564,7 @@ sp_transformation_page_scale_new (GObjec sb = gtk_spin_button_new (adj, 0.1, 2); gtk_table_attach (GTK_TABLE (tbl), sb, 1, 2, 0, 1, (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), (GtkAttachOptions)( GTK_EXPAND | GTK_FILL ), 0, 0); /* Vertical */ - img = sp_icon_new (SP_ICON_SIZE_BUTTON, "scale_ver"); + img = gtk_image_new_from_file (INKSCAPE_GLADEDIR "/scale_ver.xpm"); gtk_table_attach (GTK_TABLE (tbl), img, 0, 1, 1, 2, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0); adj = (GtkAdjustment *) gtk_adjustment_new (0.0, -1e6, 1e6, 0.01, 0.1, 0.1); g_object_set_data (obj, "scale_dimension_y", adj); @@ -674,7 +674,7 @@ sp_transformation_page_rotate_new (GObje gtk_table_set_col_spacings (GTK_TABLE (tbl), 4); gtk_box_pack_start (GTK_BOX (vb), tbl, FALSE, FALSE, 0);
- img = sp_icon_new (SP_ICON_SIZE_BUTTON, "rotate_left"); + img = gtk_image_new_from_file (INKSCAPE_GLADEDIR "/rotate_left.xpm"); gtk_table_attach (GTK_TABLE (tbl), img, 0, 1, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)0, 0, 0); adj = (GtkAdjustment *) gtk_adjustment_new (0.0, -1e6, 1e6, 0.01, 0.1, 0.1); g_object_set_data (obj, "rotate_angle", adj);
Cheers, Rob. http://members.rogers.com/rcrosbie
_________________________________________________________________ Is your computer infected with a virus? Find out with a FREE computer virus scan from McAfee. Take the FreeScan now! http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
On Sun, 2003-11-09 at 23:35, Robert Crosbie wrote:
The benefit of the icon.c routines is that you can load an xpm, png or svg with the same call. You can replace all your .xpm images with svg and you don't need to change any code. It would certainly be cool if inkscape had all svg icons since it is an svg editor.
Well, the way we should really be doing that is to register a GtkIconFactory with icon images rendered from SVGs, then use the normal GTK stock facility for our icons.
The SPIcon stuff was the product of a little too much NIH-syndrome, IMO.
That said, thank you for the patch. ^_^
Would anyone object if I applied it for 0.35?
-mental
participants (2)
-
MenTaLguY
-
Robert Crosbie