Changeset 6301 for trunk/gtk/util.c


Ignore:
Timestamp:
Jul 8, 2008, 9:08:20 PM (14 years ago)
Author:
charles
Message:

(gtk) partial fix for #562: No error message when opening broken torrent file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/util.c

    r6277 r6301  
    303303
    304304void
     305addTorrentErrorDialog( GtkWidget * child, int err, const char * filename )
     306{
     307    GtkWidget * w;
     308    GtkWidget * win;
     309    const char * fmt;
     310    char * secondary;
     311    switch( err ) {
     312        case TR_EINVALID: fmt = _( "The torrent file \"%s\" contains invalid data." ); break;
     313        case TR_EDUPLICATE: fmt = _( "The torrent file \"%s\" is already in use." ); break;
     314        default: fmt = _( "The torrent file \"%s\" encountered an unknown error." ); break;
     315    }
     316    secondary = g_strdup_printf( fmt, filename );
     317    win = ( !child || GTK_IS_WINDOW( child ) )
     318        ? child
     319        : gtk_widget_get_ancestor( child ? GTK_WIDGET( child ) : NULL, GTK_TYPE_WINDOW );
     320    w = gtk_message_dialog_new( GTK_WINDOW( win ),
     321                                GTK_DIALOG_DESTROY_WITH_PARENT,
     322                                GTK_MESSAGE_ERROR,
     323                                GTK_BUTTONS_CLOSE,
     324                                _( "Error opening torrent" ) );
     325    gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG( w ), secondary );
     326    g_signal_connect_swapped( w, "response",
     327                              G_CALLBACK( gtk_widget_destroy ), w );
     328    gtk_widget_show_all( w );
     329    g_free( secondary );
     330}
     331
     332void
    305333errmsg( GtkWindow * wind, const char * format, ... )
    306334{
Note: See TracChangeset for help on using the changeset viewer.