Add WIN32 fonts as a plugin

This commit is contained in:
LAGonauta 2020-05-20 21:02:43 -03:00
parent 6d5ee03e9e
commit 823df3ed70
8 changed files with 69 additions and 7 deletions

View file

@ -12,6 +12,9 @@ endif ()
# Prepare Plugins
set(DEFAULT_PLUGINS omemo;openpgp;http-files;ice;rtp)
if (WIN32)
set(DEFAULT_PLUGINS ${DEFAULT_PLUGINS};win32-fonts)
endif (WIN32)
foreach (plugin ${DEFAULT_PLUGINS})
if ("$CACHE{DINO_PLUGIN_ENABLED_${plugin}}" STREQUAL "")
if (NOT DEFINED DINO_PLUGIN_ENABLED_${plugin}})

View file

@ -87,7 +87,6 @@ set(RESOURCE_LIST
unified_main_content.ui
unified_window_placeholder.ui
win32_larger_fonts.css
theme.css
)

View file

@ -27,12 +27,6 @@ public class Dino.Ui.Application : Gtk.Application, Dino.Application {
Environment.set_application_name("Dino");
Window.set_default_icon_name("im.dino.Dino");
#if _WIN32
CssProvider larger_fonts = new CssProvider();
larger_fonts.load_from_resource("/im/dino/Dino/win32_larger_fonts.css");
StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), larger_fonts, STYLE_PROVIDER_PRIORITY_APPLICATION);
#endif
CssProvider provider = new CssProvider();
provider.load_from_resource("/im/dino/Dino/theme.css");
StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider, STYLE_PROVIDER_PRIORITY_APPLICATION);

View file

@ -23,3 +23,7 @@ endif(DINO_PLUGIN_ENABLED_omemo)
if(DINO_PLUGIN_ENABLED_notification-sound)
add_subdirectory(notification-sound)
endif(DINO_PLUGIN_ENABLED_notification-sound)
if(DINO_PLUGIN_ENABLED_win32-fonts)
add_subdirectory(win32-fonts)
endif(DINO_PLUGIN_ENABLED_win32-fonts)

View file

@ -0,0 +1,43 @@
find_packages(WIN32_FONTS_PACKAGES REQUIRED
Gee
GLib
GModule
GObject
GTK3
)
set(RESOURCE_LIST
larger.css
)
compile_gresources(
WIN32_FONTS_GRESOURCES_TARGET
WIN32_FONTS_GRESOURCES_XML
TARGET ${CMAKE_CURRENT_BINARY_DIR}/resources/resources.c
TYPE EMBED_C
RESOURCES ${RESOURCE_LIST}
PREFIX /im/dino/Dino/win32-fonts
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data
)
vala_precompile(WIN32_FONTS_VALA_C
SOURCES
src/plugin.vala
src/register_plugin.vala
CUSTOM_VAPIS
${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi
${CMAKE_BINARY_DIR}/exports/dino.vapi
${CMAKE_BINARY_DIR}/exports/qlite.vapi
PACKAGES
${WIN32_FONTS_PACKAGES}
GRESOURCES
${WIN32_FONTS_GRESOURCES_XML}
)
add_definitions(${VALA_CFLAGS})
add_library(win32-fonts SHARED ${WIN32_FONTS_VALA_C} ${WIN32_FONTS_GRESOURCES_TARGET})
target_link_libraries(win32-fonts libdino ${WIN32_FONTS_PACKAGES})
set_target_properties(win32-fonts PROPERTIES PREFIX "")
set_target_properties(win32-fonts PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/)
install(TARGETS win32-fonts ${PLUGIN_INSTALL})

View file

@ -0,0 +1,16 @@
using Gtk;
namespace Dino.Plugins.Win32Fonts {
public class Plugin : RootInterface, Object {
public void registered(Dino.Application app) {
CssProvider larger_fonts = new CssProvider();
larger_fonts.load_from_resource("/im/dino/Dino/win32-fonts/larger.css");
StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), larger_fonts, STYLE_PROVIDER_PRIORITY_APPLICATION);
}
public void shutdown() { }
}
}

View file

@ -0,0 +1,3 @@
public Type register_plugin(Module module) {
return typeof (Dino.Plugins.Win32Fonts.Plugin);
}