1
0
Fork 0

In progress...

This commit is contained in:
Kolan Sh 2015-11-08 00:03:19 +03:00
parent 8d4a28f4eb
commit 5d53c200bd
4 changed files with 81 additions and 2 deletions

32
src/AppDirs.vala Normal file
View File

@ -0,0 +1,32 @@
extern static char SO_PATH[256];
/*namespace LAview.Core {
class AppDirs {
public static File so_path;
public static File exec_dir;
public static File common_dir;
public static string data_plugins_dir;
public static string protocol_plugins_dir;
public static string ui_dir;
public static string settings_dir;
public static void init () {
so_path = File.new_for_path ((string)SO_PATH);
exec_dir = so_path.get_parent ();
common_dir = exec_dir.get_parent ();
ui_dir = Path.build_path (Path.DIR_SEPARATOR_S, common_dir.get_path(),
"share/laview-core-"+Config.VERSION_MAJOR.to_string()+"/ui");
settings_dir = Path.build_path (Path.DIR_SEPARATOR_S, common_dir.get_path(), "share/glib-2.0/schemas");
data_plugins_dir = Path.build_path (Path.DIR_SEPARATOR_S, exec_dir.get_path(),
"laview-core-"+Config.VERSION_MAJOR.to_string()+"/data-plugins");
protocol_plugins_dir = Path.build_path (Path.DIR_SEPARATOR_S, exec_dir.get_path(),
"laview-core-"+Config.VERSION_MAJOR.to_string()+"/protocol-plugins");
}
public static void terminate () {
}
}
}*/

View File

@ -4,10 +4,11 @@ SET (PluginPackages gtk+-3.0 gee-0.8 gobject-plugin-iface-0 laview-core-iface-0
SET (PluginPkgModules gtk+-3.0 gee-0.8 laview-core-0)
SET (PluginCustomVapis ${CMAKE_SOURCE_DIR}/config/Config.vapi)
INCLUDE_DIRECTORIES ("${CMAKE_BINARY_DIR}/config")
SET (PluginExtraSources ${PROJECT_SOURCE_DIR}/src/library_constructor.c)
SET (PluginInstall ON)
IF (WIN32)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mwindows")
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-all-symbols")
ENDIF (WIN32)
SET (PluginInstallPrefix "lib/laview-core-0/plugins")
SET (PluginInstallPrefix "lib/laview-core-0/data-plugins")
INCLUDE (ValaPluginCommonRules)

45
src/library_constructor.c Normal file
View File

@ -0,0 +1,45 @@
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#elif defined(linux) || defined(UNIX) || defined(__unix__)
#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdio.h>
#endif
char SO_PATH[FILENAME_MAX];
#include "gettext-config.h"
#if defined(_WIN32) || defined(_WIN64)
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
#elif defined(linux) || defined(UNIX) || defined(__unix__)
void __attribute__ ((constructor)) load_library (void)
#endif
{
#if defined(_WIN32) || defined(_WIN64)
gchar dllPath[FILENAME_MAX],
*dllDir,
*localePath;
GetModuleFileName (hInstance, dllPath, FILENAME_MAX);
dllDir = g_path_get_dirname (dllPath);
localePath = g_build_filename (dllDir, "../share/locale", NULL);
g_free (dllDir);
bindtextdomain (GETTEXT_PACKAGE, localePath);
g_free (localePath);
#elif defined(linux) || defined(UNIX) || defined(__unix__)
Dl_info dl_info;
dladdr(load_library, &dl_info);
strcpy (SO_PATH, dl_info.dli_fname);
#endif
#if (!GLIB_CHECK_VERSION (2, 36, 0))
g_type_init ();
#endif
#if defined(_WIN32) || defined(_WIN64)
(void) dwReason; // avoid
(void) lpReserved; // warnings
return TRUE;
#endif
}

View File

@ -1,6 +1,7 @@
using LAview, GObject.Plugins;
using LAview, Core, GObject.Plugins;
extern const string GETTEXT_PACKAGE;
extern static string so_path;
/**
* Plugin of type A1.