libxfce4menu filesystem monitoring

Jannis Pohlmann jannis at xfce.org
Thu Sep 20 21:59:37 CEST 2007


Am Thu, 20 Sep 2007 01:02:04 +0200
schrieb Jannis Pohlmann <jannis at xfce.org>:

> Am Thu, 20 Sep 2007 00:41:19 +0200
> schrieb Jannis Pohlmann <jannis at xfce.org>:
> 
> > Could you perhaps check if it works for you as well? I haven't
> > looked into what effects my changes might have on xfdesktop.
> 
> BTW, here's what I checked:
> 
> ... (snip) ...
>
> As you can see, almost everything does what it should, except for
> editing the .desktop files. I don't really know what might be going on
> there, but I'm sure we'll find out.

Sigh. All this works independently of libxfce4menu as the monitoring is
completely implemented in xfdesktop at the moment ...

Brian, this is all you need to do to use the new feature in xfdesktop:

  1. Create a XfceMenuMonitorVTable:

      struct _XfceMenuMonitorVTable
      {
         gpointer (*monitor_file)      (XfceMenu    *menu,
                                        const gchar *filename,
                                        gpointer     user_data);

         gpointer (*monitor_directory) (XfceMenu    *menu,
                                        const gchar *filename,
                                        gpointer     user_data);
       
         void     (*remove_monitor)    (XfceMenu    *menu,
                                        gpointer     monitor_handle);
      };

     This VTable defines methods for creating file and directory
     monitors as well as for removing them. Creating and reacting
     on those monitors is your part (I think we discussed that already,
     but that's been some time ago, so ... whatever).

  2. Call xfce_menu_monitor_set_vtable() before anything else (but
     after xfce_menu_init()).

  3. In the monitor_file and monitor_directory functions just request a 
     ThunarVfsMonitorHandle from the ThunarVfsMonitor and return it.
     You don't have to keep a list of handles as they are managed by
     libxfce4menu. 

  4. In the remove_monitor function, just remove the 
     ThunarVfsMonitorHandle from the default ThunarVfsMonitor. The
     second parameter to remove_monitor is guaranteed to be a
     ThunarVfsMonitorHandle*. The remove_monitor function is called in
     the finalize method of XfceMenu, so when you call g_object_unref()
     on the root menu all monitors will be removed using the
     remove_monitor function xfdesktop provides.

  5. Whenever a monitored file or directory changes, rebuild the whole
     menu and that's it.

I noticed that you call g_object_unref() on the XfceMenu after you have
generated the menu widgets. This will cause all monitors to be removed
(shortly after they were created). So you're somewhat forced to keep
the XfceMenu around and destroy it before rebuilding the menu or before
xfdesktop exits.

Have fun with it, I really hope it works flawlessly.

 - Jannis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.xfce.org/pipermail/xfce4-dev/attachments/20070920/dbdc31b8/attachment.pgp>


More information about the Xfce4-dev mailing list