diff --git a/src/helper/icon-loader.cpp b/src/helper/icon-loader.cpp index 2e65ae019cdd8a2e7149f6ca09411fd346371b4b..b36d58e97c1600950ed393853c234037ac12caf1 100644 --- a/src/helper/icon-loader.cpp +++ b/src/helper/icon-loader.cpp @@ -35,6 +35,9 @@ Glib::RefPtr sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) icon_theme->prepend_search_path(get_path_ustring(SYSTEM, ICONS)); icon_theme->prepend_search_path(get_path_ustring(USER, ICONS)); } + double original_scale = atof(g_getenv("GDK_SCALE") ? g_getenv("GDK_SCALE") : "1"); + double scale = prefs->getDouble("/theme/gdkScale", original_scale); + size *= scale; try { if (prefs->getBool("/theme/symbolicIcons", false)) { gchar colornamed[64]; diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 67bedb1f8be484790687488870996619f663ea6c..02d6473c61367d14e55a65c4f264d25bca80fbb2 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -427,6 +427,22 @@ Application::add_style_sheet() } } +static void set_scale_env() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double original_scale = atof(g_getenv("GDK_SCALE") ? g_getenv("GDK_SCALE") : "1"); + double scale_value = prefs->getDouble("/theme/gdkScale", original_scale); + const gchar *gdk_scale = std::to_string(scale_value).c_str(); + g_setenv("GDK_SCALE", gdk_scale, TRUE); + double original_scale_dpi = atof(g_getenv("GDK_DPI_SCALE") ? g_getenv("GDK_DPI_SCALE") : "1"); + double scale_dpi_value = prefs->getDouble("/theme/gdkDPIScale", original_scale_dpi); + const gchar *gdk_scale_dpi = std::to_string(scale_dpi_value).c_str(); + g_setenv("GDK_DPI_SCALE", gdk_scale_dpi, TRUE); + + // printf("GDK_SCALE = %s\n", g_getenv("GDK_SCALE")); + // printf("GDK_DPI_SCALE = %s\n", g_getenv("GDK_DPI_SCALE")); +} + /* \brief Constructor for the application. * Creates a new Inkscape::Application. * @@ -472,6 +488,7 @@ Application::Application(const char* argv, bool use_gui) : if (use_gui) { add_style_sheet(); + set_scale_env(); /* Load the preferences and menus */ GtkSettings *settings = gtk_settings_get_default(); if (settings) { @@ -488,7 +505,10 @@ Application::Application(const char* argv, bool use_gui) : else { prefs->setString("/theme/gtkTheme", Glib::ustring(gtkThemeName)); } - + double scaleText = prefs->getDouble("/theme/scaleText", -1); + if (scaleText != -1) { + g_object_set(gtk_settings_get_default(), "gtk-xft-dpi", (gint)(scaleText * 96 * 1024), NULL); + } if (prefs->getString("/theme/iconTheme") != "") { g_object_set(settings, "gtk-icon-theme-name", prefs->getString("/theme/iconTheme").c_str(), NULL); } diff --git a/src/main.cpp b/src/main.cpp index 5206a64035852f0ce8e9575f2955e9e464c19357..b0573dacb6e6cc0083316bc33d67af07d6bfa76d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,14 +55,15 @@ #undef AND #endif -#include "file.h" +#include "color.h" #include "document.h" +#include "file.h" #include "layer-model.h" -#include "selection.h" +#include "preferences.h" +#include "print.h" #include "selection-chemistry.h" +#include "selection.h" #include "ui/interface.h" -#include "print.h" -#include "color.h" #include "svg/svg.h" #include "svg/svg-color.h" @@ -618,7 +619,6 @@ static void set_extensions_env() // printf("PYTHONPATH = %s\n", g_getenv("PYTHONPATH")); } - /** * This is the classic main() entry point of the program, though on some * architectures it might be called by something else. @@ -649,7 +649,6 @@ main(int argc, char **argv) rt.setPathInfo(); } #endif - set_extensions_env(); // Prevents errors like "Unable to wrap GdkPixbuf..." (in nr-filter-image.cpp for example) Gtk::Main::init_gtkmm_internals(); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index ecf470d21c70bf517f8f5bb256d6b81a69635c95..bec409b065cad92f65eb565e9a3ab8b60d43233b 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -882,6 +882,13 @@ void InkscapePreferences::initPageUI() _page_theme.add_line(false, _("Secondary toolbar icon size:"), _misc_small_secondary, "", _("Set the size for the icons in secondary toolbars to use (requires restart)"), false); } + _gdk_scale.init("/theme/gdkScale", 0.01, 10.0, 0.01, 0.1, 1.0, false, false); + _page_theme.add_line(true, _("Scale app"), _gdk_scale, "Common value for HiDPI is 2", + "", false); + _gdk_dpi_scale.init("/theme/gdkDPIScale", 0.01, 10.0, 0.01, 0.1, 1.0, false, false); + _page_theme.add_line(true, _("Scale text dpi"), _gdk_dpi_scale, + "Common value for HiDPI is 0.5", "", false); + _apply_theme.set_label(_("Reload icons")); _apply_theme.set_tooltip_text(_("Apply icon changes (may take a few seconds)")); _page_theme.add_line(false, "", _apply_theme, "Reloading icons will close all windows and open them again. No data will be lost.", "", false); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 55ea35f63445932ed9b84df3c688ab0d138dd3bd..7e4e9cdd228174bd9b80cb915ed9ee4a0780556c 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -250,6 +250,8 @@ protected: UI::Widget::PrefCombo _misc_small_toolbar; UI::Widget::PrefCombo _misc_small_secondary; UI::Widget::PrefCombo _misc_small_tools; + UI::Widget::PrefSpinButton _gdk_scale; + UI::Widget::PrefSpinButton _gdk_dpi_scale; Gtk::Button _apply_theme; UI::Widget::PrefRadioButton _win_dockable;