Updating branch refs/heads/master
         to 4dfba2d40e3d5bd287fa472908484b5727b4131a (commit)
       from e800fd648fa1def4e8d0c5bf91bc6912699b28e0 (commit)

commit 4dfba2d40e3d5bd287fa472908484b5727b4131a
Author: Enrico Tröger <enr...@xfce.org>
Date:   Sun May 6 16:43:03 2012 +0200

    Add new command-line option to auto connect bookmarks

 gigolo.1.in |    2 ++
 src/main.c  |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/gigolo.1.in b/gigolo.1.in
index e5efe6b..01a2da5 100644
--- a/gigolo.1.in
+++ b/gigolo.1.in
@@ -13,6 +13,8 @@ bookmarks to such.
 Homepage: http://www.uvena.de/gigolo/
 .SH "OPTIONS"
 If called without any arguments, the Gigolo main window is shown.
+.IP "\fB-a\fP, \fB\-\-auto\-connect\fP         " 10
+Connect all bookmarks which are marked as 'auto connect' and exit.
 .IP "\fB-i\fP, \fB\-\-new-instance\fP         " 10
 Don't find and show an already running instance of Gigolo, instead
 force opening a new instance.
diff --git a/src/main.c b/src/main.c
index 903ebae..3a3b705 100644
--- a/src/main.c
+++ b/src/main.c
@@ -39,10 +39,12 @@
 static gboolean show_version = FALSE;
 static gboolean list_schemes = FALSE;
 static gboolean new_instance = FALSE;
+static gboolean auto_connect = FALSE;
 extern gboolean verbose_mode;
 
 static GOptionEntry cli_options[] =
 {
+       { "auto-connect", 'a', 0, G_OPTION_ARG_NONE, &auto_connect, N_("Connect 
all bookmarks marked as 'auto connect' and exit"), NULL },
        { "new-instance", 'i', 0, G_OPTION_ARG_NONE, &new_instance, N_("Ignore 
running instances, enforce opening a new instance"), NULL },
        { "list-schemes", 'l', 0, G_OPTION_ARG_NONE, &list_schemes, N_("Print a 
list of supported URI schemes"), NULL },
        { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose_mode, N_("Be 
verbose"), NULL },
@@ -51,6 +53,37 @@ static GOptionEntry cli_options[] =
 };
 
 
+static gboolean auto_connect_bookmarks(void)
+{
+       GigoloBackendGVFS *backend_gvfs;
+       GigoloSettings *settings;
+       GigoloBookmarkList *bookmarks;
+       GigoloBookmark *bm;
+       guint i;
+       gchar *uri;
+
+       backend_gvfs = gigolo_backend_gvfs_new();
+       settings = gigolo_settings_new();
+       bookmarks = gigolo_settings_get_bookmarks(settings);
+
+       for (i = 0; i < bookmarks->len; i++)
+       {
+               bm = g_ptr_array_index(bookmarks, i);
+               if (gigolo_bookmark_get_autoconnect(bm) && ! 
gigolo_bookmark_get_should_not_autoconnect(bm))
+               {
+                       uri = gigolo_bookmark_get_uri_escaped(bm);
+                       /* Mounting happens asynchronously here and so we don't 
wait until it is finished
+                        * nor de we get any feedback or errors.
+                        * TODO make this synchronous(looping and checking) and 
check for errors */
+                       gigolo_backend_gvfs_mount_uri(backend_gvfs, uri, NULL, 
NULL, FALSE);
+                       g_free(uri);
+               }
+       }
+
+       return TRUE;
+}
+
+
 static void print_supported_schemes(void)
 {
        const gchar* const *supported;
@@ -102,6 +135,13 @@ gint main(gint argc, gchar** argv)
                return EXIT_SUCCESS;
        }
 
+       if (auto_connect)
+       {
+               gboolean ret = auto_connect_bookmarks();
+
+               return ret ? EXIT_SUCCESS : EXIT_FAILURE;
+       }
+
        if (! new_instance)
        {
                gis = gigolo_single_instance_new();
_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
https://mail.xfce.org/mailman/listinfo/xfce4-commits

Reply via email to