commit - fae93e2bc6999859312a2f1e290c171d605b2c59
commit + 9490382715e2690d547c0e39a55e555e770fa222
blob - 70b6a49ba4b41fd76e2e6dc7a3e503824f1e006e
blob + 6f1bb737f4d96aafa1e77f948f216999ae4d877d
--- claws-features.h.in
+++ claws-features.h.in
#undef HAVE_LIBETPAN
#undef HAVE_VALGRIND
-#undef HAVE_SVG
#undef USE_ENCHANT
#undef USE_GNUTLS
#undef USE_GPGME
blob - a154d6415ff59fa7a8ee45ed66e8347bdf82f101
blob + af944e55e00643ae6df9bbef82969db26202fd1f
--- configure.ac
+++ configure.ac
[ --disable-valgrind Do not build valgrind support for debugging],
[enable_valgrind=$enableval], [enable_valgrind=yes])
-AC_ARG_ENABLE(svg,
- [ --disable-svg Do not build SVG support],
- [enable_svg=$enableval], [enable_svg=yes])
-
AC_ARG_ENABLE(tests,
[ --enable-tests Build unit tests],
[enable_tests=$enableval], [enable_tests=no])
fi
AM_CONDITIONAL(CLAWS_LIBETPAN, test "x$libetpan_result" = "xyes")
-dnl librsvg
-AC_MSG_CHECKING([whether to use librsvg])
-if test x"$enable_svg" = xyes; then
- AC_MSG_RESULT(yes)
- PKG_CHECK_MODULES([SVG], [librsvg-2.0 >= 2.39.0 cairo >= 1.0.0],
- [
- AC_SUBST(SVG_CFLAGS)
- AC_SUBST(SVG_LIBS)
- AC_DEFINE(HAVE_SVG, 1, [Define if librsvg2 is available for SVG support])
- enable_svg=yes
- ],
- [
- AC_MSG_NOTICE([SVG support deactivated as librsvg2 >= 2.39.0 was not found])
- enable_svg=no
- ])
-else
- AC_MSG_RESULT(no)
-fi
-
AC_MSG_CHECKING([whether to use valgrind])
if test x$enable_valgrind = xyes; then
AC_MSG_RESULT(yes)
echo "IMAP4 (libetpan) : $enable_libetpan"
echo "NNTP (libetpan) : $enable_libetpan"
echo "Manual : $enable_manual"
-echo "SVG support : $enable_svg"
echo "Unit tests : $enable_tests"
echo "Valgrind support : $enable_valgrind"
blob - 2a69d73784541cfd44b0c344d6e00f839e9b420f
blob + 9a4ae079537ce67af198faa6faebe6bc6e351e8b
--- src/common/defs.h
+++ src/common/defs.h
#define DEFAULT_PIXMAP_THEME "INTERNAL_DEFAULT"
#define PIXMAP_THEME_DIR "themes"
-#ifdef HAVE_SVG
-#define MIN_PPI 96
-#define MAX_PPI 300
-#endif
#define AVATAR_NONE 0
#define AVATAR_XFACE 1
blob - 875fa5557ed48cdabd300fec2eb8fec5b066712c
blob + 1d0952be4c75fbf5d05ca2b0d82baf3af7173943
--- src/gtk/about.c
+++ src/gtk/about.c
gtk_text_buffer_insert(buffer, &iter,
(gchar *)C_("libetpan", "adds support for IMAP and NNTP servers\n"), -1);
-#if HAVE_SVG
- gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
-#else
- gtk_text_buffer_insert_pixbuf(buffer, &iter, inactive_pixbuf);
-#endif
- gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, (" librSVG "), -1,
- "bold", NULL);
- gtk_text_buffer_insert(buffer, &iter,
- (gchar *)C_("librSVG", "adds support for SVG themes\n"), -1);
-
#if USE_OAUTH2
gtk_text_buffer_insert_pixbuf(buffer, &iter, active_pixbuf);
#else
blob - 49a818719b02224d0e495454b772039ee2c1bb5c
blob + 55022822adc5574bff92dbc61e4663a2d8654410
--- src/main.c
+++ src/main.c
#ifdef HAVE_VALGRIND
#include <valgrind.h>
#endif
-#ifdef HAVE_SVG
-#include <librsvg/rsvg.h>
-#endif
#include "claws.h"
#include "main.h"
else
g_print(" libetpan %d.%d\n", LIBETPAN_VERSION_MAJOR, LIBETPAN_VERSION_MINOR);
#endif
-
-#if HAVE_SVG
- if (show_debug_only)
- debug_print(" librSVG " LIBRSVG_VERSION "\n");
- else
- g_print(" librSVG " LIBRSVG_VERSION "\n");
-#endif
}
int main(int argc, char *argv[])
blob - 954f931754f687ff7e25ba1b705f09028d469e04
blob + 14a1c6906dc6867f55f74d8ced3dc956a7d1f963
--- src/prefs_common.c
+++ src/prefs_common.c
{"pixmap_theme_path", DEFAULT_PIXMAP_THEME,
&prefs_common.pixmap_theme_path, P_STRING,
NULL, NULL, NULL},
-#ifdef HAVE_SVG
- {"enable_alpha_svg", "TRUE",
- &prefs_common.enable_alpha_svg, P_BOOL,
- NULL, NULL, NULL},
- {"enable_pixmap_scaling", "TRUE",
- &prefs_common.enable_pixmap_scaling, P_BOOL,
- NULL, NULL, NULL},
- {"pixmap_scaling_auto", "TRUE",
- &prefs_common.pixmap_scaling_auto, P_BOOL,
- NULL, NULL, NULL},
- {"pixmap_scaling_ppi", "96",
- &prefs_common.pixmap_scaling_ppi, P_INT,
- NULL, NULL, NULL},
-#endif
{"run_processingrules_before_mark_all", "FALSE", &prefs_common.run_processingrules_before_mark_all, P_BOOL,
NULL, NULL, NULL},
blob - 5888cf55a0e0747fed14c26a2367ab87efea7548
blob + 89a0f59847dc279c0aef933e9c44535303c4c45a
--- src/prefs_common.h
+++ src/prefs_common.h
SummaryFromShow summary_from_show;
gboolean add_address_by_click;
gchar *pixmap_theme_path;
-#ifdef HAVE_SVG
- gboolean enable_alpha_svg;
- gboolean enable_pixmap_scaling;
- gboolean pixmap_scaling_auto;
- gint pixmap_scaling_ppi;
-#endif
+
int hover_timeout; /* msecs mouse hover timeout */
gboolean ask_mark_all_read;
gboolean run_processingrules_before_mark_all;
blob - c978b518ce36667bc820e4de67cdef14f45a0712
blob + 5292b3538e6db1258fb50c4ffd3b0cfbe0be6a0f
--- src/prefs_themes.c
+++ src/prefs_themes.c
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
-#ifdef HAVE_SVG
-#include <math.h>
-#endif
#include <glib.h>
#include <glib/gi18n.h>
GtkWidget *btn_remove;
GdkPixbuf *pixbufs[PREVIEW_ICONS];
-
-#ifdef HAVE_SVG
- GtkWidget *checkbtn_enable_alpha;
- GtkWidget *checkbtn_enable_scaling;
- GtkWidget *checkbtn_scaling_auto;
- GtkWidget *label_scaling_ppi;
- GtkWidget *spinbtn_scaling_ppi;
-#endif
} ThemesPage;
typedef struct _ThemeInfo
static void prefs_themes_viewall_close_btn_clicked (GtkWidget *widget, gpointer data);
static gboolean prefs_themes_viewall_key_pressed (GtkWidget *keywidget, GdkEventKey *event, GtkWidget **widget);
static void prefs_themes_menu_item_activated_cb (GtkWidget *widget, gpointer data);
-#ifdef HAVE_SVG
-static gdouble prefs_themes_compute_ppi(GdkScreen *screen);
-static gdouble prefs_themes_get_adjusted_ppi(void);
-static void prefs_themes_checkbtn_enable_scaling_toggled_cb (GtkWidget *widget, gpointer data);
-static void prefs_themes_checkbtn_scaling_auto_toggled_cb (GtkWidget *widget, gpointer data);
-#endif
static void prefs_themes_update_buttons (const ThemesData *tdata);
static void prefs_themes_display_global_stats (const ThemesData *tdata);
tpaths = g_list_first(tdata->themes);
if (tdata->displayed == NULL)
tdata->displayed = (gchar *)(tpaths->data);
-#ifdef HAVE_SVG
- if (prefs_common.pixmap_scaling_auto)
- prefs_common.pixmap_scaling_ppi = prefs_themes_get_adjusted_ppi();
-#endif
}
static void prefs_themes_free_names(ThemesData *tdata)
prefs_themes_get_theme_info(tdata);
}
-#ifdef HAVE_SVG
-#define MM_INCH 0.0393700787402
-static gdouble prefs_themes_compute_ppi(GdkScreen *screen)
-{
- GdkRectangle workarea = {0};
- GdkMonitor *monitor = gdk_display_get_primary_monitor(gdk_display_get_default());
-
- gdk_monitor_get_workarea(monitor, &workarea);
- gdouble wp = workarea.width;
- gdouble hp = workarea.height;
- gdouble wi = gdk_monitor_get_width_mm(monitor);
- gdouble hi = gdk_monitor_get_height_mm(monitor);
- gdouble dp, di;
-
- debug_print("screen is %f x %f pixels, %f x %f mm\n", wp, hp, wi, hi);
-
- /* https://en.wikipedia.org/wiki/Pixel_density */
- wi *= MM_INCH;
- hi *= MM_INCH;
- dp = sqrt(wp * wp + hp * hp);
- di = sqrt(wi * wi + hi * hi);
-
- return (di != 0.0)? dp / di: 0.0;
-}
-
-static gdouble prefs_themes_get_adjusted_ppi(void)
-{
- gdouble ppi, cppi;
- GdkScreen * screen = gdk_screen_get_default();
-
- if (screen == NULL) { /* oops! */
- g_warning("unable to get default GDK screen");
- return MIN_PPI;
- }
-
- ppi = gdk_screen_get_resolution(screen);
- cppi = prefs_themes_compute_ppi(screen);
- debug_print("returned PPI: %f / computed PPI: %f\n", ppi, cppi);
- /*
- gdk_screen_get_resolution doesn't seem to work well when running
- on a remote display and returns the value of the local display.
- height/width functions do this better, so we can compute a PPI
- from them and take the highest value.
- */
- return MAX(ppi, cppi);
-}
-
-static void prefs_themes_checkbtn_enable_scaling_toggled_cb (GtkWidget *widget, gpointer data)
-{
- ThemesPage *page = (ThemesPage *) data;
- gboolean enabled = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON (widget));
- gboolean automatic = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON (page->checkbtn_scaling_auto));
-
- gtk_widget_set_sensitive(page->checkbtn_scaling_auto, enabled);
- gtk_widget_set_sensitive(page->spinbtn_scaling_ppi, enabled && !automatic);
- gtk_widget_set_sensitive(page->label_scaling_ppi, enabled && !automatic);
-}
-
-static void prefs_themes_checkbtn_scaling_auto_toggled_cb(GtkWidget *widget, gpointer data)
-{
- ThemesPage *page = (ThemesPage *) data;
- gboolean automatic = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON (widget));
-
- gtk_widget_set_sensitive(page->spinbtn_scaling_ppi, !automatic);
- gtk_widget_set_sensitive(page->label_scaling_ppi, !automatic);
-
- if (automatic) /* update PPI value */
- gtk_spin_button_set_value(
- GTK_SPIN_BUTTON (page->spinbtn_scaling_ppi),
- prefs_themes_get_adjusted_ppi());
-}
-#endif
-
static void prefs_themes_update_buttons(const ThemesData *tdata)
{
ThemesPage *theme = tdata->page;
GtkWidget *hbuttonbox1;
GtkWidget *btn_remove;
GtkCellRenderer *renderer;
-#ifdef HAVE_SVG
- GtkWidget *frame_scaling;
- GtkWidget *checkbtn_enable_alpha;
- GtkWidget *checkbtn_enable_scaling;
- GtkWidget *checkbtn_scaling_auto;
- GtkWidget *label_scaling_ppi;
- GtkWidget *spinbtn_scaling_ppi;
- GtkAdjustment *spinbtn_scaling_ppi_adj;
-#endif
vbox1 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
gtk_container_set_border_width (GTK_CONTAINER (vbox1), 5);
gtk_widget_show (btn_viewall);
gtk_box_pack_start (GTK_BOX (hbuttonbox1), btn_viewall, FALSE, FALSE, 5);
-#ifdef HAVE_SVG
- PACK_FRAME(vbox1, frame_scaling, _("SVG rendering"));
-
- vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, VSPACING);
- gtk_widget_show (vbox2);
- gtk_container_set_border_width (GTK_CONTAINER (vbox2), 5);
- gtk_container_add (GTK_CONTAINER (frame_scaling), vbox2);
-
- PACK_CHECK_BUTTON(vbox2, checkbtn_enable_alpha, _("Enable alpha channel"));
- PACK_CHECK_BUTTON(vbox2, checkbtn_enable_scaling, _("Force scaling"));
- PACK_CHECK_BUTTON(vbox2, checkbtn_scaling_auto, _("Automatic"));
-
- hbox3 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
- gtk_widget_show (hbox3);
-
- label_scaling_ppi = gtk_label_new (_("Pixels per inch (PPI)"));
- gtk_widget_show (label_scaling_ppi);
- gtk_box_pack_start (GTK_BOX (hbox3), label_scaling_ppi,
- FALSE, FALSE, 5);
-
- spinbtn_scaling_ppi_adj = GTK_ADJUSTMENT(
- gtk_adjustment_new (MIN_PPI, MIN_PPI, MAX_PPI, 1, 10, 0));
- spinbtn_scaling_ppi = gtk_spin_button_new(
- spinbtn_scaling_ppi_adj, 1.0, 0);
- gtk_widget_show (spinbtn_scaling_ppi);
- gtk_box_pack_start (GTK_BOX (hbox3), spinbtn_scaling_ppi,
- FALSE, FALSE, 5);
-
- gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
-
- /* initialize widget values */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (checkbtn_enable_alpha),
- prefs_common.enable_alpha_svg);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (checkbtn_enable_scaling),
- prefs_common.enable_pixmap_scaling);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (checkbtn_scaling_auto),
- prefs_common.pixmap_scaling_auto);
- gtk_spin_button_set_value(GTK_SPIN_BUTTON (spinbtn_scaling_ppi),
- prefs_common.pixmap_scaling_ppi);
-
- /* sensitivity */
- gtk_widget_set_sensitive(checkbtn_scaling_auto,
- prefs_common.enable_pixmap_scaling);
- gtk_widget_set_sensitive(spinbtn_scaling_ppi,
- prefs_common.enable_pixmap_scaling
- && !prefs_common.pixmap_scaling_auto);
- gtk_widget_set_sensitive(label_scaling_ppi,
- prefs_common.enable_pixmap_scaling
- && !prefs_common.pixmap_scaling_auto);
-
- /* signals */
- g_signal_connect(G_OBJECT(checkbtn_enable_scaling), "toggled",
- G_CALLBACK(prefs_themes_checkbtn_enable_scaling_toggled_cb),
- prefs_themes);
- g_signal_connect(G_OBJECT(checkbtn_scaling_auto), "toggled",
- G_CALLBACK(prefs_themes_checkbtn_scaling_auto_toggled_cb),
- prefs_themes);
-#endif
-
g_signal_connect(G_OBJECT(btn_remove), "clicked",
G_CALLBACK(prefs_themes_btn_remove_clicked_cb),
NULL);
prefs_themes->op_menu = menu_themes;
-#ifdef HAVE_SVG
- prefs_themes->checkbtn_enable_alpha = checkbtn_enable_alpha;
- prefs_themes->checkbtn_enable_scaling = checkbtn_enable_scaling;
- prefs_themes->checkbtn_scaling_auto = checkbtn_scaling_auto;
- prefs_themes->label_scaling_ppi = label_scaling_ppi;
- prefs_themes->spinbtn_scaling_ppi = spinbtn_scaling_ppi;
-#endif
-
prefs_themes->page.widget = vbox1;
prefs_themes_set_themes_menu(GTK_COMBO_BOX(menu_themes), tdata);
{
ThemesData *tdata = prefs_themes_data;
gchar *theme_str = tdata->displayed;
-#ifdef HAVE_SVG
- ThemesPage *tpage = (ThemesPage *) page;
- gboolean alpha = prefs_common.enable_alpha_svg;
- gboolean scaling = prefs_common.enable_pixmap_scaling;
- gboolean scaling_auto = prefs_common.pixmap_scaling_auto;
- gint scaling_ppi = prefs_common.pixmap_scaling_ppi;
- prefs_common.enable_alpha_svg = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON (tpage->checkbtn_enable_alpha));
- prefs_common.enable_pixmap_scaling = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON (tpage->checkbtn_enable_scaling));
- prefs_common.pixmap_scaling_auto = gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON (tpage->checkbtn_scaling_auto));
- prefs_common.pixmap_scaling_ppi = gtk_spin_button_get_value_as_int (
- GTK_SPIN_BUTTON (tpage->spinbtn_scaling_ppi));
-#endif
-
if (!IS_CURRENT_THEME(theme_str)) {
debug_print("Changing theme to %s\n", theme_str);
g_free(prefs_common.pixmap_theme_path);
prefs_themes_update_buttons(tdata);
}
-#ifdef HAVE_SVG
- else if (scaling != prefs_common.enable_pixmap_scaling
- || alpha != prefs_common.enable_alpha_svg
- || (scaling_auto != prefs_common.pixmap_scaling_auto
- && scaling_ppi != prefs_common.pixmap_scaling_ppi)) {
- /* same theme, different scaling options */
- debug_print("Updating theme scaling\n");
- main_window_reflect_prefs_all_real(FALSE);
- compose_reflect_prefs_pixmap_theme();
- addrcompl_reflect_prefs_pixmap_theme();
- }
-#endif
}
blob - c0d95ed7315add31562b43457bf1a8c8e6998bdc
blob + 1f3e722e453b12d890cda5de7cd263f24d2994c0
--- src/stock_pixmap.c
+++ src/stock_pixmap.c
#include <glib.h>
#include <gtk/gtk.h>
#include <string.h>
-#ifdef HAVE_SVG
-#include <librsvg/rsvg.h>
-#include <math.h>
-#endif
#include "defs.h"
#include "stock_pixmap.h"
static const char *extension[] = {
".png",
".xpm",
-#ifdef HAVE_SVG
- ".svg",
-#endif
NULL
};
return NULL;
}
-#ifdef HAVE_SVG
-/*
- * Renders a SVG into a Cairo context at the given dimensions keeping
- * the aspect ratio.
- *
- * Adapted from https://developer.gnome.org/rsvg/2.40/RsvgHandle.html
- * #rsvg-handle-set-size-callback
- */
-void render_scaled_proportionally(RsvgHandle *handle, cairo_t *cr, int width, int height)
-{
-#if LIBRSVG_CHECK_VERSION(2, 46, 0)
- if (cairo_status(cr) == CAIRO_STATUS_SUCCESS) {
- const RsvgRectangle viewport = {
- .x = 0,
- .y = 0,
- .width = width,
- .height = height,
- };
- GError *err = NULL;
- cairo_rectangle(cr, 0, 0, width, height);
- cairo_clip(cr);
-
- rsvg_handle_render_document(handle, cr, &viewport, &err);
- if (err != NULL) {
- g_warning("unable to render SVG document (%d): %s", err->code, err->message);
- g_error_free(err);
- }
- }
-#else
- RsvgDimensionData dimensions;
- double x_factor, y_factor;
- double scale_factor;
-
- rsvg_handle_get_dimensions(handle, &dimensions);
-
- x_factor = (double) width / dimensions.width;
- y_factor = (double) height / dimensions.height;
-
- scale_factor = MIN(x_factor, y_factor);
-
- cairo_scale(cr, scale_factor, scale_factor);
-
- rsvg_handle_render_cairo(handle, cr);
-#endif
-}
-
-/*
- * Generates a new Pixbuf from a Cairo context of the given dimensions.
- *
- * Adapted from https://gist.github.com/bert/985903
- */
-GdkPixbuf *pixbuf_from_cairo(cairo_t *cr, gboolean alpha, int width, int height)
-{
- gint p_stride, /* Pixbuf stride value */
- p_n_channels, /* RGB -> 3, RGBA -> 4 */
- s_stride; /* Surface stride value */
- guchar *p_pixels, /* Pixbuf's pixel data */
- *s_pixels; /* Surface's pixel data */
- cairo_surface_t *surface; /* Temporary image surface */
- GdkPixbuf *pixbuf; /* Returned pixbuf */
-
- /* Create pixbuf */
- pixbuf = gdk_pixbuf_new
- (GDK_COLORSPACE_RGB, alpha, 8, width, height);
- if (pixbuf == NULL) {
- g_warning("failed to create a new %d x %d pixbuf", width, height);
- return NULL;
- }
- /* Obtain surface from where pixel values will be copied */
- surface = cairo_get_target(cr);
- if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
- g_warning("invalid cairo surface for copying");
- return NULL;
- }
- /* Inspect pixbuf */
- g_object_get(G_OBJECT(pixbuf),
- "rowstride", &p_stride,
- "n-channels", &p_n_channels,
- "pixels", &p_pixels,
- NULL);
- /* and surface */
- s_stride = cairo_image_surface_get_stride(surface);
- s_pixels = cairo_image_surface_get_data(surface);
-
- /* Copy pixel data from surface to pixbuf */
- while (height--) {
- gint i;
- guchar *p_iter = p_pixels, *s_iter = s_pixels;
- for (i = 0; i < width; i++) {
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
- /* Pixbuf: RGB(A) - Surface: BGRA */
- gdouble alpha_factor = (gdouble)0xff / s_iter[3];
- p_iter[0] = (guchar)( s_iter[2] * alpha_factor + .5 );
- p_iter[1] = (guchar)( s_iter[1] * alpha_factor + .5 );
- p_iter[2] = (guchar)( s_iter[0] * alpha_factor + .5 );
- if (p_n_channels == 4)
- p_iter[3] = s_iter[3];
-#elif G_BYTE_ORDER == G_BIG_ENDIAN
- /* Pixbuf: RGB(A) - Surface: ARGB */
- gdouble alpha_factor = (gdouble)0xff / s_iter[0];
- p_iter[0] = (guchar)( s_iter[1] * alpha_factor + .5 );
- p_iter[1] = (guchar)( s_iter[2] * alpha_factor + .5 );
- p_iter[2] = (guchar)( s_iter[3] * alpha_factor + .5 );
- if (p_n_channels == 4)
- p_iter[3] = s_iter[0];
-#else /* PDP endianness */
- /* Pixbuf: RGB(A) - Surface: RABG */
- gdouble alpha_factor = (gdouble)0xff / s_iter[1];
- p_iter[0] = (guchar)( s_iter[0] * alpha_factor + .5 );
- p_iter[1] = (guchar)( s_iter[3] * alpha_factor + .5 );
- p_iter[2] = (guchar)( s_iter[2] * alpha_factor + .5 );
- if (p_n_channels == 4)
- p_iter[3] = s_iter[1];
-#endif
- s_iter += 4;
- p_iter += p_n_channels;
- }
- s_pixels += s_stride;
- p_pixels += p_stride;
- }
- /* Destroy context */
- cairo_destroy(cr);
-
- return pixbuf;
-}
-
-/*
- * Renders a SVG file into a pixbuf with the dimensions of the
- * given pixmap data (optionally with alpha channel).
- */
-GdkPixbuf *pixbuf_from_svg_like_icon(char *filename, GError **error, StockPixmapData *icondata, gboolean alpha)
-{
- int width, height;
- cairo_surface_t *surface;
- cairo_t *context;
- RsvgHandle *handle;
-
- cm_return_val_if_fail(filename != NULL, NULL);
- cm_return_val_if_fail(icondata != NULL, NULL);
-
- /* load SVG file */
- handle = rsvg_handle_new_from_file(filename, error);
- if (handle == NULL) {
- g_warning("failed loading SVG '%s': %s (%d)", filename,
- (*error)->message, (*error)->code);
- return NULL;
- }
-
- /* scale dimensions */
- if (prefs_common.enable_pixmap_scaling) {
- /* default is pixmap icon size */
- if (sscanf((icondata->data)[0], "%d %d ", &width, &height) != 2) {
- g_warning("failed reading icondata width and height");
- return NULL;
- }
- /* which can be modified by some factor */
- if (prefs_common.pixmap_scaling_ppi > 0) {
- gdouble factor = (gdouble) prefs_common.pixmap_scaling_ppi / MIN_PPI;
- width = (int) floor(factor * width);
- height = (int) floor(factor * height);
- }
- } else { /* render using SVG size */
-#if LIBRSVG_CHECK_VERSION(2, 52, 0)
- double svg_width, svg_height;
-
- rsvg_handle_get_intrinsic_size_in_pixels(handle, &svg_width, &svg_height);
- width = (int) svg_width;
- height = (int) svg_height;
-#else
- RsvgDimensionData dimension;
-
- rsvg_handle_get_dimensions (handle, &dimension);
- width = dimension.width;
- height = dimension.height;
-#endif
- }
-
- /* create drawing context */
- surface = cairo_image_surface_create(
- alpha? CAIRO_FORMAT_ARGB32: CAIRO_FORMAT_RGB24,
- width, height);
- if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
- g_warning("failed to create a cairo surface: %s",
- cairo_status_to_string(cairo_surface_status(surface)));
- g_object_unref(handle);
- return NULL;
- }
- context = cairo_create(surface);
- cairo_surface_destroy(surface);
- if (cairo_status(context) != CAIRO_STATUS_SUCCESS) {
- g_warning("failed to create a cairo context: %s",
- cairo_status_to_string(cairo_status(context)));
- cairo_destroy(context);
- return NULL;
- }
- /* render SVG */
- render_scaled_proportionally(handle, context, width, height);
- /* build result and destroy context */
- return pixbuf_from_cairo(context, alpha, width, height);
-}
-#endif
-
gint priv_pixbuf_gdk(PrivPixmap icon, GdkPixbuf **pixbuf)
{
PrivPixmapData *pix_d;
NULL);
if (is_file_exist(icon_file_name)) {
GError *err = NULL;
-#ifdef HAVE_SVG
- if (!strncmp(extension[i], ".svg", 4)) {
- pix = pixbuf_from_svg_like_icon(icon_file_name, &err, pix_d,
- prefs_common.enable_alpha_svg);
- } else {
- pix = gdk_pixbuf_new_from_file(icon_file_name, &err);
- }
-#else
pix = gdk_pixbuf_new_from_file(icon_file_name, &err);
-#endif
if (err) g_error_free(err);
}
if (pix) {