Exposing the MIME icon generation code to the plug-ins
This commit is contained in:
parent
36f1e8a1a6
commit
3658456484
|
@ -18,6 +18,7 @@
|
|||
#ifndef DESKTOP_BROWSER_H
|
||||
# define DESKTOP_BROWSER_H
|
||||
|
||||
# include <sys/stat.h>
|
||||
# include <gtk/gtk.h>
|
||||
# include <Desktop.h>
|
||||
# include "Browser/desktop.h"
|
||||
|
@ -34,6 +35,8 @@ typedef struct _BrowserPluginHelper
|
|||
{
|
||||
Browser * browser;
|
||||
int (*error)(Browser * browser, char const * message, int ret);
|
||||
GdkPixbuf * (*get_icon)(Browser * browser, char const * type,
|
||||
struct stat * st, int size);
|
||||
Mime * (*get_mime)(Browser * browser);
|
||||
int (*set_location)(Browser * browser, char const * path);
|
||||
} BrowserPluginHelper;
|
||||
|
|
|
@ -225,6 +225,8 @@ unsigned int browser_cnt = 0;
|
|||
/* accessors */
|
||||
static gboolean _browser_plugin_is_enabled(Browser * browser,
|
||||
char const * plugin);
|
||||
static GdkPixbuf * _browser_get_icon(Browser * browser, char const * type,
|
||||
struct stat * st, int size);
|
||||
static Mime * _browser_get_mime(Browser * browser);
|
||||
static void _browser_set_status(Browser * browser, char const * status);
|
||||
|
||||
|
@ -313,6 +315,7 @@ Browser * browser_new(char const * directory)
|
|||
/* plug-ins */
|
||||
browser->pl_helper.browser = browser;
|
||||
browser->pl_helper.error = browser_error;
|
||||
browser->pl_helper.get_icon = _browser_get_icon;
|
||||
browser->pl_helper.get_mime = _browser_get_mime;
|
||||
browser->pl_helper.set_location = browser_set_location;
|
||||
|
||||
|
@ -2828,6 +2831,14 @@ static gboolean _browser_plugin_is_enabled(Browser * browser,
|
|||
}
|
||||
|
||||
|
||||
/* browser_get_icon */
|
||||
static GdkPixbuf * _browser_get_icon(Browser * browser, char const * type,
|
||||
struct stat * st, int size)
|
||||
{
|
||||
return vfs_mime_icon(browser->mime, type, st, size);
|
||||
}
|
||||
|
||||
|
||||
/* browser_get_mime */
|
||||
static Mime * _browser_get_mime(Browser * browser)
|
||||
{
|
||||
|
|
|
@ -376,6 +376,7 @@ static void _refresh_name(GtkWidget * widget, char const * filename)
|
|||
|
||||
static void _refresh_type(Properties * properties, struct stat * st)
|
||||
{
|
||||
BrowserPluginHelper * helper = properties->helper;
|
||||
char const * type = NULL;
|
||||
char const * ltype = NULL;
|
||||
GdkPixbuf * pixbuf = NULL;
|
||||
|
@ -416,16 +417,12 @@ static void _refresh_type(Properties * properties, struct stat * st)
|
|||
else if(S_ISSOCK(st->st_mode))
|
||||
type = "inode/socket";
|
||||
#endif
|
||||
if(type == NULL && properties->mime != NULL)
|
||||
{
|
||||
type = mime_type(properties->mime, properties->filename);
|
||||
if(type != NULL)
|
||||
{
|
||||
mime_icons(properties->mime, type, 48, &pixbuf, -1);
|
||||
if(pixbuf != NULL)
|
||||
image = gtk_image_new_from_pixbuf(pixbuf);
|
||||
}
|
||||
}
|
||||
if(type == NULL && properties->mime != NULL
|
||||
&& (type = mime_type(properties->mime,
|
||||
properties->filename)) != NULL
|
||||
&& (pixbuf = helper->get_icon(helper->browser,
|
||||
type, st, 48)) != NULL)
|
||||
image = gtk_image_new_from_pixbuf(pixbuf);
|
||||
if(type == NULL)
|
||||
type = _("Unknown type");
|
||||
if(image == NULL && (pixbuf = gtk_icon_theme_load_icon(
|
||||
|
|
Loading…
Reference in New Issue
Block a user