1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00

(trunk gtk) #2629 "associate transmission with magnet links" -- implemented for GTK+ client on GNOME desktops with GConf2

This commit is contained in:
Charles Kerr 2009-11-29 20:28:35 +00:00
parent 03351e9a4e
commit ce7cda7a66
3 changed files with 87 additions and 17 deletions

View file

@ -37,24 +37,26 @@ else
fi fi
AM_CONDITIONAL(TR_UNSTABLE, test "x$supported_build" = "xno") 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 CANBERRA_MINIMUM=0.10
AC_SUBST(OPENSSL_MINIMUM) AC_SUBST(CANBERRA_MINIMUM)
AC_SUBST(CURL_MINIMUM) CURL_MINIMUM=7.16.3
AC_SUBST(GIO_MINIMUM) AC_SUBST(CURL_MINIMUM)
AC_SUBST(GLIB_MINIMUM) DBUS_GLIB_MINIMUM=0.70
AC_SUBST(GTK_MINIMUM) AC_SUBST(DBUS_GLIB_MINIMUM)
AC_SUBST(LIBNOTIFY_MINIMUM) GCONF2_MINIMUM=2.20.0
AC_SUBST(DBUS_GLIB_MINIMUM) AC_SUBST(GCONF2_MINIMUM)
AC_SUBST(LIBEVENT_MINIUM) GIO_MINIMUM=2.15.5
AC_SUBST(CANBERRA_MINIMUM) 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_CC
AC_PROG_CXX AC_PROG_CXX
@ -292,6 +294,23 @@ if test "x$build_gtk" = "xyes"; then
fi fi
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], PKG_CHECK_MODULES([DBUS_GLIB],
[dbus-glib-1 >= $DBUS_GLIB_MINIMUM], [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],
[use_dbus_glib=yes], [use_dbus_glib=yes],
@ -446,6 +465,7 @@ Configuration:
... with canberra support: ${use_canberra} ... with canberra support: ${use_canberra}
... with gio support: ${use_gio} ... with gio support: ${use_gio}
... with dbus-glib support: ${use_dbus_glib} ... with dbus-glib support: ${use_dbus_glib}
... with libgconf support: ${use_libgconf}
... with libnotify support: ${use_libnotify} ... with libnotify support: ${use_libnotify}
Build Command-Line client: ${build_cli} Build Command-Line client: ${build_cli}
Build Daemon: ${build_daemon} Build Daemon: ${build_daemon}

View file

@ -22,6 +22,7 @@ AM_CPPFLAGS = \
AM_CFLAGS = \ AM_CFLAGS = \
$(LIBEVENT_CFLAGS) \ $(LIBEVENT_CFLAGS) \
$(LIBCANBERRA_CFLAGS) \ $(LIBCANBERRA_CFLAGS) \
$(LIBGCONF_CFLAGS) \
$(GTK_CFLAGS) \ $(GTK_CFLAGS) \
$(LIBCURL_CFLAGS) \ $(LIBCURL_CFLAGS) \
$(GIO_CFLAGS) \ $(GIO_CFLAGS) \
@ -104,6 +105,7 @@ transmission_LDADD = \
$(top_builddir)/third-party/miniupnp/libminiupnp.a \ $(top_builddir)/third-party/miniupnp/libminiupnp.a \
$(top_builddir)/third-party/libnatpmp/libnatpmp.a \ $(top_builddir)/third-party/libnatpmp/libnatpmp.a \
$(LIBCANBERRA_LIBS) \ $(LIBCANBERRA_LIBS) \
$(LIBGCONF_LIBS) \
$(DHT_LIBS) \ $(DHT_LIBS) \
$(GTK_LIBS) \ $(GTK_LIBS) \
$(GIO_LIBS) \ $(GIO_LIBS) \

View file

@ -123,6 +123,51 @@ static void prefschanged( TrCore * core,
static gboolean updatemodel( gpointer gdata ); 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 struct counts_data
{ {
int totalCount; int totalCount;
@ -468,6 +513,9 @@ main( int argc, char ** argv )
&& ( time( NULL ) - pref_int_get( "blocklist-date" ) > ( 60 * 60 * 24 * 7 ) ) ) && ( time( NULL ) - pref_int_get( "blocklist-date" ) > ( 60 * 60 * 24 * 7 ) ) )
tr_core_blocklist_update( cbdata->core ); tr_core_blocklist_update( cbdata->core );
/* if there's no magnet link handler registered, register us */
registerMagnetLinkHandler( );
gtk_main( ); gtk_main( );
} }
else if( err ) else if( err )