gnome-menus r841 - in trunk: . libmenu
- From: vuntz svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-menus r841 - in trunk: . libmenu
- Date: Sat, 9 Feb 2008 14:35:00 +0000 (GMT)
Author: vuntz
Date: Sat Feb 9 14:35:00 2008
New Revision: 841
URL: http://svn.gnome.org/viewvc/gnome-menus?rev=841&view=rev
Log:
2008-02-09 Vincent Untz <vuntz gnome org>
We don't need multiple monitor backends anymore. Just depend on gio.
* configure.in: unconditionnally depend on gio, remove backend
selection cruft
* libmenu/Makefile.am:
* libmenu/menu-monitor.c: (get_registry_key), (monitor_callback),
(register_monitor), (lookup_monitor), (menu_monitor_unref):
* libmenu/menu-monitor.h:
* libmenu/menu-monitor-backend.h: killed
* libmenu/menu-monitor-fam.c: killed
* libmenu/menu-monitor-gio.c: killed
* libmenu/menu-monitor-inotify.c: killed
* libmenu/menu-monitor-none.c: killed
Removed:
trunk/libmenu/menu-monitor-backend.h
trunk/libmenu/menu-monitor-fam.c
trunk/libmenu/menu-monitor-gio.c
trunk/libmenu/menu-monitor-inotify.c
trunk/libmenu/menu-monitor-none.c
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/libmenu/Makefile.am
trunk/libmenu/menu-monitor.c
trunk/libmenu/menu-monitor.h
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Sat Feb 9 14:35:00 2008
@@ -36,85 +36,10 @@
dnl make sure we keep ACLOCAL_FLAGS around for maintainer builds to work
AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS")
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6.0)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6.0 gio-2.0 >= 2.15.2)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
-AC_ARG_WITH(monitor_backend,
- [AC_HELP_STRING([--with-monitor-backend=BACKEND],
- [Select which monitor backend to use. Possible values are gio, inotify and fam [default=auto]])],
- with_monitor_backend=$withval,
- with_monitor_backend=auto)
-
-used_monitor_backend=
-if test "x$with_monitor_backend" = "xgio" -o "x$with_monitor_backend" = "xauto"; then
- PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.15.2, have_gio=yes, have_gio=no)
-
- if test "x$with_monitor_backend" = "gio" -a "x$have_gio" = "xno"; then
- AC_MSG_ERROR([No GIO found -- cannot enable GIO support])
- fi
-
- if test "x$have_gio" = "xyes"; then
- used_monitor_backend="gio"
- fi
-
- AC_SUBST(GIO_CFLAGS)
- AC_SUBST(GIO_LIBS)
-fi
-
-if test -z "$used_monitor_backend" -a \( "x$with_monitor_backend" = "xfam" -o "x$with_monitor_backend" = "xauto" \); then
- dnl check for FAM
- FAM_LIBS=
- AC_CHECK_LIB(fam, FAMOpen,
- [AC_CHECK_HEADERS(fam.h,
- [have_fam=yes
- FAM_LIBS="-lfam"],
- have_fam=no)],
- have_fam=no)
-
- if test "x$with_monitor_backend" = "fam" -a "x$have_fam" = "xno"; then
- AC_MSG_ERROR([No FAM found -- cannot enable FAM support])
- fi
-
- if test "x$have_fam" = "xyes"; then
- used_monitor_backend="fam"
- fi
-
- AC_SUBST(FAM_LIBS)
-
- dnl check for gamin extension
- gmenu_save_libs="$LIBS"
- LIBS="$LIBS $FAM_LIBS"
- AC_CHECK_FUNCS(FAMNoExists)
- LIBS="$gmenu_save_libs"
-fi
-
-if test -z "$used_monitor_backend" -a \( "x$with_monitor_backend" = "xinotify" -o "x$with_monitor_backend" = "xauto" \); then
- dnl check for inotify
- AC_CHECK_FUNC(inotify_init,
- [AC_CHECK_HEADER([sys/inotify.h],
- have_inotify=yes,
- have_inotify=no)],
- have_inotify=no)
-
- if test "x$with_monitor_backend" = "inotify" -a "x$have_inotfy" = "xno"; then
- AC_MSG_ERROR([No inotify found -- cannot enable inotify support])
- fi
-
- if test "x$have_inotify" = "xyes"; then
- used_monitor_backend="inotify"
- fi
-fi
-
-if test -z "$used_monitor_backend"; then
- used_monitor_backend="none"
-fi
-
-AM_CONDITIONAL(HAVE_GIO, test "x$used_monitor_backend" = "xgio")
-AM_CONDITIONAL(HAVE_FAM, test "x$used_monitor_backend" = "xfam")
-AM_CONDITIONAL(HAVE_INOTIFY, test "x$used_monitor_backend" = "xinotify")
-AM_CONDITIONAL(HAVE_NO_MONITOR_BACKEND, test "x$used_monitor_backend" = "xnone")
-
GNOME_COMPILE_WARNINGS(yes)
AC_ARG_ENABLE(deprecations,
Modified: trunk/libmenu/Makefile.am
==============================================================================
--- trunk/libmenu/Makefile.am (original)
+++ trunk/libmenu/Makefile.am Sat Feb 9 14:35:00 2008
@@ -1,30 +1,5 @@
NULL =
-# only one will be defined
-if HAVE_GIO
-MONITOR_CFLAGS = $(GIO_CFLAGS)
-MONITOR_LIBS = $(GIO_LIBS)
-MONITOR_SOURCES = menu-monitor-gio.c
-endif
-
-if HAVE_FAM
-MONITOR_CFLAGS =
-MONITOR_LIBS = $(FAM_LIBS)
-MONITOR_SOURCES = menu-monitor-fam.c
-endif
-
-if HAVE_INOTIFY
-MONITOR_CFLAGS =
-MONITOR_LIBS =
-MONITOR_SOURCES = menu-monitor-inotify.c
-endif
-
-if HAVE_NO_MONITOR_BACKEND
-MONITOR_CFLAGS =
-MONITOR_LIBS =
-MONITOR_SOURCES = menu-monitor-none.c
-endif
-
INCLUDES = \
-DGMENU_I_KNOW_THIS_IS_UNSTABLE \
$(GLIB_CFLAGS) \
@@ -49,7 +24,6 @@
menu-layout.h \
menu-monitor.c \
menu-monitor.h \
- menu-monitor-backend.h \
menu-util.c \
menu-util.h \
$(MONITOR_SOURCES) \
@@ -72,10 +46,6 @@
$(NULL)
EXTRA_DIST = \
- menu-monitor-gio.c \
- menu-monitor-fam.c \
- menu-monitor-inotify.c \
- menu-monitor-none.c \
libgnome-menu.pc.in \
libgnome-menu-uninstalled.pc.in \
$(NULL)
Modified: trunk/libmenu/menu-monitor.c
==============================================================================
--- trunk/libmenu/menu-monitor.c (original)
+++ trunk/libmenu/menu-monitor.c Sat Feb 9 14:35:00 2008
@@ -1,5 +1,8 @@
/*
* Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2006 Mark McLoughlin
+ * Copyright (C) 2007 Sebastian DrÃge
+ * Copyright (C) 2008 Vincent Untz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -21,7 +24,8 @@
#include "menu-monitor.h"
-#include "menu-monitor-backend.h"
+#include <gio/gio.h>
+
#include "menu-util.h"
struct MenuMonitor
@@ -31,13 +35,20 @@
GSList *notifies;
- gpointer backend_data;
+ GFileMonitor *monitor;
guint is_directory : 1;
};
typedef struct
{
+ MenuMonitor *monitor;
+ MenuMonitorEvent event;
+ char *path;
+} MenuMonitorEventInfo;
+
+typedef struct
+{
MenuMonitorNotifyFunc notify_func;
gpointer user_data;
guint refcount;
@@ -130,7 +141,7 @@
return FALSE;
}
-void
+static void
menu_monitor_queue_event (MenuMonitorEventInfo *event_info)
{
pending_events = g_slist_append (pending_events, event_info);
@@ -141,32 +152,95 @@
}
}
-gboolean
-menu_monitor_get_is_directory (MenuMonitor *monitor)
+static inline char *
+get_registry_key (const char *path,
+ gboolean is_directory)
{
- return monitor->is_directory;
+ return g_strdup_printf ("%s:%s",
+ path,
+ is_directory ? "<dir>" : "<file>");
}
-void
-menu_monitor_set_backend_data (MenuMonitor *monitor,
- gpointer backend_data)
-{
- monitor->backend_data = backend_data;
-}
+static gboolean
+monitor_callback (GFileMonitor *monitor,
+ GFile *child,
+ GFile *other_file,
+ GFileMonitorEvent eflags,
+ gpointer user_data)
+{
+ MenuMonitorEventInfo *event_info;
+ MenuMonitorEvent event;
+ MenuMonitor *menu_monitor = (MenuMonitor *) user_data;
+
+ event = MENU_MONITOR_EVENT_INVALID;
+ switch (eflags)
+ {
+ case G_FILE_MONITOR_EVENT_CHANGED:
+ event = MENU_MONITOR_EVENT_CHANGED;
+ break;
+ case G_FILE_MONITOR_EVENT_CREATED:
+ event = MENU_MONITOR_EVENT_CREATED;
+ break;
+ case G_FILE_MONITOR_EVENT_DELETED:
+ event = MENU_MONITOR_EVENT_DELETED;
+ break;
+ default:
+ return TRUE;
+ }
+
+ event_info = g_new0 (MenuMonitorEventInfo, 1);
+
+ event_info->path = g_file_get_parse_name (child);
+ event_info->event = event;
+ event_info->monitor = menu_monitor;
-gpointer
-menu_monitor_get_backend_data (MenuMonitor *monitor)
-{
- return monitor->backend_data;
+ menu_monitor_queue_event (event_info);
+
+ return TRUE;
}
-static inline char *
-get_registry_key (const char *path,
+static MenuMonitor *
+register_monitor (const char *path,
gboolean is_directory)
{
- return g_strdup_printf ("%s:%s",
- path,
- is_directory ? "<dir>" : "<file>");
+ MenuMonitor *retval;
+ GFile *file;
+
+ retval = g_new0 (MenuMonitor, 1);
+
+ retval->path = g_strdup (path);
+ retval->refcount = 1;
+ retval->is_directory = is_directory != FALSE;
+
+ file = g_file_new_for_path (retval->path);
+
+ if (file == NULL)
+ {
+ menu_verbose ("Not adding monitor on '%s', failed to create GFile\n",
+ retval->path);
+ return retval;
+ }
+
+ if (retval->is_directory)
+ retval->monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE,
+ NULL, NULL);
+ else
+ retval->monitor = g_file_monitor_file (file, G_FILE_MONITOR_NONE,
+ NULL, NULL);
+
+ g_object_unref (G_OBJECT (file));
+
+ if (retval->monitor == NULL)
+ {
+ menu_verbose ("Not adding monitor on '%s', failed to create monitor\n",
+ retval->path);
+ return retval;
+ }
+
+ g_signal_connect (retval->monitor, "changed",
+ G_CALLBACK (monitor_callback), retval);
+
+ return retval;
}
static MenuMonitor *
@@ -194,14 +268,7 @@
if (retval == NULL)
{
- retval = g_new0 (MenuMonitor, 1);
-
- retval->path = g_strdup (path);
- retval->refcount = 1;
- retval->is_directory = is_directory != FALSE;
-
- menu_monitor_backend_register_monitor (retval);
-
+ retval = register_monitor (path, is_directory);
g_hash_table_insert (monitors_registry, registry_key, retval);
return retval;
@@ -290,7 +357,12 @@
monitors_registry = NULL;
}
- menu_monitor_backend_unregister_monitor (monitor);
+ if (monitor->monitor)
+ {
+ g_file_monitor_cancel (monitor->monitor);
+ g_object_unref (monitor->monitor);
+ monitor->monitor = NULL;
+ }
g_slist_foreach (monitor->notifies, (GFunc) menu_monitor_notify_unref, NULL);
g_slist_free (monitor->notifies);
@@ -304,14 +376,6 @@
g_free (monitor);
}
-const char *
-menu_monitor_get_path (MenuMonitor *monitor)
-{
- g_return_val_if_fail (monitor != NULL, NULL);
-
- return monitor->path;
-}
-
static MenuMonitorNotify *
menu_monitor_notify_ref (MenuMonitorNotify *notify)
{
Modified: trunk/libmenu/menu-monitor.h
==============================================================================
--- trunk/libmenu/menu-monitor.h (original)
+++ trunk/libmenu/menu-monitor.h Sat Feb 9 14:35:00 2008
@@ -46,8 +46,6 @@
MenuMonitor *menu_monitor_ref (MenuMonitor *monitor);
void menu_monitor_unref (MenuMonitor *monitor);
-const char *menu_monitor_get_path (MenuMonitor *monitor);
-
void menu_monitor_add_notify (MenuMonitor *monitor,
MenuMonitorNotifyFunc notify_func,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]