gnome-menus/gnome-menus-gnome-vfs.patch

581 lines
16 KiB
Diff
Raw Normal View History

Index: configure.in
================================================================================
--- configure.in
+++ configure.in
@@ -36,25 +36,11 @@
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)
-AC_SUBST(GLIB_CFLAGS)
-AC_SUBST(GLIB_LIBS)
-
-dnl check for FAM
-FAM_LIBS=
-AC_CHECK_LIB(fam, FAMOpen,
- [AC_CHECK_HEADERS(fam.h,
- [AC_DEFINE(HAVE_FAM, [], [Define if we have FAM])
- FAM_LIBS="-lfam"],
- AC_MSG_WARN(*** FAM support will not be built (header files not found) ***))],
- AC_MSG_WARN(*** FAM support will not be built (FAM library not found) ***))
-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"
+PKG_CHECK_MODULES(LIBMENU,
+ glib-2.0 >= 2.5.6 \
+ gnome-vfs-2.0 >= 2.8.2)
+AC_SUBST(LIBMENU_CFLAGS)
+AC_SUBST(LIBMENU_LIBS)
GNOME_COMPILE_WARNINGS(yes)
@@ -63,11 +49,15 @@
[warn about deprecated usages [default=no]])],,
[enable_deprecations=no])
-DISABLE_DEPRECATED_CFLAGS=
if test "x$enable_deprecations" = "xyes"; then
- DISABLE_DEPRECATED_CFLAGS="-DG_DISABLE_DEPRECATED"
+ DISABLE_DEPRECATED_CFLAGS="\
+-DG_DISABLE_DEPRECATED \
+-DGDK_DISABLE_DEPRECATED \
+-DGTK_DISABLE_DEPRECATED \
+-DGDK_PIXBUF_DISABLE_DEPRECATED \
+-DGNOME_DISABLE_DEPRECATED"
+ AC_SUBST(DISABLE_DEPRECATED_CFLAGS)
fi
-AC_SUBST(DISABLE_DEPRECATED_CFLAGS)
dnl --enable-debug=(yes|minimum|no)
AC_ARG_ENABLE(debug, [ --enable-debug=[no/yes] turn on debugging [default=no]],,enable_debug=yes)
--- libmenu/Makefile.am
+++ libmenu/Makefile.am
@@ -2,7 +2,7 @@
INCLUDES = \
-DGMENU_I_KNOW_THIS_IS_UNSTABLE \
- $(GLIB_CFLAGS) \
+ $(LIBMENU_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS) \
$(DEBUG_CFLAGS) \
$(WARN_CFLAGS) \
@@ -21,8 +21,6 @@
gmenu-tree.h \
menu-layout.c \
menu-layout.h \
- menu-monitor.c \
- menu-monitor.h \
menu-monitor-backend.h \
menu-monitor-fam.c \
menu-util.c \
@@ -30,8 +28,7 @@
$(NULL)
libgnome_menu_la_LIBADD = \
- $(GLIB_LIBS) \
- $(FAM_LIBS) \
+ $(LIBMENU_LIBS) \
$(NULL)
libgnome_menu_la_LDFLAGS = \
-version-info $(LIB_MENU_LT_VERSION) \
@@ -52,3 +49,6 @@
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libgnome-menu.pc
+
+
+
--- libmenu/entry-directories.c
+++ libmenu/entry-directories.c
@@ -25,9 +25,9 @@
#include <errno.h>
#include <sys/types.h>
#include <dirent.h>
+#include <libgnomevfs/gnome-vfs.h>
#include "menu-util.h"
-#include "menu-monitor.h"
#include "canonicalize.h"
typedef struct CachedDir CachedDir;
@@ -58,13 +58,15 @@
GSList *entries;
GSList *subdirs;
- MenuMonitor *dir_monitor;
- GSList *monitors;
+ GnomeVFSMonitorHandle *monitor;
+ GSList *monitors;
guint have_read_entries : 1;
guint deleted : 1;
guint references : 28;
+
+ gboolean no_monitor_support;
};
struct CachedDirMonitor
@@ -78,11 +80,6 @@
static gboolean cached_dir_load_entries_recursive (CachedDir *dir,
const char *dirname);
-static void handle_cached_dir_changed (MenuMonitor *monitor,
- MenuMonitorEvent event,
- const char *path,
- CachedDir *dir);
-
/*
* Entry directory cache
*/
@@ -104,14 +101,9 @@
static void
cached_dir_free (CachedDir *dir)
{
- if (dir->dir_monitor)
- {
- menu_monitor_remove_notify (dir->dir_monitor,
- (MenuMonitorNotifyFunc) handle_cached_dir_changed,
- dir);
- menu_monitor_unref (dir->dir_monitor);
- dir->dir_monitor = NULL;
- }
+ if (dir->monitor)
+ gnome_vfs_monitor_cancel (dir->monitor);
+ dir->monitor = NULL;
g_slist_foreach (dir->monitors, (GFunc) g_free, NULL);
g_slist_free (dir->monitors);
@@ -399,20 +391,31 @@
}
static void
-handle_cached_dir_changed (MenuMonitor *monitor,
- MenuMonitorEvent event,
- const char *path,
- CachedDir *dir)
+handle_cached_dir_changed (GnomeVFSMonitorHandle *handle,
+ const char *monitor_uri,
+ const char *info_uri,
+ GnomeVFSMonitorEventType event,
+ CachedDir *dir)
{
gboolean handled = FALSE;
+ char *path;
char *basename;
char *dirname;
+ if (event != GNOME_VFS_MONITOR_EVENT_CREATED &&
+ event != GNOME_VFS_MONITOR_EVENT_DELETED &&
+ event != GNOME_VFS_MONITOR_EVENT_CHANGED)
+ return;
+
+ if (!(path = gnome_vfs_get_local_path_from_uri (info_uri)))
+ return;
+
menu_verbose ("'%s' notified of '%s' %s - invalidating cache\n",
dir->name,
path,
- event == MENU_MONITOR_EVENT_CREATED ? ("created") :
- event == MENU_MONITOR_EVENT_DELETED ? ("deleted") : ("changed"));
+ event == GNOME_VFS_MONITOR_EVENT_CREATED ? ("created") :
+ event == GNOME_VFS_MONITOR_EVENT_DELETED ? ("deleted") :
+ event == GNOME_VFS_MONITOR_EVENT_CHANGED ? ("changed") : ("unknown-event"));
dirname = g_path_get_dirname (path);
basename = g_path_get_basename (path);
@@ -424,12 +427,12 @@
{
switch (event)
{
- case MENU_MONITOR_EVENT_CREATED:
- case MENU_MONITOR_EVENT_CHANGED:
+ case GNOME_VFS_MONITOR_EVENT_CREATED:
+ case GNOME_VFS_MONITOR_EVENT_CHANGED:
handled = cached_dir_update_entry (dir, basename, path);
break;
- case MENU_MONITOR_EVENT_DELETED:
+ case GNOME_VFS_MONITOR_EVENT_DELETED:
handled = cached_dir_remove_entry (dir, basename);
break;
@@ -442,14 +445,14 @@
{
switch (event)
{
- case MENU_MONITOR_EVENT_CREATED:
+ case GNOME_VFS_MONITOR_EVENT_CREATED:
handled = cached_dir_add_subdir (dir, basename, path);
break;
- case MENU_MONITOR_EVENT_CHANGED:
+ case GNOME_VFS_MONITOR_EVENT_CHANGED:
break;
- case MENU_MONITOR_EVENT_DELETED:
+ case GNOME_VFS_MONITOR_EVENT_DELETED:
handled = cached_dir_remove_subdir (dir, basename);
break;
@@ -461,6 +464,7 @@
g_free (basename);
g_free (dirname);
+ g_free (path);
if (handled)
{
@@ -472,13 +476,23 @@
cached_dir_ensure_monitor (CachedDir *dir,
const char *dirname)
{
- if (dir->dir_monitor == NULL)
+ char *uri;
+
+ if (dir->monitor != NULL || dir->no_monitor_support)
+ return;
+
+ uri = gnome_vfs_get_uri_from_local_path (dirname);
+
+ if (gnome_vfs_monitor_add (&dir->monitor,
+ uri,
+ GNOME_VFS_MONITOR_DIRECTORY,
+ (GnomeVFSMonitorCallback) handle_cached_dir_changed,
+ dir) != GNOME_VFS_OK)
{
- dir->dir_monitor = menu_get_directory_monitor (dirname);
- menu_monitor_add_notify (dir->dir_monitor,
- (MenuMonitorNotifyFunc) handle_cached_dir_changed,
- dir);
+ dir->no_monitor_support = TRUE;
}
+
+ g_free (uri);
}
static gboolean
--- libmenu/gmenu-tree.c
+++ libmenu/gmenu-tree.c
@@ -23,9 +23,10 @@
#include <string.h>
#include <errno.h>
+#include <libgnomevfs/gnome-vfs.h>
+
#include "menu-layout.h"
-#include "menu-monitor.h"
#include "menu-util.h"
#include "canonicalize.h"
@@ -263,24 +264,19 @@
MENU_FILE_MONITOR_DIRECTORY
} MenuFileMonitorType;
-typedef struct
-{
- MenuFileMonitorType type;
- MenuMonitor *monitor;
-} MenuFileMonitor;
-
static void
-handle_nonexistent_menu_file_changed (MenuMonitor *monitor,
- MenuMonitorEvent event,
- const char *path,
- GMenuTree *tree)
+handle_nonexistent_menu_file_changed (GnomeVFSMonitorHandle *handle,
+ const char *monitor_uri,
+ const char *info_uri,
+ GnomeVFSMonitorEventType event,
+ GMenuTree *tree)
{
- if (event == MENU_MONITOR_EVENT_CHANGED ||
- event == MENU_MONITOR_EVENT_CREATED)
+ if (event == GNOME_VFS_MONITOR_EVENT_CHANGED ||
+ event == GNOME_VFS_MONITOR_EVENT_CREATED)
{
menu_verbose ("\"%s\" %s, marking tree for recanonicalization\n",
- path,
- event == MENU_MONITOR_EVENT_CREATED ? "created" : "changed");
+ info_uri,
+ event == GNOME_VFS_MONITOR_EVENT_CREATED ? "created" : "changed");
gmenu_tree_force_recanonicalize (tree);
gmenu_tree_invoke_monitors (tree);
@@ -288,33 +284,45 @@
}
static void
-handle_menu_file_changed (MenuMonitor *monitor,
- MenuMonitorEvent event,
- const char *path,
- GMenuTree *tree)
-{
+handle_menu_file_changed (GnomeVFSMonitorHandle *handle,
+ const char *monitor_uri,
+ const char *info_uri,
+ GnomeVFSMonitorEventType event,
+ GMenuTree *tree)
+{
+ if (event != GNOME_VFS_MONITOR_EVENT_DELETED &&
+ event != GNOME_VFS_MONITOR_EVENT_CHANGED &&
+ event != GNOME_VFS_MONITOR_EVENT_CREATED)
+ return;
+
menu_verbose ("\"%s\" %s, marking tree for recanicalization\n",
- path,
- event == MENU_MONITOR_EVENT_CREATED ? "created" :
- event == MENU_MONITOR_EVENT_CHANGED ? "changed" : "deleted");
+ info_uri,
+ event == GNOME_VFS_MONITOR_EVENT_CREATED ? "created" :
+ event == GNOME_VFS_MONITOR_EVENT_CHANGED ? "changed" : "deleted");
gmenu_tree_force_recanonicalize (tree);
gmenu_tree_invoke_monitors (tree);
}
static void
-handle_menu_file_directory_changed (MenuMonitor *monitor,
- MenuMonitorEvent event,
- const char *path,
- GMenuTree *tree)
-{
- if (!g_str_has_suffix (path, ".menu"))
+handle_menu_file_directory_changed (GnomeVFSMonitorHandle *handle,
+ const char *monitor_uri,
+ const char *info_uri,
+ GnomeVFSMonitorEventType event,
+ GMenuTree *tree)
+{
+ if (event != GNOME_VFS_MONITOR_EVENT_DELETED &&
+ event != GNOME_VFS_MONITOR_EVENT_CHANGED &&
+ event != GNOME_VFS_MONITOR_EVENT_CREATED)
+ return;
+
+ if (!g_str_has_suffix (info_uri, ".menu"))
return;
menu_verbose ("\"%s\" %s, marking tree for recanicalization\n",
- path,
- event == MENU_MONITOR_EVENT_CREATED ? "created" :
- event == MENU_MONITOR_EVENT_CHANGED ? "changed" : "deleted");
+ info_uri,
+ event == GNOME_VFS_MONITOR_EVENT_CREATED ? "created" :
+ event == GNOME_VFS_MONITOR_EVENT_CHANGED ? "changed" : "deleted");
gmenu_tree_force_recanonicalize (tree);
gmenu_tree_invoke_monitors (tree);
@@ -325,39 +333,44 @@
const char *path,
MenuFileMonitorType type)
{
- MenuFileMonitor *monitor;
+ GnomeVFSMonitorHandle *handle;
+ GnomeVFSResult result;
+ char *uri;
- monitor = g_new0 (MenuFileMonitor, 1);
+ uri = gnome_vfs_get_uri_from_local_path (path);
- monitor->type = type;
+ handle = NULL;
switch (type)
{
case MENU_FILE_MONITOR_FILE:
menu_verbose ("Adding a menu file monitor for \"%s\"\n", path);
- monitor->monitor = menu_get_file_monitor (path);
- menu_monitor_add_notify (monitor->monitor,
- (MenuMonitorNotifyFunc) handle_menu_file_changed,
- tree);
+ result = gnome_vfs_monitor_add (&handle,
+ uri,
+ GNOME_VFS_MONITOR_FILE,
+ (GnomeVFSMonitorCallback) handle_menu_file_changed,
+ tree);
break;
case MENU_FILE_MONITOR_NONEXISTENT_FILE:
menu_verbose ("Adding a menu file monitor for non-existent \"%s\"\n", path);
- monitor->monitor = menu_get_file_monitor (path);
- menu_monitor_add_notify (monitor->monitor,
- (MenuMonitorNotifyFunc) handle_nonexistent_menu_file_changed,
- tree);
+ result = gnome_vfs_monitor_add (&handle,
+ uri,
+ GNOME_VFS_MONITOR_FILE,
+ (GnomeVFSMonitorCallback) handle_nonexistent_menu_file_changed,
+ tree);
break;
case MENU_FILE_MONITOR_DIRECTORY:
menu_verbose ("Adding a menu directory monitor for \"%s\"\n", path);
- monitor->monitor = menu_get_directory_monitor (path);
- menu_monitor_add_notify (monitor->monitor,
- (MenuMonitorNotifyFunc) handle_menu_file_directory_changed,
- tree);
+ result = gnome_vfs_monitor_add (&handle,
+ uri,
+ GNOME_VFS_MONITOR_DIRECTORY,
+ (GnomeVFSMonitorCallback) handle_menu_file_directory_changed,
+ tree);
break;
default:
@@ -365,44 +378,18 @@
break;
}
- tree->menu_file_monitors = g_slist_prepend (tree->menu_file_monitors, monitor);
-}
-
-static void
-remove_menu_file_monitor (MenuFileMonitor *monitor,
- GMenuTree *tree)
-{
- switch (monitor->type)
+ if (result == GNOME_VFS_OK)
{
- case MENU_FILE_MONITOR_FILE:
- menu_monitor_remove_notify (monitor->monitor,
- (MenuMonitorNotifyFunc) handle_menu_file_changed,
- tree);
- break;
-
- case MENU_FILE_MONITOR_NONEXISTENT_FILE:
- menu_monitor_remove_notify (monitor->monitor,
- (MenuMonitorNotifyFunc) handle_nonexistent_menu_file_changed,
- tree);
- break;
-
- case MENU_FILE_MONITOR_DIRECTORY:
- menu_monitor_remove_notify (monitor->monitor,
- (MenuMonitorNotifyFunc) handle_menu_file_directory_changed,
- tree);
- break;
-
- default:
- g_assert_not_reached ();
- break;
+ tree->menu_file_monitors = g_slist_prepend (tree->menu_file_monitors, handle);
+ }
+ else
+ {
+ g_assert (handle == NULL);
+ menu_verbose ("Failed to add monitor for %s: %s\n",
+ path, gnome_vfs_result_to_string (result));
}
- menu_monitor_unref (monitor->monitor);
- monitor->monitor = NULL;
-
- monitor->type = MENU_FILE_MONITOR_INVALID;
-
- g_free (monitor);
+ g_free (uri);
}
static void
@@ -411,8 +398,8 @@
menu_verbose ("Removing all menu file monitors\n");
g_slist_foreach (tree->menu_file_monitors,
- (GFunc) remove_menu_file_monitor,
- tree);
+ (GFunc) gnome_vfs_monitor_cancel,
+ NULL);
g_slist_free (tree->menu_file_monitors);
tree->menu_file_monitors = NULL;
}
--- python/Makefile.am
+++ python/Makefile.am
@@ -5,7 +5,7 @@
-I$(srcdir)/../libmenu \
$(WARN_CFLAGS) \
$(NO_STRICT_ALIASING_CFLAGS) \
- $(GLIB_CFLAGS) \
+ $(LIBMENU_CFLAGS) \
$(PYTHON_INCLUDES) \
$(DISABLE_DEPRECATED_CFLAGS) \
$(DEBUG_CFLAGS) \
@@ -15,5 +15,5 @@
gmenu_LTLIBRARIES = gmenu.la
gmenu_la_LDFLAGS = -module -avoid-version -fPIC -export-symbols-regex initgmenu
-gmenu_la_LIBADD = $(GLIB_LIBS) $(top_builddir)/libmenu/libgnome-menu.la
+gmenu_la_LIBADD = $(top_builddir)/libmenu/libgnome-menu.la
gmenu_la_SOURCES = gmenu.c
--- python/gmenu.c
+++ python/gmenu.c
@@ -21,6 +21,7 @@
#include <Python.h>
#include <gmenu-tree.h>
+#include <libgnomevfs/gnome-vfs-init.h>
typedef struct
{
@@ -1716,6 +1717,9 @@
if (!PyArg_ParseTuple (args, "s|i:gmenu.lookup_tree", &menu_file, &flags))
return NULL;
+ if (!gnome_vfs_initialized ())
+ gnome_vfs_init ();
+
if (!(tree = gmenu_tree_lookup (menu_file, flags)))
{
Py_INCREF (Py_None);
--- util/Makefile.am
+++ util/Makefile.am
@@ -4,7 +4,7 @@
-DGMENU_I_KNOW_THIS_IS_UNSTABLE \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-I$(srcdir)/../libmenu \
- $(GLIB_CFLAGS) \
+ $(LIBMENU_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS) \
$(DEBUG_CFLAGS) \
$(WARN_CFLAGS) \
@@ -20,5 +20,5 @@
gnome_menu_spec_test_LDADD = \
../libmenu/libgnome-menu.la \
- $(GLIB_LIBS) \
+ $(LIBMENU_LIBS) \
$(NULL)
--- util/test-menu-spec.c
+++ util/test-menu-spec.c
@@ -23,6 +23,7 @@
#include <glib/gi18n.h>
#include <string.h>
+#include <libgnomevfs/gnome-vfs.h>
static char *menu_file = NULL;
static gboolean monitor = FALSE;
@@ -186,6 +187,8 @@
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
+ gnome_vfs_init ();
+
options_context = g_option_context_new (_("- test GNOME's implementation of the Desktop Menu Specification"));
g_option_context_add_main_entries (options_context, options, GETTEXT_PACKAGE);
g_option_context_parse (options_context, &argc, &argv, NULL);
@@ -231,5 +234,7 @@
gmenu_tree_unref (tree);
+ gnome_vfs_shutdown ();
+
return 0;
}