Blame src/ibusobservedpath.h

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