[Xfce4-commits] <garcon:master> Drop the menu monitor implementation.
Nick Schermer
nick at xfce.org
Sun Aug 16 18:40:04 CEST 2009
Updating branch refs/heads/master
to fbc06663a8c2f7e942fd064320d4f99d6648469f (commit)
from 7401838c8b4b43ad27704432e969c78fae12383f (commit)
commit fbc06663a8c2f7e942fd064320d4f99d6648469f
Author: Nick Schermer <nick at xfce.org>
Date: Sun Aug 16 18:35:40 2009 +0200
Drop the menu monitor implementation.
We're going to use something based on GFileMonitor, so drop
the old code since it also conflics with the API changes
that will be committed to GarconMenuItem.
garcon/Makefile.am | 2 -
garcon/garcon-menu-monitor.c | 363 ------------------------------------------
garcon/garcon-menu-monitor.h | 101 ------------
garcon/garcon-menu.c | 97 -----------
garcon/garcon.c | 7 -
garcon/garcon.h | 1 -
6 files changed, 0 insertions(+), 571 deletions(-)
diff --git a/garcon/Makefile.am b/garcon/Makefile.am
index ad12afb..492e263 100644
--- a/garcon/Makefile.am
+++ b/garcon/Makefile.am
@@ -38,7 +38,6 @@ libgarcon_headers = \
garcon-menu-item-cache.h \
garcon-environment.h \
garcon-menu.h \
- garcon-menu-monitor.h \
garcon-menu-item.h \
garcon-menu-node.h \
garcon-menu-tree-provider.h \
@@ -56,7 +55,6 @@ libgarcon_sources = \
garcon-menu-item-cache.c \
garcon-environment.c \
garcon-menu.c \
- garcon-menu-monitor.c \
garcon-menu-item.c \
garcon-menu-node.c \
garcon-menu-tree-provider.c \
diff --git a/garcon/garcon-menu-monitor.c b/garcon/garcon-menu-monitor.c
deleted file mode 100644
index cf69832..0000000
--- a/garcon/garcon-menu-monitor.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/* vi:set et ai sw=2 sts=2 ts=2: */
-/*-
- * Copyright (c) 2006-2009 Jannis Pohlmann <jannis at xfce.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <garcon/garcon-menu-monitor.h>
-#include <garcon/garcon-menu-item.h>
-#include <garcon/garcon.h>
-
-
-
-/* Initial vtable configuration */
-static GarconMenuMonitorVTable garcon_menu_monitor_vtable = {
- NULL,
- NULL,
- NULL,
-};
-
-/* Monitor flags */
-static GarconMenuMonitorFlags garcon_menu_monitor_flags;
-
-/* User data as provided by the client */
-static gpointer garcon_menu_monitor_user_data = NULL;
-
-/* Hash table with (GarconMenuItem => gpointer) pairs */
-static GHashTable *garcon_menu_monitor_item_handles;
-
-/* Hash table with (Directory => gpointer) pairs */
-static GHashTable *garcon_menu_monitor_shared_handles;
-
-/* Structure for directory handles */
-typedef struct _SharedHandle
-{
- gpointer monitor_handle;
- int references;
-} SharedHandle;
-
-
-
-void
-_garcon_menu_monitor_init (void)
-{
- /* Initialize hash tables */
- garcon_menu_monitor_item_handles = g_hash_table_new (NULL, NULL);
- garcon_menu_monitor_shared_handles = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- garcon_menu_monitor_flags = GARCON_MENU_MONITOR_DIRECTORIES
- | GARCON_MENU_MONITOR_MENU_FILES
- | GARCON_MENU_MONITOR_DIRECTORY_FILES
- | GARCON_MENU_MONITOR_DESKTOP_FILES;
-}
-
-
-
-void
-_garcon_menu_monitor_shutdown (void)
-{
- g_hash_table_unref (garcon_menu_monitor_item_handles);
- g_hash_table_unref (garcon_menu_monitor_shared_handles);
-}
-
-
-
-/**
- * garcon_menu_monitor_set_vtable:
- * @vtable : a #GarconMenuMonitorVTable
- * @user_data : custom pointer to be passed to the vtable functions.
- *
- * Sets the functions to be called when monitoring a file or directory
- * becomes necessary. See #GarconMenuMonitorVTable for more detailled
- * information. Be careful with redefining the #GarconMenuMonitorVTable
- * (e.g. don't redefine it while there are any #GarconMenu's around).
- *
- * In order to change the user data, just pass the same
- * #GarconMenuMonitorVTable as you did before. Pass NULL to clear the
- * vtable (e.g. if you want to disable monitoring support).
- */
-void
-garcon_menu_monitor_set_vtable (GarconMenuMonitorVTable *vtable,
- gpointer user_data)
-{
- if (G_UNLIKELY (vtable == NULL))
- {
- garcon_menu_monitor_vtable.monitor_file = NULL;
- garcon_menu_monitor_vtable.monitor_directory = NULL;
- garcon_menu_monitor_vtable.remove_monitor = NULL;
- }
- else
- {
- garcon_menu_monitor_vtable.monitor_file = vtable->monitor_file;
- garcon_menu_monitor_vtable.monitor_directory = vtable->monitor_directory;
- garcon_menu_monitor_vtable.remove_monitor = vtable->remove_monitor;
- }
-
- garcon_menu_monitor_user_data = user_data;
-}
-
-
-
-gpointer
-garcon_menu_monitor_add_item (GarconMenu *menu,
- GarconMenuItem *item)
-{
- gpointer monitor_handle;
-
- g_return_val_if_fail (GARCON_IS_MENU (menu), NULL);
- g_return_val_if_fail (GARCON_IS_MENU_ITEM (item), NULL);
-
- if (G_UNLIKELY (garcon_menu_monitor_vtable.monitor_file == NULL))
- return NULL;
-
- /* Request monitor handle from the library client */
- monitor_handle = garcon_menu_monitor_vtable.monitor_file (menu, garcon_menu_item_get_filename (item),
- garcon_menu_monitor_user_data);
-
- if (G_LIKELY (monitor_handle != NULL))
- {
- /* Store the item => handle pair in the hash table */
- g_hash_table_insert (garcon_menu_monitor_item_handles, item, monitor_handle);
- }
-
- return monitor_handle;
-}
-
-
-
-void
-garcon_menu_monitor_remove_item (GarconMenu *menu,
- GarconMenuItem *item)
-{
- gpointer monitor_handle;
-
- g_return_if_fail (GARCON_IS_MENU_ITEM (item));
-
- if (G_UNLIKELY (garcon_menu_monitor_vtable.remove_monitor == NULL))
- return;
-
- /* Lookup the monitor handle for this item */
- monitor_handle = g_hash_table_lookup (garcon_menu_monitor_item_handles, item);
-
- if (G_LIKELY (monitor_handle != NULL))
- {
- /* Remove monitor handle from the library client */
- garcon_menu_monitor_vtable.remove_monitor (menu, monitor_handle);
-
- /* ... and remove the item from the hash table */
- g_hash_table_remove (garcon_menu_monitor_item_handles, item);
- }
-}
-
-
-
-gpointer
-garcon_menu_monitor_add_directory (GarconMenu *menu,
- const gchar *directory)
-{
- SharedHandle *shared_handle;
- gpointer monitor_handle;
-
- g_return_val_if_fail (GARCON_IS_MENU (menu), NULL);
- g_return_val_if_fail (directory != NULL, NULL);
-
- if (G_UNLIKELY (garcon_menu_monitor_vtable.monitor_directory == NULL))
- return NULL;
-
- /* Load directory handle from the hash table */
- shared_handle = (SharedHandle *)g_hash_table_lookup (garcon_menu_monitor_shared_handles,
- directory);
-
- /* Check if the directory is already monitored */
- if (G_LIKELY (shared_handle != NULL))
- {
- /* Increment reference counter */
- shared_handle->references++;
-
- /* Return the monitor handle */
- monitor_handle = shared_handle->monitor_handle;
- }
- else
- {
- /* Request monitor handle from the library client */
- monitor_handle = garcon_menu_monitor_vtable.monitor_directory (menu, directory,
- garcon_menu_monitor_user_data);
-
- if (G_LIKELY (monitor_handle != NULL))
- {
- /* Allocate new directory handle */
- shared_handle = g_new0 (SharedHandle, 1);
-
- /* Set values (reference counter starts with 1) */
- shared_handle->references = 1;
- shared_handle->monitor_handle = monitor_handle;
-
- /* Store the item => handle pair in the hash table */
- g_hash_table_insert (garcon_menu_monitor_shared_handles,
- g_strdup (directory), shared_handle);
- }
- }
-
- return monitor_handle;
-}
-
-
-
-void
-garcon_menu_monitor_remove_directory (GarconMenu *menu,
- const gchar *directory)
-{
- SharedHandle *shared_handle;
-
- g_return_if_fail (directory != NULL);
-
- if (G_UNLIKELY (garcon_menu_monitor_vtable.remove_monitor == NULL))
- return;
-
- /* Lookup the directory handle for this directory */
- shared_handle = g_hash_table_lookup (garcon_menu_monitor_shared_handles, directory);
-
- if (G_LIKELY (shared_handle != NULL))
- {
- /* Decrement the reference counter */
- shared_handle->references--;
-
- /* Check if there are no references left */
- if (G_UNLIKELY (shared_handle->references == 0))
- {
- /* Remove monitor handle from the library client */
- garcon_menu_monitor_vtable.remove_monitor (menu, shared_handle->monitor_handle);
-
- /* Remove directory handle from the hash table and destroy it */
- g_hash_table_remove (garcon_menu_monitor_shared_handles, directory);
- }
- }
-}
-
-
-
-gpointer
-garcon_menu_monitor_add_file (GarconMenu *menu,
- const gchar *filename)
-{
- SharedHandle *shared_handle;
- gpointer monitor_handle;
-
- g_return_val_if_fail (GARCON_IS_MENU (menu), NULL);
- g_return_val_if_fail (filename != NULL, NULL);
-
- if (G_UNLIKELY (garcon_menu_monitor_vtable.monitor_file == NULL))
- return NULL;
-
- /* Load filename handle from the hash table */
- shared_handle = (SharedHandle *)g_hash_table_lookup (garcon_menu_monitor_shared_handles,
- filename);
-
- /* Check if the file is already monitored */
- if (G_LIKELY (shared_handle != NULL))
- {
- /* Increment reference counter */
- shared_handle->references++;
-
- /* Return the monitor handle */
- monitor_handle = shared_handle->monitor_handle;
- }
- else
- {
- /* Request monitor handle from the library client */
- monitor_handle = garcon_menu_monitor_vtable.monitor_file (menu, filename,
- garcon_menu_monitor_user_data);
-
- if (G_LIKELY (monitor_handle != NULL))
- {
- /* Allocate new filename handle */
- shared_handle = g_new0 (SharedHandle, 1);
-
- /* Set values (reference counter starts with 1) */
- shared_handle->references = 1;
- shared_handle->monitor_handle = monitor_handle;
-
- /* Store the item => handle pair in the hash table */
- g_hash_table_insert (garcon_menu_monitor_shared_handles,
- g_strdup (filename), shared_handle);
- }
- }
-
- return monitor_handle;
-}
-
-
-
-void
-garcon_menu_monitor_remove_file (GarconMenu *menu,
- const gchar *filename)
-{
- SharedHandle *shared_handle;
-
- g_return_if_fail (GARCON_IS_MENU (menu));
- g_return_if_fail (filename != NULL);
-
- if (G_UNLIKELY (garcon_menu_monitor_vtable.remove_monitor == NULL))
- return;
-
- /* Lookup the filename handle for this file */
- shared_handle = g_hash_table_lookup (garcon_menu_monitor_shared_handles, filename);
-
- if (G_LIKELY (shared_handle != NULL))
- {
- /* Decrement the reference counter */
- shared_handle->references--;
-
- /* Check if there are no references left */
- if (G_UNLIKELY (shared_handle->references == 0))
- {
- /* Remove monitor handle from the library client */
- garcon_menu_monitor_vtable.remove_monitor (menu, shared_handle->monitor_handle);
-
- /* Remove filename handle from the hash table and destroy it */
- g_hash_table_remove (garcon_menu_monitor_shared_handles, shared_handle);
- }
- }
-}
-
-
-
-void
-garcon_menu_monitor_set_flags (GarconMenuMonitorFlags flags)
-{
- garcon_menu_monitor_flags = flags;
-}
-
-
-
-GarconMenuMonitorFlags
-garcon_menu_monitor_get_flags (void)
-{
- return garcon_menu_monitor_flags;
-}
-
-
-
-gboolean
-garcon_menu_monitor_has_flags (GarconMenuMonitorFlags flags)
-{
- return (garcon_menu_monitor_flags & flags) != 0;
-}
-
diff --git a/garcon/garcon-menu-monitor.h b/garcon/garcon-menu-monitor.h
deleted file mode 100644
index ce8e4f4..0000000
--- a/garcon/garcon-menu-monitor.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* vi:set et ai sw=2 sts=2 ts=2: */
-/*-
- * Copyright (c) 2006-2009 Jannis Pohlmann <jannis at xfce.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#if !defined (GARCON_INSIDE_GARCON_H) && !defined (GARCON_COMPILATION)
-#error "Only <garcon/garcon.h> can be included directly. This file may disappear or change contents."
-#endif
-
-#ifndef __GARCON_MENU_MONITOR_H__
-#define __GARCON_MENU_MONITOR_H__
-
-#include <garcon/garcon.h>
-
-G_BEGIN_DECLS
-
-typedef enum
-{
- GARCON_MENU_MONITOR_DIRECTORIES = 1 << 0,
- GARCON_MENU_MONITOR_MENU_FILES = 1 << 1,
- GARCON_MENU_MONITOR_DIRECTORY_FILES = 1 << 2,
- GARCON_MENU_MONITOR_DESKTOP_FILES = 1 << 3
-} GarconMenuMonitorFlags;
-
-typedef struct _GarconMenuMonitorVTable GarconMenuMonitorVTable;
-
-void garcon_menu_monitor_set_vtable (GarconMenuMonitorVTable *vtable,
- gpointer user_data);
-gpointer garcon_menu_monitor_add_item (GarconMenu *menu,
- GarconMenuItem *item);
-void garcon_menu_monitor_remove_item (GarconMenu *menu,
- GarconMenuItem *item);
-gpointer garcon_menu_monitor_add_directory (GarconMenu *menu,
- const gchar *directory);
-void garcon_menu_monitor_remove_directory (GarconMenu *menu,
- const gchar *directory);
-gpointer garcon_menu_monitor_add_file (GarconMenu *menu,
- const gchar *filename);
-void garcon_menu_monitor_remove_file (GarconMenu *menu,
- const gchar *filename);
-void garcon_menu_monitor_set_flags (GarconMenuMonitorFlags flags);
-GarconMenuMonitorFlags garcon_menu_monitor_get_flags (void);
-gboolean garcon_menu_monitor_has_flags (GarconMenuMonitorFlags flags);
-
-/**
- * GarconMenuMonitorVTable:
- * @monitor_file : Function called by garcon to request that
- * a file should be monitored.
- * @monitor_directory : Function called by garcon to request that
- * a directory should be monitored.
- * @remove_monitor : Function called by garcon to request that
- * a file or directory monitor should be
- * cancelled/removed.
- *
- * This structure can be used by clients of the garcon API to
- * register functions which will be called whenever monitoring a
- * certain file or directory becomes necessary. This way garcon
- * only has to manage the monitor handles and leaves the monitoring
- * implementations to the client.
- *
- * This mechanism was invented because the two main API clients,
- * Thunar and xfdesktop are already linked to ThunarVFS which has
- * monitoring capabilities.
- **/
-struct _GarconMenuMonitorVTable
-{
- gpointer (*monitor_file) (GarconMenu *menu,
- const gchar *filename,
- gpointer user_data);
-
- gpointer (*monitor_directory) (GarconMenu *menu,
- const gchar *filename,
- gpointer user_data);
-
- void (*remove_monitor) (GarconMenu *menu,
- gpointer monitor_handle);
-};
-
-#if defined(GARCON_COMPILATION)
-void _garcon_menu_monitor_init (void) G_GNUC_INTERNAL;
-void _garcon_menu_monitor_shutdown (void) G_GNUC_INTERNAL;
-#endif
-
-G_END_DECLS
-
-#endif /* !__GARCON_MENU_MONITOR_H__ */
diff --git a/garcon/garcon-menu.c b/garcon/garcon-menu.c
index 0e41e24..b883353 100644
--- a/garcon/garcon-menu.c
+++ b/garcon/garcon-menu.c
@@ -34,7 +34,6 @@
#include <garcon/garcon-menu-directory.h>
#include <garcon/garcon-menu-item-cache.h>
#include <garcon/garcon-menu-separator.h>
-#include <garcon/garcon-menu-monitor.h>
#include <garcon/garcon-menu-node.h>
#include <garcon/garcon-menu-parser.h>
#include <garcon/garcon-menu-merger.h>
@@ -134,8 +133,6 @@ static const gchar *garcon_menu_get_element_icon_name (GarconM
static gboolean garcon_menu_get_element_visible (GarconMenuElement *element);
static gboolean garcon_menu_get_element_show_in_environment (GarconMenuElement *element);
static gboolean garcon_menu_get_element_no_display (GarconMenuElement *element);
-static void garcon_menu_monitor_start (GarconMenu *menu);
-static void garcon_menu_monitor_stop (GarconMenu *menu);
@@ -252,9 +249,6 @@ garcon_menu_finalize (GObject *object)
{
GarconMenu *menu = GARCON_MENU (object);
- /* Stop monitoring */
- garcon_menu_monitor_stop (menu);
-
/* Destroy the menu tree */
if (menu->priv->parent == NULL)
garcon_menu_node_tree_free (menu->priv->tree);
@@ -593,9 +587,6 @@ garcon_menu_load (GarconMenu *menu,
g_hash_table_unref (desktop_id_table);
- /* Start monitoring */
- garcon_menu_monitor_start (menu);
-
return TRUE;
}
@@ -1495,91 +1486,3 @@ garcon_menu_get_element_no_display (GarconMenuElement *element)
else
return garcon_menu_directory_get_no_display (menu->priv->directory);
}
-
-
-
-static void
-item_monitor_start (const gchar *desktop_id,
- GarconMenuItem *item,
- GarconMenu *menu)
-{
- garcon_menu_monitor_add_item (menu, item);
-}
-
-
-
-static void
-garcon_menu_monitor_start (GarconMenu *menu)
-{
- GList *iter;
-
- g_return_if_fail (GARCON_IS_MENU (menu));
-
- /* TODO Make monitoring work properly again */
-#if 0
- /* Monitor the menu file */
- if (G_LIKELY (garcon_menu_monitor_has_flags (GARCON_MENU_MONITOR_MENU_FILES)))
- garcon_menu_monitor_add_file (menu, menu->priv->filename);
-
- /* Monitor the menu directory file */
- if (G_LIKELY (GARCON_IS_MENU_DIRECTORY (menu->priv->directory)
- && garcon_menu_monitor_has_flags (GARCON_MENU_MONITOR_DIRECTORY_FILES)))
- {
- garcon_menu_monitor_add_file (menu, garcon_menu_directory_get_filename (menu->priv->directory));
- }
-
- /* Monitor the application directories */
- if (G_LIKELY (garcon_menu_monitor_has_flags (GARCON_MENU_MONITOR_DIRECTORIES)))
- for (iter = menu->priv->app_dirs; iter != NULL; iter = g_list_next (iter))
- garcon_menu_monitor_add_directory (menu, (const gchar *)iter->data);
-#endif
-
- /* Monitor items in the menu pool */
- if (G_LIKELY (garcon_menu_monitor_has_flags (GARCON_MENU_MONITOR_DESKTOP_FILES)))
- garcon_menu_item_pool_foreach (menu->priv->pool, (GHFunc) item_monitor_start, menu);
-
- /* Monitor items in submenus */
- for (iter = menu->priv->submenus; iter != NULL; iter = g_list_next (iter))
- garcon_menu_monitor_start (GARCON_MENU (iter->data));
-}
-
-
-
-static void
-item_monitor_stop (const gchar *desktop_id,
- GarconMenuItem *item,
- GarconMenu *menu)
-{
- garcon_menu_monitor_remove_item (menu, item);
-}
-
-
-
-static void
-garcon_menu_monitor_stop (GarconMenu *menu)
-{
- GList *iter;
-
- g_return_if_fail (GARCON_IS_MENU (menu));
-
- /* Stop monitoring items in submenus */
- for (iter = menu->priv->submenus; iter != NULL; iter = g_list_next (iter))
- garcon_menu_monitor_stop (GARCON_MENU (iter->data));
-
- /* Stop monitoring the items */
- garcon_menu_item_pool_foreach (menu->priv->pool, (GHFunc) item_monitor_stop, menu);
-
- /* TODO Make monitoring work properly again */
-#if 0
- /* Stop monitoring the application directories */
- for (iter = menu->priv->app_dirs; iter != NULL; iter = g_list_next (iter))
- garcon_menu_monitor_remove_directory (menu, (const gchar *)iter->data);
-
- /* Stop monitoring the menu directory file */
- if (GARCON_IS_MENU_DIRECTORY (menu->priv->directory))
- garcon_menu_monitor_remove_file (menu, garcon_menu_directory_get_filename (menu->priv->directory));
-
- /* Stop monitoring the menu file */
- garcon_menu_monitor_remove_file (menu, menu->priv->filename);
-#endif
-}
diff --git a/garcon/garcon.c b/garcon/garcon.c
index c4ed531..0eda8a4 100644
--- a/garcon/garcon.c
+++ b/garcon/garcon.c
@@ -28,7 +28,6 @@
#include <garcon/garcon-environment.h>
#include <garcon/garcon-menu-item-cache.h>
#include <garcon/garcon-menu-directory.h>
-#include <garcon/garcon-menu-monitor.h>
#include <garcon/garcon-menu-separator.h>
@@ -77,9 +76,6 @@ garcon_init (const gchar *env)
/* Initialize the directory module */
_garcon_menu_directory_init ();
- /* Initialize monitoring system */
- _garcon_menu_monitor_init ();
-
/* Creates the menu separator */
_garcon_menu_separator_init ();
}
@@ -103,9 +99,6 @@ garcon_shutdown (void)
/* Destroys the menu separator */
_garcon_menu_separator_shutdown ();
- /* Shutdown monitoring system */
- _garcon_menu_monitor_shutdown ();
-
/* Shutdown the directory module */
_garcon_menu_directory_shutdown ();
diff --git a/garcon/garcon.h b/garcon/garcon.h
index e757fa9..ee14acb 100644
--- a/garcon/garcon.h
+++ b/garcon/garcon.h
@@ -35,7 +35,6 @@
#include <garcon/garcon-menu-item-pool.h>
#include <garcon/garcon-menu-node.h>
#include <garcon/garcon-menu-merger.h>
-#include <garcon/garcon-menu-monitor.h>
#include <garcon/garcon-menu-parser.h>
#include <garcon/garcon-menu-separator.h>
#include <garcon/garcon-menu-tree-provider.h>
More information about the Xfce4-commits
mailing list