From e495a579d3cdd971510af455dcbd74cdf404003b Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Wed, 20 Jul 2011 23:31:39 +0000 Subject: [PATCH] (trunk gtk) #4366 "Use GAppInfo, rather than GConf2, for mime-type registration" -- done. --- configure.ac | 24 +--------------------- gtk/Makefile.am | 2 -- gtk/main.c | 43 ++++++++++------------------------------ transmission-gtk.spec.in | 2 -- 4 files changed, 12 insertions(+), 59 deletions(-) diff --git a/configure.ac b/configure.ac index 44fe9549a..947077f96 100644 --- a/configure.ac +++ b/configure.ac @@ -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} diff --git a/gtk/Makefile.am b/gtk/Makefile.am index a86a44085..2d1727259 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -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@ \ diff --git a/gtk/main.c b/gtk/main.c index 74bc7bf37..ca96ec063 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -37,11 +37,6 @@ #include #include -#ifdef HAVE_GCONF2 - #include - #include -#endif - #include #include #include @@ -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 ) + GAppInfo * app_info = g_app_info_get_default_for_uri_scheme( "magnet" ); + if( app_info == NULL ) { - gconf_value_free( value ); - return; + /* 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 ); + } } - - 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" ); - } - - g_object_unref( G_OBJECT( client ) ); -#endif } static void diff --git a/transmission-gtk.spec.in b/transmission-gtk.spec.in index fe80f866e..a9d44574e 100644 --- a/transmission-gtk.spec.in +++ b/transmission-gtk.spec.in @@ -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@