diff options
| author | Přemysl Janouch <p.janouch@gmail.com> | 2010-09-20 18:18:30 +0200 | 
|---|---|---|
| committer | Přemysl Janouch <p.janouch@gmail.com> | 2010-09-20 18:18:30 +0200 | 
| commit | f25062151941b0dfa90fdf4e6023754140b3fbcf (patch) | |
| tree | 535393765adb15524c43f90f5538ea661254a7fb /src/ld-symbol-category.c | |
| parent | f675a7c07c84d71e3cee1d61bf0e0a1b800e7d0a (diff) | |
| download | logdiag-f25062151941b0dfa90fdf4e6023754140b3fbcf.tar.gz logdiag-f25062151941b0dfa90fdf4e6023754140b3fbcf.tar.xz logdiag-f25062151941b0dfa90fdf4e6023754140b3fbcf.zip | |
Split ld-symbol-library.c.
Originally, there were three object classes defined in this file.
It would later become rather chaotic if left that way.
Diffstat (limited to 'src/ld-symbol-category.c')
| -rw-r--r-- | src/ld-symbol-category.c | 90 | 
1 files changed, 90 insertions, 0 deletions
| diff --git a/src/ld-symbol-category.c b/src/ld-symbol-category.c new file mode 100644 index 0000000..8bfe419 --- /dev/null +++ b/src/ld-symbol-category.c @@ -0,0 +1,90 @@ +/* + * ld-symbol-category.c + * + * This file is a part of logdiag. + * Copyright Přemysl Janouch 2010. All rights reserved. + * + * See the file LICENSE for licensing information. + * + */ + +#include <gtk/gtk.h> + +#include "config.h" + +#include "ld-symbol-library.h" +#include "ld-symbol-category.h" +#include "ld-symbol.h" + + +/** + * SECTION:ld-symbol-category + * @short_description: A category of symbols. + * @see_also: #LdSymbol, #LdSymbolLibrary + * + * #LdSymbolCategory represents a category of #LdSymbol objects. + */ + +G_DEFINE_TYPE (LdSymbolCategory, ld_symbol_category, G_TYPE_OBJECT); + +static void +ld_symbol_category_finalize (GObject *gobject); + + +static void +ld_symbol_category_class_init (LdSymbolCategoryClass *klass) +{ +	GObjectClass *object_class; + +	object_class = G_OBJECT_CLASS (klass); +	object_class->finalize = ld_symbol_category_finalize; +} + +static void +ld_symbol_category_init (LdSymbolCategory *self) +{ +	/* TODO: use _new_full, correct equal and specify destroy functions. */ +	/* XXX: How's the situation with subcategory names and symbol names +	 *      within the same hashtable? +	 */ +	self->children = g_hash_table_new (g_str_hash, g_str_equal); +} + +static void +ld_symbol_category_finalize (GObject *gobject) +{ +	LdSymbolCategory *self; + +	self = LD_SYMBOL_CATEGORY (gobject); + +	if (self->name) +		g_free (self->name); +	if (self->image_path) +		g_free (self->image_path); + +	g_object_unref (self->parent); +	g_hash_table_destroy (self->children); + +	/* Chain up to the parent class. */ +	G_OBJECT_CLASS (ld_symbol_category_parent_class)->finalize (gobject); +} + +/** + * ld_symbol_category_new: + * @parent: The parent library for this category. + * + * Create an instance. + */ +LdSymbolCategory * +ld_symbol_category_new (LdSymbolLibrary *parent) +{ +	LdSymbolCategory *cat; + +	cat = g_object_new (LD_TYPE_SYMBOL_CATEGORY, NULL); + +	cat->parent = parent; +	g_object_ref (parent); + +	return cat; +} + | 
