Ejemplo n.º 1
0
/******************************************************************************
 * Name
 *  on_help_contents_activate
 *
 * Synopsis
 *   #include "gui/main_menu.h"
 *
 *   void on_help_contents_activate(GtkMenuItem * menuitem,
 *						gpointer user_data)
 *
 * Description
 *   display the help contents file
 *
 * Return value
 *   void
 */
G_MODULE_EXPORT void
on_help_contents_activate(GtkMenuItem *menuitem, gpointer user_data)
{
#ifdef WIN32
	const char *lang = g_getenv("LANG");
	gchar *help_file =
	    g_win32_get_package_installation_directory_of_module(NULL);
	help_file = g_strconcat(help_file, "\0", NULL);
	if (!strncmp(lang, "fr", 2))
		help_file =
		    g_build_filename(help_file, "share", "help",
				     "xiphos_fr.chm", NULL);
	else if (!strncmp(lang, "fa", 2))
		help_file =
		    g_build_filename(help_file, "share", "help",
				     "xiphos_fa.chm", NULL);
	else
		help_file =
		    g_build_filename(help_file, "share", "help",
				     "xiphos.chm", NULL);
	xiphos_open_default(help_file);
	g_free(help_file);
#else
	GError *error = NULL;
	gtk_show_uri(NULL, "ghelp:xiphos", gtk_get_current_event_time(),
		     &error);
	if (error != NULL) {
		XI_warning(("%s", error->message));
		g_error_free(error);
	}
#endif /* WIN32 */
}
Ejemplo n.º 2
0
static const gchar *
_ev_win32_get_locale_dir (HMODULE module)
{
	if (locale_dir)
		return locale_dir;

	gchar *install_dir = NULL, *utf8_locale_dir;
	gchar *retval = NULL;

	if (evdocument_dll != NULL)
		install_dir =
		g_win32_get_package_installation_directory_of_module (module);

	if (install_dir) {
		utf8_locale_dir = g_build_filename (install_dir,
			"share", "locale", NULL);

		locale_dir = g_win32_locale_filename_from_utf8 (utf8_locale_dir);

		g_free (install_dir);
		g_free (utf8_locale_dir);
	}

	if (!locale_dir)
		locale_dir = g_strdup ("");

	return locale_dir;
}
static gchar *
get_locale_dir (void)
{
	gchar *locale_dir;

#ifdef G_OS_WIN32
	gchar *win32_dir;

	win32_dir = g_win32_get_package_installation_directory_of_module (NULL);

	locale_dir = g_build_filename (win32_dir, "share", "locale", NULL);

	g_free (win32_dir);
#elif defined (OS_OSX)
	if (gtkosx_application_get_bundle_id () != NULL)
	{
		locale_dir = g_build_filename (gtkosx_application_get_resource_path (), "share", "locale", NULL);
	}
	else
	{
		locale_dir = g_build_filename (DATADIR, "locale", NULL);
	}
#else
	locale_dir = g_build_filename (DATADIR, "locale", NULL);
#endif

	return locale_dir;
}
Ejemplo n.º 4
0
/* This code must live in gedit.exe, not in libgedit.dll, since the whole
 * point is to find and load libgedit.dll.
 */
static gboolean
gedit_w32_load_private_dll (void)
{
	gchar *dllpath;
	gchar *prefix;

	prefix = g_win32_get_package_installation_directory_of_module (NULL);

	if (prefix != NULL)
	{
		/* Instead of g_module_open () it may be possible to do any of the
		 * following:
		 * A) Change PATH to "${dllpath}/lib/gedit;$PATH"
		 * B) Call SetDllDirectory ("${dllpath}/lib/gedit")
		 * C) Call AddDllDirectory ("${dllpath}/lib/gedit")
		 * But since we only have one library, and its name is known, may as well
		 * use gmodule.
		 */
		dllpath = g_build_filename (prefix, "lib", "gedit", "libgedit.dll", NULL);
		g_free (prefix);
		libgedit_dll = g_module_open (dllpath, 0);
		g_free (dllpath);
	}

	if (libgedit_dll == NULL)
	{
		libgedit_dll = g_module_open ("libgedit.dll", 0);
	}

	return (libgedit_dll != NULL);
}
Ejemplo n.º 5
0
// TBD: Support a comma separated list of plugin directories.
static void rehash_loaders()
{
    GError *error = NULL;
    const gchar * giv_plugin_dir = PACKAGE_PLUGIN_DIR;
#ifdef G_OS_WIN32
    // Hardcoded path relative to installation dir on Windows
    gchar giv_win32_plugin_dir[512];
    sprintf(giv_win32_plugin_dir, "%s/plugins",
            g_win32_get_package_installation_directory_of_module(NULL));
    giv_plugin_dir = giv_win32_plugin_dir;
#endif

    if (getenv("GIV_PLUGIN_DIR"))
        giv_plugin_dir = (const char*)getenv("GIV_PLUGIN_DIR");

    // No matter of we succeed or not, we will not automatically
    // call this function again.
    giv_image_loaded_loaders = TRUE;
    GDir *plugin_dir = g_dir_open(giv_plugin_dir,
                                  0,
                                  &error);

    // No directory found, ok, just ignore it.
    if (error) {
        fprintf(stderr, "plugin dir error: %s\n", error->message);
        g_error_free(error);
        return;
    }

    const gchar *name;
    while( (name=g_dir_read_name(plugin_dir)) ) {
      //        printf("name = %s\n", name);
        // Try to load it as a module if it ends with ".dll"
        // or ".so".
        gchar *extension = g_strrstr(name, ".");
        if (!extension)
            continue;
        extension++;
        if (g_ascii_strncasecmp(G_MODULE_SUFFIX,
                                extension,
                                strlen(G_MODULE_SUFFIX))==0) {
            gchar *module_name = g_strndup(name, extension-name-1);
            gchar *module_path = g_strdup_printf("%s/%s",
                                                 giv_plugin_dir,
                                                 name);

            GModule *module = g_module_open (module_path, G_MODULE_BIND_MASK);

            if (module) {
                givimage_loaders = g_slist_prepend(givimage_loaders,
                                                   module);
            }
            else
                fprintf(stderr, "Failed loading module %s\n", module_path);
            g_free(module_path);
            g_free(module_name);
        }
    }
    g_dir_close(plugin_dir);
}
Ejemplo n.º 6
0
static const char *
get_atk_locale_dir (void)
{
  static gchar *atk_localedir = NULL;

  if (!atk_localedir)
    {
      const gchar *p;
      gchar *root, *temp;
      
      /* ATK_LOCALEDIR might end in either /lib/locale or
       * /share/locale. Scan for that slash.
       */
      p = ATK_LOCALEDIR + strlen (ATK_LOCALEDIR);
      while (*--p != '/')
	;
      while (*--p != '/')
	;

      root = g_win32_get_package_installation_directory_of_module (atk_dll);
      temp = g_build_filename (root, p, NULL);
      g_free (root);

      /* atk_localedir is passed to bindtextdomain() which isn't
       * UTF-8-aware.
       */
      atk_localedir = g_win32_locale_filename_from_utf8 (temp);
      g_free (temp);
    }
  return atk_localedir;
}
Ejemplo n.º 7
0
void build_package_paths(void)
{
#ifdef WINNT

    gchar* prefix;
    prefix = g_win32_get_package_installation_directory_of_module(NULL);

#ifndef TEST
    glade_dir = g_build_filename(prefix, "share", PACKAGE, "glade", NULL);
#else
    glade_dir = g_build_filename(prefix, "..", "..", "data", NULL);
#endif
    locale_dir = g_build_filename(prefix, "share", "locale", NULL);

    g_free(prefix);

#else /* WINNT */

#ifndef TEST
    glade_dir = g_strdup(GLADEDIR);
#else
    glade_dir = g_build_filename(LOCALPATH, "data", NULL);
#endif
    locale_dir = g_strdup(NETWORK_TRAFFIC_LOCALEDIR);

#endif /* WINNT */
}
Ejemplo n.º 8
0
gchar* pluma_dirs_get_pluma_locale_dir(void)
{
	gchar* locale_dir;

	#ifdef G_OS_WIN32

		gchar* win32_dir;

		win32_dir = g_win32_get_package_installation_directory_of_module(NULL);

		locale_dir = g_build_filename(win32_dir, "share", "locale", NULL);

		g_free(win32_dir);

	#elif defined(OS_OSX)

		IgeMacBundle *bundle = ige_mac_bundle_get_default();

		if (ige_mac_bundle_get_is_app_bundle(bundle))
		{
			locale_dir = g_strdup(ige_mac_bundle_get_localedir(bundle));
		}
		else
		{
			locale_dir = g_build_filename(DATADIR, "locale", NULL);
		}
	#else
		locale_dir = g_build_filename(DATADIR, "locale", NULL);
	#endif

	return locale_dir;
}
Ejemplo n.º 9
0
/**
 * pango_get_lib_subdirectory:
 *
 * On Unix, returns the name of the "pango" subdirectory of LIBDIR
 * (which is set at compile time). On Windows, returns the lib\pango
 * subdirectory of the Pango installation directory (which is deduced
 * at run time from the DLL's location).
 *
 * Return value: the Pango lib directory. The returned string should
 * not be freed.
 */
G_CONST_RETURN char *
pango_get_lib_subdirectory (void)
{
  static const gchar *result = NULL;

  if (result == NULL)
    {
#ifdef G_OS_WIN32
      gchar *root = g_win32_get_package_installation_directory_of_module (pango_dll);
      /* If we are running against an uninstalled copy of the Pango DLL,
       * use the compile-time installation prefix.
       */
      if (g_str_has_suffix (root, "\\.libs"))
	result = g_strdup (LIBDIR "/pango");
      else
	result = g_build_filename (root, "lib\\pango", NULL);
      g_free (root);
#else
      const char *libdir = g_getenv ("PANGO_LIBDIR");
      if (libdir != NULL)
	result = g_build_filename (libdir, "pango", NULL);
      else
	result = LIBDIR "/pango";
#endif
    }
  return result;
}
Ejemplo n.º 10
0
gchar* pluma_dirs_get_pluma_lib_dir(void)
{
	gchar* lib_dir;

	#ifdef G_OS_WIN32

		gchar* win32_dir;

		win32_dir = g_win32_get_package_installation_directory_of_module(NULL);

		lib_dir = g_build_filename(win32_dir, "lib", "pluma", NULL);

		g_free(win32_dir);

	#elif defined(OS_OSX)
		IgeMacBundle* bundle = ige_mac_bundle_get_default();

		if (ige_mac_bundle_get_is_app_bundle(bundle))
		{
			const gchar* path = ige_mac_bundle_get_resourcesdir(bundle);
			lib_dir = g_build_filename(path, "lib", "pluma", NULL);
		}
		else
		{
			lib_dir = g_build_filename(LIBDIR, "pluma", NULL);
		}
	#else
		lib_dir = g_build_filename(LIBDIR, "pluma", NULL);
	#endif

	return lib_dir;
}
Ejemplo n.º 11
0
Archivo: gui.c Proyecto: acli/xiphos
void gui_init(int argc, char *argv[])
{
	static int gui_init_done = FALSE;

	if (gui_init_done)
		return;
	gui_init_done = TRUE;

#ifdef ENABLE_NLS
	bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	textdomain(GETTEXT_PACKAGE);
#endif
#ifdef WIN32
	gchar *locale_dir =
	    g_win32_get_package_installation_directory_of_module(NULL);
	locale_dir = g_strconcat(locale_dir, "\0", NULL);
	locale_dir = g_build_filename(locale_dir, "share", "locale", NULL);
	bindtextdomain(GETTEXT_PACKAGE, locale_dir);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	textdomain(GETTEXT_PACKAGE);
	g_free(locale_dir);
#endif
	if (!gtk_init_with_args(&argc, &argv, NULL, NULL, NULL, NULL)) {
		exit(1);
	};
#ifndef WIN32
	gconf_setup();
#endif
#ifdef HAVE_DBUS
	ipc = ipc_init_dbus_connection(ipc);
#endif
}
Ejemplo n.º 12
0
static void
init_pc_path (void)
{
#ifdef G_OS_WIN32
  char *instdir, *lpath, *shpath;

  instdir = g_win32_get_package_installation_directory_of_module (NULL);
  if (instdir == NULL)
    {
      /* This only happens when GetModuleFilename() fails. If it does, that
       * failure should be investigated and fixed.
       */
      debug_spew ("g_win32_get_package_installation_directory_of_module failed\n");
      return;
    }

  lpath = g_build_filename (instdir, "lib", "pkgconfig", NULL);
  shpath = g_build_filename (instdir, "share", "pkgconfig", NULL);
  pkg_config_pc_path = g_strconcat (lpath, G_SEARCHPATH_SEPARATOR_S, shpath,
                                    NULL);
  g_free (instdir);
  g_free (lpath);
  g_free (shpath);
#else
  pkg_config_pc_path = PKG_CONFIG_PC_PATH;
#endif
}
Ejemplo n.º 13
0
/**
 * _glib_get_locale_dir:
 *
 * Return the path to the share\locale or lib\locale subfolder of the
 * GLib installation folder. The path is in the system codepage. We
 * have to use system codepage as bindtextdomain() doesn't have a
 * UTF-8 interface.
 */
gchar *
_glib_get_locale_dir (void)
{
  gchar *install_dir = NULL, *locale_dir;
  gchar *retval = NULL;

  if (glib_dll != NULL)
    install_dir = g_win32_get_package_installation_directory_of_module (glib_dll);

  if (install_dir)
    {
      /*
       * Append "/share/locale" or "/lib/locale" depending on whether
       * autoconfigury detected GNU gettext or not.
       */
      const char *p = GLIB_LOCALE_DIR + strlen (GLIB_LOCALE_DIR);
      while (*--p != '/')
	;
      while (*--p != '/')
	;

      locale_dir = g_build_filename (install_dir, p, NULL);

      retval = g_win32_locale_filename_from_utf8 (locale_dir);

      g_free (install_dir);
      g_free (locale_dir);
    }

  if (retval)
    return retval;
  else
    return g_strdup ("");
}
Ejemplo n.º 14
0
gchar* pluma_dirs_get_pluma_data_dir(void)
{
	gchar* data_dir;

	#ifdef G_OS_WIN32
		gchar* win32_dir;

		win32_dir = g_win32_get_package_installation_directory_of_module(NULL);

		data_dir = g_build_filename(win32_dir, "share", "pluma", NULL);

		g_free(win32_dir);

	#elif defined(OS_OSX)

		IgeMacBundle* bundle = ige_mac_bundle_get_default();

		if (ige_mac_bundle_get_is_app_bundle(bundle))
		{
			const gchar* bundle_data_dir = ige_mac_bundle_get_datadir(bundle);

			data_dir = g_build_filename(bundle_data_dir, "pluma", NULL);
		}
		else
		{
			data_dir = g_build_filename(DATADIR, "pluma", NULL);
		}
	#else
		data_dir = g_build_filename(DATADIR, "pluma", NULL);
	#endif

	return data_dir;
}
Ejemplo n.º 15
0
void gsb_dirs_init ( void )
{
#ifdef G_OS_WIN32
    {
        gchar *dir;

        dir = g_win32_get_package_installation_directory_of_module ( NULL );

        categories_dir = g_build_filename ( dir, "share/grisbi/categories", NULL );
        locale_dir = g_strconcat ( dir, "/share/locale", NULL );
        pixmaps_dir = g_strconcat ( dir, "/share/pixmaps/grisbi", NULL );
        plugins_dir = g_strconcat ( dir, "/lib/grisbi", NULL );
        ui_dir = g_strconcat ( dir, "/share/grisbi/ui", NULL );

        g_free ( dir );

        user_config_dir = g_build_filename ( g_get_user_config_dir (), "grisbi", NULL);
        user_data_dir = g_build_filename ( g_get_user_data_dir (), "grisbi", NULL);
        user_default_dir = g_strdup ( win32_get_my_documents_folder_path () );
    }
#else
#ifdef GTKOSXAPPLICATION
    if ( quartz_application_get_bundle_id ( ) )
    {
        gchar *res_path;

        res_path = quartz_application_get_resource_path ();
        categories_dir = g_build_filename ( res_path, "share/grisbi/categories", NULL );
        locale_dir = g_strconcat (res_path, "/share/locale", NULL );
        pixmaps_dir = g_strconcat (res_path, "/share/pixmaps/grisbi", NULL );
        plugins_dir = g_strconcat (res_path, "/lib/grisbi", NULL );
        ui_dir = g_strconcat (res_path, "/share/grisbi/ui", NULL );

        g_free ( res_path );

        user_config_dir = g_build_filename ( g_get_home_dir (),
                        "Library/Application Support/Grisbi/config", NULL );
        user_data_dir = g_build_filename ( g_get_home_dir (),
                        "Library/Application Support/Grisbi/data", NULL );
        user_default_dir = g_strdup ( g_get_home_dir() );

    }
#else
    {
        categories_dir = g_build_filename ( DATA_PATH, "categories", NULL );
        locale_dir = g_strdup ( LOCALEDIR );
        pixmaps_dir = g_strdup ( PIXMAPS_DIR );
        plugins_dir = g_strdup ( PLUGINS_DIR );
        ui_dir = g_strdup ( UI_DIR );

        user_config_dir = g_build_filename ( g_get_user_config_dir (), "grisbi", NULL);
        user_data_dir = g_build_filename ( g_get_user_data_dir (), "grisbi", NULL);
        user_default_dir = g_strdup ( g_get_home_dir() );
    }
#endif /* GTKOSXAPPLICATION */
#endif

    accelerator_filename = g_build_filename ( user_config_dir, "grisbi-accels", NULL );
}
Ejemplo n.º 16
0
gchar *trg_win32_support_path(gchar * file)
{
    gchar *moddir =
        g_win32_get_package_installation_directory_of_module(NULL);
    gchar *path = g_build_filename(moddir, file, NULL);
    g_free(moddir);
    return path;
}
Ejemplo n.º 17
0
void
gm_platform_init ()
{
#ifdef WIN32
  basedir = g_strdup (g_win32_get_package_installation_directory_of_module (NULL));
  sysconfdir = g_strdup (basedir);
  datadir = g_strdup (basedir);
#endif
}
Ejemplo n.º 18
0
const gchar *
_gtk_get_data_prefix (void)
{
  static char *gtk_data_prefix = NULL;
  if (gtk_data_prefix == NULL)
    gtk_data_prefix = g_win32_get_package_installation_directory_of_module (gtk_dll);

  return gtk_data_prefix;
}
Ejemplo n.º 19
0
static void
setup (void)
{
	gchar *full_prefix;
	gchar *cp_prefix;

        G_LOCK (mutex);
        if (localedir != NULL) {
                G_UNLOCK (mutex);
                return;
        }

	/* This requires that the libeutil DLL is installed in $bindir */
        full_prefix = g_win32_get_package_installation_directory_of_module(hmodule);
        cp_prefix = g_win32_locale_filename_from_utf8(full_prefix);

        localedir = replace_prefix (cp_prefix, EVOLUTION_LOCALEDIR);

        g_free (cp_prefix);

	prefix = g_strdup (full_prefix);

	/* It makes sense to have some of the paths overridable with
	 * environment variables.
	 */
	bindir = replace_prefix (full_prefix, EVOLUTION_BINDIR);
	datadir = replace_prefix (full_prefix, EVOLUTION_DATADIR);
	ecpsdir = replace_prefix (full_prefix, EVOLUTION_ECPSDIR);
	etspecdir = replace_prefix (full_prefix, EVOLUTION_ETSPECDIR);
	galviewsdir = replace_prefix (full_prefix, EVOLUTION_GALVIEWSDIR);
	helpdir = replace_prefix (full_prefix, EVOLUTION_HELPDIR);
	if (g_getenv ("EVOLUTION_ICONDIR") &&
	    g_file_test (g_getenv ("EVOLUTION_ICONDIR"), G_FILE_TEST_IS_DIR))
		icondir = g_getenv ("EVOLUTION_ICONDIR");
	else
		icondir = replace_prefix (full_prefix, EVOLUTION_ICONDIR);
	if (g_getenv ("EVOLUTION_IMAGESDIR") &&
	    g_file_test (g_getenv ("EVOLUTION_IMAGESDIR"), G_FILE_TEST_IS_DIR))
		imagesdir = g_getenv ("EVOLUTION_IMAGESDIR");
	else
		imagesdir = replace_prefix (full_prefix, EVOLUTION_IMAGESDIR);
	libdir = replace_prefix (full_prefix, EVOLUTION_LIBDIR);
	libexecdir = replace_prefix (full_prefix, EVOLUTION_LIBEXECDIR);
	moduledir = replace_prefix (full_prefix, EVOLUTION_MODULEDIR);
	plugindir = replace_prefix (full_prefix, EVOLUTION_PLUGINDIR);
	privdatadir = replace_prefix (full_prefix, EVOLUTION_PRIVDATADIR);
	ruledir = replace_prefix (full_prefix, EVOLUTION_RULEDIR);
	sounddir = replace_prefix (full_prefix, EVOLUTION_SOUNDDIR);
	sysconfdir = replace_prefix (full_prefix, EVOLUTION_SYSCONFDIR);
	toolsdir = replace_prefix (full_prefix, EVOLUTION_TOOLSDIR);
	uidir = replace_prefix (full_prefix, EVOLUTION_UIDIR);

        g_free (full_prefix);

	G_UNLOCK (mutex);
}
Ejemplo n.º 20
0
const gchar *
cut_win32_base_path (void)
{
    if (win32_base_path)
        return win32_base_path;

    win32_base_path = g_win32_get_package_installation_directory_of_module(NULL);

    return win32_base_path;
}
Ejemplo n.º 21
0
int
main (int argc,
      char *argv[])
{
#ifdef G_OS_WIN32
	gchar *prefix = g_win32_get_package_installation_directory_of_module (NULL);
#endif

#ifdef ENABLE_NLS
#ifdef G_OS_WIN32
	gchar *localedir = g_build_filename (prefix, "share", "locale", NULL);
#else
	gchar *localedir = g_strdup (PACKAGE_LOCALE_DIR);
#endif
	bindtextdomain (GETTEXT_PACKAGE, localedir);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	g_free (localedir);
#endif


	gtk_init (&argc, &argv);


	window = gpinstruct_analyzer_window_new ();


	/* Exit when the window is closed */
	g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

	gtk_widget_show_all (window);

	if (argc > 1)
	{
		gpinstruct_analyzer_window_new_session (GPINSTRUCT_ANALYZER_WINDOW (window),
		                                        argv[1]);
		if (argc > 2)
		{
			int i;

			for (i = 2; i < argc; i++)
				gpinstruct_analyzer_window_add_log_file (GPINSTRUCT_ANALYZER_WINDOW (window),
				                                         argv[i]);
		}
	}

	gtk_main ();

#ifdef G_OS_WIN32
	g_free (prefix);
#endif

	return 0;
}
Ejemplo n.º 22
0
/**
 * gsf_init :
 *
 * Initializes the GSF library
 **/
void
gsf_init (void)
{
	static gboolean libgsf_initialized = FALSE;
	if (libgsf_initialized)
		return;

#ifdef ENABLE_NLS
#ifdef G_OS_WIN32
	{
		char *pkg_dir	  = g_win32_get_package_installation_directory_of_module (gsf_dll_hmodule);
		gchar *locale_dir = g_build_filename (pkg_dir, "lib/locale", NULL);
		bindtextdomain (GETTEXT_PACKAGE, locale_dir);
		g_free (locale_dir);
		g_free (pkg_dir);
	}
#else
	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
#endif
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif

	g_type_init ();
#ifndef HAVE_G_BASE64_ENCODE
	base64_init ();
#endif

#ifdef _GSF_GTYPE_THREADING_FIXED
	if (NULL == static_type_module) {
		static_type_module = g_object_new (gsf_dummy_type_module_get_type(), NULL);
		g_assert (static_type_module != NULL);
		g_type_module_use (static_type_module);
		g_type_module_set_name (static_type_module, "libgsf-builtin");
	}
#else
	gsf_init_dynamic (NULL);
#endif

	{
		/* Little-endian representation of M_PI.  */
		static guint8 pibytes[8] = {
			0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40
		};

		/*
		 * If this fails, see
		 *   http://bugzilla.gnome.org/show_bug.cgi?id=350973
		 */
		double pi = gsf_le_get_double (pibytes);
		if (!(pi > 3.14 && pi < 3.15))
			g_error ("Compilation trouble with endianess.");
	}
}
Ejemplo n.º 23
0
gchar *
gitg_platform_support_get_locale_dir (void)
{
	gchar *module_dir;
	gchar *locale_dir;

	module_dir = g_win32_get_package_installation_directory_of_module (NULL);
	locale_dir = g_build_filename (module_dir, "share", "locale", NULL);
	g_free (module_dir);

	return locale_dir;
}
Ejemplo n.º 24
0
static G_CONST_RETURN char * G_CONST_RETURN *
gjs_get_search_path(void)
{
    char **search_path;

    /* not thread safe */

    if (!gjs_search_path) {
        G_CONST_RETURN gchar* G_CONST_RETURN * system_data_dirs;
        const char *envstr;
        GPtrArray *path;
        gchar *install_dir;
        gsize i;

        path = g_ptr_array_new();

        /* in order of priority */

        /* $GJS_PATH */
        envstr = g_getenv("GJS_PATH");
        if (envstr) {
            char **dirs, **d;
            dirs = g_strsplit(envstr, G_SEARCHPATH_SEPARATOR_S, 0);
            for (d = dirs; *d != NULL; d++)
                g_ptr_array_add(path, *d);
            /* we assume the array and strings are allocated separately */
            g_free(dirs);
        }

        /* $XDG_DATA_DIRS /gjs-1.0 */
        system_data_dirs = g_get_system_data_dirs();
        for (i = 0; system_data_dirs[i] != NULL; ++i) {
            char *s;
            s = g_build_filename(system_data_dirs[i], "gjs-1.0", NULL);
            g_ptr_array_add(path, s);
        }

        /* ${libdir}/gjs-1.0 */
        install_dir = g_win32_get_package_installation_directory_of_module (NULL);
        g_ptr_array_add(path, g_build_filename (install_dir, "lib", "gjs-1.0", NULL));
        g_free (install_dir);

        g_ptr_array_add(path, NULL);

        search_path = (char**)g_ptr_array_free(path, FALSE);

        gjs_search_path = search_path;
    } else {
        search_path = gjs_search_path;
    }

    return (G_CONST_RETURN char * G_CONST_RETURN *)search_path;
}
Ejemplo n.º 25
0
void
gm_platform_init ()
{
#if GLIB_CHECK_VERSION (2, 18, 0)
  basedir = g_strdup (g_win32_get_package_installation_directory_of_module (NULL));
#else  
  basedir = g_strdup (g_win32_get_package_installation_directory (NULL, NULL));
#endif
  sysconfdir = g_strdup (basedir);
  datadir = g_strdup (basedir);
  plugindir = g_strdup_printf ("%s/lib/contacts", basedir);
}
Ejemplo n.º 26
0
void
gtr_dirs_init ()
{
#ifdef G_OS_WIN32
  gchar *win32_dir;

  win32_dir = g_win32_get_package_installation_directory_of_module (NULL);

  gtr_data_dir = g_build_filename (win32_dir, "share", "gtranslator", NULL);
  gtr_help_dir = g_build_filename (win32_dir,
                                   "share", "gtranslator", "help", NULL);
  gtr_locale_dir = g_build_filename (win32_dir, "share", "locale", NULL);
  gtr_lib_dir = g_build_filename (win32_dir, "lib", "gtranslator", NULL);

  g_free (win32_dir);
#else /* !G_OS_WIN32 */
#ifdef OS_OSX
  IgeMacBundle *bundle = ige_mac_bundle_get_default ();

  if (ige_mac_bundle_get_is_app_bundle (bundle))
    {
      const gchar *bundle_data_dir = ige_mac_bundle_get_datadir (bundle);
      const gchar *bundle_resource_dir =
        ige_mac_bundle_get_resourcesdir (bundle);

      gtr_data_dir = g_build_filename (bundle_data_dir, "gtranslator", NULL);
      gtr_help_dir = g_build_filename (bundle_data_dir,
                                       "gtranslator", "help" NULL);
      gtr_locale_dir = g_strdup (ige_mac_bundle_get_localedir (bundle));
      gtr_lib_dir = g_build_filename (bundle_resource_dir,
                                      "lib", "gtranslator", NULL);
    }
#endif /* !OS_OSX */
  if (gtr_data_dir == NULL)
    {
      gtr_data_dir = g_build_filename (DATADIR, "gtranslator", NULL);
      gtr_help_dir = g_build_filename (DATADIR, "gnome", "help", NULL);
      gtr_locale_dir = g_build_filename (DATADIR, "locale", NULL);
      gtr_lib_dir = g_build_filename (LIBDIR, "gtranslator", NULL);
    }
#endif /* !G_OS_WIN32 */

  user_cache_dir = g_build_filename (g_get_user_cache_dir (), "gtranslator", NULL);
  user_config_dir = g_build_filename (g_get_user_config_dir (),
                                      "gtranslator", NULL);
  user_plugins_dir = g_build_filename (g_get_user_data_dir (),
                                       "gtranslator", "plugins", NULL);
  gtr_plugins_dir = g_build_filename (gtr_lib_dir, "plugins", NULL);
  gtr_plugins_data_dir = g_build_filename (gtr_data_dir, "plugins", NULL);

  gtr_pixmaps_dir = g_build_filename (gtr_data_dir, "pixmaps", NULL);
}
Ejemplo n.º 27
0
const gchar *
_gtk_get_sysconfdir (void)
{
  static char *gtk_sysconfdir = NULL;
  if (gtk_sysconfdir == NULL)
    {
      gchar *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
      gtk_sysconfdir = g_build_filename (root, "etc", NULL);
      g_free (root);
    }

  return gtk_sysconfdir;
}
Ejemplo n.º 28
0
G_MODULE_EXPORT gchar * 
am_install_path ()
{
  gchar *prgdir;

#ifdef WIN32
  prgdir = g_win32_get_package_installation_directory_of_module (NULL);
#else
  prgdir = g_strdup (CMAKE_INSTALL_PREFIX);
#endif

  return prgdir;
}
Ejemplo n.º 29
0
//!
//! @brief Loads the gtk builder xml file from the usual paths
//!
//! @param filename The filename of the xml file to look for
//!
static gboolean 
gw_window_load_ui_xml (GwWindow *window, const char *filename)
{
    if (window == NULL || filename == NULL) return FALSE;

    //Declarations
    GwWindowPrivate *priv;
    GtkWidget *toplevel;
    GtkWidget *unused;
    gchar *prefix;
    gchar *path;
    gboolean loaded;

    //Initializations
    priv = window->priv;
    loaded = FALSE;
#ifndef G_OS_WIN32
    path = g_build_filename (DATADIR2, PACKAGE, filename, NULL);
#else
    prefix = g_win32_get_package_installation_directory_of_module (NULL);
    path = g_build_filename (prefix, "share", PACKAGE, filename, NULL);
    g_free (prefix);
#endif

    //Search for the files
    if (g_file_test (path, G_FILE_TEST_IS_REGULAR) && gtk_builder_add_from_file (priv->builder, path,  NULL))
    {
      gtk_builder_connect_signals (priv->builder, NULL);

      unused = GTK_WIDGET (gtk_builder_get_object (priv->builder, "unused"));
      toplevel = GTK_WIDGET (gtk_builder_get_object (priv->builder, "toplevel"));
      g_assert (unused != NULL && toplevel != NULL);
      g_object_ref(toplevel);
      gtk_container_remove (GTK_CONTAINER (unused), toplevel);
      gtk_container_add (GTK_CONTAINER (window), toplevel);
      g_object_unref(toplevel);
  
      gtk_widget_destroy (unused); unused = NULL;

      loaded = TRUE;
    }

    g_free (path);

    //Bug test
    g_assert (loaded);

    //Return
    return loaded;
}
Ejemplo n.º 30
0
static gchar *
get_package_directory_from_module (const gchar *module_name)
{
  static GHashTable *module_dirs = NULL;
  G_LOCK_DEFINE_STATIC (module_dirs);
  HMODULE hmodule = NULL;
  gchar *fn;

  G_LOCK (module_dirs);

  if (module_dirs == NULL)
    module_dirs = g_hash_table_new (g_str_hash, g_str_equal);
  
  fn = g_hash_table_lookup (module_dirs, module_name ? module_name : "");
      
  if (fn)
    {
      G_UNLOCK (module_dirs);
      return g_strdup (fn);
    }

  if (module_name)
    {
      wchar_t *wc_module_name = g_utf8_to_utf16 (module_name, -1, NULL, NULL, NULL);
      hmodule = GetModuleHandleW (wc_module_name);
      g_free (wc_module_name);

      if (!hmodule)
	{
	  G_UNLOCK (module_dirs);
	  return NULL;
	}
    }

  fn = g_win32_get_package_installation_directory_of_module (hmodule);

  if (fn == NULL)
    {
      G_UNLOCK (module_dirs);
      return NULL;
    }
  
  g_hash_table_insert (module_dirs, module_name ? g_strdup (module_name) : "", fn);

  G_UNLOCK (module_dirs);

  return g_strdup (fn);
}