0.9.3claws23
[claws.git] / src / common / hooks.c
index 965137c5d155d1e7808e582eef86af7f055e4469..cfca1b3f6bf961a7fb11b271bce70c6e9eab6083 100644 (file)
 
 #include <glib.h>
 
+#include "utils.h"
 #include "hooks.h"
 
-GHashTable *hooklist_table;
+static GHashTable *hooklist_table;
 
 GHookList *hooks_get_hooklist(gchar *hooklist_name)
 {
@@ -45,27 +46,29 @@ GHookList *hooks_get_hooklist(gchar *hooklist_name)
        return hooklist;
 }
 
-gint hooks_register_hook(gchar *hooklist_name,
-                        SylpheedHookFunction hook_func,
-                        gpointer userdata)
+guint hooks_register_hook(gchar *hooklist_name,
+                         SylpheedHookFunction hook_func,
+                         gpointer userdata)
 {
        GHookList *hooklist;
        GHook *hook;
 
-       g_return_val_if_fail(hooklist_name != NULL, -1);
-       g_return_val_if_fail(hook_func != NULL, -1);
+       g_return_val_if_fail(hooklist_name != NULL, (guint)-1);
+       g_return_val_if_fail(hook_func != NULL, (guint)-1);
        
        hooklist = hooks_get_hooklist(hooklist_name);
-       g_return_val_if_fail(hooklist != NULL, -1);
+       g_return_val_if_fail(hooklist != NULL, (guint)-1);
 
        hook = g_hook_alloc(hooklist);
-       g_return_val_if_fail(hook != NULL, -1);
+       g_return_val_if_fail(hook != NULL, (guint)-1);
 
        hook->func = hook_func;
        hook->data = userdata;
 
        g_hook_append(hooklist, hook);
 
+       debug_print("registed new hook for '%s' as id %d\n", hooklist_name, hook->hook_id);
+
        return hook->hook_id;
 }
 
@@ -83,7 +86,9 @@ void hooks_unregister_hook(gchar *hooklist_name,
        hook = g_hook_get(hooklist, hook_id);
        g_return_if_fail(hook != NULL);
 
-       g_hook_destroy_link(hooklist, hook);
+       debug_print("unregisted hook %d in '%s'\n", hook->hook_id, hooklist_name);
+
+       g_hook_destroy(hooklist, hook);
 }
 
 struct MarshalData