gvfs r1206 - in trunk: . gconf



Author: alexl
Date: Tue Jan 29 15:51:58 2008
New Revision: 1206
URL: http://svn.gnome.org/viewvc/gvfs?rev=1206&view=rev

Log:
2008-01-29  Alexander Larsson  <alexl redhat com>

        * Makefile.am:
        * configure.ac:
        * gconf/Makefile.am: Added.
        * gconf/gapplookupgconf.[ch]: Added.
        * gconf/gconf-module.c: Added.
	Add gconf based implementation of
	g_app_info_get_default_for_uri_scheme ()



Added:
   trunk/gconf/
   trunk/gconf/Makefile.am
   trunk/gconf/gapplookupgconf.c
   trunk/gconf/gapplookupgconf.h
   trunk/gconf/gconf-module.c
Modified:
   trunk/ChangeLog
   trunk/Makefile.am
   trunk/configure.ac

Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am	(original)
+++ trunk/Makefile.am	Tue Jan 29 15:51:58 2008
@@ -4,15 +4,14 @@
 	common \
 	client \
 	daemon \
+	gconf \
 	po   \
 	programs \
 	test \
 	$(NULL)
 
 if USE_HAL
-
 SUBDIRS += hal
-
 endif
 
 DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
@@ -28,4 +27,4 @@
 	intltool-extract	\
 	intltool-merge		\
 	intltool-update		\
-	$(NULL)
\ No newline at end of file
+	$(NULL)

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Tue Jan 29 15:51:58 2008
@@ -174,6 +174,28 @@
 AM_CONDITIONAL(USE_FUSE, [test "$msg_fuse" = "yes"])
 
 dnl **********************
+dnl *** Check for GConf ***
+dnl **********************
+AC_ARG_ENABLE(gconf, [  --disable-gconf           build without GConf support])
+msg_gconf=no
+GCONF_LIBS=
+GCONF_CFLAGS=
+
+if test "x$enable_gconf" != "xno"; then
+  PKG_CHECK_EXISTS(gconf-2.0, msg_gconf=yes)
+
+  if test "x$msg_gconf" == "xyes"; then
+    PKG_CHECK_MODULES(GCONF, gconf-2.0)
+    AC_DEFINE(HAVE_GCONF, 1, [Define to 1 if GConf is available])
+  fi
+fi
+
+AC_SUBST(GCONF_LIBS)
+AC_SUBST(GCONF_CFLAGS)
+
+AM_CONDITIONAL(USE_GCONF, [test "$msg_gconf" = "yes"])
+
+dnl **********************
 dnl *** Check for HAL ***
 dnl **********************
 AC_ARG_ENABLE(hal, [  --disable-hal           build without HAL support])
@@ -329,6 +351,7 @@
 client/Makefile
 daemon/Makefile
 hal/Makefile
+gconf/Makefile
 programs/Makefile
 test/Makefile
 po/Makefile.in
@@ -341,5 +364,6 @@
 	Samba support:	              $msg_samba
 	FUSE support:                 $msg_fuse
         CDDA support:                 $msg_cdda
+        GConf support:                $msg_gconf
 	Use HAL for volume monitor:   $msg_hal (with fast init path: $have_hal_fast_init)
 "

Added: trunk/gconf/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/gconf/Makefile.am	Tue Jan 29 15:51:58 2008
@@ -0,0 +1,33 @@
+
+NULL =
+
+module_flags = -export_dynamic -avoid-version -module -no-undefined -export-symbols-regex '^g_io_module_(load|unload)'
+
+if USE_GCONF
+giomodules_LTLIBRARIES = libgiogconf.la
+endif
+
+giomodulesdir = $(libdir)/gio/modules
+
+libgiogconf_la_SOURCES =				\
+	gapplookupgconf.c gapplookupgconf.h		\
+	gconf-module.c					\
+	$(NULL)
+
+libgiogconf_la_CFLAGS =		\
+	-DG_LOG_DOMAIN=\"GVFS-GConf\"		\
+	-I$(top_srcdir)/common                  \
+	$(GLIB_CFLAGS)                          \
+	$(GCONF_CFLAGS)                         \
+	-DGIO_MODULE_DIR=\"$(GIO_MODULE_DIR)\"	\
+	-DG_DISABLE_DEPRECATED			\
+	$(NULL)
+
+libgiogconf_la_LDFLAGS = 	\
+	$(module_flags)         \
+	$(NULL)
+
+libgiogconf_la_LIBADD  =	     \
+	$(GLIB_LIBS)                 \
+	$(GCONF_LIBS)                \
+	$(NULL)

Added: trunk/gconf/gapplookupgconf.c
==============================================================================
--- (empty file)
+++ trunk/gconf/gapplookupgconf.c	Tue Jan 29 15:51:58 2008
@@ -0,0 +1,192 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/* GIO - GLib Input, Output and Streaming Library
+ * 
+ * Copyright (C) 2006-2007 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Alexader Larsson <alexl redhat com>
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <gio/gio.h>
+#include <gconf/gconf-client.h>
+
+#include "gapplookupgconf.h"
+
+
+struct _GAppLookupGConf {
+  GObject parent;
+
+};
+
+static void lookup_iface_init (GDesktopAppInfoLookupIface *iface);
+static void g_app_lookup_gconf_finalize (GObject *object);
+
+#define _G_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init)       { \
+  const GInterfaceInfo g_implement_interface_info = { \
+    (GInterfaceInitFunc) iface_init, NULL, NULL \
+  }; \
+  g_type_module_add_interface (type_module, g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
+}
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (GAppLookupGConf, g_app_lookup_gconf, G_TYPE_OBJECT, 0,
+                                _G_IMPLEMENT_INTERFACE_DYNAMIC (G_TYPE_DESKTOP_APP_INFO_LOOKUP,
+                                                                lookup_iface_init))
+
+static void
+g_app_lookup_gconf_finalize (GObject *object)
+{
+  GAppLookupGConf *lookup;
+
+  lookup = G_APP_LOOKUP_GCONF (object);
+  
+  if (G_OBJECT_CLASS (g_app_lookup_gconf_parent_class)->finalize)
+    (*G_OBJECT_CLASS (g_app_lookup_gconf_parent_class)->finalize) (object);
+}
+
+static GObject *
+g_app_lookup_gconf_constructor (GType                  type,
+                                guint                  n_construct_properties,
+                                GObjectConstructParam *construct_properties)
+{
+  GObject *object;
+  GAppLookupGConf *lookup;
+  GAppLookupGConfClass *klass;
+  GObjectClass *parent_class;  
+
+  object = NULL;
+
+  /* Invoke parent constructor. */
+  klass = G_APP_LOOKUP_GCONF_CLASS (g_type_class_peek (G_TYPE_APP_LOOKUP_GCONF));
+  parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
+  object = parent_class->constructor (type,
+                                      n_construct_properties,
+                                      construct_properties);
+
+  lookup = G_APP_LOOKUP_GCONF (object);
+
+  return object;
+}
+
+static void
+g_app_lookup_gconf_init (GAppLookupGConf *lookup)
+{
+}
+
+static void
+g_app_lookup_gconf_class_finalize (GAppLookupGConfClass *klass)
+{
+}
+
+
+static void
+g_app_lookup_gconf_class_init (GAppLookupGConfClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->constructor = g_app_lookup_gconf_constructor;
+  gobject_class->finalize = g_app_lookup_gconf_finalize;
+}
+
+#define GCONF_PATH_PREFIX "/desktop/gnome/url-handlers/"
+
+static GAppInfo *
+get_default_for_uri_scheme (GDesktopAppInfoLookup *lookup,
+                            const char  *uri_scheme)
+{
+  GAppInfo *appinfo;
+  GConfClient *client;
+  char *command_key, *enabled_key, *terminal_key, *command;
+  gboolean enabled, needs_terminal;
+  GAppInfoCreateFlags flags;
+
+  appinfo = NULL;
+  
+  client = gconf_client_get_default ();
+  
+  command_key = g_strconcat (GCONF_PATH_PREFIX,
+                             uri_scheme,
+                             "/command",
+                             NULL);
+  command = gconf_client_get_string (client,
+                                     command_key,
+                                     NULL);
+  g_free (command_key);
+  if (command)
+    {
+      enabled_key = g_strconcat (GCONF_PATH_PREFIX,
+                                 uri_scheme,
+                                 "/enabled",
+                                 NULL);
+      enabled = gconf_client_get_bool (client,
+                                       enabled_key,
+                                       NULL);
+      g_free (enabled_key);
+      
+      terminal_key = g_strconcat (GCONF_PATH_PREFIX,
+                                  uri_scheme,
+                                  "/needs_terminal",
+                                  NULL);
+      needs_terminal = gconf_client_get_bool (client,
+                                              terminal_key,
+                                              NULL);
+      g_free (terminal_key);
+
+      if (enabled)
+        {
+          if (g_str_has_suffix (command, "\"\%s\"") ||
+              g_str_has_suffix (command, "\'\%s\'"))
+            command[strlen (command) - 4] = 0;
+          else if (g_str_has_suffix (command, "\%s"))
+            command[strlen (command) - 2] = 0;
+
+          flags = G_APP_INFO_CREATE_SUPPORTS_URIS;
+          if (needs_terminal)
+            flags |= G_APP_INFO_CREATE_NEEDS_TERMINAL;
+          appinfo = g_app_info_create_from_commandline (command,
+                                                        NULL,
+                                                        flags,
+                                                        NULL);
+        }
+    }
+  
+  g_object_unref (client);
+  
+  return appinfo;
+}
+
+static void
+lookup_iface_init (GDesktopAppInfoLookupIface *iface)
+{
+  iface->get_default_for_uri_scheme = get_default_for_uri_scheme;
+}
+
+void 
+g_app_lookup_gconf_register (GIOModule *module)
+{
+  g_app_lookup_gconf_register_type (G_TYPE_MODULE (module));
+  g_io_extension_point_implement (G_DESKTOP_APP_INFO_LOOKUP_EXTENSION_POINT_NAME,
+				  G_TYPE_APP_LOOKUP_GCONF,
+				  "gconf",
+				  10);
+}

Added: trunk/gconf/gapplookupgconf.h
==============================================================================
--- (empty file)
+++ trunk/gconf/gapplookupgconf.h	Tue Jan 29 15:51:58 2008
@@ -0,0 +1,53 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/* GIO - GLib Input, Output and Streaming Library
+ * 
+ * Copyright (C) 2006-2007 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Alexander Larsson <alexl redhat com>
+ */
+
+#ifndef __G_APP_LOOKUP_GCONF_H__
+#define __G_APP_LOOKUP_GCONF_H__
+
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
+
+
+G_BEGIN_DECLS
+
+#define G_TYPE_APP_LOOKUP_GCONF        (g_app_lookup_gconf_get_type ())
+#define G_APP_LOOKUP_GCONF(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_APP_LOOKUP_GCONF, GAppLookupGConf))
+#define G_APP_LOOKUP_GCONF_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_APP_LOOKUP_GCONF, GAppLookupGConfClass))
+#define G_IS_APP_LOOKUP_GCONF(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_APP_LOOKUP_GCONF))
+#define G_IS_APP_LOOKUP_GCONF_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_APP_LOOKUP_GCONF))
+
+typedef struct _GAppLookupGConf GAppLookupGConf;
+typedef struct _GAppLookupGConfClass GAppLookupGConfClass;
+
+struct _GAppLookupGConfClass {
+  GObjectClass parent_class;
+};
+
+GType g_app_lookup_gconf_get_type (void) G_GNUC_CONST;
+void  g_app_lookup_gconf_register (GIOModule         *module);
+
+G_END_DECLS
+
+#endif /* __G_APP_LOOKUP_GCONF_H__ */

Added: trunk/gconf/gconf-module.c
==============================================================================
--- (empty file)
+++ trunk/gconf/gconf-module.c	Tue Jan 29 15:51:58 2008
@@ -0,0 +1,40 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+
+/* GIO - GLib Input, Output and Streaming Library
+ * 
+ * Copyright (C) 2006-2007 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: David Zeuthen <davidz redhat com>
+ */
+
+#include <glib.h>
+#include <gmodule.h>
+#include <gio/gio.h>
+
+#include "gapplookupgconf.h"
+
+void
+g_io_module_load (GIOModule *module)
+{
+  g_app_lookup_gconf_register (module);
+}
+
+void
+g_io_module_unload (GIOModule *module)
+{
+}



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