(trunk gtk) #2629 "associate transmission with magnet links" -- implemented for GTK+ client on GNOME desktops with GConf2
This commit is contained in:
parent
03351e9a4e
commit
ce7cda7a66
54
configure.ac
54
configure.ac
|
@ -37,24 +37,26 @@ else
|
|||
fi
|
||||
AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno")
|
||||
|
||||
OPENSSL_MINIMUM=0.9.4
|
||||
CURL_MINIMUM=7.16.3
|
||||
GIO_MINIMUM=2.15.5
|
||||
GLIB_MINIMUM=2.6.0
|
||||
GTK_MINIMUM=2.6.0
|
||||
LIBNOTIFY_MINIMUM=0.4.3
|
||||
DBUS_GLIB_MINIMUM=0.70
|
||||
LIBEVENT_MINIMUM=1.4.5
|
||||
CANBERRA_MINIMUM=0.10
|
||||
AC_SUBST(OPENSSL_MINIMUM)
|
||||
AC_SUBST(CURL_MINIMUM)
|
||||
AC_SUBST(GIO_MINIMUM)
|
||||
AC_SUBST(GLIB_MINIMUM)
|
||||
AC_SUBST(GTK_MINIMUM)
|
||||
AC_SUBST(LIBNOTIFY_MINIMUM)
|
||||
AC_SUBST(DBUS_GLIB_MINIMUM)
|
||||
AC_SUBST(LIBEVENT_MINIUM)
|
||||
AC_SUBST(CANBERRA_MINIMUM)
|
||||
AC_SUBST(CANBERRA_MINIMUM)
|
||||
CURL_MINIMUM=7.16.3
|
||||
AC_SUBST(CURL_MINIMUM)
|
||||
DBUS_GLIB_MINIMUM=0.70
|
||||
AC_SUBST(DBUS_GLIB_MINIMUM)
|
||||
GCONF2_MINIMUM=2.20.0
|
||||
AC_SUBST(GCONF2_MINIMUM)
|
||||
GIO_MINIMUM=2.15.5
|
||||
AC_SUBST(GIO_MINIMUM)
|
||||
GLIB_MINIMUM=2.6.0
|
||||
AC_SUBST(GLIB_MINIMUM)
|
||||
GTK_MINIMUM=2.6.0
|
||||
AC_SUBST(GTK_MINIMUM)
|
||||
LIBEVENT_MINIMUM=1.4.5
|
||||
AC_SUBST(LIBEVENT_MINIUM)
|
||||
LIBNOTIFY_MINIMUM=0.4.3
|
||||
AC_SUBST(LIBNOTIFY_MINIMUM)
|
||||
OPENSSL_MINIMUM=0.9.4
|
||||
AC_SUBST(OPENSSL_MINIMUM)
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_CXX
|
||||
|
@ -292,6 +294,23 @@ if test "x$build_gtk" = "xyes"; then
|
|||
fi
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES([LIBGCONF],
|
||||
[gconf-2.0 >= $GCONF2_MINIMUM],
|
||||
[have_libgconf=yes],
|
||||
[have_libgconf=no])
|
||||
AC_ARG_ENABLE([gconf2],
|
||||
AS_HELP_STRING([--enable-libgconf],[enable GConf support]),,
|
||||
[enable_libgconf=yes])
|
||||
use_libgconf=no
|
||||
if test "x$enable_libgconf" = "xyes" ; then
|
||||
if test "x$have_libgconf" = "xyes"; then
|
||||
use_libgconf=yes
|
||||
AC_SUBST(LIBGCONF_LIBS)
|
||||
AC_SUBST(LIBGCONF_CFLAGS)
|
||||
AC_DEFINE([HAVE_LIBGCONF], 1)
|
||||
fi
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES([DBUS_GLIB],
|
||||
[dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
|
||||
[use_dbus_glib=yes],
|
||||
|
@ -446,6 +465,7 @@ Configuration:
|
|||
... with canberra support: ${use_canberra}
|
||||
... with gio support: ${use_gio}
|
||||
... with dbus-glib support: ${use_dbus_glib}
|
||||
... with libgconf support: ${use_libgconf}
|
||||
... with libnotify support: ${use_libnotify}
|
||||
Build Command-Line client: ${build_cli}
|
||||
Build Daemon: ${build_daemon}
|
||||
|
|
|
@ -22,6 +22,7 @@ AM_CPPFLAGS = \
|
|||
AM_CFLAGS = \
|
||||
$(LIBEVENT_CFLAGS) \
|
||||
$(LIBCANBERRA_CFLAGS) \
|
||||
$(LIBGCONF_CFLAGS) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(LIBCURL_CFLAGS) \
|
||||
$(GIO_CFLAGS) \
|
||||
|
@ -104,6 +105,7 @@ transmission_LDADD = \
|
|||
$(top_builddir)/third-party/miniupnp/libminiupnp.a \
|
||||
$(top_builddir)/third-party/libnatpmp/libnatpmp.a \
|
||||
$(LIBCANBERRA_LIBS) \
|
||||
$(LIBGCONF_LIBS) \
|
||||
$(DHT_LIBS) \
|
||||
$(GTK_LIBS) \
|
||||
$(GIO_LIBS) \
|
||||
|
|
48
gtk/main.c
48
gtk/main.c
|
@ -123,6 +123,51 @@ static void prefschanged( TrCore * core,
|
|||
|
||||
static gboolean updatemodel( gpointer gdata );
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
#ifdef HAVE_LIBGCONF
|
||||
#include <gconf/gconf.h>
|
||||
#include <gconf/gconf-client.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
registerMagnetLinkHandler( void )
|
||||
{
|
||||
#ifdef HAVE_LIBGCONF
|
||||
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" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/***
|
||||
****
|
||||
***/
|
||||
|
||||
struct counts_data
|
||||
{
|
||||
int totalCount;
|
||||
|
@ -468,6 +513,9 @@ main( int argc, char ** argv )
|
|||
&& ( time( NULL ) - pref_int_get( "blocklist-date" ) > ( 60 * 60 * 24 * 7 ) ) )
|
||||
tr_core_blocklist_update( cbdata->core );
|
||||
|
||||
/* if there's no magnet link handler registered, register us */
|
||||
registerMagnetLinkHandler( );
|
||||
|
||||
gtk_main( );
|
||||
}
|
||||
else if( err )
|
||||
|
|
Loading…
Reference in New Issue