diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-01-02 09:54:49 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-01-02 09:54:49 -0600 |
commit | c5bca102dd4e45626e1e76b0684ef065935918ed (patch) | |
tree | 5f13e0b27facb5e725d31e13e4b77977bb2d76c5 /kio | |
parent | 6ddacfff536fc6fcedff929b315fd43c494bb02c (diff) | |
download | tdelibs-c5bca102dd4e45626e1e76b0684ef065935918ed.tar.gz tdelibs-c5bca102dd4e45626e1e76b0684ef065935918ed.zip |
Add preferred icon metadata field
Diffstat (limited to 'kio')
-rw-r--r-- | kio/kio/kfileitem.cpp | 7 | ||||
-rw-r--r-- | kio/kio/kurifilter.cpp | 7 | ||||
-rw-r--r-- | kio/kio/tdelficon.cpp | 28 | ||||
-rw-r--r-- | kio/kio/tdelficon.h | 10 |
4 files changed, 50 insertions, 2 deletions
diff --git a/kio/kio/kfileitem.cpp b/kio/kio/kfileitem.cpp index 40927f0cf..efb59043b 100644 --- a/kio/kio/kfileitem.cpp +++ b/kio/kio/kfileitem.cpp @@ -668,6 +668,13 @@ TQPixmap KFileItem::pixmap( int _size, int _state ) const { // Failed to obtain a list of ELF icons kdWarning() << "failed to obtain ELF icon: " << libr_errmsg() << endl; + + // See if there is a system icon we can use + TQString sysIconName = elf_get_resource(handle, ".metadata_sysicon"); + if (KGlobal::iconLoader()->iconPath(sysIconName.ascii(), 0, true) != "") { + p = DesktopIcon( sysIconName.ascii(), _size, _state ); + } + libr_close(handle); return p; } diff --git a/kio/kio/kurifilter.cpp b/kio/kio/kurifilter.cpp index 102d83166..24ed48328 100644 --- a/kio/kio/kurifilter.cpp +++ b/kio/kio/kurifilter.cpp @@ -216,6 +216,13 @@ TQString KURIFilterData::iconName() { // Failed to obtain a list of ELF icons kdWarning() << "failed to obtain ELF icon: " << libr_errmsg() << endl; + + // See if there is a system icon we can use + TQString sysIconName = elf_get_resource(handle, ".metadata_sysicon"); + if (KGlobal::iconLoader()->iconPath(sysIconName.ascii(), 0, true) != "") { + m_customIconPixmap = DesktopIcon( sysIconName.ascii(), _size, _state ); + } + libr_close(handle); libr_can_continue = 0; } diff --git a/kio/kio/tdelficon.cpp b/kio/kio/tdelficon.cpp index 8c5a0d9de..6e1e68169 100644 --- a/kio/kio/tdelficon.cpp +++ b/kio/kio/tdelficon.cpp @@ -58,4 +58,32 @@ iconentry *get_nexticon(iconlist *icons, iconentry *last_entry) return NULL; } return &(icons->entry); +} + +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; }
\ No newline at end of file diff --git a/kio/kio/tdelficon.h b/kio/kio/tdelficon.h index 7b17df818..7a962bdaa 100644 --- a/kio/kio/tdelficon.h +++ b/kio/kio/tdelficon.h @@ -1,8 +1,13 @@ - #include <alloca.h> #include <stdint.h> #include <cstdlib> +#include <tqdict.h> +#include <tqvalidator.h> +#include <tqcstring.h> +#include <tqfile.h> +#include <tqdatetime.h> + extern "C" { #include <libr-icons.h> @@ -45,4 +50,5 @@ extern "C" { } int get_iconlist(libr_file *file_handle, iconlist *icons); -iconentry *get_nexticon(iconlist *icons, iconentry *last_entry);
\ No newline at end of file +iconentry *get_nexticon(iconlist *icons, iconentry *last_entry); +TQString elf_get_resource(libr_file *handle, char *section_name);
\ No newline at end of file |