2006-08-13 00:26:52 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-01-01 17:20:20 +00:00
|
|
|
* Copyright (c) 2005-2008 Transmission authors and contributors
|
2006-08-13 00:26:52 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
2006-07-16 19:39:23 +00:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
|
2007-07-18 23:04:26 +00:00
|
|
|
#include <libtransmission/transmission.h>
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
#include "conf.h"
|
|
|
|
#include "dialogs.h"
|
2007-07-16 18:45:51 +00:00
|
|
|
#include "hig.h"
|
2008-02-26 19:58:03 +00:00
|
|
|
#include "tr-core.h"
|
|
|
|
#include "tr-prefs.h"
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-02-07 02:59:25 +00:00
|
|
|
struct dirdata
|
|
|
|
{
|
2008-02-13 03:00:21 +00:00
|
|
|
GtkWidget * widget;
|
|
|
|
TrCore * core;
|
|
|
|
GList * files;
|
|
|
|
tr_ctor * ctor;
|
2007-02-07 02:59:25 +00:00
|
|
|
};
|
|
|
|
|
2007-05-24 02:50:28 +00:00
|
|
|
static void
|
2008-02-13 03:00:21 +00:00
|
|
|
promptdirnocore( gpointer gdata, GObject * core UNUSED )
|
2007-05-24 02:50:28 +00:00
|
|
|
{
|
2008-02-13 03:00:21 +00:00
|
|
|
struct dirdata * stuff = gdata;
|
2007-05-24 02:50:28 +00:00
|
|
|
|
|
|
|
/* prevent the response callback from trying to remove the weak
|
|
|
|
reference which no longer exists */
|
2008-02-13 03:00:21 +00:00
|
|
|
stuff->core = NULL;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
gtk_dialog_response( GTK_DIALOG( stuff->widget ), GTK_RESPONSE_NONE );
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-02-13 03:00:21 +00:00
|
|
|
promptresp( GtkWidget * widget, gint resp, gpointer data )
|
|
|
|
{
|
|
|
|
struct dirdata * stuff;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
stuff = data;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
if( GTK_RESPONSE_ACCEPT == resp )
|
2007-05-24 02:50:28 +00:00
|
|
|
{
|
2008-02-13 03:00:21 +00:00
|
|
|
char * dir;
|
|
|
|
GList * l;
|
|
|
|
|
|
|
|
/* update the destination */
|
|
|
|
dir = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( widget ) );
|
|
|
|
tr_ctorSetDestination( stuff->ctor, TR_FORCE, dir );
|
2007-05-24 02:50:28 +00:00
|
|
|
g_free( dir );
|
2008-02-13 03:00:21 +00:00
|
|
|
|
|
|
|
/* if there's metainfo in the ctor already, use it */
|
|
|
|
if( !tr_ctorGetMetainfo( stuff->ctor, NULL ) )
|
|
|
|
tr_core_add_ctor( stuff->core, stuff->ctor );
|
|
|
|
|
|
|
|
/* if there's a list of files, use them too */
|
|
|
|
for( l=stuff->files; l!=NULL; l=l->next )
|
|
|
|
if( !tr_ctorSetMetainfoFromFile( stuff->ctor, l->data ) )
|
|
|
|
tr_core_add_ctor( stuff->core, stuff->ctor );
|
2007-05-24 02:50:28 +00:00
|
|
|
}
|
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
if( stuff->core )
|
|
|
|
g_object_weak_unref( G_OBJECT( stuff->core ), promptdirnocore, stuff );
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
gtk_widget_destroy( widget );
|
|
|
|
freestrlist( stuff->files );
|
|
|
|
tr_ctorFree( stuff->ctor );
|
|
|
|
g_free( stuff );
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
|
|
|
|
2007-04-04 00:32:58 +00:00
|
|
|
void
|
|
|
|
fmtpeercount( GtkLabel * label, int count )
|
|
|
|
{
|
|
|
|
char str[16];
|
|
|
|
|
|
|
|
if( 0 > count )
|
|
|
|
{
|
2007-10-08 19:40:34 +00:00
|
|
|
gtk_label_set_text( label, "?" );
|
2007-04-04 00:32:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-07-30 20:48:43 +00:00
|
|
|
g_snprintf( str, sizeof str, "%i", count );
|
2007-04-04 00:32:58 +00:00
|
|
|
gtk_label_set_text( label, str );
|
|
|
|
}
|
2006-07-16 19:39:23 +00:00
|
|
|
}
|
2007-02-07 02:59:25 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
static void
|
|
|
|
deleteToggled( GtkToggleButton * tb, gpointer ctor )
|
|
|
|
{
|
|
|
|
tr_ctorSetDeleteSource( ctor, gtk_toggle_button_get_active( tb ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
startToggled( GtkToggleButton * tb, gpointer ctor )
|
|
|
|
{
|
|
|
|
tr_ctorSetPaused( ctor, TR_FORCE, !gtk_toggle_button_get_active( tb ) );
|
|
|
|
}
|
|
|
|
|
2008-02-19 05:52:37 +00:00
|
|
|
GtkWidget*
|
2008-02-13 03:00:21 +00:00
|
|
|
promptfordir( GtkWindow * parent, TrCore * core, GList * files, tr_ctor * ctor )
|
2007-02-07 02:59:25 +00:00
|
|
|
{
|
2008-02-13 03:00:21 +00:00
|
|
|
uint8_t flag = 0;
|
|
|
|
const char * str;
|
2007-02-07 02:59:25 +00:00
|
|
|
struct dirdata * stuff;
|
|
|
|
GtkWidget * wind;
|
2008-02-13 03:00:21 +00:00
|
|
|
GtkWidget * v;
|
|
|
|
GtkWidget * w;
|
2007-02-07 02:59:25 +00:00
|
|
|
|
2007-05-24 10:37:07 +00:00
|
|
|
stuff = g_new0( struct dirdata, 1 );
|
2008-02-13 03:00:21 +00:00
|
|
|
stuff->core = core;
|
|
|
|
stuff->ctor = ctor;
|
|
|
|
stuff->files = dupstrlist( files );
|
2007-02-07 02:59:25 +00:00
|
|
|
|
2007-05-24 02:50:28 +00:00
|
|
|
g_object_weak_ref( G_OBJECT( core ), promptdirnocore, stuff );
|
|
|
|
|
2007-02-07 02:59:25 +00:00
|
|
|
wind = gtk_file_chooser_dialog_new( _("Choose a directory"), parent,
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL );
|
2008-02-28 14:48:23 +00:00
|
|
|
gtk_dialog_set_alternative_button_order( GTK_DIALOG( wind ),
|
|
|
|
GTK_RESPONSE_ACCEPT,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1 );
|
2007-02-07 02:59:25 +00:00
|
|
|
gtk_file_chooser_set_local_only( GTK_FILE_CHOOSER( wind ), TRUE );
|
|
|
|
gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER( wind ), FALSE );
|
2008-02-13 03:57:48 +00:00
|
|
|
if( tr_ctorGetDestination( ctor, TR_FORCE, &str ) )
|
|
|
|
g_assert_not_reached( );
|
2008-02-13 04:40:34 +00:00
|
|
|
if( !gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( wind ), str ) )
|
|
|
|
g_warning( "couldn't set destination '%s'", str );
|
2007-05-24 02:50:28 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
v = gtk_vbox_new( FALSE, GUI_PAD );
|
2007-05-24 02:50:28 +00:00
|
|
|
|
2008-02-13 03:57:48 +00:00
|
|
|
flag = 0;
|
2008-02-13 03:00:21 +00:00
|
|
|
w = gtk_check_button_new_with_mnemonic( _( "_Delete original torrent file" ) );
|
|
|
|
g_signal_connect( w, "toggled", G_CALLBACK( deleteToggled ), ctor );
|
2008-02-13 03:57:48 +00:00
|
|
|
if( tr_ctorGetDeleteSource( ctor, &flag ) )
|
|
|
|
g_assert_not_reached( );
|
2008-02-13 03:00:21 +00:00
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), flag );
|
|
|
|
gtk_box_pack_start( GTK_BOX( v ), w, FALSE, FALSE, 0 );
|
2007-05-24 02:50:28 +00:00
|
|
|
|
2008-02-13 03:57:48 +00:00
|
|
|
flag = 1;
|
2008-02-13 03:00:21 +00:00
|
|
|
w = gtk_check_button_new_with_mnemonic( _( "_Start when added" ) );
|
|
|
|
g_signal_connect( w, "toggled", G_CALLBACK( startToggled ), ctor );
|
2008-02-13 03:57:48 +00:00
|
|
|
if( tr_ctorGetPaused( ctor, TR_FORCE, &flag ) )
|
|
|
|
g_assert_not_reached( );
|
2008-02-13 03:00:21 +00:00
|
|
|
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), !flag );
|
|
|
|
gtk_box_pack_start( GTK_BOX( v ), w, FALSE, FALSE, 0 );
|
2007-02-07 02:59:25 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
gtk_file_chooser_set_extra_widget( GTK_FILE_CHOOSER( wind ), v );
|
2007-02-07 02:59:25 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
stuff->widget = wind;
|
2007-02-07 02:59:25 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
g_signal_connect( G_OBJECT( wind ), "response",
|
|
|
|
G_CALLBACK( promptresp ), stuff );
|
2007-05-24 02:50:28 +00:00
|
|
|
|
2008-02-19 05:52:37 +00:00
|
|
|
gtk_widget_show_all( wind );
|
|
|
|
return wind;
|
2007-02-07 02:59:25 +00:00
|
|
|
}
|
2007-02-19 22:09:05 +00:00
|
|
|
|
2007-07-16 18:45:51 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
struct quitdata
|
|
|
|
{
|
|
|
|
TrCore * core;
|
|
|
|
callbackfunc_t func;
|
|
|
|
void * cbdata;
|
|
|
|
GtkWidget * dontask;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
quitresp( GtkWidget * widget, int response, gpointer data )
|
|
|
|
{
|
2007-09-27 20:57:58 +00:00
|
|
|
struct quitdata * stuff = data;
|
2008-02-13 03:00:21 +00:00
|
|
|
GtkToggleButton * tb = GTK_TOGGLE_BUTTON( stuff->dontask );
|
2007-07-16 18:45:51 +00:00
|
|
|
|
2008-02-13 03:00:21 +00:00
|
|
|
tr_core_set_pref_bool( stuff->core,
|
|
|
|
PREF_KEY_ASKQUIT,
|
|
|
|
!gtk_toggle_button_get_active( tb ) );
|
2007-07-16 18:45:51 +00:00
|
|
|
|
|
|
|
if( response == GTK_RESPONSE_ACCEPT )
|
|
|
|
stuff->func( stuff->cbdata );
|
|
|
|
|
|
|
|
g_free( stuff );
|
|
|
|
gtk_widget_destroy( widget );
|
|
|
|
}
|
|
|
|
|
2008-01-27 20:12:10 +00:00
|
|
|
static gboolean
|
|
|
|
countActiveTorrents( GtkTreeModel * model,
|
|
|
|
GtkTreePath * path UNUSED,
|
|
|
|
GtkTreeIter * iter,
|
|
|
|
gpointer activeTorrentCount )
|
|
|
|
{
|
|
|
|
int status = -1;
|
|
|
|
gtk_tree_model_get( model, iter, MC_STATUS, &status, -1 );
|
|
|
|
if( status != TR_STATUS_STOPPED )
|
|
|
|
*(int*)activeTorrentCount += 1;
|
|
|
|
return FALSE; /* keep iterating */
|
|
|
|
}
|
|
|
|
|
2007-02-19 22:09:05 +00:00
|
|
|
void
|
2007-07-16 18:45:51 +00:00
|
|
|
askquit( TrCore * core,
|
|
|
|
GtkWindow * parent,
|
|
|
|
callbackfunc_t func,
|
|
|
|
void * cbdata )
|
2007-02-19 22:09:05 +00:00
|
|
|
{
|
|
|
|
struct quitdata * stuff;
|
|
|
|
GtkWidget * wind;
|
2007-07-16 18:45:51 +00:00
|
|
|
GtkWidget * dontask;
|
2008-01-27 20:12:10 +00:00
|
|
|
GtkTreeModel * model;
|
|
|
|
int activeTorrentCount;
|
2007-02-19 22:09:05 +00:00
|
|
|
|
2008-01-21 15:51:53 +00:00
|
|
|
/* if the user doesn't want to be asked, don't ask */
|
|
|
|
if( !pref_flag_get( PREF_KEY_ASKQUIT ) ) {
|
|
|
|
func( cbdata );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-27 20:12:10 +00:00
|
|
|
/* if there aren't any active torrents, don't ask */
|
|
|
|
model = tr_core_model( core );
|
|
|
|
activeTorrentCount = 0;
|
|
|
|
gtk_tree_model_foreach( model, countActiveTorrents, &activeTorrentCount );
|
|
|
|
if( !activeTorrentCount ) {
|
2007-04-05 22:28:02 +00:00
|
|
|
func( cbdata );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-19 22:09:05 +00:00
|
|
|
stuff = g_new( struct quitdata, 1 );
|
|
|
|
stuff->func = func;
|
|
|
|
stuff->cbdata = cbdata;
|
2007-07-16 18:45:51 +00:00
|
|
|
stuff->core = core;
|
2007-02-19 22:09:05 +00:00
|
|
|
|
2007-07-27 01:40:46 +00:00
|
|
|
wind = gtk_message_dialog_new_with_markup( parent,
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_QUESTION,
|
|
|
|
GTK_BUTTONS_NONE,
|
|
|
|
_("<b>Really Quit %s?</b>"),
|
|
|
|
g_get_application_name() );
|
|
|
|
|
|
|
|
gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG(wind),
|
|
|
|
_("This will close all active torrents."));
|
2007-07-16 18:45:51 +00:00
|
|
|
gtk_dialog_add_buttons( GTK_DIALOG(wind),
|
2008-02-28 14:48:23 +00:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
2007-07-16 18:45:51 +00:00
|
|
|
GTK_STOCK_QUIT, GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL );
|
2007-07-27 01:40:46 +00:00
|
|
|
gtk_dialog_set_default_response( GTK_DIALOG( wind ),
|
|
|
|
GTK_RESPONSE_ACCEPT );
|
2008-02-28 14:48:23 +00:00
|
|
|
gtk_dialog_set_alternative_button_order( GTK_DIALOG( wind ),
|
|
|
|
GTK_RESPONSE_ACCEPT,
|
|
|
|
GTK_RESPONSE_CANCEL );
|
2007-02-19 22:09:05 +00:00
|
|
|
|
2007-07-16 18:45:51 +00:00
|
|
|
dontask = gtk_check_button_new_with_mnemonic( _("_Don't Ask Me This Again") );
|
|
|
|
stuff->dontask = dontask;
|
2007-02-19 22:09:05 +00:00
|
|
|
|
2007-07-16 18:45:51 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(wind)->vbox), dontask, FALSE, FALSE, GUI_PAD );
|
2007-02-19 22:09:05 +00:00
|
|
|
|
2007-07-16 18:45:51 +00:00
|
|
|
g_signal_connect( G_OBJECT( wind ), "response",
|
|
|
|
G_CALLBACK( quitresp ), stuff );
|
2007-02-19 22:09:05 +00:00
|
|
|
|
2007-07-16 18:45:51 +00:00
|
|
|
gtk_widget_show_all( wind );
|
2007-02-19 22:09:05 +00:00
|
|
|
}
|
2008-02-19 03:57:03 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
|
|
|
|
|
|
|
struct DeleteData
|
|
|
|
{
|
2008-03-02 15:54:58 +00:00
|
|
|
gboolean delete_files;
|
2008-02-19 03:57:03 +00:00
|
|
|
GList * torrents;
|
|
|
|
TrCore * core;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2008-03-02 15:54:58 +00:00
|
|
|
removeResponse( GtkDialog * dialog, gint response, gpointer gdata )
|
2008-02-19 03:57:03 +00:00
|
|
|
{
|
|
|
|
struct DeleteData * data = gdata;
|
2008-03-02 15:54:58 +00:00
|
|
|
const int doRemove = response == GTK_RESPONSE_ACCEPT;
|
|
|
|
const int doDelete = data->delete_files;
|
2008-02-19 03:57:03 +00:00
|
|
|
GList * l;
|
|
|
|
|
|
|
|
for( l=data->torrents; l!=NULL; l=l->next )
|
|
|
|
{
|
|
|
|
TrTorrent * gtor = TR_TORRENT( l->data );
|
|
|
|
|
2008-03-02 15:54:58 +00:00
|
|
|
if( doRemove )
|
|
|
|
tr_core_remove_torrent( data->core, gtor, doDelete );
|
2008-02-19 03:57:03 +00:00
|
|
|
else
|
|
|
|
g_object_unref( G_OBJECT( gtor ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy( GTK_WIDGET( dialog ) );
|
|
|
|
g_list_free( data->torrents );
|
|
|
|
g_free( data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2008-03-02 15:54:58 +00:00
|
|
|
confirmRemove( GtkWindow * parent,
|
2008-02-19 03:57:03 +00:00
|
|
|
TrCore * core,
|
|
|
|
GList * torrents )
|
|
|
|
{
|
|
|
|
GtkWidget * d;
|
2008-03-02 15:54:58 +00:00
|
|
|
char text[128];
|
2008-02-19 03:57:03 +00:00
|
|
|
struct DeleteData * dd = g_new0( struct DeleteData, 1 );
|
|
|
|
|
|
|
|
dd->core = core;
|
|
|
|
dd->torrents = torrents;
|
2008-03-02 15:54:58 +00:00
|
|
|
dd->delete_files = FALSE;
|
|
|
|
|
|
|
|
g_snprintf( text, sizeof( text ),
|
|
|
|
ngettext( "Remove torrent?",
|
|
|
|
"Remove torrents?",
|
|
|
|
g_list_length( torrents ) ) );
|
|
|
|
d = gtk_message_dialog_new_with_markup( parent,
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_QUESTION,
|
|
|
|
GTK_BUTTONS_NONE,
|
|
|
|
"<b>%s</b>", text );
|
|
|
|
gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG( d ),
|
|
|
|
_( "This removes the torrent, not its downloads." ) );
|
|
|
|
gtk_dialog_add_buttons( GTK_DIALOG( d ),
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_REMOVE, GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL );
|
|
|
|
gtk_dialog_set_default_response( GTK_DIALOG ( d ),
|
|
|
|
GTK_RESPONSE_ACCEPT );
|
|
|
|
gtk_dialog_set_alternative_button_order( GTK_DIALOG( d ),
|
|
|
|
GTK_RESPONSE_ACCEPT,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1 );
|
|
|
|
g_signal_connect( d, "response", G_CALLBACK( removeResponse ), dd );
|
|
|
|
gtk_widget_show_all( d );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
confirmDelete( GtkWindow * parent,
|
|
|
|
TrCore * core,
|
|
|
|
GList * torrents )
|
|
|
|
{
|
|
|
|
GtkWidget * d;
|
|
|
|
char text[128];
|
|
|
|
struct DeleteData * dd = g_new0( struct DeleteData, 1 );
|
2008-02-19 03:57:03 +00:00
|
|
|
|
2008-03-02 15:54:58 +00:00
|
|
|
dd->core = core;
|
|
|
|
dd->torrents = torrents;
|
|
|
|
dd->delete_files = TRUE;
|
|
|
|
|
|
|
|
g_snprintf( text, sizeof( text ),
|
|
|
|
ngettext( "Delete torrent?",
|
|
|
|
"Delete torrents?",
|
|
|
|
g_list_length( torrents ) ) );
|
|
|
|
d = gtk_message_dialog_new_with_markup( parent,
|
|
|
|
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
|
|
GTK_MESSAGE_WARNING,
|
|
|
|
GTK_BUTTONS_NONE,
|
|
|
|
"<b>%s</b>", text );
|
|
|
|
gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG( d ),
|
|
|
|
_( "This removes the torrent and deletes its downloads!" ) );
|
|
|
|
gtk_dialog_add_buttons( GTK_DIALOG( d ),
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT,
|
|
|
|
NULL );
|
|
|
|
gtk_dialog_set_default_response( GTK_DIALOG ( d ),
|
|
|
|
GTK_RESPONSE_CANCEL );
|
2008-02-28 14:48:23 +00:00
|
|
|
gtk_dialog_set_alternative_button_order( GTK_DIALOG( d ),
|
|
|
|
GTK_RESPONSE_ACCEPT,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1 );
|
2008-03-02 15:54:58 +00:00
|
|
|
g_signal_connect( d, "response", G_CALLBACK( removeResponse ), dd );
|
|
|
|
gtk_widget_show_all( d );
|
2008-02-19 03:57:03 +00:00
|
|
|
}
|