(gtk) #859: No way of opening target folder of torrent
This commit is contained in:
parent
c6b097422f
commit
89c1fedcff
|
@ -101,7 +101,7 @@ static GtkActionEntry entries[] =
|
|||
{ "edit-menu", NULL, N_("_Edit"), NULL, NULL, NULL },
|
||||
{ "help-menu", NULL, N_("_Help"), NULL, NULL, NULL },
|
||||
{ "add-torrent-toolbar", GTK_STOCK_ADD, NULL, NULL, N_("Add a torrent"), G_CALLBACK(action_cb) },
|
||||
{ "add-torrent-menu", GTK_STOCK_ADD, N_("_Add..."), NULL, N_("Add a torrent"), G_CALLBACK(action_cb) },
|
||||
{ "add-torrent-menu", GTK_STOCK_ADD, N_("_Add..."), "<control>D", N_("Add a torrent"), G_CALLBACK(action_cb) },
|
||||
{ "start-torrent", GTK_STOCK_MEDIA_PLAY,
|
||||
N_("_Start"), "<control>S", N_("Start torrent"), G_CALLBACK(action_cb) },
|
||||
{ "show-stats", NULL, N_("_Statistics"), NULL, NULL, G_CALLBACK(action_cb) },
|
||||
|
@ -125,6 +125,8 @@ static GtkActionEntry entries[] =
|
|||
{ "edit-preferences", GTK_STOCK_PREFERENCES, NULL, NULL, NULL, G_CALLBACK(action_cb) },
|
||||
{ "show-torrent-details", GTK_STOCK_INFO,
|
||||
N_("_Details"), "<alt>Return", N_("Torrent details"), G_CALLBACK(action_cb) },
|
||||
{ "open-torrent-folder", GTK_STOCK_OPEN,
|
||||
N_("_Open Folder"), NULL, NULL, G_CALLBACK(action_cb) },
|
||||
{ "show-about-dialog", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(action_cb) },
|
||||
{ "update-tracker", GTK_STOCK_NETWORK,
|
||||
N_("Ask Tracker for _More Peers"), NULL, NULL, G_CALLBACK(action_cb) }
|
||||
|
|
18
gtk/main.c
18
gtk/main.c
|
@ -199,6 +199,7 @@ refreshTorrentActions( GtkTreeSelection * s )
|
|||
action_sensitize( "remove-torrent", counts.totalCount!=0 );
|
||||
action_sensitize( "delete-torrent", counts.totalCount!=0 );
|
||||
action_sensitize( "verify-torrent", counts.totalCount!=0 );
|
||||
action_sensitize( "open-torrent-folder", counts.totalCount==1 );
|
||||
action_sensitize( "show-torrent-details", counts.totalCount==1 );
|
||||
|
||||
canUpdate = 0;
|
||||
|
@ -934,6 +935,18 @@ detailsClosed( gpointer user_data, GObject * details )
|
|||
g_hash_table_remove( data->tor2details, hashString );
|
||||
}
|
||||
|
||||
static void
|
||||
openFolderForeach( GtkTreeModel * model,
|
||||
GtkTreePath * path UNUSED,
|
||||
GtkTreeIter * iter,
|
||||
gpointer user_data UNUSED )
|
||||
{
|
||||
TrTorrent * gtor = NULL;
|
||||
gtk_tree_model_get( model, iter, MC_TORRENT, >or, -1 );
|
||||
tr_torrent_open_folder( gtor );
|
||||
g_object_unref( G_OBJECT( gtor ) );
|
||||
}
|
||||
|
||||
static void
|
||||
showInfoForeach (GtkTreeModel * model,
|
||||
GtkTreePath * path UNUSED,
|
||||
|
@ -1040,6 +1053,11 @@ doAction ( const char * action_name, gpointer user_data )
|
|||
gtk_tree_selection_selected_foreach( s, recheckTorrentForeach, NULL );
|
||||
changed |= gtk_tree_selection_count_selected_rows( s ) != 0;
|
||||
}
|
||||
else if (!strcmp (action_name, "open-torrent-folder"))
|
||||
{
|
||||
GtkTreeSelection * s = tr_window_get_selection(data->wind);
|
||||
gtk_tree_selection_selected_foreach( s, openFolderForeach, data );
|
||||
}
|
||||
else if (!strcmp (action_name, "show-torrent-details"))
|
||||
{
|
||||
GtkTreeSelection * s = tr_window_get_selection(data->wind);
|
||||
|
|
36
gtk/notify.c
36
gtk/notify.c
|
@ -15,6 +15,7 @@
|
|||
#endif
|
||||
#include <glib/gi18n.h>
|
||||
#include "notify.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifndef HAVE_LIBNOTIFY
|
||||
|
||||
|
@ -36,41 +37,18 @@ notifyCallback( NotifyNotification * n UNUSED,
|
|||
gpointer gdata )
|
||||
{
|
||||
TrTorrent * gtor = TR_TORRENT( gdata );
|
||||
tr_torrent * tor = tr_torrent_handle( gtor );
|
||||
const tr_info * info = tr_torrent_info( gtor );
|
||||
char * path = NULL;
|
||||
|
||||
if( !strcmp( action, "folder" ) )
|
||||
{
|
||||
if( info->fileCount == 1 )
|
||||
{
|
||||
path = g_build_filename( tr_torrentGetFolder(tor), NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
path = g_build_filename( tr_torrentGetFolder(tor), info->name, NULL );
|
||||
}
|
||||
tr_torrent_open_folder( gtor );
|
||||
}
|
||||
else if( !strcmp( action, "file" ) )
|
||||
{
|
||||
path = g_build_filename( tr_torrentGetFolder(tor), info->files[0].name, NULL );
|
||||
}
|
||||
|
||||
if( path )
|
||||
{
|
||||
gboolean opened = FALSE;
|
||||
#ifdef HAVE_GIO
|
||||
GFile * file = g_file_new_for_path( path );
|
||||
char * uri = g_file_get_uri( file );
|
||||
opened = g_app_info_launch_default_for_uri( uri, NULL, NULL );
|
||||
g_free( uri );
|
||||
g_object_unref( G_OBJECT( file ) );
|
||||
#endif
|
||||
if( !opened ) {
|
||||
char * argv[] = { "xdg-open", path, NULL };
|
||||
g_spawn_async( NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL );
|
||||
}
|
||||
g_free( path );
|
||||
tr_torrent * tor = tr_torrent_handle( gtor );
|
||||
const tr_info * info = tr_torrent_info( gtor );
|
||||
char * path = g_build_filename( tr_torrentGetFolder(tor), info->files[0].name, NULL );
|
||||
gtr_open_file( path );
|
||||
g_free( path );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -344,3 +344,15 @@ tr_torrent_delete_files( TrTorrent * gtor )
|
|||
g_free( file );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tr_torrent_open_folder( TrTorrent * gtor )
|
||||
{
|
||||
tr_torrent * tor = tr_torrent_handle( gtor );
|
||||
const tr_info * info = tr_torrent_info( gtor );
|
||||
char * path = info->fileCount == 1
|
||||
? g_build_filename( tr_torrentGetFolder(tor), NULL )
|
||||
: g_build_filename( tr_torrentGetFolder(tor), info->name, NULL );
|
||||
gtr_open_file( path );
|
||||
g_free( path );
|
||||
}
|
||||
|
|
|
@ -79,6 +79,9 @@ tr_torrent_status_str ( TrTorrent * tor );
|
|||
void
|
||||
tr_torrent_delete_files( TrTorrent * tor );
|
||||
|
||||
void
|
||||
tr_torrent_open_folder( TrTorrent * tor );
|
||||
|
||||
void
|
||||
tr_torrent_check_seeding_cap ( TrTorrent* );
|
||||
void
|
||||
|
|
5
gtk/ui.h
5
gtk/ui.h
|
@ -5,11 +5,13 @@ const char * fallback_ui_file =
|
|||
" <menuitem action='add-torrent-menu'/>\n"
|
||||
" <menuitem action='new-torrent'/>\n"
|
||||
" <separator/>\n"
|
||||
" <menuitem action='show-torrent-details'/>\n"
|
||||
" <menuitem action='open-torrent-folder'/>\n"
|
||||
" <separator/>\n"
|
||||
" <menuitem action='start-torrent'/>\n"
|
||||
" <menuitem action='update-tracker'/>\n"
|
||||
" <menuitem action='pause-torrent'/>\n"
|
||||
" <menuitem action='verify-torrent'/>\n"
|
||||
" <menuitem action='show-torrent-details'/>\n"
|
||||
" <menuitem action='remove-torrent'/>\n"
|
||||
" <menuitem action='delete-torrent'/>\n"
|
||||
" <separator/>\n"
|
||||
|
@ -57,6 +59,7 @@ const char * fallback_ui_file =
|
|||
"\n"
|
||||
" <popup name='main-window-popup'>\n"
|
||||
" <menuitem action='show-torrent-details'/>\n"
|
||||
" <menuitem action='open-torrent-folder'/>\n"
|
||||
" <separator/>\n"
|
||||
" <menuitem action='start-torrent'/>\n"
|
||||
" <menuitem action='pause-torrent'/>\n"
|
||||
|
|
25
gtk/util.c
25
gtk/util.c
|
@ -436,3 +436,28 @@ tr_file_trash_or_unlink( const char * filename )
|
|||
g_unlink( filename );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtr_open_file( const char * path )
|
||||
{
|
||||
if( path )
|
||||
{
|
||||
gboolean opened = FALSE;
|
||||
#ifdef HAVE_GIO
|
||||
if( !opened )
|
||||
{
|
||||
GFile * file = g_file_new_for_path( path );
|
||||
char * uri = g_file_get_uri( file );
|
||||
opened = g_app_info_launch_default_for_uri( uri, NULL, NULL );
|
||||
g_free( uri );
|
||||
g_object_unref( G_OBJECT( file ) );
|
||||
}
|
||||
#endif
|
||||
if( !opened )
|
||||
{
|
||||
char * argv[] = { "xdg-open", (char*)path, NULL };
|
||||
g_spawn_async( NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,8 @@ checkfilenames( int argc, char ** argv );
|
|||
char *
|
||||
getdownloaddir( void );
|
||||
|
||||
void gtr_open_file( const char * path );
|
||||
|
||||
#ifdef GTK_MAJOR_VERSION
|
||||
|
||||
/* here there be dragons */
|
||||
|
|
Loading…
Reference in New Issue