Beginning to draw some emblems
This commit is contained in:
parent
eae63d7105
commit
122ffd007d
|
@ -1160,11 +1160,7 @@ static void _insert_all(Browser * browser, struct stat * lst, struct stat * st,
|
||||||
char const ** display, uint64_t * inode, uint64_t * size,
|
char const ** display, uint64_t * inode, uint64_t * size,
|
||||||
char const ** dsize, struct passwd ** pw, struct group ** gr,
|
char const ** dsize, struct passwd ** pw, struct group ** gr,
|
||||||
char const ** ddate, char const ** type, char const * path,
|
char const ** ddate, char const ** type, char const * path,
|
||||||
GdkPixbuf ** icon_24,
|
GdkPixbuf ** icon24, GdkPixbuf ** icon48, GdkPixbuf ** icon96);
|
||||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
|
||||||
GdkPixbuf ** icon_48, GdkPixbuf ** icon_96
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
static void _loop_insert(Browser * browser, GtkTreeIter * iter,
|
static void _loop_insert(Browser * browser, GtkTreeIter * iter,
|
||||||
char const * path, char const * display, struct stat * lst,
|
char const * path, char const * display, struct stat * lst,
|
||||||
|
@ -1192,7 +1188,7 @@ static void _loop_insert(Browser * browser, GtkTreeIter * iter,
|
||||||
, &icon_48, &icon_96);
|
, &icon_48, &icon_96);
|
||||||
gtk_list_store_insert_with_values(browser->store, iter, -1,
|
gtk_list_store_insert_with_values(browser->store, iter, -1,
|
||||||
#else
|
#else
|
||||||
);
|
, NULL, NULL);
|
||||||
gtk_list_store_insert_after(browser->store, iter, NULL);
|
gtk_list_store_insert_after(browser->store, iter, NULL);
|
||||||
gtk_list_store_set(browser->store, iter,
|
gtk_list_store_set(browser->store, iter,
|
||||||
#endif
|
#endif
|
||||||
|
@ -1231,11 +1227,7 @@ static void _insert_all(Browser * browser, struct stat * lst, struct stat * st,
|
||||||
char const ** display, uint64_t * inode, uint64_t * size,
|
char const ** display, uint64_t * inode, uint64_t * size,
|
||||||
char const ** dsize, struct passwd ** pw, struct group ** gr,
|
char const ** dsize, struct passwd ** pw, struct group ** gr,
|
||||||
char const ** ddate, char const ** type, char const * path,
|
char const ** ddate, char const ** type, char const * path,
|
||||||
GdkPixbuf ** icon_24,
|
GdkPixbuf ** icon24, GdkPixbuf ** icon48, GdkPixbuf ** icon96)
|
||||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
|
||||||
GdkPixbuf ** icon_48, GdkPixbuf ** icon_96
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
char const * p;
|
char const * p;
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
|
@ -1255,25 +1247,26 @@ static void _insert_all(Browser * browser, struct stat * lst, struct stat * st,
|
||||||
*ddate = _insert_date(lst->st_mtime);
|
*ddate = _insert_date(lst->st_mtime);
|
||||||
*type = _insert_mode(lst->st_mode, browser->refresh_dev, lst->st_dev);
|
*type = _insert_mode(lst->st_mode, browser->refresh_dev, lst->st_dev);
|
||||||
if(S_ISDIR(st->st_mode))
|
if(S_ISDIR(st->st_mode))
|
||||||
_insert_dir(browser, icon_24,
|
{
|
||||||
|
_insert_dir(browser, icon24,
|
||||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||||
icon_48, icon_96,
|
icon48, icon96,
|
||||||
#endif
|
#endif
|
||||||
st->st_dev);
|
st->st_dev);
|
||||||
else if(st->st_mode & S_IXUSR)
|
return;
|
||||||
mime_icons(browser->mime, "application/x-executable", 24,
|
}
|
||||||
icon_24,
|
if(st->st_mode & S_IXUSR)
|
||||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
*type = "application/x-executable";
|
||||||
48, icon_48, 96, icon_96,
|
if(browser->mime == NULL)
|
||||||
#endif
|
return;
|
||||||
-1);
|
if(*type == NULL && (*type = mime_type(browser->mime, path)) == NULL)
|
||||||
else if(browser->mime != NULL && *type == NULL
|
return;
|
||||||
&& (*type = mime_type(browser->mime, path)) != NULL)
|
if(icon24 != NULL)
|
||||||
mime_icons(browser->mime, *type, 24, icon_24,
|
*icon24 = vfs_mime_icon(browser->mime, *type, lst, 24);
|
||||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
if(icon48 != NULL)
|
||||||
48, icon_48, 96, icon_96,
|
*icon48 = vfs_mime_icon(browser->mime, *type, lst, 48);
|
||||||
#endif
|
if(icon96 != NULL)
|
||||||
-1);
|
*icon96 = vfs_mime_icon(browser->mime, *type, lst, 96);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char const * _insert_size(off_t size)
|
static char const * _insert_size(off_t size)
|
||||||
|
@ -1333,8 +1326,6 @@ static char const * _insert_mode(mode_t mode, dev_t parent, dev_t dev)
|
||||||
return "inode/chardevice";
|
return "inode/chardevice";
|
||||||
else if(S_ISFIFO(mode))
|
else if(S_ISFIFO(mode))
|
||||||
return "inode/fifo";
|
return "inode/fifo";
|
||||||
else if(S_ISLNK(mode))
|
|
||||||
return "inode/symlink";
|
|
||||||
#ifdef S_ISSOCK
|
#ifdef S_ISSOCK
|
||||||
else if(S_ISSOCK(mode))
|
else if(S_ISSOCK(mode))
|
||||||
return "inode/socket";
|
return "inode/socket";
|
||||||
|
|
58
src/vfs.c
58
src/vfs.c
|
@ -34,6 +34,64 @@ int vfs_closedir(DIR * dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* vfs_mime_icon */
|
||||||
|
GdkPixbuf * vfs_mime_icon(Mime * mime, char const * type, struct stat * st,
|
||||||
|
int size)
|
||||||
|
{
|
||||||
|
GdkPixbuf * pixbuf = NULL;
|
||||||
|
char const * emblem;
|
||||||
|
int esize;
|
||||||
|
GdkPixbuf * epixbuf;
|
||||||
|
GtkIconTheme * icontheme;
|
||||||
|
|
||||||
|
mime_icons(mime, type, size, &pixbuf, -1);
|
||||||
|
if(pixbuf == NULL)
|
||||||
|
return NULL;
|
||||||
|
/* determine the emblem */
|
||||||
|
if(S_ISLNK(st->st_mode))
|
||||||
|
emblem = "emblem-symbolic-link";
|
||||||
|
else if((st->st_mode & (S_IRUSR | S_IRGRP | S_IROTH)) == 0)
|
||||||
|
emblem = "emblem-unreadable";
|
||||||
|
else if((st->st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)) == 0)
|
||||||
|
emblem = "emblem-readonly";
|
||||||
|
else
|
||||||
|
return pixbuf;
|
||||||
|
/* determine the size of the emblem */
|
||||||
|
switch(size)
|
||||||
|
{
|
||||||
|
case 24:
|
||||||
|
esize = 12;
|
||||||
|
break;
|
||||||
|
case 48:
|
||||||
|
esize = 24;
|
||||||
|
break;
|
||||||
|
case 96:
|
||||||
|
esize = 32;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return pixbuf;
|
||||||
|
}
|
||||||
|
/* obtain the emblem's icon */
|
||||||
|
icontheme = gtk_icon_theme_get_default();
|
||||||
|
if((epixbuf = gtk_icon_theme_load_icon(icontheme, emblem, esize,
|
||||||
|
GTK_ICON_LOOKUP_USE_BUILTIN
|
||||||
|
| GTK_ICON_LOOKUP_FORCE_SIZE, NULL))
|
||||||
|
== NULL)
|
||||||
|
return pixbuf;
|
||||||
|
pixbuf = gdk_pixbuf_copy(pixbuf);
|
||||||
|
/* blit the emblem */
|
||||||
|
#if 0 /* XXX does not show anything (bottom right) */
|
||||||
|
gdk_pixbuf_composite(epixbuf, pixbuf, size - esize, size - esize,
|
||||||
|
esize, esize, 0, 0, 1.0, 1.0, GDK_INTERP_NEAREST,
|
||||||
|
255);
|
||||||
|
#else /* blitting at the top left instead */
|
||||||
|
gdk_pixbuf_composite(epixbuf, pixbuf, 0, 0, esize, esize, 0, 0,
|
||||||
|
1.0, 1.0, GDK_INTERP_NEAREST, 255);
|
||||||
|
#endif
|
||||||
|
return pixbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* vfs_opendir */
|
/* vfs_opendir */
|
||||||
DIR * vfs_opendir(char const * filename, struct stat * st)
|
DIR * vfs_opendir(char const * filename, struct stat * st)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,12 +20,16 @@
|
||||||
|
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
|
# include <gtk/gtk.h>
|
||||||
|
# include <Desktop/mime.h>
|
||||||
|
|
||||||
|
|
||||||
/* public */
|
/* public */
|
||||||
/* functions */
|
/* functions */
|
||||||
int vfs_closedir(DIR * dir);
|
int vfs_closedir(DIR * dir);
|
||||||
int vfs_lstat(char const * filename, struct stat * st);
|
int vfs_lstat(char const * filename, struct stat * st);
|
||||||
|
GdkPixbuf * vfs_mime_icon(Mime * mime, char const * type, struct stat * st,
|
||||||
|
int size);
|
||||||
DIR * vfs_opendir(char const * filename, struct stat * st);
|
DIR * vfs_opendir(char const * filename, struct stat * st);
|
||||||
struct dirent * vfs_readdir(DIR * dir);
|
struct dirent * vfs_readdir(DIR * dir);
|
||||||
int vfs_stat(char const * filename, struct stat * st);
|
int vfs_stat(char const * filename, struct stat * st);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user