summaryrefslogtreecommitdiff
path: root/libmate-desktop
diff options
context:
space:
mode:
authorBastien Nocera <[email protected]>2012-10-24 17:20:20 +0200
committerraveit65 <[email protected]>2020-01-09 00:06:04 +0100
commite8ad08431239b54904271eca88afe39389e38018 (patch)
tree13dc2de5ebe2522d242bb016d715cfaf256e78e9 /libmate-desktop
parentb25da97d5cae29861bfc9317fd9c66afb09a5405 (diff)
downloadmate-desktop-e8ad08431239b54904271eca88afe39389e38018.tar.bz2
mate-desktop-e8ad08431239b54904271eca88afe39389e38018.tar.xz
lib: Add thumbnail test application
origin commit: https://gitlab.gnome.org/GNOME/gnome-desktop/commit/cb04925 https://gitlab.gnome.org/GNOME/gnome-desktop/commit/36b131c
Diffstat (limited to 'libmate-desktop')
-rw-r--r--libmate-desktop/Makefile.am8
-rw-r--r--libmate-desktop/test-desktop-thumbnail.c63
2 files changed, 70 insertions, 1 deletions
diff --git a/libmate-desktop/Makefile.am b/libmate-desktop/Makefile.am
index 48d7378..63e5479 100644
--- a/libmate-desktop/Makefile.am
+++ b/libmate-desktop/Makefile.am
@@ -31,7 +31,7 @@ AM_CPPFLAGS = \
AM_CFLAGS = $(WARN_CFLAGS)
-noinst_PROGRAMS = test-ditem test test-languages
+noinst_PROGRAMS = test-desktop-thumbnail test-ditem test test-languages
CLEANFILES =
@@ -79,6 +79,12 @@ test_LDADD = \
libmate-desktop-2.la \
$(MATE_DESKTOP_LIBS)
+test_desktop_thumbnail_LDADD = \
+ $(lib_LTLIBRARIES) \
+ $(MATE_DESKTOP_LIBS) \
+ $(XLIB_LIBS)
+
+
test_ditem_SOURCES = \
test-ditem.c
diff --git a/libmate-desktop/test-desktop-thumbnail.c b/libmate-desktop/test-desktop-thumbnail.c
new file mode 100644
index 0000000..c37428b
--- /dev/null
+++ b/libmate-desktop/test-desktop-thumbnail.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2012,2017 Red Hat, Inc.
+ *
+ * This file is part of the Mate Library.
+ *
+ * The Gnome Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Gnome Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Gnome Library; see the file COPYING.LIB. If not,
+ * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Authors: Bastien Nocera <[email protected]>
++ */
+
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include "mate-desktop-thumbnail.h"
+#include <gtk/gtk.h>
+
+int main (int argc, char **argv)
+{
+ GdkPixbuf *pixbuf;
+ MateDesktopThumbnailFactory *factory;
+ GtkWidget *window, *image;
+ char *content_type;
+
+ gtk_init (&argc, &argv);
+
+ if (argc < 2) {
+ g_print ("Usage: %s FILE...\n", argv[0]);
+ return 1;
+ }
+
+ content_type = g_content_type_guess (argv[1], NULL, 0, NULL);
+ factory = mate_desktop_thumbnail_factory_new (MATE_DESKTOP_THUMBNAIL_SIZE_LARGE);
+ pixbuf = mate_desktop_thumbnail_factory_generate_thumbnail (factory, argv[1], content_type);
+ g_free (content_type);
+ g_object_unref (factory);
+
+ if (pixbuf == NULL) {
+ g_warning ("mate_desktop_thumbnail_factory_generate_thumbnail() failed to generate a thumbnail for %s", argv[1]);
+ return 1;
+ }
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ image = gtk_image_new_from_pixbuf (pixbuf);
+ g_object_unref (pixbuf);
+ gtk_container_add (GTK_CONTAINER (window), image);
+ gtk_widget_show_all (window);
+
+ gtk_main ();
+
+ return 0;
+}