[Xfce4-commits] <garcon:jannis/global-monitoring> Add garcon-marshal.list and GarconMenu::directory-changed signal.
Jannis Pohlmann
noreply at xfce.org
Sun Sep 5 14:50:05 CEST 2010
Updating branch refs/heads/jannis/global-monitoring
to d52de109946d56701477515c6712099c2769a6b3 (commit)
from 79683094e2414643c87ff889ba664c7f04536079 (commit)
commit d52de109946d56701477515c6712099c2769a6b3
Author: Jannis Pohlmann <jannis at xfce.org>
Date: Tue Mar 9 12:06:03 2010 +0100
Add garcon-marshal.list and GarconMenu::directory-changed signal.
The signal is supposed to be emitted whenever the GarconMenuDirectory
contents have changed and were updated or when the GarconMenuDirectory
was replaced with a different file.
garcon/Makefile.am | 73 ++++++++++++++++++++++++++++++++++++--------
garcon/garcon-marshal.list | 1 +
garcon/garcon-menu.c | 73 +++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 133 insertions(+), 14 deletions(-)
diff --git a/garcon/Makefile.am b/garcon/Makefile.am
index 84bc7e8..e92aace 100644
--- a/garcon/Makefile.am
+++ b/garcon/Makefile.am
@@ -27,36 +27,45 @@ INCLUDES = \
lib_LTLIBRARIES = \
libgarcon-1.la
+libgarcon_built_public_sources = \
+ garcon-marshal.h
+
+libgarcon_built_sources = \
+ $(libgarcon_built_public_sources) \
+ garcon-marshal.c
+
libgarcon_headers = \
garcon.h \
garcon-config.h \
- garcon-menu-element.h \
- garcon-menu-separator.h \
+ garcon-environment.h \
+ garcon-marshal.h \
garcon-menu-directory.h \
+ garcon-menu-element.h \
garcon-menu-item-pool.h \
garcon-menu-item-cache.h \
- garcon-environment.h \
- garcon-menu.h \
garcon-menu-item.h \
+ garcon-menu-merger.h \
garcon-menu-node.h \
+ garcon-menu-parser.h \
+ garcon-menu-separator.h \
garcon-menu-tree-provider.h \
- garcon-menu-merger.h \
- garcon-menu-parser.h
+ garcon-menu.h
libgarcon_sources = \
garcon-config.c \
- garcon-menu-element.c \
- garcon-menu-separator.c \
+ garcon-environment.c \
+ garcon-marshal.c \
garcon-menu-directory.c \
+ garcon-menu-element.c \
garcon-menu-item-pool.c \
garcon-menu-item-cache.c \
- garcon-environment.c \
- garcon-menu.c \
garcon-menu-item.c \
- garcon-menu-node.c \
- garcon-menu-tree-provider.c \
garcon-menu-merger.c \
+ garcon-menu-node.c \
garcon-menu-parser.c \
+ garcon-menu-separator.c \
+ garcon-menu-tree-provider.c \
+ garcon-menu.c \
garcon-private.c \
garcon-private.h
@@ -88,10 +97,48 @@ libgarcon_1_la_LIBADD = \
$(GIO_LIBS)
EXTRA_DIST = \
- garcon-config.h.in
+ garcon-config.h.in \
+ garcon-marshal.list
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = garcon-1.pc
+DISTCLEANFILES = \
+ stamp-garcon-marshal.h \
+ garcon-config.h \
+ $(libgarcon_built_sources)
+
+BUILT_SOURCES = \
+ $(libgarcon_built_sources)
+
+garcon-marshal.h: stamp-garcon-marshal.h
+ @true
+
+stamp-garcon-marshal.h: garcon-marshal.list Makefile
+ $(AM_V_GEN) ( \
+ cd $(top_builddir)/garcon \
+ && echo "#ifndef __GARCON_MARSHAL_H__" > xgen-emh \
+ && echo "#define __GARCON_MARSHAL_H__" >> xgen-emh \
+ && ( glib-genmarshal \
+ --prefix=garcon_marshal \
+ --header $(srcdir)/garcon-marshal.list ) >> xgen-emh \
+ && echo "#endif /* !__GARCON_MARSHAL_H__ */" >> xgen-emh \
+ && ( cmp -s xgen-emh garcon-marshal.h \
+ || cp xgen-emh garcon-marshal.h ) \
+ && rm -f xgen-emh \
+ && echo timestamp > $(@F) \
+ )
+
+garcon-marshal.c: garcon-marshal.list Makefile
+ $(AM_V_GEN) ( \
+ cd $(top_builddir)/garcon \
+ && echo "#include <garcon/garcon-marshal.h>" > xgen-emc \
+ && ( glib-genmarshal \
+ --prefix=garcon_marshal \
+ --body $(srcdir)/garcon-marshal.list ) >> xgen-emc \
+ && cp xgen-emc garcon-marshal.c \
+ && rm -f xgen-emc \
+ )
+
# Required for gtk-doc and make distcheck
dist-hook: all
diff --git a/garcon/garcon-marshal.list b/garcon/garcon-marshal.list
new file mode 100644
index 0000000..38076d6
--- /dev/null
+++ b/garcon/garcon-marshal.list
@@ -0,0 +1 @@
+VOID:OBJECT,OBJECT
diff --git a/garcon/garcon-menu.c b/garcon/garcon-menu.c
index 579fc01..043c72e 100644
--- a/garcon/garcon-menu.c
+++ b/garcon/garcon-menu.c
@@ -29,6 +29,7 @@
#include <glib/gi18n.h>
#include <garcon/garcon-environment.h>
+#include <garcon/garcon-marshal.h>
#include <garcon/garcon-menu-element.h>
#include <garcon/garcon-menu-item.h>
#include <garcon/garcon-menu-directory.h>
@@ -101,6 +102,7 @@ enum
enum
{
RELOAD_REQUIRED,
+ DIRECTORY_CHANGED,
LAST_SIGNAL,
};
@@ -163,6 +165,11 @@ static void garcon_menu_merge_dir_changed (GarconM
GFile *other_file,
GFileMonitorEvent event_type,
GFileMonitor *monitor);
+static void garcon_menu_directory_file_changed (GarconMenu *menu,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ GFileMonitor *monitor);
@@ -259,6 +266,19 @@ garcon_menu_class_init (GarconMenuClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+
+ menu_signals[DIRECTORY_CHANGED] =
+ g_signal_new ("directory-changed",
+ GARCON_TYPE_MENU,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_HOOKS,
+ 0,
+ NULL,
+ NULL,
+ garcon_marshal_VOID__OBJECT_OBJECT,
+ G_TYPE_NONE,
+ 2,
+ GARCON_TYPE_MENU_DIRECTORY,
+ GARCON_TYPE_MENU_DIRECTORY);
}
@@ -1658,6 +1678,7 @@ static void
garcon_menu_start_monitoring (GarconMenu *menu)
{
GFileMonitor *monitor;
+ GFile *file;
GList *lp;
g_return_if_fail (GARCON_IS_MENU (menu));
@@ -1696,7 +1717,21 @@ garcon_menu_start_monitoring (GarconMenu *menu)
}
}
- /* TODO monitor the .directory file */
+ /* Monitor the .directory file */
+ if (menu->priv->directory != NULL)
+ {
+ file = garcon_menu_directory_get_file (menu->priv->directory);
+
+ monitor = g_file_monitor (file, G_FILE_MONITOR_NONE, NULL, NULL);
+ if (monitor != NULL)
+ {
+ menu->priv->monitors = g_list_prepend (menu->priv->monitors, monitor);
+ g_signal_connect_swapped (monitor, "changed",
+ G_CALLBACK (garcon_menu_directory_file_changed), menu);
+ }
+
+ g_object_unref (file);
+ }
/* TODO monitor desktop directories */
@@ -1753,6 +1788,42 @@ garcon_menu_merge_dir_changed (GarconMenu *menu,
static void
+garcon_menu_directory_file_changed (GarconMenu *menu,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ GFileMonitor *monitor)
+{
+ g_return_if_fail (GARCON_IS_MENU (menu));
+ g_return_if_fail (menu->priv->parent == NULL);
+
+ g_debug ("directory file %s changed", g_file_get_path (file));
+
+ if (event_type == G_FILE_MONITOR_EVENT_CHANGED)
+ {
+ /* TODO reload the menu directory (we need a new method
+ * garcon_menu_directory_load() for this) and emit a
+ * GarconMenu::directory-changed signal */
+ }
+ else if (event_type == G_FILE_MONITOR_EVENT_DELETED)
+ {
+ /* TODO destroy the menu directory and emit a
+ * GarconMenu::directory-changed signal with the
+ * GarconMenuDirectory set to NULL */
+
+ /* TODO check if there is another MenuDirectory
+ * element that we can use and load instead. If this is
+ * the case, change the file of the current menu directory,
+ * reload it and emit a directory-changed signal.
+ * otherwise destroy the menu directory and emit
+ * a directory-changed signal with the GarconMenuDirectory
+ * parameter set to NULL */
+ }
+}
+
+
+
+static void
garcon_menu_stop_monitoring (GarconMenu *menu)
{
GList *lp;
More information about the Xfce4-commits
mailing list