GtkWidget* gtr_torrent_open_from_url_dialog_new( GtkWindow * parent, TrCore * core ) { int row; GtkWidget * e; GtkWidget * t; GtkWidget * w; w = gtk_dialog_new_with_buttons( _( "Open URL" ), parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL ); gtk_dialog_set_alternative_button_order( GTK_DIALOG( w ), GTK_RESPONSE_ACCEPT, GTK_RESPONSE_CANCEL, -1 ); g_signal_connect( w, "response", G_CALLBACK( onOpenURLResponse ), core ); row = 0; t = hig_workarea_create( ); hig_workarea_add_section_title( t, &row, _( "Open torrent from URL" ) ); e = gtk_entry_new( ); gtk_widget_set_size_request( e, 400, -1 ); gtr_paste_clipboard_url_into_entry( e ); g_object_set_data( G_OBJECT( w ), "url-entry", e ); hig_workarea_add_row( t, &row, _( "_URL" ), e, NULL ); gtr_dialog_set_content( GTK_DIALOG( w ), t ); return w; }
GtkWidget* gtr_relocate_dialog_new( GtkWindow * parent, TrCore * core, GSList * torrent_ids ) { guint row; GtkWidget * w; GtkWidget * d; GtkWidget * t; struct relocate_dialog_data * data; d = gtk_dialog_new_with_buttons( _( "Set Torrent Location" ), parent, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_APPLY, GTK_RESPONSE_APPLY, NULL ); gtk_dialog_set_default_response( GTK_DIALOG( d ), GTK_RESPONSE_CANCEL ); gtk_dialog_set_alternative_button_order( GTK_DIALOG( d ), GTK_RESPONSE_APPLY, GTK_RESPONSE_CANCEL, -1 ); g_signal_connect( d, "response", G_CALLBACK( onResponse ), NULL ); row = 0; t = hig_workarea_create( ); hig_workarea_add_section_title( t, &row, _( "Location" ) ); if( previousLocation == NULL ) previousLocation = g_strdup( gtr_pref_string_get( TR_PREFS_KEY_DOWNLOAD_DIR ) ); w = gtk_file_chooser_button_new( _( "Set Torrent Location" ), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ); gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( w ), previousLocation ); g_object_set_data( G_OBJECT( d ), "chooser", w ); hig_workarea_add_row( t, &row, _( "Torrent _location:" ), w, NULL ); w = gtk_radio_button_new_with_mnemonic( NULL, _( "_Move from the current folder" ) ); g_object_set_data( G_OBJECT( d ), "move_rb", w ); hig_workarea_add_wide_control( t, &row, w ); w = gtk_radio_button_new_with_mnemonic_from_widget( GTK_RADIO_BUTTON( w ), _( "Local data is _already there" ) ); hig_workarea_add_wide_control( t, &row, w ); hig_workarea_finish( t, &row ); gtr_dialog_set_content( GTK_DIALOG( d ), t ); data = g_new0( struct relocate_dialog_data, 1 ); data->core = core; data->torrent_ids = torrent_ids; data->chooser_dialog = d; g_object_set_data_full( G_OBJECT( d ), DATA_KEY, data, data_free ); return d; }
GtkWidget * gtr_confirm_quit( GtkWindow * parent, TrCore * core, callbackfunc_t func, void * cbdata ) { struct quitdata * stuff; GtkWidget * w; GtkWidget * wind; GtkWidget * dontask; stuff = g_new( struct quitdata, 1 ); stuff->func = func; stuff->cbdata = cbdata; stuff->core = core; wind = gtk_message_dialog_new_with_markup( parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE, _( "<big><b>Quit Transmission?</b></big>" ) ); gtk_dialog_add_button( GTK_DIALOG( wind ), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL ); w = gtk_dialog_add_button( GTK_DIALOG( wind ), GTK_STOCK_QUIT, GTK_RESPONSE_ACCEPT ); gtk_dialog_set_default_response( GTK_DIALOG( wind ), GTK_RESPONSE_ACCEPT ); gtk_dialog_set_alternative_button_order( GTK_DIALOG( wind ), GTK_RESPONSE_ACCEPT, GTK_RESPONSE_CANCEL, -1 ); dontask = gtk_check_button_new_with_mnemonic( _( "_Don't ask me again" ) ); stuff->dontask = dontask; gtr_dialog_set_content( GTK_DIALOG( wind ), dontask ); g_signal_connect( G_OBJECT( wind ), "response", G_CALLBACK( quitresp ), stuff ); gtk_widget_grab_focus( w ); gtk_widget_show( wind ); return wind; }
GtkWidget* gtr_torrent_options_dialog_new( GtkWindow * parent, TrCore * core, tr_ctor * ctor ) { guint row; guint col; const char * str; GtkWidget * w; GtkWidget * d; GtkWidget * t; GtkWidget * l; GtkWidget * source_chooser; struct OpenData * data; bool flag; GSList * list; GSList * walk; /* make the dialog */ d = gtk_dialog_new_with_buttons( _( "Torrent Options" ), parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, 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 ); if( tr_ctorGetDownloadDir( ctor, TR_FORCE, &str ) ) g_assert_not_reached( ); g_assert( str ); data = g_new0( struct OpenData, 1 ); data->core = core; data->ctor = ctor; data->filename = g_strdup( tr_ctorGetSourceFile( ctor ) ); data->downloadDir = g_strdup( str ); data->file_list = gtr_file_list_new( core, 0 ); str = _( "Mo_ve .torrent file to the trash" ); data->trash_check = gtk_check_button_new_with_mnemonic( str ); str = _( "_Start when added" ); data->run_check = gtk_check_button_new_with_mnemonic( str ); w = data->priority_combo = gtr_priority_combo_new( ); gtr_priority_combo_set_value( GTK_COMBO_BOX( w ), TR_PRI_NORMAL ); g_signal_connect( G_OBJECT( d ), "response", G_CALLBACK( addResponseCB ), data ); t = gtk_table_new( 6, 2, FALSE ); gtk_container_set_border_width( GTK_CONTAINER( t ), GUI_PAD_BIG ); gtk_table_set_row_spacings( GTK_TABLE( t ), GUI_PAD ); gtk_table_set_col_spacings( GTK_TABLE( t ), GUI_PAD_BIG ); row = col = 0; l = gtk_label_new_with_mnemonic( _( "_Torrent file:" ) ); gtk_misc_set_alignment( GTK_MISC( l ), 0.0f, 0.5f ); gtk_table_attach( GTK_TABLE( t ), l, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0 ); ++col; w = gtk_file_chooser_button_new( _( "Select Source File" ), GTK_FILE_CHOOSER_ACTION_OPEN ); source_chooser = w; gtk_table_attach( GTK_TABLE( t ), w, col, col + 1, row, row + 1, ~0, 0, 0, 0 ); gtk_label_set_mnemonic_widget( GTK_LABEL( l ), w ); addTorrentFilters( GTK_FILE_CHOOSER( w ) ); g_signal_connect( w, "selection-changed", G_CALLBACK( sourceChanged ), data ); ++row; col = 0; l = gtk_label_new_with_mnemonic( _( "_Destination folder:" ) ); gtk_misc_set_alignment( GTK_MISC( l ), 0.0f, 0.5f ); gtk_table_attach( GTK_TABLE( t ), l, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0 ); ++col; w = gtk_file_chooser_button_new( _( "Select Destination Folder" ), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER ); if( !gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( w ), data->downloadDir ) ) g_warning( "couldn't select '%s'", data->downloadDir ); list = get_recent_destinations( ); for( walk = list; walk; walk = walk->next ) gtk_file_chooser_add_shortcut_folder( GTK_FILE_CHOOSER( w ), walk->data, NULL ); g_slist_free( list ); gtk_table_attach( GTK_TABLE( t ), w, col, col + 1, row, row + 1, ~0, 0, 0, 0 ); gtk_label_set_mnemonic_widget( GTK_LABEL( l ), w ); g_signal_connect( w, "selection-changed", G_CALLBACK( downloadDirChanged ), data ); ++row; col = 0; w = data->file_list; gtk_widget_set_size_request ( w, 466u, 300u ); gtk_table_attach_defaults( GTK_TABLE( t ), w, col, col + 2, row, row + 1 ); ++row; col = 0; w = gtk_label_new_with_mnemonic( _( "Torrent _priority:" ) ); gtk_misc_set_alignment( GTK_MISC( w ), 0.0f, 0.5f ); gtk_table_attach( GTK_TABLE( t ), w, col, col + 1, row, row + 1, ~0, 0, 0, 0 ); ++col; gtk_table_attach( GTK_TABLE( t ), data->priority_combo, col, col + 1, row, row + 1, ~0, 0, 0, 0 ); gtk_label_set_mnemonic_widget( GTK_LABEL( w ), data->priority_combo ); ++row; col = 0; w = data->run_check; if( tr_ctorGetPaused( ctor, TR_FORCE, &flag ) ) g_assert_not_reached( ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), !flag ); gtk_table_attach( GTK_TABLE( t ), w, col, col + 2, row, row + 1, GTK_FILL, 0, 0, 0 ); ++row; col = 0; w = data->trash_check; if( tr_ctorGetDeleteSource( ctor, &flag ) ) g_assert_not_reached( ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( w ), flag ); gtk_table_attach( GTK_TABLE( t ), w, col, col + 2, row, row + 1, GTK_FILL, 0, 0, 0 ); /* trigger sourceChanged, either directly or indirectly, * so that it creates the tor/gtor objects */ w = source_chooser; if( data->filename ) gtk_file_chooser_set_filename( GTK_FILE_CHOOSER( w ), data->filename ); else sourceChanged( GTK_FILE_CHOOSER_BUTTON( w ), data ); gtr_dialog_set_content( GTK_DIALOG( d ), t ); w = gtk_dialog_get_widget_for_response( GTK_DIALOG( d ), GTK_RESPONSE_ACCEPT ); gtk_widget_grab_focus( w ); return d; }