Changeset 12562 for trunk/gtk/main.c


Ignore:
Timestamp:
Jul 20, 2011, 11:31:39 PM (11 years ago)
Author:
jordan
Message:

(trunk gtk) #4366 "Use GAppInfo, rather than GConf2, for mime-type registration" -- done.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r12511 r12562  
    3838#include <glib/gstdio.h>
    3939
    40 #ifdef HAVE_GCONF2
    41  #include <gconf/gconf.h>
    42  #include <gconf/gconf-client.h>
    43 #endif
    44 
    4540#include <libtransmission/transmission.h>
    4641#include <libtransmission/rpcimpl.h>
     
    363358register_magnet_link_handler( void )
    364359{
    365 #ifdef HAVE_GCONF2
    366     GError * err;
    367     GConfValue * value;
    368     GConfClient * client = gconf_client_get_default( );
    369     const char * key = "/desktop/gnome/url-handlers/magnet/command";
    370 
    371     /* if there's already a manget handler registered, don't do anything */
    372     value = gconf_client_get( client, key, NULL );
    373     if( value != NULL )
    374     {
    375         gconf_value_free( value );
    376         return;
    377     }
    378 
    379     err = NULL;
    380     if( !gconf_client_set_string( client, key, "transmission '%s'", &err ) )
    381     {
    382         tr_inf( "Unable to register Transmission as default magnet link handler: \"%s\"", err->message );
    383         g_clear_error( &err );
    384     }
    385     else
    386     {
    387         gconf_client_set_bool( client, "/desktop/gnome/url-handlers/magnet/needs_terminal", FALSE, NULL );
    388         gconf_client_set_bool( client, "/desktop/gnome/url-handlers/magnet/enabled", TRUE, NULL );
    389         tr_inf( "Transmission registered as default magnet link handler" );
    390     }
    391 
    392     g_object_unref( G_OBJECT( client ) );
    393 #endif
     360    GAppInfo * app_info = g_app_info_get_default_for_uri_scheme( "magnet" );
     361    if( app_info == NULL )
     362    {
     363        /* there's no default magnet handler, so register ourselves for the job... */
     364        GError * error = NULL;
     365        app_info = g_app_info_create_from_commandline( "transmission-gtk", "transmission-gtk", G_APP_INFO_CREATE_SUPPORTS_URIS, NULL );
     366        g_app_info_set_as_default_for_type( app_info, "x-scheme-handler/magnet", &error );
     367        if( error != NULL )
     368        {
     369            g_warning( _( "Error registering Transmission as x-scheme-handler/magnet handler: %s" ), error->message );
     370            g_clear_error( &error );
     371        }
     372    }
    394373}
    395374
Note: See TracChangeset for help on using the changeset viewer.