Changeset 2112


Ignore:
Timestamp:
Jun 17, 2007, 3:29:23 AM (15 years ago)
Author:
charles
Message:
  • don't crash on abort
  • more work on the gtk+ 'create torrent' dialog.
Location:
branches/file_selection
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/gtk/make-meta-ui.c

    r2109 r2112  
    3737typedef struct
    3838{
     39    char torrent_name[2048];
    3940    GtkWidget * size_lb;
    4041    GtkWidget * announce_entry;
     
    5051
    5152static void
    52 cancel_cb( GtkDialog *d UNUSED, int response UNUSED, gpointer user_data )
     53progress_response_cb ( GtkDialog *d UNUSED, int response, gpointer user_data )
    5354{
    5455    MakeMetaUI * ui = (MakeMetaUI *) user_data;
    55     ui->builder->abortFlag = TRUE;
     56
     57    if( response == GTK_RESPONSE_CANCEL )
     58    {
     59        ui->builder->abortFlag = TRUE;
     60    }
     61    else
     62    {
     63        gtk_widget_destroy( ui->dialog );
     64    }
    5665}
    5766
     
    5968refresh_cb ( gpointer user_data )
    6069{
     70    char buf[1024];
    6171    double fraction;
    6272    MakeMetaUI * ui = (MakeMetaUI *) user_data;
     73    GtkProgressBar * p = GTK_PROGRESS_BAR( ui->progressbar );
    6374
    6475    fraction = (double)ui->builder->pieceIndex / ui->builder->pieceCount;
    65     gtk_progress_bar_set_fraction( GTK_PROGRESS_BAR( ui->progressbar ), fraction );
     76    gtk_progress_bar_set_fraction( p, fraction );
     77    g_snprintf( buf, sizeof(buf), "%s (%d%%)", ui->torrent_name, (int)(fraction*100 + 0.5));
     78    gtk_progress_bar_set_text( p, buf );
    6679
    6780    if( ui->builder->isDone )
     
    8194        else
    8295        {
    83             w = gtk_message_dialog_new_with_markup (
    84                 GTK_WINDOW(ui->progress_dialog),
    85                 GTK_DIALOG_DESTROY_WITH_PARENT,
    86                 GTK_MESSAGE_INFO,
    87                 GTK_BUTTONS_CLOSE,
    88                 NULL);
    89             hig_message_dialog_set_text (GTK_MESSAGE_DIALOG(w),
    90                 _("<b>Torrent Created!</b>"),
    91                 ui->builder->outputFile);
    92             gtk_dialog_run( GTK_DIALOG( w ) );
    93             gtk_widget_destroy( ui->dialog );
     96            GtkWidget * w = ui->progress_dialog;
     97            gtk_window_set_title (GTK_WINDOW(ui->progress_dialog), _("Torrent Created!"));
     98            gtk_dialog_set_response_sensitive (GTK_DIALOG(w), GTK_RESPONSE_CANCEL, FALSE);
     99            gtk_dialog_set_response_sensitive (GTK_DIALOG(w), GTK_RESPONSE_CLOSE, TRUE);
     100            gtk_progress_bar_set_text( p, buf );
    94101        }
    95102    }
     
    103110    MakeMetaUI * ui = (MakeMetaUI*) user_data;
    104111    GtkWidget *w, *p, *fr;
    105     char *tmp, *name;
     112    char *tmp;
     113    char buf[1024];
    106114
    107115    if( response != GTK_RESPONSE_ACCEPT )
     
    115123                                     GTK_DIALOG_DESTROY_WITH_PARENT,
    116124                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
     125                                     GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
    117126                                     NULL );
    118     g_signal_connect( w, "response", G_CALLBACK(cancel_cb), ui );
     127    g_signal_connect( w, "response", G_CALLBACK(progress_response_cb), ui );
    119128    ui->progress_dialog = w;
    120 
     129    gtk_dialog_set_response_sensitive (GTK_DIALOG(w), GTK_RESPONSE_CLOSE, FALSE);
    121130
    122131    tmp = g_path_get_basename (ui->builder->top);
    123     name = g_strdup_printf( "%s.torrent", tmp );
     132    g_snprintf( ui->torrent_name, sizeof(ui->torrent_name), "%s.torrent", tmp );
     133    g_snprintf( buf, sizeof(buf), "%s (%d%%)", ui->torrent_name, 0);
    124134    p = ui->progressbar = gtk_progress_bar_new ();
    125     gtk_progress_bar_set_text( GTK_PROGRESS_BAR(p), name );
     135    gtk_progress_bar_set_text( GTK_PROGRESS_BAR(p), buf );
    126136    fr = gtk_frame_new (NULL);
    127137    gtk_frame_set_shadow_type (GTK_FRAME(fr), GTK_SHADOW_NONE);
     
    130140    gtk_box_pack_start_defaults( GTK_BOX(GTK_DIALOG(w)->vbox), fr );
    131141    gtk_widget_show_all ( w );
    132     g_free( name );
    133142    g_free( tmp );
    134143
  • branches/file_selection/libtransmission/makemeta.c

    r2109 r2112  
    257257        ++b->pieceIndex;
    258258    }
    259     assert( walk-ret == (int)(SHA_DIGEST_LENGTH*b->pieceCount) );
    260     assert( totalRemain == 0 );
     259    assert( b->abortFlag || (walk-ret == (int)(SHA_DIGEST_LENGTH*b->pieceCount)) );
     260    assert( b->abortFlag || !totalRemain );
    261261
    262262    free( buf );
Note: See TracChangeset for help on using the changeset viewer.