mirror of https://github.com/djcb/mu.git
* mu-runtime: use mu_util_init_system, some cosmetics
This commit is contained in:
parent
d602ad1f47
commit
0565587dda
|
@ -27,7 +27,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <mu-msg.h>
|
#include <mu-msg.h>
|
||||||
|
|
||||||
|
|
||||||
#include "mu-config.h"
|
#include "mu-config.h"
|
||||||
#include "mu-log.h"
|
#include "mu-log.h"
|
||||||
#include "mu-util.h"
|
#include "mu-util.h"
|
||||||
|
@ -36,45 +35,19 @@
|
||||||
#define MU_BOOKMARKS_FILENAME "bookmarks"
|
#define MU_BOOKMARKS_FILENAME "bookmarks"
|
||||||
|
|
||||||
struct _MuRuntimeData {
|
struct _MuRuntimeData {
|
||||||
gchar *_muhome;
|
gchar *_muhome;
|
||||||
gchar *_xapian_dir;
|
gchar *_xapian_dir;
|
||||||
gchar *_bookmarks_file;
|
gchar *_bookmarks_file;
|
||||||
MuConfigOptions *_config;
|
MuConfigOptions *_config;
|
||||||
};
|
};
|
||||||
typedef struct _MuRuntimeData MuRuntimeData;
|
typedef struct _MuRuntimeData MuRuntimeData;
|
||||||
|
|
||||||
/* static, global data for this singleton */
|
/* static, global data for this singleton */
|
||||||
static gboolean _initialized = FALSE;
|
static gboolean _initialized = FALSE;
|
||||||
static MuRuntimeData *_data = NULL;
|
static MuRuntimeData *_data = NULL;
|
||||||
|
|
||||||
static void runtime_free (void);
|
static void runtime_free (void);
|
||||||
|
|
||||||
static gboolean
|
|
||||||
init_system (void)
|
|
||||||
{
|
|
||||||
/* without setlocale, non-ascii cmdline params (like search
|
|
||||||
* terms) won't work */
|
|
||||||
setlocale (LC_ALL, "");
|
|
||||||
|
|
||||||
/* init the random number generator; this is not really *that*
|
|
||||||
* random, but good enough for our humble needs... */
|
|
||||||
srandom ((unsigned)(getpid()*time(NULL)));
|
|
||||||
|
|
||||||
/* on FreeBSD, it seems g_slice_new and friends lead to
|
|
||||||
* segfaults. So we shut if off */
|
|
||||||
#ifdef __FreeBSD__
|
|
||||||
if (!g_setenv ("G_SLICE", "always-malloc", TRUE)) {
|
|
||||||
g_critical ("cannot set G_SLICE");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#endif /*__FreeBSD__*/
|
|
||||||
|
|
||||||
g_type_init ();
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mu_runtime_init (const char* muhome_arg)
|
mu_runtime_init (const char* muhome_arg)
|
||||||
|
@ -83,7 +56,7 @@ mu_runtime_init (const char* muhome_arg)
|
||||||
|
|
||||||
g_return_val_if_fail (!_initialized, FALSE);
|
g_return_val_if_fail (!_initialized, FALSE);
|
||||||
|
|
||||||
if (!init_system())
|
if (!mu_util_init_system())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (muhome_arg)
|
if (muhome_arg)
|
||||||
|
@ -121,7 +94,7 @@ mu_runtime_init_from_cmdline (int *pargc, char ***pargv)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (!_initialized, FALSE);
|
g_return_val_if_fail (!_initialized, FALSE);
|
||||||
|
|
||||||
if (!init_system())
|
if (!mu_util_init_system())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
_data = g_new0 (MuRuntimeData, 1);
|
_data = g_new0 (MuRuntimeData, 1);
|
||||||
|
@ -182,8 +155,6 @@ g_return_val_if_fail (_initialized, NULL);
|
||||||
return _data->_muhome;
|
return _data->_muhome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
mu_runtime_xapian_dir (void)
|
mu_runtime_xapian_dir (void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue