1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 obt/linkbase.c for the Openbox window manager
4 Copyright (c) 2010 Dana Jansens
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 See the COPYING file for a copy of the GNU General Public License.
19 #include "obt/linkbase.h"
21 #include "obt/paths.h"
22 #include "obt/watch.h"
31 static void func(ObtWatch *w, const gchar *subpath, ObtWatchNotifyType type,
36 ObtLinkBase* obt_linkbase_new(ObtPaths *paths)
41 b = g_slice_new(ObtLinkBase);
42 b->watch = obt_watch_new();
43 b->base = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
44 (GDestroyNotify)obt_link_unref);
46 for (it = obt_paths_data_dirs(paths); it; it = g_slist_next(it)) {
48 p = g_strconcat(it->data, "/applications", NULL);
49 obt_watch_add(b->watch, p, FALSE, func, b);
54 void obt_linkbase_ref(ObtLinkBase *lb)
59 void obt_linkbase_unref(ObtLinkBase *lb)
62 obt_watch_unref(lb->watch);
63 g_hash_table_unref(lb->base);
64 g_slice_free(ObtLinkBase, lb);