Blame src/ibusobservedpath.h

Packit 3ff832
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
Packit 3ff832
/* vim:set et sts=4: */
Packit 3ff832
/* ibus - The Input IBus
Packit 3ff832
 * Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
Packit 3ff832
 * Copyright (C) 2008-2013 Red Hat, Inc.
Packit 3ff832
 *
Packit 3ff832
 * This library is free software; you can redistribute it and/or
Packit 3ff832
 * modify it under the terms of the GNU Lesser General Public
Packit 3ff832
 * License as published by the Free Software Foundation; either
Packit 3ff832
 * version 2.1 of the License, or (at your option) any later version.
Packit 3ff832
 *
Packit 3ff832
 * This library is distributed in the hope that it will be useful,
Packit 3ff832
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 3ff832
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 3ff832
 * Lesser General Public License for more details.
Packit 3ff832
 *
Packit 3ff832
 * You should have received a copy of the GNU Lesser General Public
Packit 3ff832
 * License along with this library; if not, write to the Free Software
Packit 3ff832
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
Packit 3ff832
 * USA
Packit 3ff832
 */
Packit 3ff832
Packit 3ff832
#if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
Packit 3ff832
#error "Only <ibus.h> can be included directly"
Packit 3ff832
#endif
Packit 3ff832
Packit 3ff832
#ifndef __IBUS_OBSERVED_PATH_H_
Packit 3ff832
#define __IBUS_OBSERVED_PATH_H_
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * SECTION: ibusobservedpath
Packit 3ff832
 * @short_description: Path object of IBus.
Packit 3ff832
 * @stability: Stable
Packit 3ff832
 *
Packit 3ff832
 * IBusObservedPath provides methods for file path manipulation,
Packit 3ff832
 * such as monitor modification, directory tree traversal.
Packit 3ff832
 */
Packit 3ff832
Packit 3ff832
#include "ibusserializable.h"
Packit 3ff832
#include "ibusxml.h"
Packit 3ff832
Packit 3ff832
/*
Packit 3ff832
 * Type macros.
Packit 3ff832
 */
Packit 3ff832
Packit 3ff832
/* define GOBJECT macros */
Packit 3ff832
#define IBUS_TYPE_OBSERVED_PATH             \
Packit 3ff832
    (ibus_observed_path_get_type ())
Packit 3ff832
#define IBUS_OBSERVED_PATH(obj)             \
Packit 3ff832
    (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_OBSERVED_PATH, IBusObservedPath))
Packit 3ff832
#define IBUS_OBSERVED_PATH_CLASS(klass)     \
Packit 3ff832
    (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_OBSERVED_PATH, IBusObservedPathClass))
Packit 3ff832
#define IBUS_IS_OBSERVED_PATH(obj)          \
Packit 3ff832
    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_OBSERVED_PATH))
Packit 3ff832
#define IBUS_IS_OBSERVED_PATH_CLASS(klass)  \
Packit 3ff832
    (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_OBSERVED_PATH))
Packit 3ff832
#define IBUS_OBSERVED_PATH_GET_CLASS(obj)   \
Packit 3ff832
    (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_OBSERVED_PATH, IBusObservedPathClass))
Packit 3ff832
Packit 3ff832
G_BEGIN_DECLS
Packit 3ff832
Packit 3ff832
typedef struct _IBusObservedPath IBusObservedPath;
Packit 3ff832
typedef struct _IBusObservedPathClass IBusObservedPathClass;
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * IBusObservedPath:
Packit 3ff832
 * @path: Path to be handled.
Packit 3ff832
 * @mtime: Modified time.
Packit 3ff832
 * @is_dir: Whether the file is the path directory.
Packit 3ff832
 * @is_exist: Whether the file exists.
Packit 3ff832
 *
Packit 3ff832
 * Data structure of IBusObservedPath.
Packit 3ff832
 */
Packit 3ff832
struct _IBusObservedPath {
Packit 3ff832
    IBusSerializable parent;
Packit 3ff832
    /* instance members */
Packit 3ff832
Packit 3ff832
    /*< public >*/
Packit 3ff832
    gchar *path;
Packit 3ff832
    glong mtime;
Packit 3ff832
    gboolean is_dir;
Packit 3ff832
    gboolean is_exist;
Packit 3ff832
Packit 3ff832
};
Packit 3ff832
Packit 3ff832
struct _IBusObservedPathClass {
Packit 3ff832
    IBusSerializableClass parent;
Packit 3ff832
Packit 3ff832
    /* class members */
Packit 3ff832
};
Packit 3ff832
Packit 3ff832
GType                ibus_observed_path_get_type            (void);
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * ibus_observed_path_new_from_xml_node:
Packit 3ff832
 * @node: An XML node that contain path.
Packit 3ff832
 * @fill_stat: Auto-fill the path status.
Packit 3ff832
 *
Packit 3ff832
 * Creates an new #IBusObservedPath from an XML node.
Packit 3ff832
 *
Packit 3ff832
 * Returns: A newly allocated #IBusObservedPath.
Packit 3ff832
 */
Packit 3ff832
IBusObservedPath    *ibus_observed_path_new_from_xml_node   (XMLNode            *node,
Packit 3ff832
                                                             gboolean            fill_stat);
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * ibus_observed_path_new:
Packit 3ff832
 * @path: The path string.
Packit 3ff832
 * @fill_stat: Auto-fill the path status.
Packit 3ff832
 *
Packit 3ff832
 * Creates a new #IBusObservedPath from an XML node.
Packit 3ff832
 *
Packit 3ff832
 * Returns: A newly allocated #IBusObservedPath.
Packit 3ff832
 */
Packit 3ff832
IBusObservedPath    *ibus_observed_path_new                 (const gchar        *path,
Packit 3ff832
                                                             gboolean            fill_stat);
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * ibus_observed_path_traverse:
Packit 3ff832
 * @path: An IBusObservedPath.
Packit 3ff832
 * @dir_only: Only looks for subdirs, not files
Packit 3ff832
 *
Packit 3ff832
 * Recursively traverse the path and put the files and subdirectory in to
Packit 3ff832
 * a newly allocated
Packit 3ff832
 * GLists, if the @path is a directory. Otherwise returns NULL.
Packit 3ff832
 *
Packit 3ff832
 * Returns: (transfer full) (element-type IBusObservedPath): A newly allocate
Packit 3ff832
 * GList which holds content in path; NULL if @path is not directory.
Packit 3ff832
 */
Packit 3ff832
GList               *ibus_observed_path_traverse            (IBusObservedPath   *path,
Packit 3ff832
                                                             gboolean            dir_only);
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * ibus_observed_path_check_modification:
Packit 3ff832
 * @path: An IBusObservedPath.
Packit 3ff832
 *
Packit 3ff832
 * Checks whether the path is modified by comparing the mtime in object and
Packit 3ff832
 * mtime in file system.
Packit 3ff832
 *
Packit 3ff832
 * Returns: %TRUE if imtime is changed, otherwise %FALSE.
Packit 3ff832
 */
Packit 3ff832
gboolean             ibus_observed_path_check_modification  (IBusObservedPath   *path);
Packit 3ff832
Packit 3ff832
/**
Packit 3ff832
 * ibus_observed_path_output:
Packit 3ff832
 * @path: An IBusObservedPath.
Packit 3ff832
 * @output: Path is appended to.
Packit 3ff832
 * @indent: number of indent.
Packit 3ff832
 *
Packit 3ff832
 * Append the observed path to a string with following format:
Packit 3ff832
 * <path mtime="<i>modified time</i>" ><i>path</i></path>
Packit 3ff832
 */
Packit 3ff832
void                 ibus_observed_path_output              (IBusObservedPath   *path,
Packit 3ff832
                                                             GString            *output,
Packit 3ff832
                                                             gint                indent);
Packit 3ff832
Packit 3ff832
G_END_DECLS
Packit 3ff832
#endif
Packit 3ff832