Renamed LdSymbolLibrary to LdLibrary.

This commit is contained in:
Přemysl Eric Janouch 2010-09-25 16:14:09 +02:00
parent 5da5689541
commit c0ec389b59
11 changed files with 122 additions and 122 deletions

View File

@ -88,9 +88,9 @@ set (logdiag_SOURCES
src/ld-window-main.c
src/ld-document.c
src/ld-canvas.c
src/ld-symbol.c
src/ld-library.c
src/ld-symbol-category.c
src/ld-symbol-library.c
src/ld-symbol.c
src/ld-lua.c)
set (logdiag_HEADERS
${CMAKE_CURRENT_BINARY_DIR}/config.h
@ -98,9 +98,9 @@ set (logdiag_HEADERS
src/ld-window-main.h
src/ld-document.h
src/ld-canvas.h
src/ld-symbol.h
src/ld-library.h
src/ld-symbol-category.h
src/ld-symbol-library.h
src/ld-symbol.h
src/ld-lua.h)
# Generate a configure file

View File

@ -14,7 +14,7 @@
G_BEGIN_DECLS
#define LD_TYPE_DOCUMENT (ld_symbol_library_get_type ())
#define LD_TYPE_DOCUMENT (ld_library_get_type ())
#define LD_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST \
((obj), LD_TYPE_DOCUMENT, LdDocument))
#define LD_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \

View File

@ -1,5 +1,5 @@
/*
* ld-symbol-library.c
* ld-library.c
*
* This file is a part of logdiag.
* Copyright Přemysl Janouch 2010. All rights reserved.
@ -12,44 +12,44 @@
#include "config.h"
#include "ld-symbol-library.h"
#include "ld-library.h"
#include "ld-symbol-category.h"
#include "ld-symbol.h"
/**
* SECTION:ld-symbol-library
* SECTION:ld-library
* @short_description: A symbol library.
* @see_also: #LdSymbol, #LdSymbolCategory
*
* #LdSymbolLibrary is used for loading symbols from their files.
* #LdLibrary is used for loading symbols from their files.
*/
/*
* LdSymbolLibraryPrivate:
* LdLibraryPrivate:
* @script_state: State of the scripting language.
*/
struct _LdSymbolLibraryPrivate
struct _LdLibraryPrivate
{
gpointer script_state;
};
G_DEFINE_TYPE (LdSymbolLibrary, ld_symbol_library, G_TYPE_OBJECT);
G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT);
static void
ld_symbol_library_finalize (GObject *gobject);
ld_library_finalize (GObject *gobject);
static void
ld_symbol_library_class_init (LdSymbolLibraryClass *klass)
ld_library_class_init (LdLibraryClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = ld_symbol_library_finalize;
object_class->finalize = ld_library_finalize;
/**
* LdSymbolLibrary::changed:
* LdLibrary::changed:
* @library: The library object.
*
* Contents of the library have changed.
@ -59,14 +59,14 @@ ld_symbol_library_class_init (LdSymbolLibraryClass *klass)
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
g_type_class_add_private (klass, sizeof (LdSymbolLibraryPrivate));
g_type_class_add_private (klass, sizeof (LdLibraryPrivate));
}
static void
ld_symbol_library_init (LdSymbolLibrary *self)
ld_library_init (LdLibrary *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE
(self, LD_TYPE_SYMBOL_LIBRARY, LdSymbolLibraryPrivate);
(self, LD_TYPE_LIBRARY, LdLibraryPrivate);
/* TODO */
self->priv->script_state = NULL;
@ -76,27 +76,27 @@ ld_symbol_library_init (LdSymbolLibrary *self)
}
static void
ld_symbol_library_finalize (GObject *gobject)
ld_library_finalize (GObject *gobject)
{
LdSymbolLibrary *self;
LdLibrary *self;
self = LD_SYMBOL_LIBRARY (gobject);
self = LD_LIBRARY (gobject);
g_hash_table_destroy (self->categories);
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_symbol_library_parent_class)->finalize (gobject);
G_OBJECT_CLASS (ld_library_parent_class)->finalize (gobject);
}
/**
* ld_symbol_library_new:
* ld_library_new:
*
* Create an instance.
*/
LdSymbolLibrary *
ld_symbol_library_new (void)
LdLibrary *
ld_library_new (void)
{
return g_object_new (LD_TYPE_SYMBOL_LIBRARY, NULL);
return g_object_new (LD_TYPE_LIBRARY, NULL);
}
/*
@ -108,12 +108,12 @@ ld_symbol_library_new (void)
* Loads a category into the library.
*/
static LdSymbolCategory *
load_category (LdSymbolLibrary *self, const char *path, const char *name)
load_category (LdLibrary *self, const char *path, const char *name)
{
LdSymbolCategory *cat;
gchar *icon_file;
g_return_val_if_fail (LD_IS_SYMBOL_LIBRARY (self), NULL);
g_return_val_if_fail (LD_IS_LIBRARY (self), NULL);
g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
@ -138,20 +138,20 @@ load_category (LdSymbolLibrary *self, const char *path, const char *name)
}
/**
* ld_symbol_library_load:
* ld_library_load:
* @self: A symbol library object.
* @directory: A directory to be loaded.
*
* Load the contents of a directory into the library.
*/
gboolean
ld_symbol_library_load (LdSymbolLibrary *self, const char *path)
ld_library_load (LdLibrary *self, const char *path)
{
GDir *dir;
const gchar *item;
gboolean changed = FALSE;
g_return_val_if_fail (LD_IS_SYMBOL_LIBRARY (self), FALSE);
g_return_val_if_fail (LD_IS_LIBRARY (self), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
dir = g_dir_open (path, 0, NULL);
@ -175,25 +175,25 @@ ld_symbol_library_load (LdSymbolLibrary *self, const char *path)
if (changed)
g_signal_emit (self,
LD_SYMBOL_LIBRARY_GET_CLASS (self)->changed_signal, 0);
LD_LIBRARY_GET_CLASS (self)->changed_signal, 0);
return TRUE;
}
/**
* ld_symbol_library_clear:
* ld_library_clear:
* @self: A symbol library object.
*
* Clears all the contents.
*/
void
ld_symbol_library_clear (LdSymbolLibrary *self)
ld_library_clear (LdLibrary *self)
{
g_return_if_fail (LD_IS_SYMBOL_LIBRARY (self));
g_return_if_fail (LD_IS_LIBRARY (self));
g_hash_table_remove_all (self->categories);
g_signal_emit (self,
LD_SYMBOL_LIBRARY_GET_CLASS (self)->changed_signal, 0);
LD_LIBRARY_GET_CLASS (self)->changed_signal, 0);
}

70
src/ld-library.h Normal file
View File

@ -0,0 +1,70 @@
/*
* ld-library.h
*
* This file is a part of logdiag.
* Copyright Přemysl Janouch 2010. All rights reserved.
*
* See the file LICENSE for licensing information.
*
*/
#ifndef __LD_LIBRARY_H__
#define __LD_LIBRARY_H__
G_BEGIN_DECLS
#define LD_TYPE_LIBRARY (ld_library_get_type ())
#define LD_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
((obj), LD_TYPE_LIBRARY, LdLibrary))
#define LD_LIBRARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
((klass), LD_TYPE_LIBRARY, LdLibraryClass))
#define LD_IS_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
((obj), LD_TYPE_LIBRARY))
#define LD_IS_LIBRARY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
((klass), LD_TYPE_LIBRARY))
#define LD_LIBRARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
((obj), LD_LIBRARY, LdLibraryClass))
typedef struct _LdLibrary LdLibrary;
typedef struct _LdLibraryPrivate LdLibraryPrivate;
typedef struct _LdLibraryClass LdLibraryClass;
/**
* LdLibrary:
* @categories: Lists all the categories (#LdSymbolCategory).
*
* Object structure.
*/
struct _LdLibrary
{
/*< private >*/
GObject parent_instance;
LdLibraryPrivate *priv;
/*< public >*/
GHashTable *categories;
};
struct _LdLibraryClass
{
/*< private >*/
GObjectClass parent_class;
guint changed_signal;
};
GType ld_library_get_type (void) G_GNUC_CONST;
LdLibrary *ld_library_new (void);
gboolean ld_library_load (LdLibrary *self,
const gchar *directory);
void ld_library_clear (LdLibrary *self);
G_END_DECLS
#endif /* ! __LD_LIBRARY_H__ */

View File

@ -15,7 +15,7 @@
#include "config.h"
#include "ld-symbol-library.h"
#include "ld-library.h"
#include "ld-lua.h"

View File

@ -12,7 +12,7 @@
#include "config.h"
#include "ld-symbol-library.h"
#include "ld-library.h"
#include "ld-symbol-category.h"
#include "ld-symbol.h"
@ -20,7 +20,7 @@
/**
* SECTION:ld-symbol-category
* @short_description: A category of symbols.
* @see_also: #LdSymbol, #LdSymbolLibrary
* @see_also: #LdSymbol, #LdLibrary
*
* #LdSymbolCategory represents a category of #LdSymbol objects.
*/
@ -76,7 +76,7 @@ ld_symbol_category_finalize (GObject *gobject)
* Create an instance.
*/
LdSymbolCategory *
ld_symbol_category_new (LdSymbolLibrary *parent)
ld_symbol_category_new (LdLibrary *parent)
{
LdSymbolCategory *cat;

View File

@ -32,7 +32,7 @@ typedef struct _LdSymbolCategoryClass LdSymbolCategoryClass;
/**
* LdSymbolCategory:
* @parent: The parent object, may be #LdSymbolLibrary
* @parent: The parent object, may be #LdLibrary
* or another #LdSymbolCategory.
* @name: The name of the category.
* @image_path: Path to the image for this category.
@ -63,7 +63,7 @@ struct _LdSymbolCategoryClass
GType ld_symbol_category_get_type (void) G_GNUC_CONST;
LdSymbolCategory *
ld_symbol_category_new (LdSymbolLibrary *parent);
ld_symbol_category_new (LdLibrary *parent);
G_END_DECLS

View File

@ -1,70 +0,0 @@
/*
* ld-symbol-library.h
*
* This file is a part of logdiag.
* Copyright Přemysl Janouch 2010. All rights reserved.
*
* See the file LICENSE for licensing information.
*
*/
#ifndef __LD_SYMBOL_LIBRARY_H__
#define __LD_SYMBOL_LIBRARY_H__
G_BEGIN_DECLS
#define LD_TYPE_SYMBOL_LIBRARY (ld_symbol_library_get_type ())
#define LD_SYMBOL_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
((obj), LD_TYPE_SYMBOL_LIBRARY, LdSymbolLibrary))
#define LD_SYMBOL_LIBRARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
((klass), LD_TYPE_SYMBOL_LIBRARY, LdSymbolLibraryClass))
#define LD_IS_SYMBOL_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
((obj), LD_TYPE_SYMBOL_LIBRARY))
#define LD_IS_SYMBOL_LIBRARY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
((klass), LD_TYPE_SYMBOL_LIBRARY))
#define LD_SYMBOL_LIBRARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
((obj), LD_SYMBOL_LIBRARY, LdSymbolLibraryClass))
typedef struct _LdSymbolLibrary LdSymbolLibrary;
typedef struct _LdSymbolLibraryPrivate LdSymbolLibraryPrivate;
typedef struct _LdSymbolLibraryClass LdSymbolLibraryClass;
/**
* LdSymbolLibrary:
* @categories: Lists all the categories (#LdSymbolCategory).
*
* Object structure.
*/
struct _LdSymbolLibrary
{
/*< private >*/
GObject parent_instance;
LdSymbolLibraryPrivate *priv;
/*< public >*/
GHashTable *categories;
};
struct _LdSymbolLibraryClass
{
/*< private >*/
GObjectClass parent_class;
guint changed_signal;
};
GType ld_symbol_library_get_type (void) G_GNUC_CONST;
LdSymbolLibrary *ld_symbol_library_new (void);
gboolean ld_symbol_library_load (LdSymbolLibrary *self,
const gchar *directory);
void ld_symbol_library_clear (LdSymbolLibrary *self);
G_END_DECLS
#endif /* ! __LD_SYMBOL_LIBRARY_H__ */

View File

@ -12,7 +12,7 @@
#include "config.h"
#include "ld-symbol-library.h"
#include "ld-library.h"
#include "ld-symbol-category.h"
#include "ld-symbol.h"
@ -28,12 +28,12 @@
/*
* LdSymbolPrivate:
* @library: The parent LdSymbolLibrary.
* @library: The parent LdLibrary.
* The library contains the real function for rendering.
*/
struct _LdSymbolPrivate
{
LdSymbolLibrary *library;
LdLibrary *library;
};
G_DEFINE_TYPE (LdSymbol, ld_symbol, G_TYPE_OBJECT);
@ -79,7 +79,7 @@ ld_symbol_finalize (GObject *gobject)
*
* Load a symbol from a file into the library.
*/
LdSymbol *ld_symbol_new (LdSymbolLibrary *library)
LdSymbol *ld_symbol_new (LdLibrary *library)
{
LdSymbol *symbol;

View File

@ -53,7 +53,7 @@ struct _LdSymbolClass
GType ld_symbol_get_type (void) G_GNUC_CONST;
LdSymbol *ld_symbol_new (LdSymbolLibrary *library);
LdSymbol *ld_symbol_new (LdLibrary *library);
gchar *ld_symbol_build_identifier (LdSymbol *self);
void ld_symbol_draw (LdSymbol *self, cairo_t *cr, GHashTable *param);

View File

@ -15,7 +15,7 @@
#include "ld-window-main.h"
#include "ld-document.h"
#include "ld-canvas.h"
#include "ld-symbol-library.h"
#include "ld-library.h"
#include "ld-symbol-category.h"
#include "ld-symbol.h"
@ -41,7 +41,7 @@ struct _LdWindowMainPrivate
GtkWidget *menu;
GtkWidget *toolbar;
LdSymbolLibrary *library;
LdLibrary *library;
LdCanvas *canvas;
GtkWidget *statusbar;
@ -215,8 +215,8 @@ ld_window_main_init (LdWindowMain *self)
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->toolbar, FALSE, FALSE, 0);
/* Symbol library. */
priv->library = ld_symbol_library_new ();
ld_symbol_library_load (priv->library, PROJECT_SHARE_DIR "library");
priv->library = ld_library_new ();
ld_library_load (priv->library, PROJECT_SHARE_DIR "library");
load_toolbar (self);