grim/guifications3

moved guifications-gtk to cmake
cmake
2010-12-13, Gary Kramlich
36e02fafe588
moved guifications-gtk to cmake
/*
* Guifications - The end-all, be-all notification framework
* Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* ...
* ;::::;
* ;::::; :;
* ;:::::' :;
* ;:::::; ;.
* ,:::::' ; OOO\
* ::::::; ; OOOOO\
* ;:::::; ; OOOOOOOO
* ,;::::::; ;' / OOOOOOO
* ;:::::::::`. ,,,;. / / DOOOOOO
* .';:::::::::::::::::;, / / DOOOO
* ,::::::;::::::;;;;::::;, / / DOOO
* ;`::::::`'::::::;;;::::: ,#/ / DOOO
* :`:::::::`;::::::;;::: ;::# / DOOO
* ::`:::::::`;:::::::: ;::::# / DOO
* `:`:::::::`;:::::: ;::::::#/ DOO
* :::`:::::::`;; ;:::::::::## OO
* ::::`:::::::`;::::::::;:::# OO
* `:::::`::::::::::::;'`:;::# O
* `:::::`::::::::;' / / `:#
* ::::::`:::::;' / / `#
*
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <stdlib.h>
#include <gflib/gf_intl.h>
#include <gflib/gf_core.h>
#include <gflib/gf_log.h>
#include <gflib/gf_private.h>
/******************************************************************************
* Globals
*****************************************************************************/
static gchar *prefs_uri = NULL;
static gboolean disable_plugins = FALSE;
static const GOptionEntry gflib_args[] = {
{
"prefs-uri", 0, 0, G_OPTION_ARG_STRING,
&prefs_uri,
"The uri describing the preference engine and options.",
"uri",
}, {
"disable-plugins", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_NONE,
&disable_plugins,
"Tells gflib to not load any plugins.",
NULL,
}, {
NULL,
},
};
/******************************************************************************
* Helpers
*****************************************************************************/
static void
gettext_initialize(void) {
#ifdef ENABLE_NLS
/* Bind to our gettext domain */
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bindtextdomain(GETTEXT_PACKAGE "-properties", LOCALEDIR);
# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
bind_textdomain_codeset(GETTEXT_PACKAGE "-properties", "UTF-8");
# endif /* HAVE_BIND_TEXTDOMAIN_CODESET */
#endif /* ENABLE_NLS */
}
/******************************************************************************
* API
*****************************************************************************/
/**
* gf_lib_init:
* @argc : Address of the argc parameter of your main() function. Changed if
* any arguments were handled.
* @argv : Address of the argv parameter of main(). Any parameters understood
* by gtk_init() are stripped before return.
*
* Initalizes gflib.
*
* Note: This function must be called before trying to use any object in gflib!
*/
void
gf_lib_init(gint *argc, gchar ***argv) {
gchar *appname = NULL;
/* do some magic to see if argv was passed in as null */
if(!argv)
appname = NULL;
if(!argv[0])
appname = NULL;
/* initialize gettext */
gettext_initialize();
/* Initialize the GType system */
g_type_init();
/* initialize gthread, we don't use this directly but a few plugins do, and
* if it's not initialized before the mainloop is run, it gets all sorts of
* messed up.
*/
if(!g_thread_supported())
g_thread_init(NULL);
/* setup the system log */
gf_log_init();
/* initialize preferences, this is done before plugins so we know which
* ones we're not supposed to load.
*/
gf_preferences_init(appname, prefs_uri);
/* initialize the plugin manager */
gf_plugin_manager_init(disable_plugins);
/* initialize the connection manager
*
* This MUST be done after the plugin manager so a manual refresh is NOT
* required.
*/
gf_connection_manager_init();
}
/**
* gf_lib_uninit:
*
* Uninitializes gflib.
*/
void
gf_lib_uninit(void) {
gf_connection_manager_uninit();
gf_plugin_manager_uninit();
gf_preferences_uninit();
gf_log_uninit();
}
/**
* gf_lib_get_configure_args:
*
* Gets the configure arguments that were used to build gflib.
*
* Return Value: The configure arguments that were used to build gflib.
*/
const gchar *
gf_lib_get_configure_args(void) {
#ifdef CONFIG_ARGS
return CONFIG_ARGS;
#else
return "";
#endif
}
/**
* gf_lib_get_version:
*
* Gets the version of gflib.
*
* Return Value: The version of gflib.
*/
const gchar *
gf_lib_get_version(void) {
#ifdef VERSION
return VERSION;
#else
return "";
#endif
}
/**
* gf_lib_get_lib_version:
*
* Get the library version of gflib.
*
* Return Value: The library version of gflib.
*/
const gchar *
gf_lib_get_lib_version(void) {
#ifdef GFLIB_VERSION_S
return GFLIB_VERSION_S;
#else
return "";
#endif
}
/**
* gf_lib_get_website:
*
* Gets the website for gflib.
*
* Return Value: The website for gflib.
*/
const gchar *
gf_lib_get_website(void) {
#ifdef GFLIB_WEBSITE
return GFLIB_WEBSITE;
#else
return "";
#endif
}
/**
* gf_get_option_group:
*
* Returns a #GOptionGroup for the commandline arguments recognized by gflib.
* You should add this group to your #GOptionContext with
* g_option_context_add_group(), if you are using g_option_context_parse() to
* parse your commandline arguments.
*
* Returns: A #GOptionGroup for the command line arguments recognized by gflib.
*/
GOptionGroup *
gf_get_option_group(void) {
GOptionGroup *group = NULL;
group = g_option_group_new("gflib", _("GfLib Options"),
_("Show gflib options"), NULL, NULL);
g_option_group_add_entries(group, gflib_args);
g_option_group_set_translation_domain(group, GETTEXT_PACKAGE);
return group;
}