Overall cleanup.

* Add missing asserts to exported functions.
* Unify formatting.
* Fix the gtk-doc comment for ld_symbol_category_set_human_name().
* Make ld_library_load() reflect it's declaration.
* Remove an unused variable in ld_library_load_cb().
* Change all char's to gchar's.
This commit is contained in:
Přemysl Eric Janouch 2010-12-16 05:18:41 +01:00
parent 4a946b3241
commit 721cc30478
6 changed files with 25 additions and 20 deletions

View File

@ -384,6 +384,9 @@ ld_canvas_new (void)
void void
ld_canvas_set_document (LdCanvas *self, LdDocument *document) ld_canvas_set_document (LdCanvas *self, LdDocument *document)
{ {
g_return_if_fail (LD_IS_CANVAS (self));
g_return_if_fail (LD_IS_DOCUMENT (document));
if (self->priv->document) if (self->priv->document)
g_object_unref (self->priv->document); g_object_unref (self->priv->document);
@ -403,6 +406,7 @@ ld_canvas_set_document (LdCanvas *self, LdDocument *document)
LdDocument * LdDocument *
ld_canvas_get_document (LdCanvas *self) ld_canvas_get_document (LdCanvas *self)
{ {
g_return_val_if_fail (LD_IS_CANVAS (self), NULL);
return self->priv->document; return self->priv->document;
} }
@ -416,6 +420,9 @@ ld_canvas_get_document (LdCanvas *self)
void void
ld_canvas_set_library (LdCanvas *self, LdLibrary *library) ld_canvas_set_library (LdCanvas *self, LdLibrary *library)
{ {
g_return_if_fail (LD_IS_CANVAS (self));
g_return_if_fail (LD_IS_LIBRARY (library));
if (self->priv->library) if (self->priv->library)
g_object_unref (self->priv->library); g_object_unref (self->priv->library);
@ -435,6 +442,7 @@ ld_canvas_set_library (LdCanvas *self, LdLibrary *library)
LdLibrary * LdLibrary *
ld_canvas_get_library (LdCanvas *self) ld_canvas_get_library (LdCanvas *self)
{ {
g_return_val_if_fail (LD_IS_CANVAS (self), NULL);
return self->priv->library; return self->priv->library;
} }

View File

@ -43,11 +43,10 @@ struct _LdLibraryPrivate
G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT); G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT);
static void static void ld_library_finalize (GObject *gobject);
ld_library_finalize (GObject *gobject);
static LdSymbolCategory *load_category static LdSymbolCategory *load_category (LdLibrary *self,
(LdLibrary *self, const char *path, const char *name); const gchar *path, const gchar *name);
static gboolean load_category_cb (const gchar *base, static gboolean load_category_cb (const gchar *base,
const gchar *filename, gpointer userdata); const gchar *filename, gpointer userdata);
static void load_category_symbol_cb (LdSymbol *symbol, gpointer user_data); static void load_category_symbol_cb (LdSymbol *symbol, gpointer user_data);
@ -175,7 +174,7 @@ LoadCategoryData;
* Loads a category into the library. * Loads a category into the library.
*/ */
static LdSymbolCategory * static LdSymbolCategory *
load_category (LdLibrary *self, const char *path, const char *name) load_category (LdLibrary *self, const gchar *path, const gchar *name)
{ {
LdSymbolCategory *cat; LdSymbolCategory *cat;
gchar *icon_file, *category_file; gchar *icon_file, *category_file;
@ -353,16 +352,16 @@ LibraryLoadData;
* Load the contents of a directory into the library. * Load the contents of a directory into the library.
*/ */
gboolean gboolean
ld_library_load (LdLibrary *self, const char *path) ld_library_load (LdLibrary *self, const gchar *directory)
{ {
LibraryLoadData data; LibraryLoadData data;
g_return_val_if_fail (LD_IS_LIBRARY (self), FALSE); g_return_val_if_fail (LD_IS_LIBRARY (self), FALSE);
g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (directory != NULL, FALSE);
data.self = self; data.self = self;
data.changed = FALSE; data.changed = FALSE;
foreach_dir (path, ld_library_load_cb, &data, NULL); foreach_dir (directory, ld_library_load_cb, &data, NULL);
if (data.changed) if (data.changed)
g_signal_emit (self, LD_LIBRARY_GET_CLASS (self)->changed_signal, 0); g_signal_emit (self, LD_LIBRARY_GET_CLASS (self)->changed_signal, 0);
@ -379,7 +378,6 @@ static gboolean
ld_library_load_cb (const gchar *base, const gchar *filename, gpointer userdata) ld_library_load_cb (const gchar *base, const gchar *filename, gpointer userdata)
{ {
LdSymbolCategory *cat; LdSymbolCategory *cat;
gchar *categ_path;
LibraryLoadData *data; LibraryLoadData *data;
g_return_val_if_fail (base != NULL, FALSE); g_return_val_if_fail (base != NULL, FALSE);

View File

@ -223,6 +223,8 @@ gboolean
ld_lua_check_file (LdLua *self, const gchar *filename) ld_lua_check_file (LdLua *self, const gchar *filename)
{ {
g_return_val_if_fail (LD_IS_LUA (self), FALSE); g_return_val_if_fail (LD_IS_LUA (self), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
return g_str_has_suffix (filename, ".lua") return g_str_has_suffix (filename, ".lua")
&& g_file_test (filename, G_FILE_TEST_IS_REGULAR); && g_file_test (filename, G_FILE_TEST_IS_REGULAR);
} }
@ -297,6 +299,7 @@ ld_lua_private_draw (LdLua *self, LdLuaSymbol *symbol, cairo_t *cr)
g_return_if_fail (LD_IS_LUA (self)); g_return_if_fail (LD_IS_LUA (self));
g_return_if_fail (LD_IS_LUA_SYMBOL (symbol)); g_return_if_fail (LD_IS_LUA_SYMBOL (symbol));
g_return_if_fail (cr != NULL);
data.symbol = symbol; data.symbol = symbol;
data.cr = cr; data.cr = cr;

View File

@ -49,16 +49,11 @@ enum
PROP_IMAGE_PATH PROP_IMAGE_PATH
}; };
static void static void ld_symbol_category_get_property (GObject *object, guint property_id,
ld_symbol_category_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec); GValue *value, GParamSpec *pspec);
static void ld_symbol_category_set_property (GObject *object, guint property_id,
static void
ld_symbol_category_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec); const GValue *value, GParamSpec *pspec);
static void ld_symbol_category_finalize (GObject *gobject);
static void
ld_symbol_category_finalize (GObject *gobject);
static void static void
@ -179,6 +174,7 @@ ld_symbol_category_finalize (GObject *gobject)
G_OBJECT_CLASS (ld_symbol_category_parent_class)->finalize (gobject); G_OBJECT_CLASS (ld_symbol_category_parent_class)->finalize (gobject);
} }
/** /**
* ld_symbol_category_new: * ld_symbol_category_new:
* @name: The name of the new category. * @name: The name of the new category.
@ -235,7 +231,7 @@ ld_symbol_category_get_name (LdSymbolCategory *self)
/** /**
* ld_symbol_category_set_human_name: * ld_symbol_category_set_human_name:
* @self: An #LdSymbolCategory object. * @self: An #LdSymbolCategory object.
* @name: The new localized human name for this category. * @human_name: The new localized human name for this category.
*/ */
void void
ld_symbol_category_set_human_name (LdSymbolCategory *self, ld_symbol_category_set_human_name (LdSymbolCategory *self,

View File

@ -90,7 +90,6 @@ enum
static void ld_symbol_get_property (GObject *object, guint property_id, static void ld_symbol_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec); GValue *value, GParamSpec *pspec);
static void ld_symbol_set_property (GObject *object, guint property_id, static void ld_symbol_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec); const GValue *value, GParamSpec *pspec);

View File

@ -15,7 +15,8 @@
#include "ld-window-main.h" #include "ld-window-main.h"
int main (int argc, char *argv[]) int
main (int argc, char *argv[])
{ {
GtkWidget *wnd; GtkWidget *wnd;