summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/itemviews/qfileiconprovider.cpp15
-rw-r--r--src/gui/styles/gtksymbols.cpp28
-rw-r--r--src/gui/styles/gtksymbols_p.h29
3 files changed, 72 insertions, 0 deletions
diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp
index 4abdef9..c78a49b 100644
--- a/src/gui/itemviews/qfileiconprovider.cpp
+++ b/src/gui/itemviews/qfileiconprovider.cpp
@@ -54,6 +54,12 @@
#elif defined(Q_WS_MAC)
#include <private/qt_cocoa_helpers_mac_p.h>
#endif
+
+#if defined(Q_WS_X11) && !defined(Q_NO_STYLE_GTK)
+#include <private/qt_x11_p.h>
+#include <private/gtksymbols_p.h>
+#endif
+
#include <private/qfunctions_p.h>
#ifndef SHGFI_ADDOVERLAYS
@@ -378,6 +384,15 @@ QIcon QFileIconProviderPrivate::getMacIcon(const QFileInfo &fi) const
QIcon QFileIconProvider::icon(const QFileInfo &info) const
{
Q_D(const QFileIconProvider);
+
+#if defined(Q_WS_X11) && !defined(QT_NO_STYLE_GTK)
+ if (X11->desktopEnvironment == DE_GNOME) {
+ QIcon gtkIcon = QGtk::getFilesystemIcon(info);
+ if (!gtkIcon.isNull())
+ return gtkIcon;
+ }
+#endif
+
#ifdef Q_WS_MAC
QIcon retIcon = d->getMacIcon(info);
if (!retIcon.isNull())
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
index 1cb0ca4..d8f140f 100644
--- a/src/gui/styles/gtksymbols.cpp
+++ b/src/gui/styles/gtksymbols.cpp
@@ -58,6 +58,7 @@
#include <QtCore/QStringList>
#include <QtCore/QTextStream>
#include <QtCore/QHash>
+#include <QtCore/QUrl>
#include <private/qapplication_p.h>
#include <private/qiconloader_p.h>
@@ -124,6 +125,7 @@ Ptr_gtk_progress_set_adjustment QGtk::gtk_progress_set_adjustment = 0;
Ptr_gtk_range_set_adjustment QGtk::gtk_range_set_adjustment = 0;
Ptr_gtk_range_set_inverted QGtk::gtk_range_set_inverted = 0;
Ptr_gtk_icon_factory_lookup_default QGtk::gtk_icon_factory_lookup_default = 0;
+Ptr_gtk_icon_theme_get_default QGtk::gtk_icon_theme_get_default = 0;
Ptr_gtk_widget_style_get QGtk::gtk_widget_style_get = 0;
Ptr_gtk_icon_set_render_icon QGtk::gtk_icon_set_render_icon = 0;
Ptr_gtk_fixed_new QGtk::gtk_fixed_new = 0;
@@ -196,6 +198,9 @@ Ptr_gconf_client_get_default QGtk::gconf_client_get_default = 0;
Ptr_gconf_client_get_string QGtk::gconf_client_get_string = 0;
Ptr_gconf_client_get_bool QGtk::gconf_client_get_bool = 0;
+Ptr_gnome_icon_lookup_sync QGtk::gnome_icon_lookup_sync = 0;
+Ptr_gnome_vfs_init QGtk::gnome_vfs_init = 0;
+
static QString classPath(GtkWidget *widget)
{
char* class_path;
@@ -281,6 +286,7 @@ static void resolveGtk()
QGtk::gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)libgtk.resolve("gtk_range_set_inverted");
QGtk::gtk_container_add = (Ptr_gtk_container_add)libgtk.resolve("gtk_container_add");
QGtk::gtk_icon_factory_lookup_default = (Ptr_gtk_icon_factory_lookup_default)libgtk.resolve("gtk_icon_factory_lookup_default");
+ QGtk::gtk_icon_theme_get_default = (Ptr_gtk_icon_theme_get_default)libgtk.resolve("gtk_icon_theme_get_default");
QGtk::gtk_widget_style_get = (Ptr_gtk_widget_style_get)libgtk.resolve("gtk_widget_style_get");
QGtk::gtk_icon_set_render_icon = (Ptr_gtk_icon_set_render_icon)libgtk.resolve("gtk_icon_set_render_icon");
QGtk::gtk_fixed_new = (Ptr_gtk_fixed_new)libgtk.resolve("gtk_fixed_new");
@@ -325,6 +331,9 @@ static void resolveGtk()
QGtk::pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
QGtk::pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
QGtk::pango_font_description_get_style = (Ptr_pango_font_description_get_style)libgtk.resolve("pango_font_description_get_style");
+
+ QGtk::gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve( QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
+ QGtk::gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve( QLS("gnomevfs-2"), 0, "gnome_vfs_init");
}
void QGtk::cleanup_gtk_widgets()
@@ -969,6 +978,25 @@ QString QGtk::saveFilename(QWidget *parent, const QString &caption, const QStrin
return filename;
}
+QIcon QGtk::getFilesystemIcon(const QFileInfo &info)
+{
+ QIcon icon;
+ if (QGtk::gnome_vfs_init && QGtk::gnome_icon_lookup_sync) {
+ QGtk::gnome_vfs_init();
+ GtkIconTheme *theme = QGtk::gtk_icon_theme_get_default();
+ QString fileurl = QUrl::fromLocalFile(info.absoluteFilePath());
+ char * icon_name = QGtk::gnome_icon_lookup_sync(theme,
+ NULL,
+ qPrintable(fileurl),
+ NULL,
+ GNOME_ICON_LOOKUP_FLAGS_NONE,
+ NULL);
+ return QIcon::fromTheme(icon_name);
+ g_free(icon_name);
+ }
+ return icon;
+}
+
QT_END_NAMESPACE
#endif // !defined(QT_NO_STYLE_GTK)
diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/gtksymbols_p.h
index 4fb193d..313d948 100644
--- a/src/gui/styles/gtksymbols_p.h
+++ b/src/gui/styles/gtksymbols_p.h
@@ -121,6 +121,7 @@ typedef void (*Ptr_gtk_progress_set_adjustment)(GtkProgress *, GtkAdjustment *);
typedef void (*Ptr_gtk_range_set_inverted)(GtkRange*, bool);
typedef void (*Ptr_gtk_container_add)(GtkContainer *container, GtkWidget *widget);
typedef GtkIconSet* (*Ptr_gtk_icon_factory_lookup_default) (const gchar*);
+typedef GtkIconTheme* (*Ptr_gtk_icon_theme_get_default) (void);
typedef void (*Ptr_gtk_widget_style_get)(GtkWidget *, const gchar *first_property_name, ...);
typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_column_new)(void);
typedef GtkWidget* (*Ptr_gtk_fixed_new)(void);
@@ -195,6 +196,29 @@ typedef void (*Ptr_gdk_x11_window_set_user_time) (GdkWindow *window, guint32);
typedef XID (*Ptr_gdk_x11_drawable_get_xid) (GdkDrawable *);
typedef Display* (*Ptr_gdk_x11_drawable_get_xdisplay) ( GdkDrawable *);
+
+typedef enum {
+ GNOME_ICON_LOOKUP_FLAGS_NONE = 0,
+ GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1<<0,
+ GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES = 1<<1,
+ GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES = 1<<2
+} GnomeIconLookupFlags;
+
+typedef enum {
+ GNOME_ICON_LOOKUP_RESULT_FLAGS_NONE = 0,
+ GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL = 1<<0
+} GnomeIconLookupResultFlags;
+
+struct GnomeThumbnailFactory;
+typedef gboolean (*Ptr_gnome_vfs_init) (void);
+typedef char* (*Ptr_gnome_icon_lookup_sync) (
+ GtkIconTheme *icon_theme,
+ GnomeThumbnailFactory *,
+ const char *file_uri,
+ const char *custom_icon,
+ GnomeIconLookupFlags flags,
+ GnomeIconLookupResultFlags *result);
+
QT_BEGIN_NAMESPACE
class QGtk
@@ -219,6 +243,7 @@ public:
QString *selectedFilter, QFileDialog::Options options);
static QString getGConfString(const QString &key, const QString &fallback = QString());
static bool getGConfBool(const QString &key, bool fallback = 0);
+ static QIcon getFilesystemIcon(const QFileInfo &);
static Ptr_gtk_container_forall gtk_container_forall;
static Ptr_gtk_init gtk_init;
@@ -263,6 +288,7 @@ public:
static Ptr_gtk_range_set_adjustment gtk_range_set_adjustment;
static Ptr_gtk_range_set_inverted gtk_range_set_inverted;
static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default;
+ static Ptr_gtk_icon_theme_get_default gtk_icon_theme_get_default;
static Ptr_gtk_widget_style_get gtk_widget_style_get;
static Ptr_gtk_icon_set_render_icon gtk_icon_set_render_icon;
static Ptr_gtk_fixed_new gtk_fixed_new;
@@ -333,6 +359,9 @@ public:
static Ptr_gconf_client_get_default gconf_client_get_default;
static Ptr_gconf_client_get_string gconf_client_get_string;
static Ptr_gconf_client_get_bool gconf_client_get_bool;
+
+ static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync;
+ static Ptr_gnome_vfs_init gnome_vfs_init;
};
// Helper to ensure that we have polished all our gtk widgets