Alex, my answers of your question are inserted into the following mail body:


On Mon, Apr 20, 2009 at 9:01 PM, Alexander Larsson <al...@redhat.com> wrote:

> On Mon, 2009-04-20 at 15:10 +0800, JF Ding wrote:
> > Hi list,
> >   Recently I have added one new feature to nautilus in my local
> > branch: run nautilus as a daemon without any
> > window created (file explorer or desktop) and can monitor media
> > automount events.
> >   As we know, nautilus cannot startup with both --no-desktop and
> > --no-default-window options. But in the desktop
> > session of our current project, we need nautilus as the default file
> > manager but need not its desktop window. This
> > patch is to enable this requirement.
> >  Also this request and patch are files to bugzilla, the link is
> > http://bugzilla.gnome.org/show_bug.cgi?id=579574
>
>
> +      <key>/schemas/apps/nautilus/preferences/daemon_enable</key>
> +      <applyto>/apps/nautilus/preferences/daemon_enable</applyto>
>
> +#define
> NAUTILUS_PREFERENCES_DAEMON_ENABLE
>  "preferences/daemon_enable"
>
> A better name would be "daemon_mode"
>

> +static gboolean allow_daemon = FALSE;
>
> Same here, call it "daemon_mode".
>

About the variable names, including gconf key and the two new vars, the name
does be indicating the usage.
In fact, in my first design, the name of gconf key is "daemon_mode", but I
think it is not precise, because the key
is to indicate whether nautilus can run as a daemon. I rename it to
"daemon_enable".
The static global "allow_daemon", the same cause.
And the stack variable in main(), "daemon_mode" to be sync with command line
option "--daemon", its meaning
is whether it run in "daemon mode", which will not created desktop and
default window.
I hope this can be explained clearly. Of course I will rename them if you
cannot agree with the usage of them.


>
>
> @@ -139,6 +141,12 @@ nautilus_main_event_loop_quit (gboolean explicit)
>        while (event_loop_registrants != NULL) {
>                gtk_object_destroy (event_loop_registrants->data);
>        }
> +
> +       /* To quit all instances, disable daemon */
> +       if (allow_daemon) {
> +               allow_daemon = FALSE;
> +               eel_gtk_main_quit_all ();
> +       }
>  }
>
>  static void
>
> Only do this if explicit is TRUE. It is always true atm, but that may
> change.


These lines is for quit by "--quit" option. If the first instance of
nautilus run with allow_daemon TRUE,
and another new nautilus instance send CLOSE message to it, the code will
reach here, and must reset allow_daemon
to FALSE and go quit. Maybe it's not so neat here, any suggestion?


>
>
> +               { "daemon", '\0', 0, G_OPTION_ARG_NONE, &daemon_mode,
> +                 N_("Start Nautilus as a daemon for media automount."),
> NULL },
>
> I don't understand why you added the command line argument. It seems to
> just


--daemon option will suppress any window explicitly. And can run as daemon
without
gconf key settings.

complicate everything and have no additional gain. For instance, if
> you pass --daemon and another nautilus is already running then you
> would need to call into the running instance and tell it to enable
> daemon mode. All this seems unnecessary and we should just drop the
> --daemon switch.
>
> However, you need to fix the handling of the gconf setting so that if
> the setting is changed this is picked up during runtime. Easiest way
> to do this is with eel_preferences_add_auto_boolean, however in this
> case you probably have to use eel_preferences_add_callback since you
> don't just want to update the daemon_mode boolean but also ensure that
> we exit if the value goes from TRUE to FALSE when there are no windows
> availible.
>

Yeah, these more requirement is not met by now.
You know, this my first time to dive into nautilus codes, there may be some
wrong way
in my solution:)
Thanks a lot.

Regards,
jf.ding
--
nautilus-list mailing list
nautilus-list@gnome.org
http://mail.gnome.org/mailman/listinfo/nautilus-list

Reply via email to