[Xfce4-commits] <garcon:master> Get rid of garcon_{init, shutdown}.
Nick Schermer
nick at xfce.org
Mon Aug 17 19:44:02 CEST 2009
Updating branch refs/heads/master
to 4e827bbd0288495f4ead0691246687f0f4d87b1e (commit)
from e105048e6e1c7699aa70dc286bef1c1d3a495ad3 (commit)
commit 4e827bbd0288495f4ead0691246687f0f4d87b1e
Author: Nick Schermer <nick at xfce.org>
Date: Mon Aug 17 19:39:56 2009 +0200
Get rid of garcon_{init,shutdown}.
Most likely garcon will only be used in normal applications,
so calling g_type_init() is handled by gtk_init(), if not
the user should call it.
For now an application implementing garcon should call
garcon_set_environment (...) before using any of the functions.
This will leak the string once, so if you want to avoid this
call garcon_set_environment (NULL) when the app exits..
garcon/Makefile.am | 1 -
garcon/garcon-config.c | 34 +++++++++++++
garcon/garcon-config.h.in | 2 +
garcon/garcon.c | 117 ---------------------------------------------
garcon/garcon.h | 9 ----
5 files changed, 36 insertions(+), 127 deletions(-)
diff --git a/garcon/Makefile.am b/garcon/Makefile.am
index 492e263..738c487 100644
--- a/garcon/Makefile.am
+++ b/garcon/Makefile.am
@@ -45,7 +45,6 @@ libgarcon_headers = \
garcon-menu-parser.h
libgarcon_sources = \
- garcon.c \
garcon-config.c \
garcon-gio.c \
garcon-menu-element.c \
diff --git a/garcon/garcon-config.c b/garcon/garcon-config.c
index c1e2b62..3669262 100644
--- a/garcon/garcon-config.c
+++ b/garcon/garcon-config.c
@@ -74,3 +74,37 @@ garcon_check_version (guint required_major,
{
return NULL;
}
+
+
+
+gchar *
+garcon_config_lookup (const gchar *filename)
+{
+ const gchar * const *dirs;
+ gchar *path;
+ guint i;
+
+ g_return_val_if_fail (filename != NULL && *filename != '\0', NULL);
+
+ /* Look for the file in the user's config directory */
+ path = g_build_filename (g_get_user_config_dir (), filename, NULL);
+ if (g_path_is_absolute (path)
+ && g_file_test (path, G_FILE_TEST_IS_REGULAR))
+ return path;
+ g_free (path);
+
+ /* Look for the file in the system config directories */
+ dirs = g_get_system_config_dirs ();
+ for (i = 0; dirs[i] != NULL; ++i)
+ {
+ /* Build the filename, if the file exists return the path */
+ path = g_build_filename (dirs[i], filename, NULL);
+ if (g_path_is_absolute (path)
+ && g_file_test (path, G_FILE_TEST_IS_REGULAR))
+ return path;
+ g_free (path);
+ }
+
+ /* Nothing found */
+ return NULL;
+}
diff --git a/garcon/garcon-config.h.in b/garcon/garcon-config.h.in
index a4727e9..613a137 100644
--- a/garcon/garcon-config.h.in
+++ b/garcon/garcon-config.h.in
@@ -50,6 +50,8 @@ const gchar *garcon_check_version (guint required_major,
guint required_minor,
guint required_micro);
+gchar *garcon_config_lookup (const gchar *filename) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+
G_END_DECLS
#endif /* !__GARCON_CONFIG_H__ */
diff --git a/garcon/garcon.c b/garcon/garcon.c
deleted file mode 100644
index 836ebbe..0000000
--- a/garcon/garcon.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* vi:set et ai sw=2 sts=2 ts=2: */
-/*-
- * Copyright (c) 2009 Jannis Pohlmann <jannis at xfce.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib-object.h>
-
-#include <garcon/garcon.h>
-#include <garcon/garcon-environment.h>
-
-
-
-/**
- * SECTION:garcon
- * @title: Library Initialization and Shutdown
- *
- * Library Initialization and Shutdown.
- **/
-
-
-
-static gint garcon_ref_count = 0;
-
-
-
-/**
- * garcon_init:
- * @env : name of the desktop environment (e.g. XFCE, GNOME or KDE)
- * or %NULL.
- *
- * Initializes the garcon library. @env optionally defines the
- * name of the desktop environment for which menus will be generated.
- * This means that items belonging only to other desktop environments
- * will be ignored.
- **/
-void
-garcon_init (const gchar *env)
-{
- if (g_atomic_int_exchange_and_add (&garcon_ref_count, 1) == 0)
- {
- /* Initialize the GObject type system */
- g_type_init ();
-
- /* Set desktop environment */
- garcon_set_environment (env);
- }
-}
-
-
-
-/**
- * garcon_shutdown:
- *
- * Shuts the garcon library down.
- **/
-void
-garcon_shutdown (void)
-{
- if (g_atomic_int_dec_and_test (&garcon_ref_count))
- {
- /* Unset desktop environment */
- garcon_set_environment (NULL);
- }
-}
-
-
-
-gchar *
-garcon_config_lookup (const gchar *filename)
-{
- const gchar * const *dirs;
- gchar *path;
- guint i;
-
- g_return_val_if_fail (filename != NULL && *filename != '\0', NULL);
-
- /* Look for the file in the user's config directory */
- path = g_build_filename (g_get_user_config_dir (), filename, NULL);
- if (g_path_is_absolute (path)
- && g_file_test (path, G_FILE_TEST_IS_REGULAR))
- return path;
- g_free (path);
-
- /* Look for the file in the system config directories */
- dirs = g_get_system_config_dirs ();
- for (i = 0; dirs[i] != NULL; ++i)
- {
- /* Build the filename, if the file exists return the path */
- path = g_build_filename (dirs[i], filename, NULL);
- if (g_path_is_absolute (path)
- && g_file_test (path, G_FILE_TEST_IS_REGULAR))
- return path;
- g_free (path);
- }
-
- /* Nothing found */
- return NULL;
-}
diff --git a/garcon/garcon.h b/garcon/garcon.h
index ee14acb..1783486 100644
--- a/garcon/garcon.h
+++ b/garcon/garcon.h
@@ -41,13 +41,4 @@
#undef GARCON_INSIDE_GARCON_H
-G_BEGIN_DECLS
-
-void garcon_init (const gchar *env);
-void garcon_shutdown (void);
-
-gchar *garcon_config_lookup (const gchar *filename) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
-
-G_END_DECLS
-
#endif /* !__GARCON_H__ */
More information about the Xfce4-commits
mailing list