Gtk2-Recent
view release on metacpan or search on metacpan
recent-files/egg-recent-model.c view on Meta::CPAN
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see
* <https://www.gnu.org/licenses/>.
*
* Authors:
* James Willcox <jwillcox@cs.indiana.edu>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <time.h>
#include <gtk/gtk.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <gconf/gconf-client.h>
#include "egg-recent-model.h"
#include "egg-recent-item.h"
#define EGG_RECENT_MODEL_FILE_PATH "/.recently-used"
#define EGG_RECENT_MODEL_BUFFER_SIZE 8192
#define EGG_RECENT_MODEL_MAX_ITEMS 500
#define EGG_RECENT_MODEL_DEFAULT_LIMIT 10
#define EGG_RECENT_MODEL_TIMEOUT_LENGTH 200
#define EGG_RECENT_MODEL_POLL_TIME 3
/* needed for Darwin */
#if !HAVE_DECL_LOCKF
int lockf (int filedes, int function, off_t size);
#endif
#define EGG_RECENT_MODEL_KEY_DIR "/desktop/gnome/recent_files"
#define EGG_RECENT_MODEL_DEFAULT_LIMIT_KEY EGG_RECENT_MODEL_KEY_DIR "/default_limit"
#define EGG_RECENT_MODEL_EXPIRE_KEY EGG_RECENT_MODEL_KEY_DIR "/expire"
struct _EggRecentModelPrivate {
GSList *mime_filter_values; /* list of mime types we allow */
GSList *group_filter_values; /* list of groups we allow */
GSList *scheme_filter_values; /* list of URI schemes we allow */
EggRecentModelSort sort_type; /* type of sorting to be done */
int limit; /* soft limit for length of the list */
int expire_days; /* number of days to hold an item */
char *path; /* path to the file we store stuff in */
GHashTable *monitors;
GnomeVFSMonitorHandle *monitor;
GConfClient *client;
gboolean use_default_limit;
guint limit_change_notify_id;
guint expiration_change_notify_id;
guint changed_timeout;
guint poll_timeout;
time_t last_mtime;
};
/* signals */
enum {
CHANGED,
LAST_SIGNAL
};
static GType model_signals[LAST_SIGNAL] = { 0 };
/* properties */
enum {
PROP_BOGUS,
PROP_MIME_FILTERS,
PROP_GROUP_FILTERS,
PROP_SCHEME_FILTERS,
PROP_SORT_TYPE,
PROP_LIMIT
};
typedef struct {
GSList *states;
GList *items;
EggRecentItem *current_item;
} ParseInfo;
typedef enum {
STATE_START,
STATE_RECENT_FILES,
STATE_RECENT_ITEM,
STATE_URI,
STATE_MIME_TYPE,
( run in 0.312 second using v1.01-cache-2.11-cpan-39bf76dae61 )