Add debug output

Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2016-06-24 18:56:45 +02:00
parent b93ebeb327
commit b85e8c389f
3 changed files with 12 additions and 2 deletions

View file

@ -3,6 +3,7 @@
#include "file-monitor-glib.h" #include "file-monitor-glib.h"
#include "macros.h" #include "macros.h"
#include <girara/utils.h>
#include <gio/gio.h> #include <gio/gio.h>
struct zathura_glibfilemonitor_s struct zathura_glibfilemonitor_s
@ -16,15 +17,20 @@ G_DEFINE_TYPE(ZathuraGLibFileMonitor, zathura_glibfilemonitor,
ZATHURA_TYPE_FILEMONITOR) ZATHURA_TYPE_FILEMONITOR)
static void static void
file_changed(GFileMonitor* UNUSED(monitor), GFile* UNUSED(file), file_changed(GFileMonitor* UNUSED(monitor), GFile* file,
GFile* UNUSED(other_file), GFileMonitorEvent event, GFile* UNUSED(other_file), GFileMonitorEvent event,
ZathuraGLibFileMonitor* file_monitor) ZathuraGLibFileMonitor* file_monitor)
{ {
switch (event) { switch (event) {
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
case G_FILE_MONITOR_EVENT_CREATED: case G_FILE_MONITOR_EVENT_CREATED: {
char* uri = g_file_get_uri(file);
girara_debug("received file-monitor event for %s", uri);
g_free(uri);
g_signal_emit_by_name(file_monitor, "reload-file"); g_signal_emit_by_name(file_monitor, "reload-file");
break; break;
}
default: default:
return; return;
} }

View file

@ -2,6 +2,7 @@
#include "file-monitor-signal.h" #include "file-monitor-signal.h"
#include <girara/utils.h>
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
#include <glib-unix.h> #include <glib-unix.h>
#endif #endif
@ -24,6 +25,7 @@ signal_handler(gpointer data)
ZathuraSignalFileMonitor* signalfilemonitor = data; ZathuraSignalFileMonitor* signalfilemonitor = data;
girara_debug("SIGHUP received");
g_signal_emit_by_name(signalfilemonitor, "reload-file"); g_signal_emit_by_name(signalfilemonitor, "reload-file");
return TRUE; return TRUE;

View file

@ -127,11 +127,13 @@ zathura_filemonitor_new(const char* file_path,
GObject* ret = NULL; GObject* ret = NULL;
switch (filemonitor_type) { switch (filemonitor_type) {
case ZATHURA_FILEMONITOR_GLIB: case ZATHURA_FILEMONITOR_GLIB:
girara_debug("using glib file monitor");
ret = g_object_new(ZATHURA_TYPE_GLIBFILEMONITOR, "file-path", file_path, ret = g_object_new(ZATHURA_TYPE_GLIBFILEMONITOR, "file-path", file_path,
NULL); NULL);
break; break;
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
case ZATHURA_FILEMONITOR_SIGNAL: case ZATHURA_FILEMONITOR_SIGNAL:
girara_debug("using SIGHUB file monitor");
ret = g_object_new(ZATHURA_TYPE_SIGNALFILEMONITOR, "file-path", file_path, ret = g_object_new(ZATHURA_TYPE_SIGNALFILEMONITOR, "file-path", file_path,
NULL); NULL);
break; break;