Also manage references to GdkPixbuf objects

This commit is contained in:
Pierre Pronchery 2012-12-06 23:34:34 +01:00
parent b44772f0c4
commit 3f43c99b2d
2 changed files with 12 additions and 1 deletions

View File

@ -642,6 +642,7 @@ int desktop_get_drag_data(Desktop * desktop, GtkSelectionData * seldata)
/* desktop_get_file */
GdkPixbuf * desktop_get_file(Desktop * desktop)
{
g_object_ref(desktop->file);
return desktop->file;
}
@ -649,6 +650,7 @@ GdkPixbuf * desktop_get_file(Desktop * desktop)
/* desktop_get_folder */
GdkPixbuf * desktop_get_folder(Desktop * desktop)
{
g_object_ref(desktop->folder);
return desktop->folder;
}

View File

@ -157,6 +157,8 @@ DesktopIcon * desktopicon_new(Desktop * desktop, char const * name,
}
if((desktopicon = _desktopicon_new_do(desktop, image, name)) == NULL)
return NULL;
if(image != NULL)
g_object_unref(image);
gtk_drag_source_set(desktopicon->event, GDK_BUTTON1_MASK, targets,
targets_cnt, GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_drag_dest_set(desktopicon->event, GTK_DEST_DEFAULT_ALL, targets,
@ -231,6 +233,8 @@ DesktopIcon * desktopicon_new_application(Desktop * desktop, char const * path)
if(image == NULL)
image = desktop_get_file(desktop);
desktopicon = _desktopicon_new_do(desktop, image, p);
if(image != NULL)
g_object_unref(image);
config_delete(config); /* XXX also remove reference to the pixbuf */
if(desktopicon == NULL)
{
@ -511,8 +515,13 @@ static DesktopIcon * _desktopicon_new_do(Desktop * desktop, GdkPixbuf * image,
gtk_container_add(GTK_CONTAINER(desktopicon->window),
desktopicon->event);
if(image == NULL)
{
image = desktop_get_file(desktop);
_desktopicon_set_icon(desktopicon, image);
_desktopicon_set_icon(desktopicon, image);
g_object_unref(image);
}
else
_desktopicon_set_icon(desktopicon, image);
_desktopicon_set_name(desktopicon, name);
_desktopicon_update_transparency(desktopicon);
return desktopicon;