[gedit/wip/reusable-code: 1/2] Prepare the metadata-manager for the libgedit
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/reusable-code: 1/2] Prepare the metadata-manager for the libgedit
- Date: Thu, 12 Sep 2013 20:34:35 +0000 (UTC)
commit 0d858858aecae2a357e437165fab106d7deaa4e7
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu Sep 12 20:38:05 2013 +0200
Prepare the metadata-manager for the libgedit
gedit/gedit-debug.c | 2 -
gedit/gedit-debug.h | 8 +--
gedit/gedit-document-loader.h | 2 +-
gedit/gedit-metadata-manager.c | 92 +++++++++++++++++++++++-----------------
gedit/gedit-metadata-manager.h | 7 ---
5 files changed, 57 insertions(+), 54 deletions(-)
---
diff --git a/gedit/gedit-debug.c b/gedit/gedit-debug.c
index 372c2b8..29d5b59 100644
--- a/gedit/gedit-debug.c
+++ b/gedit/gedit-debug.c
@@ -96,8 +96,6 @@ gedit_debug_init (void)
debug = debug | GEDIT_DEBUG_SESSION;
if (g_getenv ("GEDIT_DEBUG_UTILS") != NULL)
debug = debug | GEDIT_DEBUG_UTILS;
- if (g_getenv ("GEDIT_DEBUG_METADATA") != NULL)
- debug = debug | GEDIT_DEBUG_METADATA;
if (g_getenv ("GEDIT_DEBUG_WINDOW") != NULL)
debug = debug | GEDIT_DEBUG_WINDOW;
if (g_getenv ("GEDIT_DEBUG_PANEL") != NULL)
diff --git a/gedit/gedit-debug.h b/gedit/gedit-debug.h
index fec2b33..e089130 100644
--- a/gedit/gedit-debug.h
+++ b/gedit/gedit-debug.h
@@ -59,10 +59,9 @@ typedef enum {
GEDIT_DEBUG_APP = 1 << 8,
GEDIT_DEBUG_SESSION = 1 << 9,
GEDIT_DEBUG_UTILS = 1 << 10,
- GEDIT_DEBUG_METADATA = 1 << 11,
- GEDIT_DEBUG_WINDOW = 1 << 12,
- GEDIT_DEBUG_PANEL = 1 << 13,
- GEDIT_DEBUG_DBUS = 1 << 14
+ GEDIT_DEBUG_WINDOW = 1 << 11,
+ GEDIT_DEBUG_PANEL = 1 << 12,
+ GEDIT_DEBUG_DBUS = 1 << 13
} GeditDebugSection;
#define DEBUG_VIEW GEDIT_DEBUG_VIEW, __FILE__, __LINE__, G_STRFUNC
@@ -76,7 +75,6 @@ typedef enum {
#define DEBUG_APP GEDIT_DEBUG_APP, __FILE__, __LINE__, G_STRFUNC
#define DEBUG_SESSION GEDIT_DEBUG_SESSION, __FILE__, __LINE__, G_STRFUNC
#define DEBUG_UTILS GEDIT_DEBUG_UTILS, __FILE__, __LINE__, G_STRFUNC
-#define DEBUG_METADATA GEDIT_DEBUG_METADATA,__FILE__, __LINE__, G_STRFUNC
#define DEBUG_WINDOW GEDIT_DEBUG_WINDOW, __FILE__, __LINE__, G_STRFUNC
#define DEBUG_PANEL GEDIT_DEBUG_PANEL, __FILE__, __LINE__, G_STRFUNC
#define DEBUG_DBUS GEDIT_DEBUG_DBUS, __FILE__, __LINE__, G_STRFUNC
diff --git a/gedit/gedit-document-loader.h b/gedit/gedit-document-loader.h
index ee4d08b..b86b8cb 100644
--- a/gedit/gedit-document-loader.h
+++ b/gedit/gedit-document-loader.h
@@ -25,7 +25,7 @@
#ifndef __GEDIT_DOCUMENT_LOADER_H__
#define __GEDIT_DOCUMENT_LOADER_H__
-#include <gedit/gedit-document.h>
+#include "gedit-document.h"
G_BEGIN_DECLS
diff --git a/gedit/gedit-metadata-manager.c b/gedit/gedit-metadata-manager.c
index 31c4506..c28aa7c 100644
--- a/gedit/gedit-metadata-manager.c
+++ b/gedit/gedit-metadata-manager.c
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* gedit-metadata-manager.c
* This file is part of gedit
@@ -21,21 +20,22 @@
* Boston, MA 02111-1307, USA.
*/
-/*
- * Modified by the gedit Team, 2003-2007. See the AUTHORS file for a
- * list of people on the gedit Team.
- * See the ChangeLog files for a list of changes.
- */
-
#include <time.h>
#include <stdlib.h>
#include <libxml/xmlreader.h>
#include "gedit-metadata-manager.h"
-#include "gedit-debug.h"
-/*
-#define GEDIT_METADATA_VERBOSE_DEBUG 1
-*/
+#if 0
+#define DEBUG(x) (x)
+#else
+#define DEBUG(x)
+#endif
+
+#if 0
+#define VERBOSE_DEBUG(x) (x)
+#else
+#define VERBOSE_DEBUG(x)
+#endif
#define MAX_ITEMS 50
@@ -74,9 +74,9 @@ item_free (gpointer data)
g_return_if_fail (data != NULL);
-#ifdef GEDIT_METADATA_VERBOSE_DEBUG
- gedit_debug (DEBUG_METADATA);
-#endif
+ VERBOSE_DEBUG ({
+ g_print ("%s\n", G_STRFUNC);
+ });
item = (Item *)data;
@@ -110,7 +110,9 @@ gedit_metadata_manager_arm_timeout (void)
void
gedit_metadata_manager_init (const gchar *metadata_filename)
{
- gedit_debug (DEBUG_METADATA);
+ DEBUG ({
+ g_print ("%s\n", G_STRFUNC);
+ });
if (gedit_metadata_manager != NULL)
return;
@@ -139,7 +141,9 @@ gedit_metadata_manager_init (const gchar *metadata_filename)
void
gedit_metadata_manager_shutdown (void)
{
- gedit_debug (DEBUG_METADATA);
+ DEBUG ({
+ g_print ("%s\n", G_STRFUNC);
+ });
if (gedit_metadata_manager == NULL)
return;
@@ -168,9 +172,9 @@ parseItem (xmlDocPtr doc, xmlNodePtr cur)
xmlChar *uri;
xmlChar *atime;
-#ifdef GEDIT_METADATA_VERBOSE_DEBUG
- gedit_debug (DEBUG_METADATA);
-#endif
+ VERBOSE_DEBUG ({
+ g_print ("%s\n", G_STRFUNC);
+ });
if (xmlStrcmp (cur->name, (const xmlChar *)"document") != 0)
return;
@@ -237,7 +241,9 @@ load_values (void)
xmlDocPtr doc;
xmlNodePtr cur;
- gedit_debug (DEBUG_METADATA);
+ DEBUG ({
+ g_print ("%s\n", G_STRFUNC);
+ });
g_return_val_if_fail (gedit_metadata_manager != NULL, FALSE);
g_return_val_if_fail (gedit_metadata_manager->values_loaded == FALSE, FALSE);
@@ -314,7 +320,9 @@ gedit_metadata_manager_get (GFile *location,
uri = g_file_get_uri (location);
- gedit_debug_message (DEBUG_METADATA, "URI: %s --- key: %s", uri, key );
+ DEBUG ({
+ g_print ("URI: %s --- key: %s\n", uri, key);
+ });
if (!gedit_metadata_manager->values_loaded)
{
@@ -371,7 +379,9 @@ gedit_metadata_manager_set (GFile *location,
uri = g_file_get_uri (location);
- gedit_debug_message (DEBUG_METADATA, "URI: %s --- key: %s --- value: %s", uri, key, value);
+ DEBUG ({
+ g_print ("URI: %s --- key: %s --- value: %s\n", uri, key, value);
+ });
if (!gedit_metadata_manager->values_loaded)
{
@@ -427,9 +437,9 @@ save_values (const gchar *key, const gchar *value, xmlNodePtr parent)
{
xmlNodePtr xml_node;
-#ifdef GEDIT_METADATA_VERBOSE_DEBUG
- gedit_debug (DEBUG_METADATA);
-#endif
+ VERBOSE_DEBUG ({
+ g_print ("%s\n", G_STRFUNC);
+ });
g_return_if_fail (key != NULL);
@@ -448,9 +458,9 @@ save_values (const gchar *key, const gchar *value, xmlNodePtr parent)
(const xmlChar *)"value",
(const xmlChar *)value);
-#ifdef GEDIT_METADATA_VERBOSE_DEBUG
- gedit_debug_message (DEBUG_METADATA, "entry: %s = %s", key, value);
-#endif
+ VERBOSE_DEBUG ({
+ g_print ("entry: %s = %s\n", key, value);
+ });
}
static void
@@ -460,9 +470,9 @@ save_item (const gchar *key, const gpointer *data, xmlNodePtr parent)
const Item *item = (const Item *)data;
gchar *atime;
-#ifdef GEDIT_METADATA_VERBOSE_DEBUG
- gedit_debug (DEBUG_METADATA);
-#endif
+ VERBOSE_DEBUG ({
+ g_print ("%s\n", G_STRFUNC);
+ });
g_return_if_fail (key != NULL);
@@ -473,16 +483,16 @@ save_item (const gchar *key, const gpointer *data, xmlNodePtr parent)
xmlSetProp (xml_node, (const xmlChar *)"uri", (const xmlChar *)key);
-#ifdef GEDIT_METADATA_VERBOSE_DEBUG
- gedit_debug_message (DEBUG_METADATA, "uri: %s", key);
-#endif
+ VERBOSE_DEBUG ({
+ g_print ("uri: %s\n", key);
+ });
atime = g_strdup_printf ("%ld", item->atime);
xmlSetProp (xml_node, (const xmlChar *)"atime", (const xmlChar *)atime);
-#ifdef GEDIT_METADATA_VERBOSE_DEBUG
- gedit_debug_message (DEBUG_METADATA, "atime: %s", atime);
-#endif
+ VERBOSE_DEBUG ({
+ g_print ("atime: %s\n", atime);
+ });
g_free (atime);
@@ -539,7 +549,9 @@ gedit_metadata_manager_save (gpointer data)
xmlDocPtr doc;
xmlNodePtr root;
- gedit_debug (DEBUG_METADATA);
+ DEBUG ({
+ g_print ("%s\n", G_STRFUNC);
+ });
gedit_metadata_manager->timeout_id = 0;
@@ -580,7 +592,9 @@ gedit_metadata_manager_save (gpointer data)
xmlFreeDoc (doc);
- gedit_debug_message (DEBUG_METADATA, "DONE");
+ DEBUG ({
+ g_print ("DONE\n");
+ });
return FALSE;
}
diff --git a/gedit/gedit-metadata-manager.h b/gedit/gedit-metadata-manager.h
index 371cbc5..ee34c10 100644
--- a/gedit/gedit-metadata-manager.h
+++ b/gedit/gedit-metadata-manager.h
@@ -1,4 +1,3 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* gedit-metadata-manager.h
* This file is part of gedit
@@ -21,12 +20,6 @@
* Boston, MA 02111-1307, USA.
*/
-/*
- * Modified by the gedit Team, 2003. See the AUTHORS file for a
- * list of people on the gedit Team.
- * See the ChangeLog files for a list of changes.
- */
-
#ifndef __GEDIT_METADATA_MANAGER_H__
#define __GEDIT_METADATA_MANAGER_H__
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]