Add icon request ability

pull/16/head
Timothy Pearson 13 years ago
parent c5bca102dd
commit 6d74bae8a1

@ -41,34 +41,6 @@ typedef unsigned long uint32_t;
typedef unsigned short uint16_t; typedef unsigned short uint16_t;
#endif #endif
TQString elf_get_resource(libr_file *handle, char *section_name)
{
size_t buffer_size = 0;
char *buffer = NULL;
TQString result;
/* Get the resource from the ELF binary */
if(!libr_size(handle, section_name, &buffer_size))
{
kdWarning() << "failed to obtain ELF resource size: " << libr_errmsg() << endl;
return result;
}
/* Get the resource from the ELF file */
buffer = (char *) malloc(buffer_size+1);
buffer[buffer_size] = 0;
if(!libr_read(handle, section_name, buffer))
{
kdWarning() << "failed to obtain ELF resource: " << libr_errmsg() << endl;
goto fail;
}
result = buffer;
fail:
free(buffer);
return result;
}
typedef KGenericFactory<KElfPlugin> ElfFactory; typedef KGenericFactory<KElfPlugin> ElfFactory;
K_EXPORT_COMPONENT_FACTORY(kfile_elf, ElfFactory( "kfile_elf" )) K_EXPORT_COMPONENT_FACTORY(kfile_elf, ElfFactory( "kfile_elf" ))
@ -96,7 +68,7 @@ KElfPlugin::KElfPlugin(TQObject *parent, const char *name,
item = addItemInfo(group, "Product", i18n("Product"), TQVariant::String); item = addItemInfo(group, "Product", i18n("Product"), TQVariant::String);
item = addItemInfo(group, "Organization", i18n("Organization"), TQVariant::String); item = addItemInfo(group, "Organization", i18n("Organization"), TQVariant::String);
item = addItemInfo(group, "Version", i18n("Version"), TQVariant::String); item = addItemInfo(group, "Version", i18n("Version"), TQVariant::String);
item = addItemInfo(group, "DateTime", i18n("Creation Date/Time"), TQVariant::String); item = addItemInfo(group, "DateTime", i18n("Compilation Date/Time"), TQVariant::String);
item = addItemInfo(group, "SystemIcon", i18n("Requested Icon"), TQVariant::String); item = addItemInfo(group, "SystemIcon", i18n("Requested Icon"), TQVariant::String);
item = addItemInfo(group, "Notes", i18n("Comments"), TQVariant::String); item = addItemInfo(group, "Notes", i18n("Comments"), TQVariant::String);

@ -671,8 +671,10 @@ TQPixmap KFileItem::pixmap( int _size, int _state ) const
// See if there is a system icon we can use // See if there is a system icon we can use
TQString sysIconName = elf_get_resource(handle, ".metadata_sysicon"); TQString sysIconName = elf_get_resource(handle, ".metadata_sysicon");
if (KGlobal::iconLoader()->iconPath(sysIconName.ascii(), 0, true) != "") { if (!sysIconName.isEmpty()) {
p = DesktopIcon( sysIconName.ascii(), _size, _state ); if (KGlobal::iconLoader()->iconPath(sysIconName.ascii(), 0, true) != "") {
p = DesktopIcon( sysIconName.ascii(), _size, _state );
}
} }
libr_close(handle); libr_close(handle);
@ -694,7 +696,7 @@ TQPixmap KFileItem::pixmap( int _size, int _state ) const
} }
} }
if (iconresnamefound == 0) { if ((iconresnamefound == 0) && (icon)) {
// Extract the embedded icon // Extract the embedded icon
size_t icon_data_length; size_t icon_data_length;
char* icondata = libr_icon_malloc(icon, &icon_data_length); char* icondata = libr_icon_malloc(icon, &icon_data_length);

@ -219,8 +219,10 @@ TQString KURIFilterData::iconName()
// See if there is a system icon we can use // See if there is a system icon we can use
TQString sysIconName = elf_get_resource(handle, ".metadata_sysicon"); TQString sysIconName = elf_get_resource(handle, ".metadata_sysicon");
if (KGlobal::iconLoader()->iconPath(sysIconName.ascii(), 0, true) != "") { if (!sysIconName.isEmpty()) {
m_customIconPixmap = DesktopIcon( sysIconName.ascii(), _size, _state ); if (KGlobal::iconLoader()->iconPath(sysIconName.ascii(), 0, true) != "") {
m_strIconName = sysIconName;
}
} }
libr_close(handle); libr_close(handle);
@ -242,7 +244,7 @@ TQString KURIFilterData::iconName()
} }
} }
if (iconresnamefound == 0) { if ((iconresnamefound == 0) && (icon)) {
// Extract the embedded icon // Extract the embedded icon
size_t icon_data_length; size_t icon_data_length;
char* icondata = libr_icon_malloc(icon, &icon_data_length); char* icondata = libr_icon_malloc(icon, &icon_data_length);

@ -69,7 +69,7 @@ TQString elf_get_resource(libr_file *handle, char *section_name)
/* Get the resource from the ELF binary */ /* Get the resource from the ELF binary */
if(!libr_size(handle, section_name, &buffer_size)) if(!libr_size(handle, section_name, &buffer_size))
{ {
kdWarning() << "failed to obtain ELF resource size: " << libr_errmsg() << endl; // kdWarning() << "failed to obtain ELF resource size: " << libr_errmsg() << endl;
return result; return result;
} }
/* Get the resource from the ELF file */ /* Get the resource from the ELF file */
@ -77,7 +77,7 @@ TQString elf_get_resource(libr_file *handle, char *section_name)
buffer[buffer_size] = 0; buffer[buffer_size] = 0;
if(!libr_read(handle, section_name, buffer)) if(!libr_read(handle, section_name, buffer))
{ {
kdWarning() << "failed to obtain ELF resource: " << libr_errmsg() << endl; // kdWarning() << "failed to obtain ELF resource: " << libr_errmsg() << endl;
goto fail; goto fail;
} }
result = buffer; result = buffer;

@ -496,7 +496,7 @@ int main_console(int argc, char **argv)
} break; } break;
case MODE_SET_EMPTY_UUID: case MODE_SET_EMPTY_UUID:
section = ICON_SECTION; section = ICON_SECTION;
clear_resource(handle, section); clear_resource(handle, section);
if(!libr_icon_setuuid(handle, "00000000-0000-0000-0000-000000000000")) if(!libr_icon_setuuid(handle, "00000000-0000-0000-0000-000000000000"))
{ {
@ -549,6 +549,8 @@ int main_console(int argc, char **argv)
if (systemIcon.isNull()) { if (systemIcon.isNull()) {
systemIcon = KGlobal::iconLoader()->iconPath(argv[PARAM_ICON_NAME], 0, false); systemIcon = KGlobal::iconLoader()->iconPath(argv[PARAM_ICON_NAME], 0, false);
printf("NOT FOUND, refusing to add unknown icon (this message is harmless)\n\r"); printf("NOT FOUND, refusing to add unknown icon (this message is harmless)\n\r");
section = ICON_SECTION;
clear_resource(handle, section);
goto fail; goto fail;
} }
else { else {

Loading…
Cancel
Save