Changeset 11253
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/main.c
r11215 r11253 1395 1395 1396 1396 static void 1397 aboutDialogActivateLink( GtkAboutDialog * dialog UNUSED, 1398 const gchar * link_, 1399 gpointer user_data UNUSED ) 1400 { 1401 gtr_open_file( link_ ); 1397 onUriClicked( GtkAboutDialog * u UNUSED, const gchar * uri, gpointer u2 UNUSED ) 1398 { 1399 gtr_open_uri( uri ); 1402 1400 } 1403 1401 … … 1413 1411 }; 1414 1412 1415 const char * website_url= "http://www.transmissionbt.com/";1416 1417 gtk_about_dialog_set_url_hook( aboutDialogActivateLink, NULL, NULL );1413 const char * website_uri = "http://www.transmissionbt.com/"; 1414 1415 gtk_about_dialog_set_url_hook( onUriClicked, NULL, NULL ); 1418 1416 1419 1417 gtk_show_about_dialog( parent, … … 1422 1420 _( "A fast and easy BitTorrent client" ), 1423 1421 "version", LONG_VERSION_STRING, 1424 "website", website_ur l,1425 "website-label", website_ur l,1422 "website", website_uri, 1423 "website-label", website_uri, 1426 1424 "copyright", 1427 1425 _( "Copyright (c) The Transmission Project" ), … … 1616 1614 else if( !strcmp( action_name, "donate" ) ) 1617 1615 { 1618 gtr_open_ file( "http://www.transmissionbt.com/donate.php" );1616 gtr_open_uri( "http://www.transmissionbt.com/donate.php" ); 1619 1617 } 1620 1618 else if( !strcmp( action_name, "pause-all-torrents" ) ) … … 1743 1741 else if( !strcmp ( action_name, "help" ) ) 1744 1742 { 1745 char * url = gtr_get_help_url( ); 1746 gtr_open_file( url ); 1747 g_free( url ); 1743 gtr_open_uri( gtr_get_help_uri( ) ); 1748 1744 } 1749 1745 else if( !strcmp( action_name, "toggle-main-window" ) ) -
trunk/gtk/tr-prefs.c
r11132 r11253 40 40 if( response == GTK_RESPONSE_HELP ) 41 41 { 42 char * base = gtr_get_help_url( ); 43 char * url = g_strdup_printf( "%s/html/preferences.html", base ); 44 gtr_open_file( url ); 45 g_free( url ); 46 g_free( base ); 42 char * uri = g_strconcat( gtr_get_help_uri(), "/html/preferences.html", NULL ); 43 gtr_open_uri( uri ); 44 g_free( uri ); 47 45 } 48 46 … … 718 716 719 717 static void 720 onLaunchClutchCB( GtkButton * w UNUSED, 721 gpointer data UNUSED ) 722 { 723 int port = pref_int_get( TR_PREFS_KEY_RPC_PORT ); 724 char * url = g_strdup_printf( "http://localhost:%d/transmission/web", 725 port ); 726 727 gtr_open_file( url ); 728 g_free( url ); 718 onLaunchClutchCB( GtkButton * w UNUSED, gpointer data UNUSED ) 719 { 720 const int port = pref_int_get( TR_PREFS_KEY_RPC_PORT ); 721 char * uri = g_strdup_printf( "http://localhost:%d/transmission/web", port ); 722 723 gtr_open_uri( uri ); 724 g_free( uri ); 729 725 } 730 726 -
trunk/gtk/util.c
r11216 r11253 465 465 } 466 466 467 char* 468 gtr_get_help_url( void ) 469 { 470 const char * fmt = "http://www.transmissionbt.com/help/gtk/%d.%dx"; 471 int major, minor; 472 473 sscanf( SHORT_VERSION_STRING, "%d.%d", &major, &minor ); 474 return g_strdup_printf( fmt, major, minor / 10 ); 467 const char* 468 gtr_get_help_uri( void ) 469 { 470 static char * uri = NULL; 471 472 if( !uri ) 473 { 474 int major, minor; 475 const char * fmt = "http://www.transmissionbt.com/help/gtk/%d.%dx"; 476 sscanf( SHORT_VERSION_STRING, "%d.%d", &major, &minor ); 477 uri = g_strdup_printf( fmt, major, minor / 10 ); 478 } 479 480 return uri; 475 481 } 476 482 … … 478 484 gtr_open_file( const char * path ) 479 485 { 480 if( path ) 486 char * uri = NULL; 487 488 #ifdef HAVE_GIO 489 GFile * file = g_file_new_for_path( path ); 490 uri = g_file_get_uri( file ); 491 g_object_unref( G_OBJECT( file ) ); 492 #else 493 if( g_path_is_absolute( path ) ) 494 uri = g_strdup_printf( "file://%s", path ); 495 else { 496 char * cwd = g_get_current_dir(); 497 uri = g_strdup_printf( "file://%s/%s", cwd, path ); 498 g_free( cwd ); 499 } 500 #endif 501 502 gtr_open_uri( uri ); 503 g_free( uri ); 504 } 505 506 void 507 gtr_open_uri( const char * uri ) 508 { 509 if( uri ) 481 510 { 482 511 gboolean opened = FALSE; 512 483 513 #ifdef HAVE_GIO 484 514 if( !opened ) 485 {486 GFile * file = g_file_new_for_path( path );487 char * uri = g_file_get_uri( file );488 515 opened = g_app_info_launch_default_for_uri( uri, NULL, NULL ); 489 g_free( uri ); 490 g_object_unref( G_OBJECT( file ) ); 491 } 492 #endif 493 if( !opened ) 494 { 495 char * argv[] = { (char*)"xdg-open", (char*)path, NULL }; 516 #endif 517 518 if( !opened ) { 519 char * argv[] = { (char*)"xdg-open", (char*)uri, NULL }; 496 520 opened = g_spawn_async( NULL, argv, NULL, G_SPAWN_SEARCH_PATH, 497 521 NULL, NULL, NULL, NULL ); … … 499 523 500 524 if( !opened ) 501 { 502 g_message( "Unable to open \"%s\"", path ); 503 } 525 g_message( "Unable to open \"%s\"", uri ); 504 526 } 505 527 } -
trunk/gtk/util.h
r11132 r11253 110 110 ***/ 111 111 112 void gtr_open_uri( const char * uri ); 113 112 114 void gtr_open_file( const char * path ); 113 115 … … 116 118 gboolean gtr_dbus_present_window( void ); 117 119 118 c har* gtr_get_help_url( void );120 const char* gtr_get_help_uri( void ); 119 121 120 122 /***
Note: See TracChangeset
for help on using the changeset viewer.