(trunk gtk) #4366 "Use GAppInfo, rather than GConf2, for mime-type registration"...
authorJordan Lee <jordan@transmissionbt.com>
Wed, 20 Jul 2011 23:31:39 +0000 (23:31 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Wed, 20 Jul 2011 23:31:39 +0000 (23:31 +0000)
configure.ac
gtk/Makefile.am
gtk/main.c
transmission-gtk.spec.in

index 44fe9549a4dc53a42d4add48f3ec830a4f1d3fda..947077f960603a63bd05a09885d74e3a36d807ed 100644 (file)
@@ -66,9 +66,6 @@ AC_SUBST(CANBERRA_MINIMUM)
 # inhibit hibernation when a torrent is active...
 DBUS_GLIB_MINIMUM=0.70
 AC_SUBST(DBUS_GLIB_MINIMUM)
-# register the GTK+ client as a magnet link handler...
-GCONF2_MINIMUM=2.20.0
-AC_SUBST(GCONF2_MINIMUM)
 # implement "watch" directories to use new .torrent files...
 GIO_MINIMUM=2.15.5
 AC_SUBST(GIO_MINIMUM)
@@ -266,7 +263,6 @@ use_libappindicator=no
 use_libnotify=no
 use_dbus_glib=no
 use_canberra=no
-use_gconf2=no
 if test "x$want_gtk" = "xyes" ; then
     if test "x$have_gtk" = "xyes"; then
       build_gtk=yes
@@ -340,23 +336,6 @@ if test "x$build_gtk" = "xyes"; then
         fi
     fi
 
-    PKG_CHECK_MODULES([GCONF2],
-                      [gconf-2.0 >= $GCONF2_MINIMUM],
-                      [have_gconf2=yes],
-                      [have_gconf2=no])
-    AC_ARG_ENABLE([gconf2], 
-                  AS_HELP_STRING([--enable-gconf2],[enable GConf support]),, 
-                  [enable_gconf2=yes]) 
-    if test "x$have_gconf2" = "xyes"; then
-        if test "x$enable_gconf2" = "xyes" ; then
-            use_gconf2=yes
-            AC_DEFINE([HAVE_GCONF2], 1) 
-        else
-            GCONF2_CFLAGS=
-            GCONF2_LIBS=
-        fi
-    fi
-
     PKG_CHECK_MODULES([DBUS_GLIB],
                       [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
                       [use_dbus_glib=yes],
@@ -536,10 +515,9 @@ Configuration:
      Optional dependencies for GTK+ client:
 
       * dbus support:                                 ${use_dbus_glib}
-      * gio for watchdir support:                     ${use_gio}
+      * gio for watchdir and mime-type support:       ${use_gio}
       * libnotify for 'download completed' popups:    ${use_libnotify}
       * libcanberra for 'download completed' sounds:  ${use_canberra}
-      * gconf2 to register as a magnet link handler:  ${use_gconf2}
       * libappindicator for an Ubuntu-style tray:     ${use_libappindicator}
 
    Build Daemon:                                      ${build_daemon}
index a86a44085e18569dfdb149d6db93d49b81f68218..2d17272594999b1bc5b0b9e9a125ca4c91a9bfd5 100644 (file)
@@ -16,7 +16,6 @@ AM_CFLAGS = \
     @LIBAPPINDICATOR_CFLAGS@ \
     @LIBEVENT_CFLAGS@ \
     @LIBCANBERRA_CFLAGS@ \
-    @GCONF2_CFLAGS@ \
     @GTK_CFLAGS@ \
     @LIBCURL_CFLAGS@ \
     @GIO_CFLAGS@ \
@@ -96,7 +95,6 @@ transmission_gtk_LDADD = \
     $(top_builddir)/third-party/miniupnp/libminiupnp.a \
     $(top_builddir)/third-party/libnatpmp/libnatpmp.a \
     @LIBCANBERRA_LIBS@ \
-    @GCONF2_LIBS@ \
     @DHT_LIBS@ \
     @LIBUTP_LIBS@ \
     @GTK_LIBS@ \
index 74bc7bf371eb79f5ba2f125fc04599e894d3df65..ca96ec063bc2be60923c1c61563f8c0cb20e1957 100644 (file)
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 
-#ifdef HAVE_GCONF2
- #include <gconf/gconf.h>
- #include <gconf/gconf-client.h>
-#endif
-
 #include <libtransmission/transmission.h>
 #include <libtransmission/rpcimpl.h>
 #include <libtransmission/utils.h>
@@ -362,35 +357,19 @@ static gboolean update_model( gpointer gdata );
 static void
 register_magnet_link_handler( void )
 {
-#ifdef HAVE_GCONF2
-    GError * err;
-    GConfValue * value;
-    GConfClient * client = gconf_client_get_default( );
-    const char * key = "/desktop/gnome/url-handlers/magnet/command";
-
-    /* if there's already a manget handler registered, don't do anything */
-    value = gconf_client_get( client, key, NULL );
-    if( value != NULL )
-    {
-        gconf_value_free( value );
-        return;
-    }
-
-    err = NULL;
-    if( !gconf_client_set_string( client, key, "transmission '%s'", &err ) )
-    {
-        tr_inf( "Unable to register Transmission as default magnet link handler: \"%s\"", err->message );
-        g_clear_error( &err );
-    }
-    else
-    {
-        gconf_client_set_bool( client, "/desktop/gnome/url-handlers/magnet/needs_terminal", FALSE, NULL );
-        gconf_client_set_bool( client, "/desktop/gnome/url-handlers/magnet/enabled", TRUE, NULL );
-        tr_inf( "Transmission registered as default magnet link handler" );
+    GAppInfo * app_info = g_app_info_get_default_for_uri_scheme( "magnet" );
+    if( app_info == NULL )
+    {
+        /* there's no default magnet handler, so register ourselves for the job... */
+        GError * error = NULL;
+        app_info = g_app_info_create_from_commandline( "transmission-gtk", "transmission-gtk", G_APP_INFO_CREATE_SUPPORTS_URIS, NULL );
+        g_app_info_set_as_default_for_type( app_info, "x-scheme-handler/magnet", &error );
+        if( error != NULL )
+        {
+            g_warning( _( "Error registering Transmission as x-scheme-handler/magnet handler: %s" ), error->message );
+            g_clear_error( &error );
+        }
     }
-
-    g_object_unref( G_OBJECT( client ) );
-#endif
 }
 
 static void
index fe80f866e5a5e35e221305bd6dc1cfe21ffe91fb..a9d44574e1128fa07cc707ba53f90b70c0e6c365 100644 (file)
@@ -27,11 +27,9 @@ BuildRequires: gtk2-devel >= @GTK_MINIMUM@
 Requires: glib2 >= @GLIB_MINIMUM@
 Requires: gtk2 >= @GTK_MINIMUM@
 # OPTIONAL for the gtk+ client... see configure.ac for details
-BuildRequires: GConf2-devel >= @GCONF2_MINIMUM@
 BuildRequires: dbus-glib-devel >= @DBUS_GLIB_MINIMUM@
 BuildRequires: libcanberra-devel >= @CANBERRA_MINIMUM@
 BuildRequires: libnotify-devel >= @LIBNOTIFY_MINIMUM@
-Requires: GConf2 >= @GCONF2_MINIMUM@
 Requires: dbus-glib >= @DBUS_GLIB_MINIMUM@
 Requires: libcanberra >= @CANBERRA_MINIMUM@
 Requires: libnotify >= @LIBNOTIFY_MINIMUM@