Commit 928aab91 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Implement noop file monitor

parent e0324e53
......@@ -131,6 +131,7 @@ sources = files(
'zathura/document.c',
'zathura/file-monitor.c',
'zathura/file-monitor-glib.c',
'zathura/file-monitor-noop.c',
'zathura/file-monitor-signal.c',
'zathura/jumplist.c',
'zathura/links.c',
......
/* See LICENSE file for license and copyright information */
#include "file-monitor-noop.h"
#include <girara/utils.h>
#ifdef G_OS_UNIX
#include <glib-unix.h>
#endif
struct zathura_noopfilemonitor_s
{
ZathuraFileMonitor parent;
};
G_DEFINE_TYPE(ZathuraNoopFileMonitor, zathura_noopfilemonitor,
ZATHURA_TYPE_FILEMONITOR)
static void
start(ZathuraFileMonitor* GIRARA_UNUSED(file_monitor))
{
}
static void
stop(ZathuraFileMonitor* GIRARA_UNUSED(file_monitor))
{
}
static void
zathura_noopfilemonitor_finalize(GObject* object)
{
stop(ZATHURA_FILEMONITOR(object));
G_OBJECT_CLASS(zathura_noopfilemonitor_parent_class)->finalize(object);
}
static void
zathura_noopfilemonitor_class_init(ZathuraNoopFileMonitorClass* class)
{
ZathuraFileMonitorClass* filemonitor_class = ZATHURA_FILEMONITOR_CLASS(class);
filemonitor_class->start = start;
filemonitor_class->stop = stop;
GObjectClass* object_class = G_OBJECT_CLASS(class);
object_class->finalize = zathura_noopfilemonitor_finalize;
}
static void
zathura_noopfilemonitor_init(ZathuraNoopFileMonitor* GIRARA_UNUSED(noopfilemonitor))
{
}
/* See LICENSE file for license and copyright information */
#ifndef FILEMONITOR_NOOP_H
#define FILEMONITOR_NOOP_H
#include "file-monitor.h"
#define ZATHURA_TYPE_NOOPFILEMONITOR (zathura_noopfilemonitor_get_type())
#define ZATHURA_NOOPFILEMONITOR(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), ZATHURA_TYPE_NOOPFILEMONITOR, \
ZathuraNoopFileMonitor))
#define ZATHURA_NOOPFILEMONITOR_CLASS(obj) \
(G_TYPE_CHECK_CLASS_CAST((obj), ZATHURA_TYPE_NOOPFILEMONITOR, \
ZathuraNoopFileMonitorClass))
#define ZATHURA_IS_NOOPFILEMONITOR(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), ZATHURA_TYPE_NOOPFILEMONITOR))
#define ZATHURA_IS_NOOPFILEMONITOR_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((obj), ZATHURA_TYPE_NOOPFILEMONITOR))
#define ZATHURA_NOOPFILEMONITOR_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), ZATHURA_TYPE_NOOPFILEMONITOR, \
ZathuraNoopFileMonitorClass))
typedef struct zathura_noopfilemonitor_s ZathuraNoopFileMonitor;
typedef struct zathura_noopfilemonitor_class_s ZathuraNoopFileMonitorClass;
struct zathura_noopfilemonitor_class_s
{
ZathuraFileMonitorClass parent_class;
};
GType zathura_noopfilemonitor_get_type(void) G_GNUC_CONST;
#endif
......@@ -5,6 +5,7 @@
#ifdef G_OS_UNIX
#include "file-monitor-signal.h"
#endif
#include "file-monitor-noop.h"
#include "macros.h"
#include <girara/utils.h>
......@@ -141,6 +142,11 @@ zathura_filemonitor_new(const char* file_path,
NULL);
break;
#endif
case ZATHURA_FILEMONITOR_NOOP:
girara_debug("using noop file monitor");
ret = g_object_new(ZATHURA_TYPE_NOOPFILEMONITOR, "file-path", file_path,
NULL);
break;
default:
girara_debug("invalid filemonitor type: %d", filemonitor_type);
g_return_val_if_fail(false, NULL);
......
......@@ -55,7 +55,8 @@ GType zathura_filemonitor_get_type(void) G_GNUC_CONST;
*/
typedef enum zathura_filemonitor_type_e {
ZATHURA_FILEMONITOR_GLIB, /**< Use filemonitor from GLib */
ZATHURA_FILEMONITOR_SIGNAL /**< Reload when receiving SIGHUP */
ZATHURA_FILEMONITOR_SIGNAL, /**< Reload when receiving SIGHUP */
ZATHURA_FILEMONITOR_NOOP /**< Monitor that does nothing */
} zathura_filemonitor_type_t;
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment