Re: How do I watch a file for changes using JS/Gnome Shell? [SOLVED]



Hi Bernd,

you can try to print/log the type of event generated.
A similar code is, in fedora 16, here: /usr/share/gnome-shell/js/ui/runDialog.js (function _onChanged).

--
  Stefano

On 12/25/2011 05:10 PM, Bernd Schlapsi wrote:
Hello Stefano,

I tried to use your code in my extension, but the log message appears 5
times for every file change.
Did you experience the same with your code?

  ~Bernd

On 12/22/2011 12:34 PM, Stefano Ciancio wrote:
Hi all,

with the help of Giovanni I succeeded in writing  an extension with
file monitoring.

In the following some parts of my code:

----

TestMonitor.prototype = {
     __proto__: PanelMenu.SystemStatusButton.prototype,

     _init: function() {
         ...
         let FILE_TO_MONITOR = '/path/of/file/to/monitoring';

         let file = Gio.file_new_for_path(FILE_TO_MONITOR);
         this._monitor = file.monitor(Gio.FileMonitorFlags.NONE, null);
         this._monitor.connect('changed', Lang.bind(this,
this._onChanged));
         ...
     },

     _onChanged : function () {
         global.log("Something has happened!");
     },
...

Thanks to all,

    Stefano


On 12/21/2011 11:28 AM, Giovanni Campagna wrote:
Il giorno mer, 21/12/2011 alle 11.25 +0100, Stefano Ciancio ha scritto:
I am testing with success GFileMonitor with python, but I have some
difficult with javascript.

Have you some example or link from which start?
No real world example, but should be as easy as
file = Gio.file_new_for_uri(uri)
monitor = file.monitor(Gio.FileMonitorFlags.NONE, cancellable);
monitor.connect('changed', function() {
     print("Something has happened!");
});

Giovanni

Thanks,
      Stefano


On 12/21/2011 11:15 AM, Giovanni Campagna wrote:
Il giorno mer, 21/12/2011 alle 08.51 +0100, Stefano Ciancio ha
scritto:
Hi all,

i have a configuration file written by a little python interface.
I want
to watch for changes of config file in gnome shell extension.
Each time a change occurs I'd like to reload new data in my
extension.

What's the best way to do this?
GFileMonitor (Gio.FileMonitor) it's what you're looking for. See the
docs in devhelp or online at developer.gnome.org/gio/unstable.

Giovanni


_______________________________________________
gnome-shell-list mailing list
gnome-shell-list gnome org
http://mail.gnome.org/mailman/listinfo/gnome-shell-list
_______________________________________________
gnome-shell-list mailing list
gnome-shell-list gnome org
http://mail.gnome.org/mailman/listinfo/gnome-shell-list
_______________________________________________
gnome-shell-list mailing list
gnome-shell-list gnome org
http://mail.gnome.org/mailman/listinfo/gnome-shell-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]