Add Ctrl+space customization.
[platform/upstream/ibus.git] / src / ibusobservedpath.h
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.
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24 #error "Only <ibus.h> can be included directly"
25 #endif
26
27 /**
28  * SECTION: ibusobservedpath
29  * @short_description: Path object of IBus.
30  * @stability: Stable
31  *
32  * IBusObservedPath provides methods for file path manipulation,
33  * such as monitor modification, directory tree traversal.
34  */
35
36 #ifndef __IBUS_OBSERVED_PATH_H_
37 #define __IBUS_OBSERVED_PATH_H_
38
39 #include "ibusserializable.h"
40 #include "ibusxml.h"
41
42 /*
43  * Type macros.
44  */
45
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))
59
60 G_BEGIN_DECLS
61
62 typedef struct _IBusObservedPath IBusObservedPath;
63 typedef struct _IBusObservedPathClass IBusObservedPathClass;
64
65 /**
66  * IBusObservedPath:
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.
71  *
72  * Data structure of IBusObservedPath.
73  */
74 struct _IBusObservedPath {
75     IBusSerializable parent;
76     /* instance members */
77
78     /*< public >*/
79     gchar *path;
80     glong mtime;
81     gboolean is_dir;
82     gboolean is_exist;
83
84 };
85
86 struct _IBusObservedPathClass {
87     IBusSerializableClass parent;
88
89     /* class members */
90 };
91
92 GType                ibus_observed_path_get_type            (void);
93
94 /**
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.
99  *
100  * New an IBusObservedPath from an XML node.
101  */
102 IBusObservedPath    *ibus_observed_path_new_from_xml_node   (XMLNode            *node,
103                                                              gboolean            fill_stat);
104
105 /**
106  * ibus_observed_path_new:
107  * @path: The path string.
108  * @fill_stat: Auto-fill the path status.
109  * @returns: A newly allocated IBusObservedPath.
110  *
111  * New an IBusObservedPath from an XML node.
112  */
113 IBusObservedPath    *ibus_observed_path_new                 (const gchar        *path,
114                                                              gboolean            fill_stat);
115
116 /**
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.
121  *
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.
124  */
125 GList               *ibus_observed_path_traverse            (IBusObservedPath   *path,
126                                                              gboolean            dir_only);
127
128 /**
129  * ibus_observed_path_check_modification:
130  * @path: An IBusObservedPath.
131  * @returns: TRUE if mtime is changed; FALSE otherwise.
132  *
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.
135  */
136 gboolean             ibus_observed_path_check_modification  (IBusObservedPath   *path);
137
138 /**
139  * ibus_observed_path_output:
140  * @path: An IBusObservedPath.
141  * @output: Path is appended to.
142  * @indent: number of indent.
143  *
144  * Append the observed path to a string with following format:
145  * &lt;path mtime="&lt;i&gt;modified time&lt;/i&gt;" &gt;&lt;i&gt;path&lt;/i&gt;&lt;/path&gt;
146  */
147 void                 ibus_observed_path_output              (IBusObservedPath   *path,
148                                                              GString            *output,
149                                                              gint                indent);
150
151 G_END_DECLS
152 #endif
153