Changeset 5583


Ignore:
Timestamp:
Apr 11, 2008, 2:21:33 AM (15 years ago)
Author:
charles
Message:

(gtk) #859: No way of opening target folder of torrent

Location:
trunk/gtk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/actions.c

    r5536 r5583  
    102102  { "help-menu", NULL, N_("_Help"), NULL, NULL, NULL },
    103103  { "add-torrent-toolbar", GTK_STOCK_ADD, NULL, NULL, N_("Add a torrent"), G_CALLBACK(action_cb) },
    104   { "add-torrent-menu", GTK_STOCK_ADD, N_("_Add..."), NULL, N_("Add a torrent"), G_CALLBACK(action_cb) },
     104  { "add-torrent-menu", GTK_STOCK_ADD, N_("_Add..."), "<control>D", N_("Add a torrent"), G_CALLBACK(action_cb) },
    105105  { "start-torrent", GTK_STOCK_MEDIA_PLAY,
    106106    N_("_Start"), "<control>S", N_("Start torrent"), G_CALLBACK(action_cb) },
     
    126126  { "show-torrent-details", GTK_STOCK_INFO,
    127127    N_("_Details"), "<alt>Return", N_("Torrent details"), G_CALLBACK(action_cb) },
     128  { "open-torrent-folder", GTK_STOCK_OPEN,
     129    N_("_Open Folder"), NULL, NULL, G_CALLBACK(action_cb) },
    128130  { "show-about-dialog", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(action_cb) },
    129131  { "update-tracker", GTK_STOCK_NETWORK,
  • trunk/gtk/main.c

    r5517 r5583  
    200200    action_sensitize( "delete-torrent", counts.totalCount!=0 );
    201201    action_sensitize( "verify-torrent", counts.totalCount!=0 );
     202    action_sensitize( "open-torrent-folder", counts.totalCount==1 );
    202203    action_sensitize( "show-torrent-details", counts.totalCount==1 );
    203204
     
    936937
    937938static void
     939openFolderForeach( GtkTreeModel * model,
     940                   GtkTreePath  * path UNUSED,
     941                   GtkTreeIter  * iter,
     942                   gpointer       user_data UNUSED )
     943{
     944    TrTorrent * gtor = NULL;
     945    gtk_tree_model_get( model, iter, MC_TORRENT, &gtor, -1 );
     946    tr_torrent_open_folder( gtor );
     947    g_object_unref( G_OBJECT( gtor ) );
     948}
     949
     950static void
    938951showInfoForeach (GtkTreeModel * model,
    939952                 GtkTreePath  * path UNUSED,
     
    10401053        gtk_tree_selection_selected_foreach( s, recheckTorrentForeach, NULL );
    10411054        changed |= gtk_tree_selection_count_selected_rows( s ) != 0;
     1055    }
     1056    else if (!strcmp (action_name, "open-torrent-folder"))
     1057    {
     1058        GtkTreeSelection * s = tr_window_get_selection(data->wind);
     1059        gtk_tree_selection_selected_foreach( s, openFolderForeach, data );
    10421060    }
    10431061    else if (!strcmp (action_name, "show-torrent-details"))
  • trunk/gtk/notify.c

    r5231 r5583  
    1616#include <glib/gi18n.h>
    1717#include "notify.h"
     18#include "util.h"
    1819
    1920#ifndef HAVE_LIBNOTIFY
     
    3738{
    3839    TrTorrent * gtor = TR_TORRENT( gdata );
    39     tr_torrent * tor = tr_torrent_handle( gtor );
    40     const tr_info * info = tr_torrent_info( gtor );
    41     char * path = NULL;
    4240
    4341    if( !strcmp( action, "folder" ) )
    4442    {
    45         if( info->fileCount == 1 )
    46         {
    47             path = g_build_filename( tr_torrentGetFolder(tor), NULL );
    48         }
    49         else
    50         {
    51             path = g_build_filename( tr_torrentGetFolder(tor), info->name, NULL );
    52         }
     43        tr_torrent_open_folder( gtor );
    5344    }
    5445    else if( !strcmp( action, "file" ) )
    5546    {
    56         path = g_build_filename( tr_torrentGetFolder(tor), info->files[0].name, NULL );
    57     }
    58 
    59     if( path )
    60     {
    61         gboolean opened = FALSE;
    62 #ifdef HAVE_GIO
    63         GFile * file = g_file_new_for_path( path );
    64         char * uri = g_file_get_uri( file );
    65         opened = g_app_info_launch_default_for_uri( uri, NULL, NULL );
    66         g_free( uri );
    67         g_object_unref( G_OBJECT( file ) );
    68 #endif
    69         if( !opened ) {
    70             char * argv[] = { "xdg-open", path, NULL };
    71             g_spawn_async( NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL );
    72         }
    73         g_free( path );
     47        tr_torrent * tor = tr_torrent_handle( gtor );
     48        const tr_info * info = tr_torrent_info( gtor );
     49        char * path = g_build_filename( tr_torrentGetFolder(tor), info->files[0].name, NULL );
     50        gtr_open_file( path );
     51        g_free( path );
    7452    }
    7553}
  • trunk/gtk/tr-torrent.c

    r5539 r5583  
    345345    }
    346346}
     347
     348void
     349tr_torrent_open_folder( TrTorrent * gtor )
     350{
     351    tr_torrent * tor = tr_torrent_handle( gtor );
     352    const tr_info * info = tr_torrent_info( gtor );
     353    char * path = info->fileCount == 1
     354        ? g_build_filename( tr_torrentGetFolder(tor), NULL )
     355        : g_build_filename( tr_torrentGetFolder(tor), info->name, NULL );
     356    gtr_open_file( path );
     357    g_free( path );
     358}
  • trunk/gtk/tr-torrent.h

    r5122 r5583  
    8181
    8282void
     83tr_torrent_open_folder( TrTorrent * tor );
     84
     85void
    8386tr_torrent_check_seeding_cap ( TrTorrent* );
    8487void
  • trunk/gtk/ui.h

    r5536 r5583  
    66"      <menuitem action='new-torrent'/>\n"
    77"      <separator/>\n"
     8"      <menuitem action='show-torrent-details'/>\n"
     9"      <menuitem action='open-torrent-folder'/>\n"
     10"      <separator/>\n"
    811"      <menuitem action='start-torrent'/>\n"
    912"      <menuitem action='update-tracker'/>\n"
    1013"      <menuitem action='pause-torrent'/>\n"
    1114"      <menuitem action='verify-torrent'/>\n"
    12 "      <menuitem action='show-torrent-details'/>\n"
    1315"      <menuitem action='remove-torrent'/>\n"
    1416"      <menuitem action='delete-torrent'/>\n"
     
    5860"  <popup name='main-window-popup'>\n"
    5961"    <menuitem action='show-torrent-details'/>\n"
     62"    <menuitem action='open-torrent-folder'/>\n"
    6063"    <separator/>\n"
    6164"    <menuitem action='start-torrent'/>\n"
  • trunk/gtk/util.c

    r5313 r5583  
    437437    }
    438438}
     439
     440void
     441gtr_open_file( const char * path )
     442{
     443    if( path )
     444    {
     445        gboolean opened = FALSE;
     446#ifdef HAVE_GIO
     447        if( !opened )
     448        {
     449            GFile * file = g_file_new_for_path( path );
     450            char * uri = g_file_get_uri( file );
     451            opened = g_app_info_launch_default_for_uri( uri, NULL, NULL );
     452            g_free( uri );
     453            g_object_unref( G_OBJECT( file ) );
     454        }
     455#endif
     456        if( !opened )
     457        {
     458            char * argv[] = { "xdg-open", (char*)path, NULL };
     459            g_spawn_async( NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
     460                           NULL, NULL, NULL, NULL );
     461        }
     462    }
     463}
  • trunk/gtk/util.h

    r5276 r5583  
    8484getdownloaddir( void );
    8585
     86void gtr_open_file( const char * path );
     87
    8688#ifdef GTK_MAJOR_VERSION
    8789
Note: See TracChangeset for help on using the changeset viewer.