1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */
3 /* ibus - The Input IBus
4 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
5 * Copyright (C) 2008-2010 Red Hat, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24 #error "Only <ibus.h> can be included directly"
28 * SECTION: ibusobservedpath
29 * @short_description: Path object of IBus.
32 * IBusObservedPath provides methods for file path manipulation,
33 * such as monitor modification, directory tree traversal.
36 #ifndef __IBUS_OBSERVED_PATH_H_
37 #define __IBUS_OBSERVED_PATH_H_
39 #include "ibusserializable.h"
46 /* define GOBJECT macros */
47 #define IBUS_TYPE_OBSERVED_PATH \
48 (ibus_observed_path_get_type ())
49 #define IBUS_OBSERVED_PATH(obj) \
50 (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_OBSERVED_PATH, IBusObservedPath))
51 #define IBUS_OBSERVED_PATH_CLASS(klass) \
52 (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_OBSERVED_PATH, IBusObservedPathClass))
53 #define IBUS_IS_OBSERVED_PATH(obj) \
54 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_OBSERVED_PATH))
55 #define IBUS_IS_OBSERVED_PATH_CLASS(klass) \
56 (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_OBSERVED_PATH))
57 #define IBUS_OBSERVED_PATH_GET_CLASS(obj) \
58 (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_OBSERVED_PATH, IBusObservedPathClass))
62 typedef struct _IBusObservedPath IBusObservedPath;
63 typedef struct _IBusObservedPathClass IBusObservedPathClass;
67 * @path: Path to be handled.
68 * @mtime: Modified time.
69 * @is_dir: Whether the file is the path directory.
70 * @is_exist: Whether the file exists.
72 * Data structure of IBusObservedPath.
74 struct _IBusObservedPath {
75 IBusSerializable parent;
76 /* instance members */
86 struct _IBusObservedPathClass {
87 IBusSerializableClass parent;
92 GType ibus_observed_path_get_type (void);
95 * ibus_observed_path_new_from_xml_node:
96 * @node: An XML node that contain path.
97 * @fill_stat: Auto-fill the path status.
98 * @returns: A newly allocated IBusObservedPath.
100 * New an IBusObservedPath from an XML node.
102 IBusObservedPath *ibus_observed_path_new_from_xml_node (XMLNode *node,
106 * ibus_observed_path_new:
107 * @path: The path string.
108 * @fill_stat: Auto-fill the path status.
109 * @returns: A newly allocated IBusObservedPath.
111 * New an IBusObservedPath from an XML node.
113 IBusObservedPath *ibus_observed_path_new (const gchar *path,
117 * ibus_observed_path_traverse:
118 * @path: An IBusObservedPath.
119 * @dir_only: Only looks for subdirs, not files
120 * @returns: (element-type IBusObservedPath): A newly allocate GList which holds content in path; NULL if @path is not directory.
122 * Recursively traverse the path and put the files and subdirectory in to a newly allocated
123 * GLists, if the @path is a directory. Otherwise returns NULL.
125 GList *ibus_observed_path_traverse (IBusObservedPath *path,
129 * ibus_observed_path_check_modification:
130 * @path: An IBusObservedPath.
131 * @returns: TRUE if mtime is changed; FALSE otherwise.
133 * Checks whether the path is modified by comparing the mtime in object and mtime in file system.
134 * Returns TRUE if imtime is changed, otherwise FALSE.
136 gboolean ibus_observed_path_check_modification (IBusObservedPath *path);
139 * ibus_observed_path_output:
140 * @path: An IBusObservedPath.
141 * @output: Path is appended to.
142 * @indent: number of indent.
144 * Append the observed path to a string with following format:
145 * <path mtime="<i>modified time</i>" ><i>path</i></path>
147 void ibus_observed_path_output (IBusObservedPath *path,