Obsah

Negenerování náhledů souborů v nautilus

Pokusy

Vlastní program

LIBS = $(shell pkg-config gnome-desktop-3.0 --libs) $(shell pkg-config gnome-vfs-2.0 --libs)
INCL = $(shell pkg-config gnome-desktop-3.0 --cflags) $(shell pkg-config gnome-vfs-2.0 --cflags)
CXXFLAGS = -O2 -g -Wall $(INCL) -DGNOME_DESKTOP_USE_UNSTABLE_API
 
OBJS = thumb-sampl3.o
TARGET = thumb-sampl3
 
$(TARGET): $(OBJS)
	$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
 
all: $(TARGET)
 
clean:
	rm -f $(OBJS) $(TARGET)
#include <iostream>
#include <ctime>
#include <sys/stat.h>
#include <libgnome-desktop/gnome-desktop-thumbnail.h>
#include <libgnomevfs/gnome-vfs-mime.h>
 
using namespace std;
 
int main(int argc, char **argv) {
 
  GnomeDesktopThumbnailFactory *thumbnail_factory;
  char *fpath;
  char *uri;
  time_t mtime;
  const char *mime_type;
 
  if (argc!=2) {
	  cerr << "No input file" << endl;
	  return 1;
  }
 
  fpath = argv[1];
  cerr << "filepath: " << fpath << endl;
 
  thumbnail_factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
 
  if (!thumbnail_factory) {
    cerr << "cannot initialize" << endl;
    return 1;
  }
 
  cerr << "initialized with GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE set to: ";
  cerr << GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE << endl;
 
  GFile *loc;
  loc = g_file_new_for_path(fpath);
  uri = g_file_get_uri (loc);
  cerr << "uri: " << uri << endl;
 
  mime_type = gnome_vfs_mime_type_from_name(fpath);
  cerr << "mime_type: " << mime_type << endl;
 
  struct stat finfo;
  if (stat(fpath, &finfo)==0) {
	  mtime = finfo.st_mtim.tv_sec;
  } else {
	  cerr << "cannot get mtime of file" << endl;
	  return 1;
  }
 
  cerr << "mtime: " << mtime << endl;
 
  gboolean res;
  res = gnome_desktop_thumbnail_factory_can_thumbnail (thumbnail_factory,
                                                       uri,
                                                       mime_type,
                                                       mtime);
  cerr << "can thumbnail res: " << res << endl;
 
  GdkPixbuf *pixbuf;
  pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (thumbnail_factory,
                                                               uri,
                                                               mime_type);
 
  cerr << "generated pixbuf??: " << (!pixbuf==NULL) << endl;
 
  if (pixbuf) {
 
    gnome_desktop_thumbnail_factory_save_thumbnail (thumbnail_factory,
                                                    pixbuf,
                                                    uri,
                                                    mtime);
    cerr << "after save_thumbnail" << endl;
    g_object_unref (pixbuf);
 
  } else {
 
    //gnome_desktop_thumbnail_factory_create_failed_thumbnail (thumbnail_factory,
    //                                                         uri,
    //                                                         mtime);
    //cerr << "after create_failed_thumbnail" << endl;
 
	cerr << "calling create_failed_thumbnail skipped" << endl;
  }
 
  //g_free (mime_type);
  g_free (uri);
 
}

Zjištění z vlastního programu

./thumb-sampl3 /home/djbuldog/Pictures/Snímek\ z\ 2014-11-18\ 20\:27\:27.png 
filepath: /home/djbuldog/Pictures/Snímek z 2014-11-18 20:27:27.png
initialized with GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE set to: 1
uri: file:///home/djbuldog/Pictures/Sn%C3%ADmek%20z%202014-11-18%2020:27:27.png
mime_type: image/png
mtime: 1416338848
can thumbnail res: 1
generated pixbuf??: 0
calling create_failed_thumbnail skipped
strace -vf -s 1024 ./thumb-sampl3 /home/djbuldog/Pictures/Snímek\ z\ 2014-11-18\ 20\:27\:27.png 
..
pid 15953] execve("/usr/bin/bwrap", ["bwrap", "--ro-bind", "/usr", "/usr", "--ro-bind", "/lib", "/lib", "--ro-bind", "/lib64", "/lib64", "--proc", "/proc", "--dev", "/dev", "--symlink", "usr/bin", "/bin", "--symlink", "usr/sbin", "/sbin", "--chdir", "/", "--setenv", "GIO_USE_VFS", "local", "--unshare-all", "--die-with-parent", "--bind", "/tmp/gnome-desktop-thumbnailer-YVNH9Y", "/tmp", "--ro-bind", "/home/djbuldog/Pictures/Sn\303\255mek z 2014-11-18 20:27:27.png", "/tmp/gnome-desktop-file-to-thumbnail.png", "--seccomp", "5", "/usr/bin/gdk-pixbuf-thumbnailer", "-s", "256", "file:///tmp/gnome-desktop-file-to-thumbnail.png", "/tmp/gnome-desktop-thumbnailer.png"], ["WINDOW_MANAGER=/usr/bin/compiz", .....
...
pid 15953] write(2, "Creating new namespace failed, likely because the kernel does not support user namespaces.  bwrap must be installed setuid on such systems.", 139 <unfinished ...>
..
mkdir /tmp/gnome-desktop-thumbnailer-Y8FU9Y
"/usr/bin/bwrap" "--ro-bind" "/usr" "/usr" "--ro-bind" "/lib" "/lib" "--ro-bind" "/lib64" "/lib64" "--proc" "/proc" "--dev" "/dev" "--symlink" "usr/bin" "/bin" "--symlink" "usr/sbin" "/sbin" "--chdir" "/" "--setenv" "GIO_USE_VFS" "local" "--unshare-all" "--die-with-parent" "--bind" "/tmp/gnome-desktop-thumbnailer-Y8FU9Y" "/tmp" "--ro-bind" "/home/djbuldog/Pictures/Sn\303\255mek z 2014-11-18 20:27:27.png" "/tmp/gnome-desktop-file-to-thumbnail.png" "--seccomp" "5"  "/usr/bin/gdk-pixbuf-thumbnailer" "-s" "256" "file:///tmp/gnome-desktop-file-to-thumbnail.png" "/tmp/gnome-desktop-thumbnailer.png"
bwrap: Creating new namespace failed, likely because the kernel does not support user namespaces.  bwrap must be installed setuid on such systems.
stat("/sys/module/user_namespace/parameters/enable", 0x7ffee7d684b0) = -1 ENOENT (No such file or directory)
bwrap --unshare-all bash